diff --git a/.changelog/unreleased/api-breaking/1964-deprecate-soft-opt-out.md b/.changelog/unreleased/api-breaking/1964-deprecate-soft-opt-out.md deleted file mode 100644 index 73de583293..0000000000 --- a/.changelog/unreleased/api-breaking/1964-deprecate-soft-opt-out.md +++ /dev/null @@ -1,2 +0,0 @@ -- Remove soft opt-out feature. - ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) \ No newline at end of file diff --git a/.changelog/unreleased/dependencies/2013-bump-comet.md b/.changelog/unreleased/dependencies/2013-bump-comet.md new file mode 100644 index 0000000000..a68b1e78fe --- /dev/null +++ b/.changelog/unreleased/dependencies/2013-bump-comet.md @@ -0,0 +1,3 @@ +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.9](https://github.com/cometbft/cometbft/releases/tag/v0.38.9). + ([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/unreleased/dependencies/2013-bump-ibc.md b/.changelog/unreleased/dependencies/2013-bump-ibc.md new file mode 100644 index 0000000000..eeaec9b362 --- /dev/null +++ b/.changelog/unreleased/dependencies/2013-bump-ibc.md @@ -0,0 +1,3 @@ +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.2.1](https://github.com/cosmos/ibc-go/releases/tag/v8.2.1). + ([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/unreleased/dependencies/2013-bump-sdk.md b/.changelog/unreleased/dependencies/2013-bump-sdk.md new file mode 100644 index 0000000000..34354e35e7 --- /dev/null +++ b/.changelog/unreleased/dependencies/2013-bump-sdk.md @@ -0,0 +1,3 @@ +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.7) +([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/unreleased/features/1964-deprecate-soft-opt-out.md b/.changelog/unreleased/features/1964-deprecate-soft-opt-out.md deleted file mode 100644 index 73de583293..0000000000 --- a/.changelog/unreleased/features/1964-deprecate-soft-opt-out.md +++ /dev/null @@ -1,2 +0,0 @@ -- Remove soft opt-out feature. - ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) \ No newline at end of file diff --git a/.changelog/unreleased/state-breaking/1964-deprecate-soft-opt-out.md b/.changelog/unreleased/state-breaking/1964-deprecate-soft-opt-out.md deleted file mode 100644 index 73de583293..0000000000 --- a/.changelog/unreleased/state-breaking/1964-deprecate-soft-opt-out.md +++ /dev/null @@ -1,2 +0,0 @@ -- Remove soft opt-out feature. - ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) \ No newline at end of file diff --git a/.changelog/unreleased/state-breaking/2013-bump-comet.md b/.changelog/unreleased/state-breaking/2013-bump-comet.md new file mode 100644 index 0000000000..a68b1e78fe --- /dev/null +++ b/.changelog/unreleased/state-breaking/2013-bump-comet.md @@ -0,0 +1,3 @@ +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.9](https://github.com/cometbft/cometbft/releases/tag/v0.38.9). + ([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/unreleased/state-breaking/2013-bump-ibc.md b/.changelog/unreleased/state-breaking/2013-bump-ibc.md new file mode 100644 index 0000000000..eeaec9b362 --- /dev/null +++ b/.changelog/unreleased/state-breaking/2013-bump-ibc.md @@ -0,0 +1,3 @@ +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.2.1](https://github.com/cosmos/ibc-go/releases/tag/v8.2.1). + ([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/unreleased/state-breaking/2013-bump-sdk.md b/.changelog/unreleased/state-breaking/2013-bump-sdk.md new file mode 100644 index 0000000000..34354e35e7 --- /dev/null +++ b/.changelog/unreleased/state-breaking/2013-bump-sdk.md @@ -0,0 +1,3 @@ +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.7) +([\#2013](https://github.com/cosmos/interchain-security/pull/2013)) \ No newline at end of file diff --git a/.changelog/v5.0.0/dependencies/1698-bump-comet.md b/.changelog/v5.0.0/dependencies/1698-bump-comet.md new file mode 100644 index 0000000000..7e750b5120 --- /dev/null +++ b/.changelog/v5.0.0/dependencies/1698-bump-comet.md @@ -0,0 +1,3 @@ +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.4\5](https://github.com/cometbft/cometbft/releases/tag/v0.38.5). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/dependencies/1698-bump-ibc.md b/.changelog/v5.0.0/dependencies/1698-bump-ibc.md new file mode 100644 index 0000000000..40fe475f7b --- /dev/null +++ b/.changelog/v5.0.0/dependencies/1698-bump-ibc.md @@ -0,0 +1,3 @@ +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.1.x](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/dependencies/1698-bump-sdk.md b/.changelog/v5.0.0/dependencies/1698-bump-sdk.md new file mode 100644 index 0000000000..ec22555002 --- /dev/null +++ b/.changelog/v5.0.0/dependencies/1698-bump-sdk.md @@ -0,0 +1,3 @@ +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.4) +([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/features/consumer/1814-add-update-consumer-params-msg.md b/.changelog/v5.0.0/features/consumer/1814-add-update-consumer-params-msg.md new file mode 100644 index 0000000000..811c56401b --- /dev/null +++ b/.changelog/v5.0.0/features/consumer/1814-add-update-consumer-params-msg.md @@ -0,0 +1,2 @@ +- Add consumer `MsgUpdateParams` from [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). +([\#1814](https://github.com/cosmos/interchain-security/pull/1814)). \ No newline at end of file diff --git a/.changelog/v5.0.0/features/provider/1698-add-update-provider-params-msg.md b/.changelog/v5.0.0/features/provider/1698-add-update-provider-params-msg.md new file mode 100644 index 0000000000..ca2ce372e2 --- /dev/null +++ b/.changelog/v5.0.0/features/provider/1698-add-update-provider-params-msg.md @@ -0,0 +1,2 @@ +- Add provider `MsgUpdateParams` from [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). +([\#1698](https://github.com/cosmos/interchain-security/pull/1698)). \ No newline at end of file diff --git a/.changelog/v5.0.0/state-breaking/1698-bump-comet.md b/.changelog/v5.0.0/state-breaking/1698-bump-comet.md new file mode 100644 index 0000000000..7e750b5120 --- /dev/null +++ b/.changelog/v5.0.0/state-breaking/1698-bump-comet.md @@ -0,0 +1,3 @@ +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.4\5](https://github.com/cometbft/cometbft/releases/tag/v0.38.5). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/state-breaking/1698-bump-ibc.md b/.changelog/v5.0.0/state-breaking/1698-bump-ibc.md new file mode 100644 index 0000000000..40fe475f7b --- /dev/null +++ b/.changelog/v5.0.0/state-breaking/1698-bump-ibc.md @@ -0,0 +1,3 @@ +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.1.x](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/state-breaking/1698-bump-sdk.md b/.changelog/v5.0.0/state-breaking/1698-bump-sdk.md new file mode 100644 index 0000000000..ec22555002 --- /dev/null +++ b/.changelog/v5.0.0/state-breaking/1698-bump-sdk.md @@ -0,0 +1,3 @@ +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.4) +([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) \ No newline at end of file diff --git a/.changelog/v5.0.0/state-breaking/1819-revert-put-unbonding-on-hold.md b/.changelog/v5.0.0/state-breaking/1819-revert-put-unbonding-on-hold.md new file mode 100644 index 0000000000..126b04f4f3 --- /dev/null +++ b/.changelog/v5.0.0/state-breaking/1819-revert-put-unbonding-on-hold.md @@ -0,0 +1,2 @@ +- Revert `PutUnbondingOnHold` behavior to ICS@v1 +([\#1819](https://github.com/cosmos/interchain-security/pull/1819)) \ No newline at end of file diff --git a/.changelog/v5.0.0/summary.md b/.changelog/v5.0.0/summary.md new file mode 100644 index 0000000000..98cfdacda8 --- /dev/null +++ b/.changelog/v5.0.0/summary.md @@ -0,0 +1,2 @@ +*May 9, 2024* + diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2150c8ac86..7a18604ac7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -37,7 +37,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 687f6a4679..051c80c0f0 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.22' - uses: technote-space/get-diff-action@v6.1.2 id: git_diff with: diff --git a/.github/workflows/nightly-e2e.yml b/.github/workflows/nightly-e2e.yml index c426e42fd5..3e6915771e 100644 --- a/.github/workflows/nightly-e2e.yml +++ b/.github/workflows/nightly-e2e.yml @@ -18,11 +18,11 @@ on: jobs: compatibility-test: runs-on: ubuntu-latest - timeout-minutes: 180 + timeout-minutes: 200 steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 with: fetch-depth: 0 # get all history for all branches and tags @@ -31,7 +31,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E compatibility test # Run compatibility tests for different consumer (-cv) and provider (-pv) versions. # Combination of all provider versions with consumer versions are tested. @@ -43,14 +43,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E happy-path test run: go run ./tests/e2e/... --tc happy-path changeover-test: @@ -59,14 +59,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E changeover test run: go run ./tests/e2e/... --tc changeover democracy-reward-test: @@ -75,14 +75,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E democracy-reward tests run: go run ./tests/e2e/... --tc democracy-reward democracy-test: @@ -91,14 +91,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E democracy tests run: go run ./tests/e2e/... --tc democracy slash-throttle-test: @@ -107,14 +107,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E slash-throttle tests run: go run ./tests/e2e/... --tc slash-throttle multiconsumer-test: @@ -123,14 +123,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E multi-consumer tests run: go run ./tests/e2e/... --tc multiconsumer consumer-misbehaviour-test: @@ -139,14 +139,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E consumer-misbehaviour tests run: go run ./tests/e2e/... --tc consumer-misbehaviour consumer-double-sign-test: @@ -155,14 +155,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E consumer-double-sign tests run: go run ./tests/e2e/... --tc consumer-double-sign consumer-double-downtime-test: @@ -171,14 +171,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E consumer-double-downtime tests run: go run ./tests/e2e/... --tc consumer-double-downtime partial-set-security-opt-in-test: @@ -187,14 +187,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security opt-in chain run: go run ./tests/e2e/... --tc partial-set-security-opt-in partial-set-security-top-n-test: @@ -203,14 +203,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security Top N chain run: go run ./tests/e2e/... --tc partial-set-security-top-n partial-set-security-validator-set-cap-test: @@ -219,14 +219,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security validator-set cap run: go run ./tests/e2e/... --tc partial-set-security-validator-set-cap partial-set-security-validators-power-cap-test: @@ -235,14 +235,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security validators-power cap run: go run ./tests/e2e/... --tc partial-set-security-validators-power-cap partial-set-security-validators-allowlisted-test: @@ -251,14 +251,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security allowlist run: go run ./tests/e2e/... --tc partial-set-security-validators-allowlisted partial-set-security-validators-denylisted-test: @@ -267,14 +267,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security denylist run: go run ./tests/e2e/... --tc partial-set-security-validators-denylisted partial-set-security-modification-proposal: @@ -283,14 +283,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E partial set security modification proposal run: go run ./tests/e2e/... --tc partial-set-security-modification-proposal active-set-changes-test: @@ -299,14 +299,14 @@ jobs: steps: - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.21" # The Go version to download (if necessary) and use. + go-version: "1.22" # The Go version to download (if necessary) and use. - name: E2E active set changes run: go run ./tests/e2e/... --tc active-set-changes diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08d8ee7847..fef4a7d880 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum @@ -65,7 +65,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum @@ -96,7 +96,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum @@ -177,7 +177,7 @@ jobs: run: git lfs checkout - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum @@ -208,7 +208,7 @@ jobs: run: git lfs checkout - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum @@ -229,37 +229,6 @@ jobs: run: | make test-e2e-compatibility-tests-latest - test-cometmock: - runs-on: Gaia-Runner-medium - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - name: checkout LFS objects - run: git lfs checkout - - uses: actions/setup-go@v5 - with: - go-version: "1.21" - check-latest: true - cache: true - cache-dependency-path: go.sum - - uses: technote-space/get-diff-action@v6.1.2 - id: git_diff - with: - PATTERNS: | - **/*.go - go.mod - go.sum - **/go.mod - **/go.sum - **/Makefile - Makefile - Dockerfile* - - name: cometmock tests - if: env.GIT_DIFF - run: | - make test-e2e-short-cometmock - test-trace: runs-on: ubuntu-latest steps: @@ -270,7 +239,7 @@ jobs: run: git lfs checkout - uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" check-latest: true cache: true cache-dependency-path: go.sum diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e050c3989..7cc3e8a931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,63 @@ # CHANGELOG +## v5.0.0 + +*May 9, 2024* + +### DEPENDENCIES + +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.1.x](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.4\5](https://github.com/cometbft/cometbft/releases/tag/v0.38.5). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.4) +([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) + +### FEATURES + +- [Consumer](x/ccv/consumer) + - Add consumer `MsgUpdateParams` from [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). + ([\#1814](https://github.com/cosmos/interchain-security/pull/1814)). +- [Provider](x/ccv/provider) + - Add provider `MsgUpdateParams` from [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)). + +### STATE BREAKING + +- Bump [ibc-go](https://github.com/cosmos/ibc-go) to + [v8.1.x](https://github.com/cosmos/ibc-go/releases/tag/v8.1.0). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) +- Bump [CometBFT](https://github.com/cometbft/cometbft) to + [v0.38.4\5](https://github.com/cometbft/cometbft/releases/tag/v0.38.5). + ([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) +- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to +[v0.50.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.4) +([\#1698](https://github.com/cosmos/interchain-security/pull/1698)) +- Revert `PutUnbondingOnHold` behavior to ICS@v1 +([\#1819](https://github.com/cosmos/interchain-security/pull/1819)) + +## v4.4.0 + +*July 16, 2024* + +### API BREAKING + +- Remove soft opt-out feature. + ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) + +### FEATURES + +- Remove soft opt-out feature. + ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) + +### STATE BREAKING + +- Remove soft opt-out feature. + ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)) + ## v4.3.1 *July 4, 2024* diff --git a/Dockerfile b/Dockerfile index 830b101b2f..36eaf5188b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 -FROM golang:1.21-alpine AS is-builder +FROM golang:1.22-alpine AS is-builder ENV PACKAGES curl make git libc-dev bash gcc linux-headers RUN apk add --no-cache $PACKAGES @@ -32,7 +32,7 @@ RUN make install FROM --platform=linux/amd64 ghcr.io/informalsystems/hermes:v1.8.0 AS hermes-builder # Get CometMock -FROM ghcr.io/informalsystems/cometmock:v0.37.x as cometmock-builder +FROM ghcr.io/informalsystems/cometmock:v0.38.x as cometmock-builder # Get GoRelayer FROM ghcr.io/informalsystems/relayer-no-gas-sim:v2.3.0-rc4-no-gas-sim AS gorelayer-builder diff --git a/Dockerfile.gaia b/Dockerfile.gaia index de3f1b2ff7..3ecf9e4e72 100644 --- a/Dockerfile.gaia +++ b/Dockerfile.gaia @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 # build latest tagged gaia -FROM golang:1.21-alpine AS gaia-builder +FROM golang:1.22-alpine AS gaia-builder # WORKDIR is set to /go by default ARG USE_GAIA_TAG ENV GAIA_TAG=${USE_GAIA_TAG} @@ -30,7 +30,7 @@ RUN if [ -n "${GAIA_TAG}" ]; \ # if GAIA_TAG is not set, build the latest tagged version else \ git checkout $(git tag | sort -Vr | head -n1); \ - fi + fi # Also replace sdk version in the go.mod if specified RUN if [ -d "/interchain-security/cosmos-sdk" ]; then \ @@ -40,10 +40,10 @@ RUN if [ -d "/interchain-security/cosmos-sdk" ]; then \ RUN go mod tidy # Print the version of the sdk used in the build -RUN go list -m github.com/cosmos/cosmos-sdk +RUN go list -m github.com/cosmos/cosmos-sdk RUN make build -FROM golang:1.21-alpine AS is-builder +FROM golang:1.22-alpine AS is-builder ENV PACKAGES curl make git libc-dev bash gcc linux-headers RUN apk add --no-cache $PACKAGES diff --git a/Makefile b/Makefile index 255bba294a..e68df6fd63 100644 --- a/Makefile +++ b/Makefile @@ -188,7 +188,7 @@ $(BUILDDIR)/: DOCKER := $(shell which docker) HTTPS_GIT := https://github.com/cosmos/interchain-security.git -containerProtoVer=0.13.0 +containerProtoVer=0.14.0 containerProtoImage=ghcr.io/cosmos/proto-builder:$(containerProtoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) diff --git a/UPGRADING.md b/UPGRADING.md index cacd0634a7..f6e856bba5 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,5 +1,15 @@ # Upgrading Replicated Security +## [v4.4.x](https://github.com/cosmos/interchain-security/releases/tag/v4.4.0) + +### Provider + +***Note that provider chains should not use this version of ICS*** + +### Consumer + +Upgrading the consumer from `v4.0.0` to `v4.4.0` will not require state migration. + This guide provides instructions for upgrading to specific versions of Replicated Security. ## [v4.3.x](https://github.com/cosmos/interchain-security/releases/tag/v4.3.0) diff --git a/app/consumer-democracy/abci.go b/app/consumer-democracy/abci.go new file mode 100644 index 0000000000..94b34cc3bb --- /dev/null +++ b/app/consumer-democracy/abci.go @@ -0,0 +1,84 @@ +package app + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + // VoteExtensionHandler defines a dummy vote extension handler for SimApp. + // + // NOTE: This implementation is solely used for testing purposes. DO NOT use + // in a production application! + VoteExtensionHandler struct{} + + // VoteExtension defines the structure used to create a dummy vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/app/consumer-democracy/ante/forbidden_proposals_ante_test.go b/app/consumer-democracy/ante/forbidden_proposals_ante_test.go index 8fd7fe3824..e1e1fda79b 100644 --- a/app/consumer-democracy/ante/forbidden_proposals_ante_test.go +++ b/app/consumer-democracy/ante/forbidden_proposals_ante_test.go @@ -3,19 +3,18 @@ package ante_test import ( "testing" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/stretchr/testify/require" 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" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - app "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - "github.com/cosmos/interchain-security/v4/app/consumer-democracy/ante" + app "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + "github.com/cosmos/interchain-security/v5/app/consumer-democracy/ante" ) // in SDKv47 parameter updates full params object is required @@ -98,8 +97,9 @@ func TestForbiddenProposalsDecorator(t *testing.T) { } } -// Only ibctransfertypes.SendEnabled/ReceiveEnabled support legacy proposals for changing params -// Note: see LegacyWhitelistedParams in proposals_whitelisting.go +// Legacy parameter proposals are not supported in cosmos-sdk v0.50 +// since modules parameters were moved to their respective modules +// this test is to ensure that legacy parameter proposals are not allowed func TestForbiddenLegacyProposalsDecorator(t *testing.T) { txCfg := app.MakeTestEncodingConfig().TxConfig @@ -109,17 +109,6 @@ func TestForbiddenLegacyProposalsDecorator(t *testing.T) { msgs []sdk.Msg expectErr bool }{ - { - name: "Allowed legacy param change -- only for ibctransfertypes.SendEnabled/ReceiveEnabled", - ctx: sdk.Context{}, - msgs: []sdk.Msg{ - newLegacyParamChangeProposalMsg([]proposal.ParamChange{ - // only subspace and key are relevant for testing - {Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"}, - }), - }, - expectErr: false, - }, { name: "Forbidden param change", ctx: sdk.Context{}, @@ -131,33 +120,16 @@ func TestForbiddenLegacyProposalsDecorator(t *testing.T) { expectErr: true, }, { - name: "Allowed and forbidden param changes in the same msg", + name: "Multiple forbidden param changes in the same msg", ctx: sdk.Context{}, msgs: []sdk.Msg{ newLegacyParamChangeProposalMsg([]proposal.ParamChange{ - // allowed {Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"}, - // disallowed {Subspace: authtypes.ModuleName, Key: "MaxMemoCharacters", Value: ""}, }), }, expectErr: true, }, - { - name: "Allowed and forbidden param changes in different msg", - ctx: sdk.Context{}, - msgs: []sdk.Msg{ - newLegacyParamChangeProposalMsg([]proposal.ParamChange{ - // disallowed - {Subspace: banktypes.ModuleName, Key: "SendEnabled", Value: ""}, - }), - newLegacyParamChangeProposalMsg([]proposal.ParamChange{ - // allowed - {Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled", Value: "true"}, - }), - }, - expectErr: true, - }, } for _, tc := range testCases { @@ -187,11 +159,11 @@ func newLegacyParamChangeProposalMsg(changes []proposal.ParamChange) *govv1.MsgS if err != nil { return nil } - msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "") + msg, _ := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false) return msg } func newParamChangeProposalMsg(msgs []sdk.Msg) *govv1.MsgSubmitProposal { - msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "") + msg, _ := govv1.NewMsgSubmitProposal(msgs, sdk.NewCoins(), sdk.AccAddress{}.String(), "", "", "", false) return msg } diff --git a/app/consumer-democracy/ante_handler.go b/app/consumer-democracy/ante_handler.go index 7e652ebb0c..a8efdfffb3 100644 --- a/app/consumer-democracy/ante_handler.go +++ b/app/consumer-democracy/ante_handler.go @@ -1,8 +1,8 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" errorsmod "cosmossdk.io/errors" @@ -10,9 +10,9 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - democracyante "github.com/cosmos/interchain-security/v4/app/consumer-democracy/ante" - consumerante "github.com/cosmos/interchain-security/v4/app/consumer/ante" - ibcconsumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" + democracyante "github.com/cosmos/interchain-security/v5/app/consumer-democracy/ante" + consumerante "github.com/cosmos/interchain-security/v5/app/consumer/ante" + ibcconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" ) // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index a57f237a14..6ceb8952e4 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -1,33 +1,44 @@ package app import ( + "context" "fmt" "io" stdlog "log" "os" "path/filepath" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - 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/cosmos/gogoproto/proto" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" + + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -37,14 +48,14 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/std" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -55,9 +66,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -66,12 +74,6 @@ import ( crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" gov "github.com/cosmos/cosmos-sdk/x/gov" @@ -79,6 +81,14 @@ 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" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + + // add mint + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" 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" @@ -92,33 +102,39 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" - - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - consumer "github.com/cosmos/interchain-security/v4/x/ccv/consumer" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvdistr "github.com/cosmos/interchain-security/v4/x/ccv/democracy/distribution" - ccvgov "github.com/cosmos/interchain-security/v4/x/ccv/democracy/governance" - ccvstaking "github.com/cosmos/interchain-security/v4/x/ccv/democracy/staking" + dbm "github.com/cosmos/cosmos-db" + + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + consumer "github.com/cosmos/interchain-security/v5/x/ccv/consumer" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvdistr "github.com/cosmos/interchain-security/v5/x/ccv/democracy/distribution" + ccvgov "github.com/cosmos/interchain-security/v5/x/ccv/democracy/governance" + ccvstaking "github.com/cosmos/interchain-security/v5/x/ccv/democracy/staking" ) const ( - AppName = "interchain-security-cd" - upgradeName = "sovereign-changeover" // arbitrary name, define your own appropriately named upgrade - AccountAddressPrefix = "consumer" + AppName = "interchain-security-cd" + upgradeName = "sovereign-changeover" // arbitrary name, define your own appropriately named upgrade + + Bech32MainPrefix = "consumer" ) +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + stdlog.Println("Failed to get home dir %2", err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) +} + var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -135,11 +151,8 @@ var ( mint.AppModuleBasic{}, ccvdistr.AppModuleBasic{}, gov.NewAppModuleBasic( - // TODO: eventually remove upgrade proposal handler and cancel proposal handler []govclient.ProposalHandler{ paramsclient.ProposalHandler, - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, }, ), params.AppModuleBasic{}, @@ -152,8 +165,7 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, - tendermint.AppModuleBasic{}, - // router.AppModuleBasic{}, + ibctm.AppModuleBasic{}, consumer.AppModuleBasic{}, consensus.AppModuleBasic{}, ) @@ -226,15 +238,6 @@ type App struct { // nolint: golint configurator module.Configurator } -func init() { - userHomeDir, err := os.UserHomeDir() - if err != nil { - stdlog.Println("Failed to get home dir %2", err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) -} - // New returns a reference to an initialized App. func New( logger log.Logger, @@ -244,19 +247,26 @@ func New( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { - encodingConfig := makeEncodingConfig() + encodingConfig := MakeTestEncodingConfig() appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig + // ABCI++, v50 + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp) + bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, @@ -264,8 +274,8 @@ func New( capabilitytypes.StoreKey, authzkeeper.StoreKey, consensusparamtypes.StoreKey, consumertypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, @@ -286,8 +296,8 @@ func New( ) // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{}) + bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( @@ -303,10 +313,11 @@ func New( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - AccountAddressPrefix, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -319,34 +330,37 @@ func New( app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, bankBlockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, ) app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, - app.BaseApp.MsgServiceRouter(), + app.MsgServiceRouter(), app.AccountKeeper, ) app.FeeGrantKeeper = feegrantkeeper.NewKeeper( appCodec, - keys[feegrant.StoreKey], + runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper, ) app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, @@ -357,13 +371,13 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], - &app.ConsumerKeeper, + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), + app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -374,13 +388,13 @@ func New( invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = *crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), ) - // get skipUpgradeHeights from the app options skipUpgradeHeights := map[int64]bool{} for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) { @@ -390,7 +404,7 @@ func New( // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -407,14 +421,11 @@ func New( // register the proposal types ccvgovRouter := govv1beta1.NewRouter() ccvgovRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - // TODO: remove upgrade handler from gov once admin module or decision for only signaling proposal is made. - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)) - + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) govConfig := govtypes.DefaultConfig() govKeeper := govkeeper.NewKeeper( - appCodec, keys[govtypes.StoreKey], app.AccountKeeper, app.BankKeeper, - app.StakingKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, + app.StakingKeeper, app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) govKeeper.SetLegacyRouter(ccvgovRouter) @@ -438,6 +449,7 @@ func New( app.ConsumerKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.IBCKeeper = ibckeeper.NewKeeper( @@ -447,6 +459,7 @@ func New( &app.ConsumerKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Create CCV consumer and modules @@ -456,7 +469,7 @@ func New( app.GetSubspace(consumertypes.ModuleName), scopedIBCConsumerKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.SlashingKeeper, @@ -465,6 +478,9 @@ func New( &app.TransferKeeper, app.IBCKeeper, authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) // Setting the standalone staking keeper is only needed for standalone to consumer changeover chains @@ -475,7 +491,7 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), &app.ConsumerKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -490,10 +506,11 @@ func New( app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) transferModule := transfer.NewAppModule(app.TransferKeeper) ibcmodule := transfer.NewIBCModule(app.TransferKeeper) @@ -507,9 +524,11 @@ func New( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), &app.ConsumerKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) app.EvidenceKeeper = *evidenceKeeper @@ -521,8 +540,8 @@ func New( app.MM = module.NewManager( genutil.NewAppModule( app.AccountKeeper, - app.ConsumerKeeper, - app.BaseApp.DeliverTx, + &app.ConsumerKeeper, + app, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), @@ -533,27 +552,36 @@ func New( feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), ccvgov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, IsProposalWhitelisted, app.GetSubspace(govtypes.ModuleName), IsModuleWhiteList), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper, authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)), - ccvstaking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(&app.UpgradeKeeper), + ccvstaking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ibc.NewAppModule(app.IBCKeeper), + ibctm.NewAppModule(), transferModule, consumerModule, consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), ) + ModuleBasics = module.NewBasicManagerFromManager( + app.MM, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + }) + + app.MM.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) + // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.MM.SetOrderBeginBlockers( - // upgrades should be run first - upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, @@ -612,7 +640,6 @@ func New( slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, - crisistypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, @@ -624,67 +651,23 @@ func New( ibchost.ModuleName, ibctransfertypes.ModuleName, consumertypes.ModuleName, + crisistypes.ModuleName, ) app.MM.RegisterInvariants(&app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.MM.RegisterServices(app.configurator) - - // create the simulation manager and define the order of the modules for deterministic simulations - // - // NOTE: this is not required apps that don't use the simulator for fuzz testing - // transactions - app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), - capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - ccvgov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, IsProposalWhitelisted, app.GetSubspace(govtypes.ModuleName), IsModuleWhiteList), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - ccvstaking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - ccvdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper, authtypes.FeeCollectorName, app.GetSubspace(distrtypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - transferModule, - ) - - app.sm.RegisterStoreDecoders() - - // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) - - anteHandler, err := NewAnteHandler( - HandlerOptions{ - HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - FeegrantKeeper: app.FeeGrantKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, - IBCKeeper: app.IBCKeeper, - ConsumerKeeper: app.ConsumerKeeper, - }, - ) + err := app.MM.RegisterServices(app.configurator) if err != nil { - panic(fmt.Errorf("failed to create AnteHandler: %s", err)) + panic(err) } - app.SetAnteHandler(anteHandler) - - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - app.SetEndBlocker(app.EndBlocker) // Note this upgrade handler is just an example and may not be exactly what you need to implement. // See https://docs.cosmos.network/v0.45/building-modules/upgrade.html app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { - app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) + func(ctx context.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + app.IBCKeeper.ConnectionKeeper.SetParams(sdkCtx, ibcconnectiontypes.DefaultParams()) fromVM := make(map[string]uint64) @@ -714,9 +697,9 @@ func New( appCodec.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis) consumerGenesis.PreCCV = true - app.ConsumerKeeper.InitGenesis(ctx, &consumerGenesis) + app.ConsumerKeeper.InitGenesis(sdkCtx, &consumerGenesis) - ctx.Logger().Info("start to run module migrations...") + app.Logger().Info("start to run module migrations...") // Note: consumer ccv module is added to app.MM.Modules constructor above, // meaning the consumer ccv module will have an entry in fromVM. @@ -743,23 +726,64 @@ func New( app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) + + reflectionSvc, err := runtimeservices.NewReflectionService() + if err != nil { + panic(err) + } + reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + + // initialize stores + app.MountKVStores(keys) + app.MountTransientStores(tkeys) + app.MountMemoryStores(memKeys) + + anteHandler, err := NewAnteHandler( + HandlerOptions{ + HandlerOptions: ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + IBCKeeper: app.IBCKeeper, + ConsumerKeeper: app.ConsumerKeeper, + }, + ) + if err != nil { + panic(fmt.Errorf("failed to create AnteHandler: %w", err)) + } + app.SetAnteHandler(anteHandler) + + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) + app.SetBeginBlocker(app.BeginBlocker) + app.SetEndBlocker(app.EndBlocker) + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err)) } } - app.ScopedIBCKeeper = scopedIBCKeeper - app.ScopedTransferKeeper = scopedTransferKeeper - app.ScopedIBCConsumerKeeper = scopedIBCConsumerKeeper - - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) - - reflectionSvc, err := runtimeservices.NewReflectionService() + // At startup, after all modules have been registered, check that all prot + // annotations are correct. + protoFiles, err := proto.MergedRegistry() if err != nil { panic(err) } - reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + err = msgservice.ValidateProtoAnnotations(protoFiles) + if err != nil { + // Once we switch to using protoreflect-based antehandlers, we might + // want to panic here instead of logging a warning. + fmt.Fprintln(os.Stderr, err.Error()) + } + + app.ScopedIBCKeeper = scopedIBCKeeper + app.ScopedTransferKeeper = scopedTransferKeeper + app.ScopedIBCConsumerKeeper = scopedIBCConsumerKeeper return app } @@ -767,18 +791,22 @@ func New( // Name returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } +func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.MM.PreBlock(ctx) +} + // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.MM.BeginBlock(ctx, req) +func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.MM.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.MM.EndBlock(ctx, req) +func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.MM.EndBlock(ctx) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -881,7 +909,7 @@ func (app *App) GetTestSlashingKeeper() testutil.TestSlashingKeeper { } // GetTestEvidenceKeeper implements the ConsumerApp interface. -func (app *App) GetTestEvidenceKeeper() testutil.TestEvidenceKeeper { +func (app *App) GetTestEvidenceKeeper() evidencekeeper.Keeper { return app.EvidenceKeeper } @@ -896,12 +924,12 @@ func (app *App) GetTestDistributionKeeper() testutil.TestDistributionKeeper { } // GetTestMintKeeper implements the ConsumerApp interface. -func (app *App) GetTestMintKeeper() testutil.TestMintKeeper { +func (app *App) GetTestMintKeeper() mintkeeper.Keeper { return app.MintKeeper } // GetTestGovKeeper implements the ConsumerApp interface. -func (app *App) GetTestGovKeeper() testutil.TestGovKeeper { +func (app *App) GetTestGovKeeper() govkeeper.Keeper { return app.GovKeeper } @@ -929,7 +957,7 @@ func (app *App) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { // GetTxConfig implements the TestingApp interface. func (app *App) GetTxConfig() client.TxConfig { - return MakeTestEncodingConfig().TxConfig + return app.txConfig } // TxConfig returns SimApp's TxConfig @@ -937,6 +965,26 @@ func (app *App) TxConfig() client.TxConfig { return app.txConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *App) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.MM.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { @@ -944,7 +992,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register node gRPC service for grpc-gateway. nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) @@ -963,13 +1011,13 @@ func (app *App) RegisterTxService(clientCtx client.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } -func (app *App) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *App) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) + cmtservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) } // GetMaccPerms returns a copy of the module account permissions @@ -1012,12 +1060,3 @@ func MakeTestEncodingConfig() appencoding.EncodingConfig { ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } - -func makeEncodingConfig() appencoding.EncodingConfig { - encodingConfig := appencoding.MakeTestEncodingConfig() - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig -} diff --git a/app/consumer-democracy/export.go b/app/consumer-democracy/export.go index bb710da1c4..9f73ae654d 100644 --- a/app/consumer-democracy/export.go +++ b/app/consumer-democracy/export.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" ) @@ -18,7 +17,7 @@ func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs, modulesToExport []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContext(true) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -28,7 +27,10 @@ func (app *App) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.MM.ExportGenesis(ctx, app.appCodec) + genState, err := app.MM.ExportGenesis(ctx, app.appCodec) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err diff --git a/app/consumer-democracy/proposals_whitelisting.go b/app/consumer-democracy/proposals_whitelisting.go index 1e9141895c..975c9dbbad 100644 --- a/app/consumer-democracy/proposals_whitelisting.go +++ b/app/consumer-democracy/proposals_whitelisting.go @@ -1,8 +1,7 @@ package app import ( - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/params/types/proposal" ) @@ -11,7 +10,6 @@ func IsProposalWhitelisted(content v1beta1.Content) bool { switch c := content.(type) { case *proposal.ParameterChangeProposal: return isLegacyParamChangeWhitelisted(c.Changes) - default: return false } @@ -31,19 +29,24 @@ type legacyParamChangeKey struct { Subspace, Key string } +// these parameters don't exist in the consumer app -- keeping them as an example var LegacyWhitelistedParams = map[legacyParamChangeKey]struct{}{ - // ibc transfer - {Subspace: ibctransfertypes.ModuleName, Key: "SendEnabled"}: {}, - {Subspace: ibctransfertypes.ModuleName, Key: "ReceiveEnabled"}: {}, - // add interchain account params(HostEnabled, AllowedMessages) once the module is added to the consumer app + // add whitelisted legacy parameters here [cosmos-sdk <= 0.47] + // commented parameters are just an example - most params have been moved to their respective modules + // and they cannot be changed through legacy governance proposals + {Subspace: banktypes.ModuleName, Key: "SendEnabled"}: {}, } +// add whitelisted module param update messages [cosmos-sdk >= 0.47] var WhiteListModule = map[string]struct{}{ - "/cosmos.gov.v1.MsgUpdateParams": {}, - "/cosmos.bank.v1beta1.MsgUpdateParams": {}, - "/cosmos.staking.v1beta1.MsgUpdateParams": {}, - "/cosmos.distribution.v1beta1.MsgUpdateParams": {}, - "/cosmos.mint.v1beta1.MsgUpdateParams": {}, + "/cosmos.gov.v1.MsgUpdateParams": {}, + "/cosmos.bank.v1beta1.MsgUpdateParams": {}, + "/cosmos.staking.v1beta1.MsgUpdateParams": {}, + "/cosmos.distribution.v1beta1.MsgUpdateParams": {}, + "/cosmos.mint.v1beta1.MsgUpdateParams": {}, + "/cosmos.gov.v1beta1.TextProposal": {}, + "/ibc.applications.transfer.v1.MsgUpdateParams": {}, + "/interchain_security.ccv.consumer.v1.MsgUpdateParams": {}, } func IsModuleWhiteList(typeUrl string) bool { diff --git a/app/consumer-democracy/proposals_whitelisting_test.go b/app/consumer-democracy/proposals_whitelisting_test.go deleted file mode 100644 index 47dd42317a..0000000000 --- a/app/consumer-democracy/proposals_whitelisting_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package app_test - -import ( - "testing" - - ibctesting "github.com/cosmos/ibc-go/v7/testing" - "github.com/stretchr/testify/require" - - appConsumer "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" -) - -func TestDemocracyGovernanceWhitelistingKeys(t *testing.T) { - _, valUpdates, _, err := testutil.CreateValidators(4, "consumer") - require.NoError(t, err) - 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) - require.True(t, ok, "Unknown subspace %s", paramKey.Subspace) - hasKey := ss.Has(chain.GetContext(), []byte(paramKey.Key)) - require.True(t, hasKey, "Invalid key %s for subspace %s", paramKey.Key, paramKey.Subspace) - } -} diff --git a/app/consumer/abci.go b/app/consumer/abci.go new file mode 100644 index 0000000000..94b34cc3bb --- /dev/null +++ b/app/consumer/abci.go @@ -0,0 +1,84 @@ +package app + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + // VoteExtensionHandler defines a dummy vote extension handler for SimApp. + // + // NOTE: This implementation is solely used for testing purposes. DO NOT use + // in a production application! + VoteExtensionHandler struct{} + + // VoteExtension defines the structure used to create a dummy vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/app/consumer/ante/disabled_modules_ante_test.go b/app/consumer/ante/disabled_modules_ante_test.go index 7fa95f37c6..187d8bc956 100644 --- a/app/consumer/ante/disabled_modules_ante_test.go +++ b/app/consumer/ante/disabled_modules_ante_test.go @@ -3,17 +3,17 @@ package ante_test import ( "testing" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/stretchr/testify/require" + evidencetypes "cosmossdk.io/x/evidence/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/interchain-security/v4/app/consumer/ante" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" + "github.com/cosmos/interchain-security/v5/app/consumer/ante" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" ) func TestDisabledModulesDecorator(t *testing.T) { diff --git a/app/consumer/ante/msg_filter_ante_test.go b/app/consumer/ante/msg_filter_ante_test.go index bfc1bb0a50..9080844c03 100644 --- a/app/consumer/ante/msg_filter_ante_test.go +++ b/app/consumer/ante/msg_filter_ante_test.go @@ -3,14 +3,14 @@ package ante_test import ( "testing" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/interchain-security/v4/app/consumer/ante" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" + "github.com/cosmos/interchain-security/v5/app/consumer/ante" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" ) type consumerKeeper struct { diff --git a/app/consumer/ante_handler.go b/app/consumer/ante_handler.go index fa28a52caf..24dcfea0e9 100644 --- a/app/consumer/ante_handler.go +++ b/app/consumer/ante_handler.go @@ -1,8 +1,8 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" errorsmod "cosmossdk.io/errors" @@ -10,8 +10,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - consumerante "github.com/cosmos/interchain-security/v4/app/consumer/ante" - ibcconsumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" + consumerante "github.com/cosmos/interchain-security/v5/app/consumer/ante" + ibcconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" ) // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC diff --git a/app/consumer/app.go b/app/consumer/app.go index e1d82bb600..8eb64bf5c6 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -1,33 +1,48 @@ package app import ( + "context" "fmt" "io" stdlog "log" "os" "path/filepath" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - 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" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" + "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" + + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" + "github.com/spf13/cast" + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -37,14 +52,13 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/std" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -55,19 +69,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -77,29 +83,39 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" + dbm "github.com/cosmos/cosmos-db" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - ibcconsumer "github.com/cosmos/interchain-security/v4/x/ccv/consumer" - ibcconsumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - ibcconsumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + ibcconsumer "github.com/cosmos/interchain-security/v5/x/ccv/consumer" + ibcconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + ibcconsumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) const ( - AppName = "interchain-security-c" - upgradeName = "ics-v1-to-v2" - AccountAddressPrefix = "consumer" + AppName = "interchain-security-c" + upgradeName = "ics-v1-to-v2" + + Bech32MainPrefix = "consumer" ) +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + stdlog.Println("Failed to get home dir %2", err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) +} + var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -122,7 +138,7 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, - tendermint.AppModuleBasic{}, + ibctm.AppModuleBasic{}, // router.AppModuleBasic{}, ibcconsumer.AppModuleBasic{}, ) @@ -149,12 +165,13 @@ type App struct { // nolint: golint *baseapp.BaseApp legacyAmino *codec.LegacyAmino appCodec codec.Codec - txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry + txConfig client.TxConfig // keys to access the substores - keys map[string]*storetypes.KVStoreKey - tkeys map[string]*storetypes.TransientStoreKey + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey // keepers @@ -163,10 +180,6 @@ type App struct { // nolint: golint CapabilityKeeper *capabilitykeeper.Keeper SlashingKeeper slashingkeeper.Keeper - // NOTE the distribution keeper should either be removed - // from consumer chain or set to use an independent - // different fee-pool from the consumer chain ConsumerKeeper - CrisisKeeper crisiskeeper.Keeper UpgradeKeeper upgradekeeper.Keeper ParamsKeeper paramskeeper.Keeper @@ -191,15 +204,6 @@ type App struct { // nolint: golint configurator module.Configurator } -func init() { - userHomeDir, err := os.UserHomeDir() - if err != nil { - stdlog.Println("Failed to get home dir %2", err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) -} - // New returns a reference to an initialized App. func New( logger log.Logger, @@ -216,20 +220,28 @@ func New( interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig + // ABCI++, v50 + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp) + bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, slashingtypes.StoreKey, crisistypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, + consensusparamtypes.StoreKey, ibcconsumertypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, @@ -250,8 +262,8 @@ func New( ) // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{}) + bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( @@ -267,10 +279,11 @@ func New( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - AccountAddressPrefix, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -283,20 +296,22 @@ func New( app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, bankBlockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, ) app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, - app.BaseApp.MsgServiceRouter(), + app.MsgServiceRouter(), app.AccountKeeper, ) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( appCodec, - keys[feegrant.StoreKey], + runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper, ) @@ -305,7 +320,7 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), &app.ConsumerKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -313,11 +328,12 @@ func New( invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = *crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), ) // get skipUpgradeHeights from the app options @@ -329,7 +345,7 @@ func New( // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -353,6 +369,7 @@ func New( app.ConsumerKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // initialize the actual consumer keeper @@ -362,7 +379,7 @@ func New( app.GetSubspace(ibcconsumertypes.ModuleName), scopedIBCConsumerKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.SlashingKeeper, @@ -371,6 +388,9 @@ func New( &app.TransferKeeper, app.IBCKeeper, authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) // register slashing module Slashing hooks to the consumer keeper @@ -383,10 +403,11 @@ func New( app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) transferModule := transfer.NewAppModule(app.TransferKeeper) ibcmodule := transfer.NewIBCModule(app.TransferKeeper) @@ -400,9 +421,11 @@ func New( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), &app.ConsumerKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) app.EvidenceKeeper = *evidenceKeeper @@ -415,7 +438,7 @@ func New( genutil.NewAppModule( app.AccountKeeper, app.ConsumerKeeper, - app.BaseApp.DeliverTx, + app, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), @@ -423,17 +446,28 @@ func New( bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper, app.GetSubspace(slashingtypes.ModuleName)), - upgrade.NewAppModule(&app.UpgradeKeeper), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), + upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ibc.NewAppModule(app.IBCKeeper), + ibctm.NewAppModule(), params.NewAppModule(app.ParamsKeeper), transferModule, consumerModule, ) + ModuleBasics = module.NewBasicManagerFromManager( + app.MM, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + }) + + app.MM.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) + // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. @@ -441,7 +475,6 @@ func New( // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.MM.SetOrderBeginBlockers( // upgrades should be run first - upgradetypes.ModuleName, capabilitytypes.ModuleName, crisistypes.ModuleName, ibctransfertypes.ModuleName, @@ -457,6 +490,8 @@ func New( vestingtypes.ModuleName, ibcconsumertypes.ModuleName, ) + app.SetPreBlocker(app.PreBlocker) + app.MM.SetOrderEndBlockers( crisistypes.ModuleName, ibctransfertypes.ModuleName, @@ -501,30 +536,32 @@ func New( app.MM.RegisterInvariants(&app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.MM.RegisterServices(app.configurator) - - // create the simulation manager and define the order of the modules for deterministic simulations - // - // NOTE: this is not required apps that don't use the simulator for fuzz testing - // transactions - app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), - capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), - transferModule, - ) + err := app.MM.RegisterServices(app.configurator) + if err != nil { + panic(err) + } - app.sm.RegisterStoreDecoders() + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) + + reflectionSvc, err := runtimeservices.NewReflectionService() + if err != nil { + panic(err) + } + reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + + // add test gRPC service for testing gRPC queries in isolation + testpb.RegisterQueryServer(app.GRPCQueryRouter(), testpb.QueryImpl{}) // initialize stores app.MountKVStores(keys) app.MountTransientStores(tkeys) app.MountMemoryStores(memKeys) + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) + app.SetBeginBlocker(app.BeginBlocker) + app.SetEndBlocker(app.EndBlocker) + anteHandler, err := NewAnteHandler( HandlerOptions{ HandlerOptions: ante.HandlerOptions{ @@ -539,20 +576,17 @@ func New( }, ) if err != nil { - panic(fmt.Errorf("failed to create AnteHandler: %s", err)) + panic(fmt.Errorf("failed to create AnteHandler: %w", err)) } app.SetAnteHandler(anteHandler) - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - app.SetEndBlocker(app.EndBlocker) - // Note this upgrade handler is just an example and may not be exactly what you need to implement. // See https://docs.cosmos.network/v0.45/building-modules/upgrade.html app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { - app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) + func(ctx context.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + app.IBCKeeper.ConnectionKeeper.SetParams(sdkCtx, ibcconnectiontypes.DefaultParams()) fromVM := make(map[string]uint64) @@ -563,7 +597,7 @@ func New( } } - ctx.Logger().Info("start to run module migrations...") + app.Logger().Info("start to run module migrations...") return app.MM.RunMigrations(ctx, app.configurator, fromVM) }, @@ -591,32 +625,28 @@ func New( app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedIBCConsumerKeeper = scopedIBCConsumerKeeper - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) - - reflectionSvc, err := runtimeservices.NewReflectionService() - if err != nil { - panic(err) - } - reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) - return app } // Name returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } +func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.MM.PreBlock(ctx) +} + // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.MM.BeginBlock(ctx, req) +func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.MM.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.MM.EndBlock(ctx, req) +func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.MM.EndBlock(ctx) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -719,7 +749,7 @@ func (app *App) GetTestSlashingKeeper() testutil.TestSlashingKeeper { } // GetTestEvidenceKeeper implements the ConsumerApp interface. -func (app *App) GetTestEvidenceKeeper() testutil.TestEvidenceKeeper { +func (app *App) GetTestEvidenceKeeper() evidencekeeper.Keeper { return app.EvidenceKeeper } @@ -755,6 +785,26 @@ func (app *App) TxConfig() client.TxConfig { return app.txConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *App) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.MM.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { @@ -763,7 +813,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc query routes. ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) @@ -774,13 +824,13 @@ func (app *App) RegisterTxService(clientCtx client.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } -func (app *App) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *App) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) + cmtservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) } // GetMaccPerms returns a copy of the module account permissions @@ -807,28 +857,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -// func MakeTestEncodingConfig() appparams.EncodingConfig { -// encodingConfig := appparams.MakeTestEncodingConfig() -// std.RegisterLegacyAminoCodec(encodingConfig.Amino) -// std.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) -// ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// return encodingConfig -// } - -// func makeEncodingConfig() simappparams.EncodingConfig { -// encodingConfig := simappparams.MakeTestEncodingConfig() -// std.RegisterLegacyAminoCodec(encodingConfig.Amino) -// std.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) -// ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// return encodingConfig -// } - func MakeTestEncodingConfig() appencoding.EncodingConfig { encodingConfig := appencoding.MakeTestEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/consumer/export.go b/app/consumer/export.go index 4260efda92..c8fd545f05 100644 --- a/app/consumer/export.go +++ b/app/consumer/export.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" ) @@ -18,7 +17,7 @@ func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs, modulesToExport []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContext(true) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -28,7 +27,10 @@ func (app *App) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.MM.ExportGenesis(ctx, app.appCodec) + genState, err := app.MM.ExportGenesis(ctx, app.appCodec) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err diff --git a/app/consumer/genesis.go b/app/consumer/genesis.go index 176d9d2d0e..ed7e1e7831 100644 --- a/app/consumer/genesis.go +++ b/app/consumer/genesis.go @@ -15,9 +15,8 @@ import ( "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/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + consumerTypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // The genesis state of the blockchain is represented here as a map of raw json diff --git a/app/consumer/genesis_test.go b/app/consumer/genesis_test.go index 16cdf94e25..e91c8a66d5 100644 --- a/app/consumer/genesis_test.go +++ b/app/consumer/genesis_test.go @@ -16,9 +16,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/x/auth/types" - app "github.com/cosmos/interchain-security/v4/app/consumer" - consumerTypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + app "github.com/cosmos/interchain-security/v5/app/consumer" + consumerTypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( diff --git a/app/encoding/encoding.go b/app/encoding/encoding.go index 6897e53634..216adac79c 100644 --- a/app/encoding/encoding.go +++ b/app/encoding/encoding.go @@ -1,10 +1,14 @@ package encoding import ( + "cosmossdk.io/x/tx/signing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/cosmos/gogoproto/proto" ) // EncodingConfig specifies the concrete encoding types to use for a given app. @@ -19,7 +23,17 @@ type EncodingConfig struct { // MakeTestEncodingConfig creates an EncodingConfig for an amino based test configuration. func MakeTestEncodingConfig() EncodingConfig { amino := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) chainCodec := codec.NewProtoCodec(interfaceRegistry) txCfg := tx.NewTxConfig(chainCodec, tx.DefaultSignModes) diff --git a/app/provider/abci.go b/app/provider/abci.go new file mode 100644 index 0000000000..94b34cc3bb --- /dev/null +++ b/app/provider/abci.go @@ -0,0 +1,84 @@ +package app + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + // VoteExtensionHandler defines a dummy vote extension handler for SimApp. + // + // NOTE: This implementation is solely used for testing purposes. DO NOT use + // in a production application! + VoteExtensionHandler struct{} + + // VoteExtension defines the structure used to create a dummy vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/app/provider/ante_handler.go b/app/provider/ante_handler.go index 9ba33d3264..564f96284d 100644 --- a/app/provider/ante_handler.go +++ b/app/provider/ante_handler.go @@ -1,8 +1,8 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" errorsmod "cosmossdk.io/errors" diff --git a/app/provider/app.go b/app/provider/app.go index 47eee5c79c..23262161b4 100644 --- a/app/provider/app.go +++ b/app/provider/app.go @@ -1,37 +1,47 @@ package app import ( + "context" "fmt" "io" stdlog "log" "os" "path/filepath" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client" - ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - 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/cosmos/gogoproto/proto" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" + + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/tx/signing" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -40,14 +50,15 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/std" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" + "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -55,19 +66,15 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -89,30 +96,31 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" - - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - ibcprovider "github.com/cosmos/interchain-security/v4/x/ccv/provider" - ibcproviderclient "github.com/cosmos/interchain-security/v4/x/ccv/provider/client" - ibcproviderkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + dbm "github.com/cosmos/cosmos-db" + + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + ibcprovider "github.com/cosmos/interchain-security/v5/x/ccv/provider" + ibcproviderclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" + ibcproviderkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + + "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" + sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" ) const ( - AppName = "interchain-security-p" - upgradeName = "ics-v1-to-v2" - AccountAddressPrefix = "cosmos" + AppName = "interchain-security-p" + upgradeName = "ics-v1-to-v2" ) // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals @@ -125,36 +133,33 @@ var ( // non-dependant module elements, such as codec registration // and genesis verification. ModuleBasics = module.NewBasicManager( - auth.AppModuleBasic{}, genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + auth.AppModuleBasic{}, + vesting.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, - staking.AppModuleBasic{}, - mint.AppModuleBasic{}, - distr.AppModuleBasic{}, + consensus.AppModuleBasic{}, + crisis.AppModuleBasic{}, gov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, ibcproviderclient.ConsumerAdditionProposalHandler, ibcproviderclient.ConsumerRemovalProposalHandler, ibcproviderclient.ConsumerModificationProposalHandler, ibcproviderclient.ChangeRewardDenomsProposalHandler, }, ), - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, + mint.AppModuleBasic{}, slashing.AppModuleBasic{}, - ibc.AppModuleBasic{}, + distr.AppModuleBasic{}, + staking.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, + + ibc.AppModuleBasic{}, + ibctm.AppModuleBasic{}, + params.AppModuleBasic{}, transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - tendermint.AppModuleBasic{}, - // router.AppModuleBasic{}, ibcprovider.AppModuleBasic{}, ) @@ -246,27 +251,52 @@ func New( appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { - encodingConfig := makeEncodingConfig() - - appCodec := encodingConfig.Codec - legacyAmino := encodingConfig.Amino - interfaceRegistry := encodingConfig.InterfaceRegistry + interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, + }) + appCodec := codec.NewProtoCodec(interfaceRegistry) + legacyAmino := codec.NewLegacyAmino() + txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) + + std.RegisterLegacyAminoCodec(legacyAmino) + std.RegisterInterfaces(interfaceRegistry) + // ABCI++, v50 + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp) - bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp := baseapp.NewBaseApp(AppName, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, providertypes.StoreKey, + consensusparamtypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + + // register streaming services + if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { + panic(err) + } + + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, @@ -276,7 +306,7 @@ func New( keys: keys, tkeys: tkeys, memKeys: memKeys, - txConfig: encodingConfig.TxConfig, + txConfig: txConfig, } app.ParamsKeeper = initParamsKeeper( @@ -288,8 +318,14 @@ func New( // set the BaseApp's parameter store // upgradetypes.StoreKey -> maybe consensusparamtypes.StoreKey (package consensusparamtypes ("github.com/cosmos/cosmos-sdk/x/consensus/types") - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + runtime.EventService{}, + ) + + bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( @@ -297,7 +333,7 @@ func New( keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey], ) - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedIBCProviderKeeper := app.CapabilityKeeper.ScopeToModule(providertypes.ModuleName) app.CapabilityKeeper.Seal() @@ -305,10 +341,11 @@ func New( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - AccountAddressPrefix, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -321,22 +358,25 @@ func New( app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, bankBlockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, ) app.StakingKeeper = stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, @@ -345,7 +385,7 @@ func New( ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -355,7 +395,7 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -363,11 +403,12 @@ func New( invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = *crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), ) // get skipUpgradeHeights from the app options @@ -379,7 +420,7 @@ func New( // set the governance module account as the authority for conducting upgrades app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -398,29 +439,34 @@ func New( app.IBCKeeper = ibckeeper.NewKeeper( appCodec, - keys[ibchost.StoreKey], - app.GetSubspace(ibchost.ModuleName), + keys[ibcexported.StoreKey], + app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // create evidence keeper with router app.EvidenceKeeper = *evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), app.StakingKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) + govConfig := govtypes.DefaultConfig() app.GovKeeper = govkeeper.NewKeeper( appCodec, - keys[govtypes.StoreKey], + runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, + app.DistrKeeper, app.MsgServiceRouter(), - govtypes.DefaultConfig(), + govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -430,7 +476,7 @@ func New( app.GetSubspace(providertypes.ModuleName), scopedIBCProviderKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.IBCKeeper.ConnectionKeeper, app.IBCKeeper.ClientKeeper, app.StakingKeeper, @@ -438,22 +484,20 @@ func New( app.AccountKeeper, app.DistrKeeper, app.BankKeeper, - app.GovKeeper, + *app.GovKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), authtypes.FeeCollectorName, ) - providerModule := ibcprovider.NewAppModule(&app.ProviderKeeper, app.GetSubspace(providertypes.ModuleName)) - - // register the proposal types + // gov router must be set after the provider keeper is created + // otherwise the provider keeper will not be able to handle proposals (will be nil) govRouter := govv1beta1.NewRouter() govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)). - AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(app.ProviderKeeper)). - AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)) - + AddRoute(providertypes.RouterKey, ibcprovider.NewProviderProposalHandler(app.ProviderKeeper)) // Set legacy router for backwards compatibility with gov v1beta1 app.GovKeeper.SetLegacyRouter(govRouter) @@ -461,22 +505,25 @@ func New( govtypes.NewMultiGovHooks(app.ProviderKeeper.Hooks()), ) + providerModule := ibcprovider.NewAppModule(&app.ProviderKeeper, app.GetSubspace(providertypes.ModuleName)) + app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // Add an IBC middleware callback to track the consumer rewards var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) - transferStack = provider.NewIBCMiddleware(transferStack, app.ProviderKeeper) + transferStack = ibcprovider.NewIBCMiddleware(transferStack, app.ProviderKeeper) // create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() @@ -484,16 +531,6 @@ func New( ibcRouter.AddRoute(providertypes.ModuleName, providerModule) app.IBCKeeper.SetRouter(ibcRouter) - // create evidence keeper with router - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, - keys[evidencetypes.StoreKey], - app.StakingKeeper, - app.SlashingKeeper, - ) - - app.EvidenceKeeper = *evidenceKeeper - skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified @@ -502,41 +539,79 @@ func New( genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, - app.BaseApp.DeliverTx, - encodingConfig.TxConfig, + app, + txConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(&app.UpgradeKeeper), + upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), + ibc.NewAppModule(app.IBCKeeper), + ibctm.NewAppModule(), params.NewAppModule(app.ParamsKeeper), transfer.NewAppModule(app.TransferKeeper), providerModule, ) + // NOTE: @Msalopek -> ModuleBasic override is happening because Tx commands don't work without it + ModuleBasics = module.NewBasicManagerFromManager( + app.MM, + map[string]module.AppModuleBasic{ + genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + govtypes.ModuleName: gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + ibcproviderclient.ConsumerAdditionProposalHandler, + ibcproviderclient.ConsumerRemovalProposalHandler, + ibcproviderclient.ConsumerModificationProposalHandler, + ibcproviderclient.ChangeRewardDenomsProposalHandler, + }, + ), + }) + ModuleBasics.RegisterLegacyAminoCodec(app.legacyAmino) + ModuleBasics.RegisterInterfaces(app.interfaceRegistry) + + enabledSignModes := append(authtx.DefaultSignModes, + sigtypes.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := authtx.ConfigOptions{ + EnabledSignModes: enabledSignModes, + TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), + } + txConfig, err := authtx.NewTxConfigWithOptions( + appCodec, + txConfigOpts, + ) + if err != nil { + panic(err) + } + app.txConfig = txConfig + + app.MM.SetOrderPreBlockers( + upgradetypes.ModuleName, + ) + // During begin block slashing happens after distr.BeginBlocker so that // there is nothing left over in the validator fee pool, so as to keep the // CanWithdrawInvariant invariant. // NOTE: staking module is required if HistoricalEntries param > 0 // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) app.MM.SetOrderBeginBlockers( - // upgrades should be run first - upgradetypes.ModuleName, capabilitytypes.ModuleName, crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, ibctransfertypes.ModuleName, - ibchost.ModuleName, + ibcexported.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, @@ -554,7 +629,7 @@ func New( govtypes.ModuleName, stakingtypes.ModuleName, ibctransfertypes.ModuleName, - ibchost.ModuleName, + ibcexported.ModuleName, capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, @@ -585,7 +660,7 @@ func New( govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - ibchost.ModuleName, + ibcexported.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, genutiltypes.ModuleName, @@ -593,64 +668,23 @@ func New( upgradetypes.ModuleName, vestingtypes.ModuleName, providertypes.ModuleName, + consensusparamtypes.ModuleName, ) app.MM.RegisterInvariants(&app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - app.MM.RegisterServices(app.configurator) - - // create the simulation manager and define the order of the modules for deterministic simulations - // - // NOTE: this is not required apps that don't use the simulator for fuzz testing - // transactions - app.sm = module.NewSimulationManager( - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), - capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - transfer.NewAppModule(app.TransferKeeper), - ) - - app.sm.RegisterStoreDecoders() - - // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) - - anteHandler, err := NewAnteHandler( - HandlerOptions{ - HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, - IBCKeeper: app.IBCKeeper, - }, - ) + err = app.MM.RegisterServices(app.configurator) if err != nil { - panic(fmt.Errorf("failed to create AnteHandler: %s", err)) + panic(err) } - app.SetAnteHandler(anteHandler) - - app.SetInitChainer(app.InitChainer) - app.SetBeginBlocker(app.BeginBlocker) - app.SetEndBlocker(app.EndBlocker) // Note this upgrade handler is just an example and may not be exactly what you need to implement. // See https://docs.cosmos.network/v0.45/building-modules/upgrade.html app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { - app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) + func(ctx context.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + app.IBCKeeper.ConnectionKeeper.SetParams(sdkCtx, ibcconnectiontypes.DefaultParams()) fromVM := make(map[string]uint64) @@ -661,7 +695,7 @@ func New( } } - ctx.Logger().Info("start to run module migrations...") + app.Logger().Info("start to run module migrations...") return app.MM.RunMigrations(ctx, app.configurator, fromVM) }, @@ -679,6 +713,58 @@ func New( app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) + + reflectionSvc, err := runtimeservices.NewReflectionService() + if err != nil { + panic(err) + } + reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) + + // add test gRPC service for testing gRPC queries in isolation + testpb.RegisterQueryServer(app.GRPCQueryRouter(), testpb.QueryImpl{}) + + // initialize stores + app.MountKVStores(keys) + app.MountTransientStores(tkeys) + app.MountMemoryStores(memKeys) + + anteHandler, err := NewAnteHandler( + HandlerOptions{ + HandlerOptions: ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: txConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + IBCKeeper: app.IBCKeeper, + }, + ) + if err != nil { + panic(fmt.Errorf("failed to create AnteHandler: %w", err)) + } + + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(app.PreBlocker) + app.SetBeginBlocker(app.BeginBlocker) + app.SetEndBlocker(app.EndBlocker) + app.SetAnteHandler(anteHandler) + + app.setPostHandler() + + // At startup, after all modules have been registered, check that all prot + // annotations are correct. + protoFiles, err := proto.MergedRegistry() + if err != nil { + panic(err) + } + err = msgservice.ValidateProtoAnnotations(protoFiles) + if err != nil { + // Once we switch to using protoreflect-based antehandlers, we might + // want to panic here instead of logging a warning. + fmt.Fprintln(os.Stderr, err.Error()) + } + if loadLatest { if err := app.LoadLatestVersion(); err != nil { tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err)) @@ -689,32 +775,44 @@ func New( app.ScopedTransferKeeper = scopedTransferKeeper app.ScopedIBCProviderKeeper = scopedIBCProviderKeeper - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.MM.Modules)) + return app +} - reflectionSvc, err := runtimeservices.NewReflectionService() +// Name returns the name of the App +func (app *App) Name() string { return app.BaseApp.Name() } + +// Configurator returns the configurator for the app +func (app *App) Configurator() module.Configurator { + return app.configurator +} + +func (app *App) setPostHandler() { + postHandler, err := posthandler.NewPostHandler( + posthandler.HandlerOptions{}, + ) if err != nil { panic(err) } - reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc) - return app + app.SetPostHandler(postHandler) } -// Name returns the name of the App -func (app *App) Name() string { return app.BaseApp.Name() } +func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.MM.PreBlock(ctx) +} // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.MM.BeginBlock(ctx, req) +func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.MM.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.MM.EndBlock(ctx, req) +func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.MM.EndBlock(ctx) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -827,6 +925,11 @@ func (app *App) GetTestAccountKeeper() testutil.TestAccountKeeper { return app.AccountKeeper } +// GetTestGovKeeper implements the ProviderApp interface. +func (app *App) GetTestGovKeeper() *govkeeper.Keeper { + return app.GovKeeper +} + // TestingApp functions // GetBaseApp implements the TestingApp interface. @@ -859,6 +962,27 @@ func (app *App) TxConfig() client.TxConfig { return app.txConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *App) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.MM.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.MM.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { @@ -866,7 +990,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register node gRPC service for grpc-gateway. nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) @@ -885,13 +1009,14 @@ func (app *App) RegisterTxService(clientCtx client.Context) { authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) } -func (app *App) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *App) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) + cmtApp := server.NewCometABCIWrapper(app) + cmtservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query) } // GetMaccPerms returns a copy of the module account permissions @@ -916,25 +1041,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(gov.ProvideKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(ibchost.ModuleName) + paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(providertypes.ModuleName) return paramsKeeper } -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -// func MakeTestEncodingConfig() appparams.EncodingConfig { -// encodingConfig := appparams.MakeTestEncodingConfig() -// std.RegisterLegacyAminoCodec(encodingConfig.Amino) -// std.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) -// ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// return encodingConfig -// } - func MakeTestEncodingConfig() appencoding.EncodingConfig { encodingConfig := appencoding.MakeTestEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) @@ -946,9 +1058,5 @@ func MakeTestEncodingConfig() appencoding.EncodingConfig { func makeEncodingConfig() appencoding.EncodingConfig { encodingConfig := appencoding.MakeTestEncodingConfig() - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) return encodingConfig } diff --git a/app/provider/export.go b/app/provider/export.go index 74faed0657..9fec37e3f2 100644 --- a/app/provider/export.go +++ b/app/provider/export.go @@ -4,13 +4,12 @@ import ( "encoding/json" "log" + storetypes "cosmossdk.io/store/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" ) // ExportAppStateAndValidators exports the state of the application for a genesis @@ -19,7 +18,7 @@ func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs, modulesToExport []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContext(true) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -29,7 +28,10 @@ func (app *App) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.MM.ExportGenesis(ctx, app.appCodec) + genState, err := app.MM.ExportGenesis(ctx, app.appCodec) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err @@ -76,7 +78,12 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // withdraw all validator commission app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + valAddr, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } + + _, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valAddr) if err != nil { panic(err) } @@ -84,9 +91,22 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str }) // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) + dels, err := app.StakingKeeper.GetAllDelegations(ctx) + if err != nil { + panic(err) + } for _, delegation := range dels { - _, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr()) + // TODO: add tests to figure this out (it's low impact since this is just a test app) + delAddr, err := app.AccountKeeper.AddressCodec().StringToBytes(delegation.GetDelegatorAddr()) + if err != nil { + panic(err) + } + // NOTE: @MSalopek this may be wrong -> need validator addr codec + valAddr, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(delegation.GetValidatorAddr()) + if err != nil { + panic(err) + } + _, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) if err != nil { panic(err) } @@ -105,12 +125,23 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // reinitialize all validators app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) + valAddr, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + panic(err) + } + + scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valAddr) + if err != nil { + panic(err) + } + feePool, err := app.DistrKeeper.FeePool.Get(ctx) + if err != nil { + panic(err) + } feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) + app.DistrKeeper.FeePool.Set(ctx, feePool) - err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + err = app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valAddr) if err != nil { panic(err) } @@ -119,11 +150,19 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // reinitialize all delegations for _, del := range dels { - err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + delAddr, err := app.AccountKeeper.AddressCodec().StringToBytes(del.GetDelegatorAddr()) + if err != nil { + panic(err) + } + valAddr, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(del.GetValidatorAddr()) if err != nil { panic(err) } - err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + err = app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) + if err != nil { + panic(err) + } + err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) if err != nil { panic(err) } @@ -155,13 +194,13 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) + iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { + validator, err := app.StakingKeeper.GetValidator(ctx, addr) + if err != nil { panic("expected validator, not found") } diff --git a/app/sovereign/Readme.md b/app/sovereign/Readme.md new file mode 100644 index 0000000000..5c50725983 --- /dev/null +++ b/app/sovereign/Readme.md @@ -0,0 +1,3 @@ +# Sovereign/Standalone chain + +Standalone simapp is modeled after the `app/consumer/app.go`. It must support all features that `app/consumer/app.go` supports so we can use it in standalone to consumer changeover procedures in our test suites. diff --git a/app/sovereign/abci.go b/app/sovereign/abci.go new file mode 100644 index 0000000000..94b34cc3bb --- /dev/null +++ b/app/sovereign/abci.go @@ -0,0 +1,84 @@ +package app + +import ( + "bytes" + "crypto/rand" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type ( + // VoteExtensionHandler defines a dummy vote extension handler for SimApp. + // + // NOTE: This implementation is solely used for testing purposes. DO NOT use + // in a production application! + VoteExtensionHandler struct{} + + // VoteExtension defines the structure used to create a dummy vote extension. + VoteExtension struct { + Hash []byte + Height int64 + Data []byte + } +) + +func NewVoteExtensionHandler() *VoteExtensionHandler { + return &VoteExtensionHandler{} +} + +func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { + bApp.SetExtendVoteHandler(h.ExtendVote()) + bApp.SetVerifyVoteExtensionHandler(h.VerifyVoteExtension()) +} + +func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { + return func(_ sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + buf := make([]byte, 1024) + + _, err := rand.Read(buf) + if err != nil { + return nil, fmt.Errorf("failed to generate random vote extension data: %w", err) + } + + ve := VoteExtension{ + Hash: req.Hash, + Height: req.Height, + Data: buf, + } + + bz, err := json.Marshal(ve) + if err != nil { + return nil, fmt.Errorf("failed to encode vote extension: %w", err) + } + + return &abci.ResponseExtendVote{VoteExtension: bz}, nil + } +} + +func (h *VoteExtensionHandler) VerifyVoteExtension() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + var ve VoteExtension + + if err := json.Unmarshal(req.VoteExtension, &ve); err != nil { + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + switch { + case req.Height != ve.Height: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case !bytes.Equal(req.Hash, ve.Hash): + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + + case len(ve.Data) != 1024: + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_REJECT}, nil + } + + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/app/sovereign/ante_handler.go b/app/sovereign/ante_handler.go index 9ba33d3264..564f96284d 100644 --- a/app/sovereign/ante_handler.go +++ b/app/sovereign/ante_handler.go @@ -1,8 +1,8 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" errorsmod "cosmossdk.io/errors" diff --git a/app/sovereign/app.go b/app/sovereign/app.go index 3d1a981e83..328fb5e4b9 100644 --- a/app/sovereign/app.go +++ b/app/sovereign/app.go @@ -1,33 +1,43 @@ package app import ( + "context" "fmt" "io" stdlog "log" "os" "path/filepath" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - 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/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v8/modules/core" + ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - + "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/core/appmodule" + + storetypes "cosmossdk.io/store/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" - "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -37,12 +47,12 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/std" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -54,9 +64,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/consensus" consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" @@ -66,12 +73,6 @@ import ( sdkdistr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov" @@ -79,7 +80,14 @@ 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" + "github.com/cosmos/ibc-go/modules/capability" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + // add mint + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" 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" @@ -94,25 +102,21 @@ import ( sdkstaking "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/cosmos-sdk/x/upgrade" - upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" - upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" + dbm "github.com/cosmos/cosmos-db" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" ) const ( AppName = "interchain-security-s" upgradeName = "v07-Theta" // arbitrary name, define your own appropriately named upgrade - AccountAddressPrefix = "consumer" + AccountAddressPrefix = "cosmos" ) var ( @@ -133,8 +137,6 @@ var ( sdkgov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, - upgradeclient.LegacyProposalHandler, - upgradeclient.LegacyCancelProposalHandler, }, ), params.AppModuleBasic{}, @@ -147,7 +149,7 @@ var ( evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, - tendermint.AppModuleBasic{}, + ibctm.AppModuleBasic{}, consensus.AppModuleBasic{}, ) @@ -240,21 +242,29 @@ func New( appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry + txConfig := encodingConfig.TxConfig + + // ABCI++, v50 + voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) + } + baseAppOptions = append(baseAppOptions, voteExtOp) bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) - keys := sdk.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, consensusparamtypes.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) + memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) app := &App{ BaseApp: bApp, @@ -264,7 +274,7 @@ func New( keys: keys, tkeys: tkeys, memKeys: memKeys, - txConfig: encodingConfig.TxConfig, + txConfig: txConfig, } app.ParamsKeeper = initParamsKeeper( @@ -275,9 +285,8 @@ func New( ) // set the BaseApp's parameter store - // upgradetypes.StoreKey -> maybe consensusparamtypes.StoreKey (package consensusparamtypes ("github.com/cosmos/cosmos-sdk/x/consensus/types") - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) - bApp.SetParamStore(&app.ConsensusParamsKeeper) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{}) + bApp.SetParamStore(&app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper( @@ -292,10 +301,11 @@ func New( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, - keys[authtypes.StoreKey], + runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, - AccountAddressPrefix, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + sdk.GetConfig().GetBech32AccountAddrPrefix(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -303,34 +313,38 @@ func New( app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, - keys[banktypes.StoreKey], + runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, bankBlockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, ) app.AuthzKeeper = authzkeeper.NewKeeper( - keys[authzkeeper.StoreKey], + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, - app.BaseApp.MsgServiceRouter(), + app.MsgServiceRouter(), app.AccountKeeper, ) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper( appCodec, - keys[feegrant.StoreKey], + runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper, ) app.StakingKeeper = *stakingkeeper.NewKeeper( appCodec, - keys[stakingtypes.StoreKey], + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, - keys[minttypes.StoreKey], + runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, @@ -341,14 +355,14 @@ func New( app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, - keys[distrtypes.StoreKey], + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, @@ -359,11 +373,12 @@ func New( invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = *crisiskeeper.NewKeeper( appCodec, - keys[crisistypes.StoreKey], + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + app.AccountKeeper.AddressCodec(), ) // get skipUpgradeHeights from the app options @@ -374,7 +389,7 @@ func New( homePath := cast.ToString(appOpts.Get(flags.FlagHome)) app.UpgradeKeeper = *upgradekeeper.NewKeeper( skipUpgradeHeights, - keys[upgradetypes.StoreKey], + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, @@ -394,16 +409,16 @@ func New( sdkgovRouter := govv1beta1.NewRouter() sdkgovRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)) + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) govConfig := govtypes.DefaultConfig() app.GovKeeper = *govkeeper.NewKeeper( appCodec, - keys[govtypes.StoreKey], + runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, + app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -418,12 +433,13 @@ func New( &app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, legacyAmino, - keys[slashingtypes.StoreKey], + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -434,10 +450,11 @@ func New( app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, - &app.IBCKeeper.PortKeeper, + app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) transferModule := transfer.NewAppModule(app.TransferKeeper) ibcmodule := transfer.NewIBCModule(app.TransferKeeper) @@ -450,9 +467,11 @@ func New( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, - keys[evidencetypes.StoreKey], + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), &app.StakingKeeper, app.SlashingKeeper, + app.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), ) app.EvidenceKeeper = *evidenceKeeper @@ -465,7 +484,7 @@ func New( genutil.NewAppModule( app.AccountKeeper, app.StakingKeeper, - app.BaseApp.DeliverTx, + app, encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, nil, app.GetSubspace(authtypes.ModuleName)), @@ -476,10 +495,10 @@ func New( feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), sdkgov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), sdkdistr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), sdkstaking.NewAppModule(appCodec, &app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(&app.UpgradeKeeper), + upgrade.NewAppModule(&app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), @@ -578,7 +597,7 @@ func New( }, ) if err != nil { - panic(fmt.Errorf("failed to create AnteHandler: %s", err)) + panic(fmt.Errorf("failed to create AnteHandler: %w", err)) } app.SetAnteHandler(anteHandler) @@ -588,9 +607,9 @@ func New( app.UpgradeKeeper.SetUpgradeHandler( upgradeName, - func(ctx sdk.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { - app.IBCKeeper.ConnectionKeeper.SetParams(ctx, ibcconnectiontypes.DefaultParams()) - + func(ctx context.Context, _ upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + app.IBCKeeper.ConnectionKeeper.SetParams(sdkCtx, ibcconnectiontypes.DefaultParams()) fromVM := make(map[string]uint64) for moduleName := range app.MM.Modules { @@ -600,7 +619,7 @@ func New( } } - ctx.Logger().Info("start to run module migrations...") + app.Logger().Info("start to run module migrations...") return app.MM.RunMigrations(ctx, app.configurator, fromVM) }, @@ -639,18 +658,22 @@ func New( // Name returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } +func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.MM.PreBlock(ctx) +} + // BeginBlocker application updates every begin block -func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - return app.MM.BeginBlock(ctx, req) +func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.MM.BeginBlock(ctx) } // EndBlocker application updates every end block -func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - return app.MM.EndBlock(ctx, req) +func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.MM.EndBlock(ctx) } // InitChainer application update at chain initialization -func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState GenesisState if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -742,7 +765,7 @@ func (app *App) GetTestSlashingKeeper() testutil.TestSlashingKeeper { return app.SlashingKeeper } -func (app *App) GetTestEvidenceKeeper() testutil.TestEvidenceKeeper { +func (app *App) GetTestEvidenceKeeper() evidencekeeper.Keeper { return app.EvidenceKeeper } @@ -754,11 +777,11 @@ func (app *App) GetTestDistributionKeeper() testutil.TestDistributionKeeper { return app.DistrKeeper } -func (app *App) GetTestMintKeeper() testutil.TestMintKeeper { +func (app *App) GetTestMintKeeper() mintkeeper.Keeper { return app.MintKeeper } -func (app *App) GetTestGovKeeper() testutil.TestGovKeeper { +func (app *App) GetTestGovKeeper() govkeeper.Keeper { return app.GovKeeper } @@ -794,23 +817,51 @@ func (app *App) TxConfig() client.TxConfig { return app.txConfig } +// AutoCliOpts returns the autocli options for the app. +func (app *App) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.MM.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.MM.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register new tendermint queries routes from grpc-gateway. - tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // Register new CometBFT queries routes from grpc-gateway. + cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register node gRPC service for grpc-gateway. nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register legacy and grpc-gateway routes for all modules. + // Register grpc-gateway routes for all modules. ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + + // register swagger API from root so that other applications can override easily + if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil { + panic(err) + } } -func (app *App) RegisterNodeService(clientCtx client.Context) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } // RegisterTxService implements the Application.RegisterTxService method. @@ -820,7 +871,8 @@ func (app *App) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *App) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) + cmtApp := server.NewCometABCIWrapper(app) + cmtservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, cmtApp.Query) } // GetMaccPerms returns a copy of the module account permissions @@ -850,19 +902,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -// func MakeTestEncodingConfig() appparams.EncodingConfig { -// encodingConfig := appparams.MakeTestEncodingConfig() -// std.RegisterLegacyAminoCodec(encodingConfig.Amino) -// std.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) -// ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// return encodingConfig -// } - func MakeTestEncodingConfig() appencoding.EncodingConfig { encodingConfig := appencoding.MakeTestEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/sovereign/export.go b/app/sovereign/export.go index 93d46bf973..53e9f6fee1 100644 --- a/app/sovereign/export.go +++ b/app/sovereign/export.go @@ -2,15 +2,16 @@ package app import ( "encoding/json" + "errors" "log" + storetypes "cosmossdk.io/store/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" ) // ExportAppStateAndValidators exports the state of the application for a genesis @@ -19,7 +20,7 @@ func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs, modulesToExport []string, ) (servertypes.ExportedApp, error) { // as if they could withdraw from the start of the next block - ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) + ctx := app.NewContext(true) // We export at last height + 1, because that's the height at which // Tendermint will start InitChain. @@ -29,7 +30,10 @@ func (app *App) ExportAppStateAndValidators( app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs) } - genState := app.MM.ExportGenesis(ctx, app.appCodec) + genState, err := app.MM.ExportGenesis(ctx, app.appCodec) + if err != nil { + return servertypes.ExportedApp{}, err + } appState, err := json.MarshalIndent(genState, "", " ") if err != nil { return servertypes.ExportedApp{}, err @@ -76,20 +80,31 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // withdraw all validator commission app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { panic(err) } + _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz) return false }) // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) + dels, err := app.StakingKeeper.GetAllDelegations(ctx) + if err != nil { + panic(err) + } for _, delegation := range dels { - _, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr()) + valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) if err != nil { panic(err) } + + delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) + if err != nil { + panic(err) + } + _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) } // clear validator slash events @@ -103,27 +118,49 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + valBz, err := sdk.ValAddressFromBech32(val.GetOperator()) + if err != nil { + panic(err) + } // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) + scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) + if err != nil { + panic(err) + } + feePool, err := app.DistrKeeper.FeePool.Get(ctx) + if err != nil { + panic(err) + } feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) + if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { + panic(err) + } - err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) - if err != nil { + if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil { panic(err) } return false }) + if err != nil { + panic(err) + } // reinitialize all delegations for _, del := range dels { - err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) + if err != nil { + panic(err) + } + delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) if err != nil { panic(err) } - err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()) + err = app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) + if err != nil { + panic(err) + } + err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) if err != nil { panic(err) } @@ -155,14 +192,14 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) + iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { - panic("expected validator, not found") + validator, err := app.StakingKeeper.GetValidator(ctx, addr) + if err != nil { + panic(errors.New("expected validator, not found")) } validator.UnbondingHeight = 0 diff --git a/cmd/interchain-security-cd/cmd/root.go b/cmd/interchain-security-cd/cmd/root.go index 215b45317a..0a980f3452 100644 --- a/cmd/interchain-security-cd/cmd/root.go +++ b/cmd/interchain-security-cd/cmd/root.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" - + "cosmossdk.io/client/v2/autocli" + confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" @@ -17,6 +17,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -27,12 +29,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" tmcfg "github.com/cometbft/cometbft/config" - "github.com/cometbft/cometbft/libs/log" + dbm "github.com/cosmos/cosmos-db" - consumer "github.com/cosmos/interchain-security/v4/app/consumer" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" + consumer "github.com/cosmos/interchain-security/v5/app/consumer" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" ) // NewRootCmd creates a new root command for simd. It is called once in the @@ -87,10 +89,38 @@ func NewRootCmd() *cobra.Command { } initRootCmd(rootCmd, encodingConfig) + autoCliOpts, err := enrichAutoCliOpts(tempApp.AutoCliOpts(), initClientCtx) + if err != nil { + panic(err) + } + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } return rootCmd } +func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { + autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) + autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) + autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) + + var err error + clientCtx, err = config.ReadFromClientConfig(clientCtx) + if err != nil { + return autocli.AppOptions{}, err + } + + autoCliOpts.ClientCtx = clientCtx + autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(clientCtx.Keyring) + if err != nil { + return autocli.AppOptions{}, err + } + + return autoCliOpts, nil +} + // initTendermintConfig helps to override default Tendermint Config values. // return tmcfg.DefaultConfig if no custom configuration is required for the application. func initTendermintConfig() *tmcfg.Config { @@ -121,11 +151,8 @@ func txCommand() *cobra.Command { authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), ) - consumer.ModuleBasics.AddTxCommands(cmd) - return cmd } @@ -187,29 +214,23 @@ lru_size = 0` } func initRootCmd(rootCmd *cobra.Command, encodingConfig appencoding.EncodingConfig) { - cfg := sdk.GetConfig() - cfg.Seal() - rootCmd.AddCommand( genutilcli.InitCmd(consumer.ModuleBasics, consumer.DefaultNodeHome), debug.Cmd(), - config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp, consumer.DefaultNodeHome), + confixcmd.ConfigCommand(), ) server.AddCommands(rootCmd, consumer.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + server.StatusCommand(), genesisCommand(encodingConfig, consumer.GetConsumerGenesisTransformCmd()), queryCommand(), txCommand(), - keys.Commands(consumer.DefaultNodeHome), + keys.Commands(), ) - - // add rosetta - rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) } // newApp is an appCreator @@ -296,16 +317,16 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), - rpc.BlockCommand(), + server.QueryBlockCmd(), + server.QueryBlocksCmd(), + server.QueryBlockResultsCmd(), authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), ) - consumer.ModuleBasics.AddQueryCommands(cmd) - return cmd } diff --git a/cmd/interchain-security-cd/main.go b/cmd/interchain-security-cd/main.go index a64a2a8645..6b36b93859 100644 --- a/cmd/interchain-security-cd/main.go +++ b/cmd/interchain-security-cd/main.go @@ -1,26 +1,23 @@ package main import ( + "fmt" "os" - "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - app "github.com/cosmos/interchain-security/v4/app/consumer" - appparams "github.com/cosmos/interchain-security/v4/app/params" - "github.com/cosmos/interchain-security/v4/cmd/interchain-security-cd/cmd" + app "github.com/cosmos/interchain-security/v5/app/consumer" + appparams "github.com/cosmos/interchain-security/v5/app/params" + "github.com/cosmos/interchain-security/v5/cmd/interchain-security-cd/cmd" ) func main() { - appparams.SetAddressPrefixes("consumer") + appparams.SetAddressPrefixes(app.Bech32MainPrefix) + rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - default: - os.Exit(1) - } + if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) } } diff --git a/cmd/interchain-security-cdd/cmd/root.go b/cmd/interchain-security-cdd/cmd/root.go index 6b2e6cc726..b71e1422c1 100644 --- a/cmd/interchain-security-cdd/cmd/root.go +++ b/cmd/interchain-security-cdd/cmd/root.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" - + "cosmossdk.io/client/v2/autocli" + confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" @@ -17,22 +17,28 @@ import ( "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" tmcfg "github.com/cometbft/cometbft/config" - "github.com/cometbft/cometbft/libs/log" + dbm "github.com/cosmos/cosmos-db" - cdd "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" + cdd "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" ) // NewRootCmd creates a new root command for simd. It is called once in the @@ -75,6 +81,24 @@ func NewRootCmd() *cobra.Command { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !initClientCtx.Offline { + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfigWithTextual, err := tx.NewTxConfigWithOptions( + codec.NewProtoCodec(encodingConfig.InterfaceRegistry), + txConfigOpts, + ) + if err != nil { + return err + } + initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual) + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -87,10 +111,38 @@ func NewRootCmd() *cobra.Command { } initRootCmd(rootCmd, encodingConfig) + autoCliOpts, err := enrichAutoCliOpts(tempApp.AutoCliOpts(), initClientCtx) + if err != nil { + panic(err) + } + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } return rootCmd } +func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { + autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) + autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) + autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) + + var err error + clientCtx, err = config.ReadFromClientConfig(clientCtx) + if err != nil { + return autocli.AppOptions{}, err + } + + autoCliOpts.ClientCtx = clientCtx + autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(clientCtx.Keyring) + if err != nil { + return autocli.AppOptions{}, err + } + + return autoCliOpts, nil +} + // initTendermintConfig helps to override default Tendermint Config values. // return tmcfg.DefaultConfig if no custom configuration is required for the application. func initTendermintConfig() *tmcfg.Config { @@ -121,11 +173,8 @@ func txCommand() *cobra.Command { authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), ) - cdd.ModuleBasics.AddTxCommands(cmd) - return cmd } @@ -187,29 +236,23 @@ lru_size = 0` } func initRootCmd(rootCmd *cobra.Command, encodingConfig appencoding.EncodingConfig) { - cfg := sdk.GetConfig() - cfg.Seal() - rootCmd.AddCommand( genutilcli.InitCmd(cdd.ModuleBasics, cdd.DefaultNodeHome), debug.Cmd(), - config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp, cdd.DefaultNodeHome), + confixcmd.ConfigCommand(), ) server.AddCommands(rootCmd, cdd.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + server.StatusCommand(), genesisCommand(encodingConfig), queryCommand(), txCommand(), - keys.Commands(cdd.DefaultNodeHome), + keys.Commands(), ) - - // add rosetta - rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) } // newApp is an appCreator @@ -296,14 +339,16 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), - rpc.BlockCommand(), + server.QueryBlockCmd(), + server.QueryBlocksCmd(), + server.QueryBlockResultsCmd(), authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), + authcmd.GetEncodeCommand(), + authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), ) - cdd.ModuleBasics.AddQueryCommands(cmd) - return cmd } diff --git a/cmd/interchain-security-cdd/main.go b/cmd/interchain-security-cdd/main.go index 9b6aacd759..d6a5d29d22 100644 --- a/cmd/interchain-security-cdd/main.go +++ b/cmd/interchain-security-cdd/main.go @@ -1,26 +1,23 @@ package main import ( + "fmt" "os" - "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - app "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - appparams "github.com/cosmos/interchain-security/v4/app/params" - "github.com/cosmos/interchain-security/v4/cmd/interchain-security-cdd/cmd" + app "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + appparams "github.com/cosmos/interchain-security/v5/app/params" + "github.com/cosmos/interchain-security/v5/cmd/interchain-security-cdd/cmd" ) func main() { - appparams.SetAddressPrefixes("consumer") + appparams.SetAddressPrefixes(app.Bech32MainPrefix) + rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - default: - os.Exit(1) - } + if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) } } diff --git a/cmd/interchain-security-pd/cmd/root.go b/cmd/interchain-security-pd/cmd/root.go index 8a8f5fec32..da0d719981 100644 --- a/cmd/interchain-security-pd/cmd/root.go +++ b/cmd/interchain-security-pd/cmd/root.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" - + "cosmossdk.io/client/v2/autocli" + confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" @@ -17,30 +17,36 @@ import ( "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - dbm "github.com/cometbft/cometbft-db" - tmcfg "github.com/cometbft/cometbft/config" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + cmtcfg "github.com/cometbft/cometbft/config" + dbm "github.com/cosmos/cosmos-db" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - providerApp "github.com/cosmos/interchain-security/v4/app/provider" + appEncoding "github.com/cosmos/interchain-security/v5/app/encoding" + providerApp "github.com/cosmos/interchain-security/v5/app/provider" ) // NewRootCmd creates a new root command for simd. It is called once in the // main function. func NewRootCmd() *cobra.Command { // we "pre"-instantiate the application for getting the injected/configured encoding configuration - tempApp := providerApp.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(providerApp.DefaultNodeHome)) - encodingConfig := appencoding.EncodingConfig{ + tempApp := providerApp.New(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir())) + encodingConfig := appEncoding.EncodingConfig{ InterfaceRegistry: tempApp.InterfaceRegistry(), Codec: tempApp.AppCodec(), TxConfig: tempApp.TxConfig(), @@ -50,7 +56,6 @@ func NewRootCmd() *cobra.Command { initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). @@ -58,13 +63,15 @@ func NewRootCmd() *cobra.Command { WithViper("") // In simapp, we don't use any prefix for env variables. rootCmd := &cobra.Command{ - Use: "simd", - Short: "simulation app", + Use: "simd", + Short: "simulation app", + SilenceErrors: true, PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { // set the default command outputs cmd.SetOut(cmd.OutOrStdout()) cmd.SetErr(cmd.ErrOrStderr()) + initClientCtx = initClientCtx.WithCmdContext(cmd.Context()) initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags()) if err != nil { return err @@ -75,58 +82,78 @@ func NewRootCmd() *cobra.Command { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !initClientCtx.Offline { + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfigWithTextual, err := tx.NewTxConfigWithOptions( + codec.NewProtoCodec(encodingConfig.InterfaceRegistry), + txConfigOpts, + ) + if err != nil { + return err + } + initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual) + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } customAppTemplate, customAppConfig := initAppConfig() - customTMConfig := initTendermintConfig() + customCMTConfig := initCometBFTConfig() - return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) + return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customCMTConfig) }, } initRootCmd(rootCmd, encodingConfig) + autoCliOpts, err := enrichAutoCliOpts(tempApp.AutoCliOpts(), initClientCtx) + if err != nil { + panic(err) + } + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } return rootCmd } -// initTendermintConfig helps to override default Tendermint Config values. -// return tmcfg.DefaultConfig if no custom configuration is required for the application. -func initTendermintConfig() *tmcfg.Config { - cfg := tmcfg.DefaultConfig() - - // these values put a higher strain on node memory - // cfg.P2P.MaxNumInboundPeers = 100 - // cfg.P2P.MaxNumOutboundPeers = 40 +func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { + autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) + autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) + autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) - return cfg -} + var err error + clientCtx, err = config.ReadFromClientConfig(clientCtx) + if err != nil { + return autocli.AppOptions{}, err + } -func txCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "tx", - Short: "Transactions subcommands", - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, + autoCliOpts.ClientCtx = clientCtx + autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(clientCtx.Keyring) + if err != nil { + return autocli.AppOptions{}, err } - cmd.AddCommand( - authcmd.GetSignCommand(), - authcmd.GetSignBatchCommand(), - authcmd.GetMultiSignCommand(), - authcmd.GetMultiSignBatchCmd(), - authcmd.GetValidateSignaturesCommand(), - authcmd.GetBroadcastCommand(), - authcmd.GetEncodeCommand(), - authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), - ) + return autoCliOpts, nil +} - providerApp.ModuleBasics.AddTxCommands(cmd) +// initCometBFTConfig helps to override default CometBFT Config values. +// return cmtcfg.DefaultConfig if no custom configuration is required for the application. +func initCometBFTConfig() *cmtcfg.Config { + cfg := cmtcfg.DefaultConfig() - return cmd + // these values put a higher strain on node memory + // cfg.P2P.MaxNumInboundPeers = 100 + // cfg.P2P.MaxNumOutboundPeers = 40 + + return cfg } // initAppConfig helps to override default appConfig template and configs. @@ -186,30 +213,91 @@ lru_size = 0` return customAppTemplate, customAppConfig } -func initRootCmd(rootCmd *cobra.Command, encodingConfig appencoding.EncodingConfig) { +func initRootCmd(rootCmd *cobra.Command, encodingConfig appEncoding.EncodingConfig) { cfg := sdk.GetConfig() cfg.Seal() rootCmd.AddCommand( genutilcli.InitCmd(providerApp.ModuleBasics, providerApp.DefaultNodeHome), debug.Cmd(), - config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp, providerApp.DefaultNodeHome), + confixcmd.ConfigCommand(), + server.QueryBlockResultsCmd(), ) server.AddCommands(rootCmd, providerApp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + server.StatusCommand(), genesisCommand(encodingConfig), - queryCommand(), txCommand(), - keys.Commands(providerApp.DefaultNodeHome), + queryCommand(), + keys.Commands(), ) +} - // add rosetta - rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) +func addModuleInitFlags(startCmd *cobra.Command) { + crisis.AddModuleInitFlags(startCmd) +} + +func queryCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "query", + Aliases: []string{"q"}, + Short: "Querying subcommands", + DisableFlagParsing: false, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + rpc.ValidatorCommand(), + server.QueryBlockCmd(), + authcmd.QueryTxsByEventsCmd(), + server.QueryBlocksCmd(), + authcmd.QueryTxCmd(), + authcmd.GetSimulateCmd(), + ) + + return cmd +} + +func txCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "tx", + Short: "Transactions subcommands", + DisableFlagParsing: false, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + authcmd.GetSignCommand(), + authcmd.GetSignBatchCommand(), + authcmd.GetMultiSignCommand(), + authcmd.GetMultiSignBatchCmd(), + authcmd.GetValidateSignaturesCommand(), + authcmd.GetBroadcastCommand(), + authcmd.GetEncodeCommand(), + authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), + ) + + // NOTE: this must be registered for now so that submit-legacy-proposal + // message can be routed to the provider handler and processed correctly. + providerApp.ModuleBasics.AddTxCommands(cmd) + + return cmd +} + +// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter +func genesisCommand(encodingConfig appEncoding.EncodingConfig, cmds ...*cobra.Command) *cobra.Command { + cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, providerApp.ModuleBasics, providerApp.DefaultNodeHome) + for _, sub_cmd := range cmds { + cmd.AddCommand(sub_cmd) + } + return cmd } // newApp is an appCreator @@ -271,40 +359,12 @@ func appExport( return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } -func addModuleInitFlags(startCmd *cobra.Command) { - crisis.AddModuleInitFlags(startCmd) -} - -// genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter -func genesisCommand(encodingConfig appencoding.EncodingConfig, cmds ...*cobra.Command) *cobra.Command { - cmd := genutilcli.GenesisCoreCommand(encodingConfig.TxConfig, providerApp.ModuleBasics, providerApp.DefaultNodeHome) - for _, sub_cmd := range cmds { - cmd.AddCommand(sub_cmd) +var tempDir = func() string { + dir, err := os.MkdirTemp("", "."+providerApp.AppName) + if err != nil { + dir = providerApp.DefaultNodeHome } - return cmd -} + defer os.RemoveAll(dir) -func queryCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "query", - Aliases: []string{"q"}, - Short: "Querying subcommands", - DisableFlagParsing: false, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - cmd.AddCommand( - authcmd.GetAccountCmd(), - rpc.ValidatorCommand(), - rpc.BlockCommand(), - authcmd.QueryTxsByEventsCmd(), - authcmd.QueryTxCmd(), - authcmd.GetEncodeCommand(), - authcmd.GetDecodeCommand(), - ) - - providerApp.ModuleBasics.AddQueryCommands(cmd) - - return cmd + return dir } diff --git a/cmd/interchain-security-pd/main.go b/cmd/interchain-security-pd/main.go index 7788f06bff..daf68d27d5 100644 --- a/cmd/interchain-security-pd/main.go +++ b/cmd/interchain-security-pd/main.go @@ -1,26 +1,21 @@ package main import ( + "fmt" "os" - "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - appparams "github.com/cosmos/interchain-security/v4/app/params" - app "github.com/cosmos/interchain-security/v4/app/provider" - "github.com/cosmos/interchain-security/v4/cmd/interchain-security-pd/cmd" + appparams "github.com/cosmos/interchain-security/v5/app/params" + app "github.com/cosmos/interchain-security/v5/app/provider" + "github.com/cosmos/interchain-security/v5/cmd/interchain-security-pd/cmd" ) func main() { appparams.SetAddressPrefixes("cosmos") rootCmd := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - - default: - os.Exit(1) - } + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) } } diff --git a/cmd/interchain-security-sd/cmd/root.go b/cmd/interchain-security-sd/cmd/root.go index 28520ef1a4..5e65e536fb 100644 --- a/cmd/interchain-security-sd/cmd/root.go +++ b/cmd/interchain-security-sd/cmd/root.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - rosettaCmd "cosmossdk.io/tools/rosetta/cmd" - + "cosmossdk.io/client/v2/autocli" + confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" @@ -17,22 +17,28 @@ import ( "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" + "github.com/cosmos/cosmos-sdk/codec" + addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" tmcfg "github.com/cometbft/cometbft/config" - "github.com/cometbft/cometbft/libs/log" + dbm "github.com/cosmos/cosmos-db" - appencoding "github.com/cosmos/interchain-security/v4/app/encoding" - sovereignApp "github.com/cosmos/interchain-security/v4/app/sovereign" + appencoding "github.com/cosmos/interchain-security/v5/app/encoding" + sovereignApp "github.com/cosmos/interchain-security/v5/app/sovereign" ) // NewRootCmd creates a new root command for simd. It is called once in the @@ -75,6 +81,24 @@ func NewRootCmd() *cobra.Command { return err } + // This needs to go after ReadFromClientConfig, as that function + // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode + // is only available if the client is online. + if !initClientCtx.Offline { + txConfigOpts := tx.ConfigOptions{ + EnabledSignModes: append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL), + TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), + } + txConfigWithTextual, err := tx.NewTxConfigWithOptions( + codec.NewProtoCodec(encodingConfig.InterfaceRegistry), + txConfigOpts, + ) + if err != nil { + return err + } + initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual) + } + if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil { return err } @@ -87,10 +111,38 @@ func NewRootCmd() *cobra.Command { } initRootCmd(rootCmd, encodingConfig) + autoCliOpts, err := enrichAutoCliOpts(tempApp.AutoCliOpts(), initClientCtx) + if err != nil { + panic(err) + } + + if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { + panic(err) + } return rootCmd } +func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { + autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) + autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) + autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) + + var err error + clientCtx, err = config.ReadFromClientConfig(clientCtx) + if err != nil { + return autocli.AppOptions{}, err + } + + autoCliOpts.ClientCtx = clientCtx + autoCliOpts.Keyring, err = keyring.NewAutoCLIKeyring(clientCtx.Keyring) + if err != nil { + return autocli.AppOptions{}, err + } + + return autoCliOpts, nil +} + // initTendermintConfig helps to override default Tendermint Config values. // return tmcfg.DefaultConfig if no custom configuration is required for the application. func initTendermintConfig() *tmcfg.Config { @@ -121,11 +173,8 @@ func txCommand() *cobra.Command { authcmd.GetBroadcastCommand(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), - authcmd.GetAuxToFeeCommand(), ) - sovereignApp.ModuleBasics.AddTxCommands(cmd) - return cmd } @@ -193,23 +242,20 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appencoding.EncodingConf rootCmd.AddCommand( genutilcli.InitCmd(sovereignApp.ModuleBasics, sovereignApp.DefaultNodeHome), debug.Cmd(), - config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp, sovereignApp.DefaultNodeHome), + confixcmd.ConfigCommand(), ) server.AddCommands(rootCmd, sovereignApp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - rpc.StatusCommand(), + server.StatusCommand(), genesisCommand(encodingConfig), queryCommand(), txCommand(), - keys.Commands(sovereignApp.DefaultNodeHome), + keys.Commands(), ) - - // add rosetta - rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)) } // newApp is an appCreator @@ -295,16 +341,16 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - authcmd.GetAccountCmd(), rpc.ValidatorCommand(), - rpc.BlockCommand(), + server.QueryBlockCmd(), + server.QueryBlocksCmd(), + server.QueryBlockResultsCmd(), authcmd.QueryTxsByEventsCmd(), authcmd.QueryTxCmd(), authcmd.GetEncodeCommand(), authcmd.GetDecodeCommand(), + authcmd.GetSimulateCmd(), ) - sovereignApp.ModuleBasics.AddQueryCommands(cmd) - return cmd } diff --git a/cmd/interchain-security-sd/main.go b/cmd/interchain-security-sd/main.go index 2265afad90..99f6b9b371 100644 --- a/cmd/interchain-security-sd/main.go +++ b/cmd/interchain-security-sd/main.go @@ -1,26 +1,20 @@ package main import ( + "fmt" "os" - "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - appparams "github.com/cosmos/interchain-security/v4/app/params" - app "github.com/cosmos/interchain-security/v4/app/sovereign" - "github.com/cosmos/interchain-security/v4/cmd/interchain-security-sd/cmd" + app "github.com/cosmos/interchain-security/v5/app/sovereign" + "github.com/cosmos/interchain-security/v5/cmd/interchain-security-sd/cmd" ) func main() { - appparams.SetAddressPrefixes("consumer") rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { - switch e := err.(type) { - case server.ErrorCode: - os.Exit(e.Code) - default: - os.Exit(1) - } + if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) } } diff --git a/docs/docs/features/proposals.md b/docs/docs/features/proposals.md index 44ea4f0298..5f5457fc0a 100644 --- a/docs/docs/features/proposals.md +++ b/docs/docs/features/proposals.md @@ -77,6 +77,14 @@ Minimal example: } ``` +:::warning +Before the introduction of Partial Set Security, consumer chains typically included a "soft opt-out mechanism" +which allows the bottom N% of the provider's validators to not validate the consumer chain, without being jailed for downtime on the provider. +After the introduction of Partial Set Security, the use of the soft opt-out mechanism is discouraged, and consumer chains are +encouraged to use the topN parameter to not force validators with little stake to validate the chain. +::: + + ## `ConsumerModificationProposal` Proposal type used to change the power shaping parameters of a running consumer chain, as well as to change a Top N running consumer chain to an Opt-In chain and vice versa. diff --git a/docs/docs/upgrading/_category_.json b/docs/docs/upgrading/_category_.json new file mode 100644 index 0000000000..372e6c1900 --- /dev/null +++ b/docs/docs/upgrading/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Upgrading", + "position": 2 +} diff --git a/docs/docs/upgrading/migrate_v4_v5.md b/docs/docs/upgrading/migrate_v4_v5.md new file mode 100644 index 0000000000..d655984b54 --- /dev/null +++ b/docs/docs/upgrading/migrate_v4_v5.md @@ -0,0 +1,381 @@ +--- +sidebar_position: 1 +--- + +# Upgrading to ICS v5.0.0 + +This ICS version uses cosmos-sdk v0.50.x and ibc-go v8.x. + +To migrate you application to cosmos-sdk v0.50.x please use this [guide](https://docs.cosmos.network/v0.50/build/migrations/upgrading). + +To migrate your application to ibc-go v8.x.y please use the following guides: + * [migrate ibc-go to v8.0.0](https://ibc.cosmos.network/main/migrations/v7-to-v8) + * [migrate ibc-go to v8.1.0](https://ibc.cosmos.network/main/migrations/v8-to-v8_1) + + +ICS specific changes are outlined below. + +Pre-requisite version for this upgrade: `v4.x`. + +## Provider + +### Keeper initialization + +```diff +// app.go + +app.ProviderKeeper = ibcproviderkeeper.NewKeeper( + appCodec, + keys[providertypes.StoreKey], + app.GetSubspace(providertypes.ModuleName), + scopedIBCProviderKeeper, + app.IBCKeeper.ChannelKeeper, +- app.IBCKeeper.PortKeeper ++ app.IBCKeeper.PortKeeper, + app.IBCKeeper.ConnectionKeeper, + app.IBCKeeper.ClientKeeper, + app.StakingKeeper, + app.SlashingKeeper, + app.AccountKeeper, + app.DistrKeeper, + app.BankKeeper, + *app.GovKeeper, ++ authtypes.NewModuleAddress(govtypes.ModuleName).String(), ++ authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), ++ authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + authtypes.FeeCollectorName, +) +``` + +* `authority` was added - requirement for executing `MsgUpdateParams` + * uses `x/gov` module address by default + +* `validatorAddressCodec` & `consensusAddressCodec` were added - they must match the bech32 address codec used by `x/auth`, `x/bank`, `x/staking` + + +### Protocol changes + +#### Revert `AfterUnbondingInitiated` + +`AfterUnbondingInitiated` behavior was reverted to [ICS@v1.2.0-multiden](https://github.com/cosmos/interchain-security/blob/v1.2.0-multiden/x/ccv/provider/keeper/hooks.go#L53) + +The revert re-introduces an additional state check. + +See this [issue](https://github.com/cosmos/interchain-security/issues/1045) for more context and the actions taken. + + +### Migration (v4 -> v5) + +ConensusVersion was bumped to `5`. + +The migration allows storing the provider module params in the `x/ccv/provider` module store instead of relying on legacy `x/param` store. + +There are no special requirements for executing this migration. + + +### Additions + +### MsgUpdateParams transaction + +`x/gov` module account is selected as the default `authority`. + +It is available when using `gov` CLI commands: + +Drafting a proposal: + +```shell +interchain-security-pd tx gov draft-proposal +# select "other" +# find and select "/interchain_security.ccv.provider.v1.MsgUpdateParams" +``` + +Submitting a proposal: + +```shell +interchain-security-pd tx gov submit-proposal +``` + +Example `proposal-message.json`: + +```json +{ + "messages": [ + { + "@type": "/interchain_security.ccv.provider.v1.MsgUpdateParams", + "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", + "params": { + "trusting_period_fraction": "0.66", + "ccv_timeout_period": "2419200s", + "init_timeout_period": "604800s", + "vsc_timeout_period": "3024000s", + "slash_meter_replenish_period": "3s", + "slash_meter_replenish_fraction": "1.0", + "consumer_reward_denom_registration_fee": { + "denom": "stake", + "amount": "10000000" + }, + "blocks_per_epoch": "600" + } + } + ], + "metadata": "ipfs://CID", + "deposit": "10000stake", + "title": "Update Provider params", + "summary": "Update Provider params", + "expedited": false +} +``` + +### + +When updating parameters **all** parameters fields must be specified. Make sure you are only changing parameters that you are interested in. + +To avoid accidentally changing parameters you can first check the current on-chain provider params using: + +```shell +interchain-security-pd q provider params -o json + +{ + "template_client": {...}, + "trusting_period_fraction": "0.66", + "ccv_timeout_period": "2419200s", + "init_timeout_period": "604800s", + "vsc_timeout_period": "3024000s", + "slash_meter_replenish_period": "3s", + "slash_meter_replenish_fraction": "1.0", + "consumer_reward_denom_registration_fee": { + "denom": "stake", + "amount": "10000000" + }, + "blocks_per_epoch": "600" +} +``` + +### Governance proposals + +Submitting the following legacy proposals is still supported: + +# Consumer addition proposal + +```shell +interchain-security-pd tx gov submit-legacy-proposal consumer-addition +``` + +# Consumer removal proposal + +```shell +interchain-security-pd tx gov submit-legacy-proposal consumer-removal +``` + +# Consumer addition proposal +```shell +interchain-security-pd tx gov submit-legacy-proposal change-reward-denoms +``` + +You may also submit proposal messages above using `submit-proposal`. + + +## Consumer + +### Keeper initialization + +```diff +// pre-initialize ConsumerKeeper to satsfy ibckeeper.NewKeeper +app.ConsumerKeeper = ibcconsumerkeeper.NewNonZeroKeeper( + appCodec, + keys[ibcconsumertypes.StoreKey], + app.GetSubspace(ibcconsumertypes.ModuleName), +) + +app.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + keys[ibchost.StoreKey], + app.GetSubspace(ibchost.ModuleName), + app.ConsumerKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), +) + +// initialize the actual consumer keeper +app.ConsumerKeeper = ibcconsumerkeeper.NewKeeper( + appCodec, + keys[ibcconsumertypes.StoreKey], + app.GetSubspace(ibcconsumertypes.ModuleName), + scopedIBCConsumerKeeper, + app.IBCKeeper.ChannelKeeper, +- &app.IBCKeeper.PortKeeper, ++ app.IBCKeeper.PortKeeper, + app.IBCKeeper.ConnectionKeeper, + app.IBCKeeper.ClientKeeper, + app.SlashingKeeper, + app.BankKeeper, + app.AccountKeeper, + &app.TransferKeeper, + app.IBCKeeper, + authtypes.FeeCollectorName, + + // make sure the authority address makes sense for your chain + // the exact module account may differ depending on your setup (x/gov, x/admin or custom module) + // for x/ccv/democracy using the x/gov module address is correct + // if you don't have a way of updating consumer params you may still use the line below as it will have no affect ++ authtypes.NewModuleAddress(govtypes.ModuleName).String(), + + // add address codecs ++ authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), ++ authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), +) +``` + + +* `authority` was added - requirement for executing `MsgUpdateParams` + * make sure the authority address makes sense for your chain + * the exact module account may differ depending on your setup (`x/gov`, `x/admin` or custom module) + * for `x/ccv/democracy` using the `x/gov` module address is correct + * if you don't have a way of updating consumer params you may use `authtypes.NewModuleAddress(govtypes.ModuleName).String()` (has no effect on functionality) + +* `validatorAddressCodec` & `consensusAddressCodec` were added - they must match the bech32 address codec used by `x/auth`, `x/bank`, `x/staking` + + +### Additions + +#### `MsgUpdateParams` transaction + +**This functionality is not supported on `x/ccv/consumer` without additional configuration.** +* if you are using `x/ccv/democracy` the feature is supported out of the box +* if you are using custom logic for changing consumer params, please update your code by providing the appropriate `authority` module account during `ConsumerKeeper` initialization in `app.go`. + +**You must add `"/interchain_security.ccv.consumer.v1.MsgUpdateParams"` to your parameters whitelist to be able to change `ccvconsumer` parameters via governance.** + +It is available when using `gov` CLI commands: + +Drafting a proposal: + +```shell +interchain-security-cd tx gov draft-proposal +# select "other" +# find and select "/interchain_security.ccv.consumer.v1.MsgUpdateParams" +``` + +Submitting a proposal: +* **this proposal cannot be executed on chains without access to `x/gov` or other modules for managing governance** + +```shell + +interchain-security-cdd tx gov submit-proposal + +``` + +Example `proposal-message.json`. +```json +{ + "messages": [ + { + "@type": "/interchain_security.ccv.consumer.v1.MsgUpdateParams", + "authority": "consumer10d07y265gmmuvt4z0w9aw880jnsr700jlh7295", + "params": { + "enabled": true, + "blocks_per_distribution_transmission": "20", + "distribution_transmission_channel": "channel-1", + "provider_fee_pool_addr_str": "", + "ccv_timeout_period": "2419200s", + "transfer_timeout_period": "3000s", + "consumer_redistribution_fraction": "0.75", + "historical_entries": "10000", + "unbonding_period": "1209600s", + "soft_opt_out_threshold": "0.05", + "reward_denoms": [], + "provider_reward_denoms": [], + "retry_delay_period": "3000s" + } + } + ], + "metadata": "ipfs://CID", + "deposit": "1000uatom", + "title": "Update Consumer Params -- change transfer_timeout_period to 3000s", + "summary": "Test Update Consumer Params", + "expedited": false +} +``` + +When updating parameters **all** parameters fields must be specified. Make sure you are only changing parameters that you are interested in. + +To avoid accidentally changing parameters you can first check the current on-chain consumer params using: + +```shell +interchain-security-pd q ccvconsumer params -o json +``` + + +#### Params Query + +Consumer params query was added: +```shell +interchain-security-cd q ccvconsumer params -o json + +{ + "params": { + "enabled": true, + "blocks_per_distribution_transmission": "1000", + "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": "1209600s", + "soft_opt_out_threshold": "0.05", + "reward_denoms": [], + "provider_reward_denoms": [], + "retry_delay_period": "3600s" + } +} +``` + + +### Migration (v2 -> v3) +ConensusVersion was bumped to `3`. + +The migration allows storing the consumer module params in the `x/ccv/consumer` module store instead of relying on legacy `x/param` store. + +There are no special requirements for executing this migration. + + +### Interface method changes +Consumer methods were changed to match the cosmos-sdk `StakingKeeper` interface. +You will not need to change your code, unless you are using the `ConsumerKeeper` inside custom tests or you have developed custom app functionality that relies on `ConsumerKeeper`. + +Please check the list below if you are using any of the consumer methods: +```go +type StakingKeeper interface { + UnbondingTime(ctx context.Context) (time.Duration, error) + GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, error) + GetLastValidatorPower(ctx context.Context, operator sdk.ValAddress) (int64, error) + Jail(context.Context, sdk.ConsAddress) error // jail a validator + Slash(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec) (math.Int, error) + SlashWithInfractionReason(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec, infraction stakingtypes.Infraction) (math.Int, error) + Unjail(ctx context.Context, addr sdk.ConsAddress) error + GetValidator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.Validator, error) + IterateLastValidatorPowers(ctx context.Context, cb func(addr sdk.ValAddress, power int64) (stop bool)) error + IterateValidators(ctx context.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error + Validator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.ValidatorI, error) + IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error) + ValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.ValidatorI, error) + Delegation(ctx context.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.DelegationI, error) + MaxValidators(ctx context.Context) (uint32, error) +} +``` + +The consumer implements the `StakingKeeper` interface shown above. + +## Democracy + +Changes in `Consumer` also apply to `Democracy`. + +Democracy `x/staking`, `x/distribution` and `x/gov` were updated to reflect changes in `cosmos-sdk v0.50.x`. + +There were no notable changes arising to the module functionality aside from conforming to `cosmos-sdk v0.50.x`. + + +## Note: +You must add `"/interchain_security.ccv.consumer.v1.MsgUpdateParams"` to your parameters whitelist to be able to change `consumer` parameters via governance. diff --git a/docs/internal/migrations/cosmos-sdk-v0.50-migration.md b/docs/internal/migrations/cosmos-sdk-v0.50-migration.md new file mode 100644 index 0000000000..9844de696e --- /dev/null +++ b/docs/internal/migrations/cosmos-sdk-v0.50-migration.md @@ -0,0 +1,353 @@ +# cosmos-sdk v0.50.x internal upgrade doc + +This file lists various changes that were needed when upgrading from cosmos-sdk v0.47.x -> v0.50.x. + +Upgrade instructions used: +* https://docs.cosmos.network/v0.50/migrations/upgrading +* https://ibc.cosmos.network/main/migrations/v7-to-v8.html +* https://ibc.cosmos.network/main/migrations/v8-to-v8_1 + +## Proto files +Some proto files needed to be updated to reflect changes required for cosmos-sdk v50. + +## Provider proto changes + +### proto/interchain_security/ccv/provider/v1/tx.proto + +Added rpc methods and message types to support v50 governance (`submit-proposal`) +* `rpc ConsumerAddition` +* `rpc ConsumerRemoval` +* `message MsgUpdateParams` +* `message MsgConsumerAddition` +* `message MsgConsumerRemoval` +* `message MsgChangeRewardDenoms` +* `message MsgUpdateParams` + + +Update existing messages with `option (cosmos.msg.v1.signer) = "signer"` so they are considered as Tx messages by v50. +* `message MsgAssignConsumerKey` + +`message MsgUpdateParams` was added to support updating params via governance. + + +## Generating protos with updated dependencies: + +``` +# update Makefile containerProtoVersion to latest (v0.14.0) +cd proto +# update buf.yml +buf mod update +cd .. +make proto-gen +``` + +### Steps for upgrading cosmos-sdk and ibc-go +Key dependencies: +* `cosmos-sdk@v0.50.4` +* `ibc-go/v8@v8.1.0` +* `ibc-go/modules/capability@v1.0.0` + +```shell +go get github.com/cosmos/cosmos-sdk@v0.50.4 +go get github.com/cosmos/ibc-go/v8@v8.1.0 +go get github.com/cosmos/ibc-go/modules/capability@v1.0.0-rc5 +``` + +`ibc-go/v8` is using the `x/capability` module that lives in `github.com/cosmos/ibc-go/modules/capability`. +* this module was added after all the file imports were changed for ibc-go (from v7 -> v8) to avoid weird import behaviour + +### Search & replace +* github.com/cosmos/ibc-go/v7 -> github.com/cosmos/ibc-go/v8 +* github.com/cosmos/cosmos-sdk/store -> cosmossdk.io/store +* github.com/cosmos/cosmos-sdk/x/feegrant -> cosmossdk.io/x/feegrant +* github.com/cosmos/cosmos-sdk/x/evidence -> cosmossdk.io/x/evidence +* github.com/cosmos/cosmos-sdk/x/upgrade -> cosmossdk.io/x/upgrade + +* github.com/cometbft/cometbft/libs/log -> cosmossdk.io/log +* github.com/cosmos/cosmos-sdk/x/capability/keeper -> github.com/cosmos/ibc-go/modules/capability +* github.com/cosmos/cosmos-sdk/client/grpc/tmservice -> github.com/cosmos/cosmos-sdk/client/grpc/cmtservice + +### Remove +* cosmossdk.io/x/upgrade/client -> no longer exists and not needed +* github.com/cosmos/ibc-go/v7/modules/core/02-client/client -> these gov handlers no longer exist (deprecated) + +### Math search & replace +* use `math.LegacyDec` instead of `sdk.Dec` and other types + * eg. `sdk.NewDecFromStr`, `sdktypes.NewDecFromStr`, `sdk.NewDec` + * `sdk.ZeroDec` -> `math.LegacyZeroDec` + * `sdk.NewDecFromInt` -> `math.LegacyNewDecFromInt` + * `sdk.MustNewDecFromStr` -> `math.LegacyMustNewDecFromStr` + * `sdk.NewDecFromInt` -> `math.LegacyNewDecFromInt` + * `sdk.OneDec` -> `math.LegacyOneDec` + * `sdk.NewDecWithPrec` -> `math.LegacyNewDecWithPrec` + * also update all function defintions that are using them + +* use `math.NewInt` instead of `sdk.NewInt` + * `sdktypes.NewInt`, + * `sdktypes.ZeroInt` -> `math.ZeroInt` + * also update all dunction definitions that are using them + +## Genesis +`expedited_voting_period` was introduced. All functions using gov proposals needed to be updated to support `expedited_voting_period (bool)` + + +## Governance proposals (provider) +Legacy proposal handlers were modified to reflect cosmos-sdk v0.50.x changes. Legacy proposals are still supported. + +## Query & Tx +AutoCLI usage was added. + +To use AutoCLI all Txs must be annotated with `option (cosmos.msg.v1.service) = true`; + + +## ICS code changes + +## migrate x/staking & x/slashing interfaces + +New interfaces match x/staking and x/slashing on cosmos-sdk v0.50.x. + +```go +type StakingKeeper interface { + GetValidatorUpdates(ctx context.Context) ([]abci.ValidatorUpdate, error) + UnbondingCanComplete(ctx context.Context, id uint64) error + UnbondingTime(ctx context.Context) (time.Duration, error) + GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, error) + GetLastValidatorPower(ctx context.Context, operator sdk.ValAddress) (int64, error) + Jail(context.Context, sdk.ConsAddress) error // jail a validator + Slash(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec) (math.Int, error) + SlashWithInfractionReason(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec, infraction stakingtypes.Infraction) (math.Int, error) + SlashUnbondingDelegation(ctx context.Context, unbondingDelegation stakingtypes.UnbondingDelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) + SlashRedelegation(ctx context.Context, srcValidator stakingtypes.Validator, redelegation stakingtypes.Redelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) + Unjail(ctx context.Context, addr sdk.ConsAddress) error + GetValidator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.Validator, error) + IterateLastValidatorPowers(ctx context.Context, cb func(addr sdk.ValAddress, power int64) (stop bool)) error + PowerReduction(ctx context.Context) math.Int + PutUnbondingOnHold(ctx context.Context, id uint64) error + IterateValidators(ctx context.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error + Validator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.ValidatorI, error) + IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error) + ValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.ValidatorI, error) + Delegation(ctx context.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.DelegationI, error) + MaxValidators(ctx context.Context) (uint32, error) + GetLastTotalPower(ctx context.Context) (math.Int, error) + GetLastValidators(ctx context.Context) ([]stakingtypes.Validator, error) + BondDenom(ctx context.Context) (string, error) + GetUnbondingDelegationsFromValidator(ctx context.Context, valAddr sdk.ValAddress) ([]stakingtypes.UnbondingDelegation, error) + GetRedelegationsFromSrcValidator(ctx context.Context, valAddr sdk.ValAddress) ([]stakingtypes.Redelegation, error) + GetUnbondingType(ctx context.Context, id uint64) (stakingtypes.UnbondingType, error) +} + +type SlashingKeeper interface { + JailUntil(context.Context, sdk.ConsAddress, time.Time) error // called from provider keeper only + GetValidatorSigningInfo(context.Context, sdk.ConsAddress) (slashingtypes.ValidatorSigningInfo, error) + SetValidatorSigningInfo(context.Context, sdk.ConsAddress, slashingtypes.ValidatorSigningInfo) error + DowntimeJailDuration(context.Context) (time.Duration, error) + SlashFractionDowntime(context.Context) (math.LegacyDec, error) + SlashFractionDoubleSign(context.Context) (math.LegacyDec, error) + Tombstone(context.Context, sdk.ConsAddress) error + IsTombstoned(context.Context, sdk.ConsAddress) bool +} +``` + +Changes to these interfaces required changing unit and integration test assertions. Almost all methods are now returning an `error`. Previously, almost none of the methods were returning errors. + +## Refactoring ICS keepers + +### Context +Instead of using `sdk.Context` we need to use `context.Context`. + +Example: +```go +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) // we accept context.Context and unwrap it + return sdkCtx.Logger().With("module", "x/"+ibchost.ModuleName+"-"+types.ModuleName) +} +``` + +Remaining work for future upgrades: +* allow store access via `k.storeService.OpenKVStore(ctx)` instead of `ctx.KVStore(k.storeKey)`. + + +### validator.GetConsAddr() +Cannot do `sdk.ConsAddress(validatorConsumerAddrs.ConsumerAddr).Equals(consensusAddr)` because `.Equals()` now takes a `sdk.Address` interface type. +Change to `sdk.ConsAddress(validatorConsumerAddrs.ConsumerAddr).Equals(sdk.ConsAddress(consensusAddr))` + + + +### ICS keepers initialization +```go +type Keeper struct { + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + + // address codecs were added + validatorAddressCodec addresscodec.Codec + consensusAddressCodec addresscodec.Codec +} + +// GetAuthority returns the module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +``` + + +### Hooks +In v0.50.x hooks are setup in the `keeper.go` + +```go +// Hooks gets the hooks for staking *Keeper +func (k *Keeper) Hooks() types.StakingHooks { + if k.hooks == nil { + // return a no-op implementation if no hooks are set + return types.MultiStakingHooks{} + } + + return k.hooks +} + +// SetHooks sets the validator hooks. In contrast to other receivers, this method must take a pointer due to nature +// of the hooks interface and SDK start up sequence. +func (k *Keeper) SetHooks(sh types.StakingHooks) { + if k.hooks != nil { + panic("cannot set validator hooks twice") + } + + k.hooks = sh +} +``` + +## Proposals + +`sdk.Handler` no longer exists and needs to be replaced with `baseapp.MsgServiceHandler +```diff +// x/ccv/provider/handler.go +-func NewHandler(k *keeper.Keeper) sdk.Handler { +- msgServer := keeper.NewMsgServerImpl(k) ++func NewHandler(k *keeper.Keeper) sdk.Handler { ++ msgServer := keeper.NewMsgServerImpl(k) + // ... +} +``` + + +## validator.GetOperator() has different return type +Previously `validator.GetOperator()` was returning `sdk.ValAddress`. In v0.50.x it returns a `string`. + +Additional processing is required when fetching validator operator address: +```diff +-slashedVal.GetOperator() ++providerKeeper.ValidatorAddressCodec().StringToBytes(slashedVal.GetOperator()) +``` + +Example: +```diff +// from integration tests +-lastValPower := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), slashedVal.GetOperator()) ++slashedValOperator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(slashedVal.GetOperator()) // must get the addr bytes first ++s.Require().NoError(err) ++lastValPower, err := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), slashedValOperator) +``` + + +## evidencekeeper equivocation handling was made private + +```diff +type EvidenceKeeper interface { +- HandleEquivocationEvidence(ctx sdk.Context, evidence *evidencetypes.Equivocation) ++ handleEquivocationEvidence(ctx sdk.Context, evidence *evidencetypes.Equivocation) +} +``` + +This method is only used in integration testing. To preserve testing, the method was copied and modified to fit the testing use case. +```go +// copy of the function from slashing/keeper.go +// in cosmos-sdk v0.50.x the function HandleEquivocationEvidence is not exposed (it was exposed for versions <= v0.47.x) +// https://github.com/cosmos/cosmos-sdk/blob/v0.50.4/x/evidence/keeper/infraction.go#L27 +func handleEquivocationEvidence(ctx context.Context, k integration.ConsumerApp, evidence *types.Equivocation) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + slashingKeeper := k.GetTestSlashingKeeper().(slashingkeeper.Keeper) + evidenceKeeper := k.GetTestEvidenceKeeper() + consAddr := evidence.GetConsensusAddress(k.GetConsumerKeeper().ConsensusAddressCodec()) + + validator, err := k.GetConsumerKeeper().ValidatorByConsAddr(ctx, consAddr) + if err != nil { + return err + } + if validator == nil || validator.IsUnbonded() { + return nil + } + + if len(validator.GetOperator()) != 0 { + if _, err := slashingKeeper.GetPubkey(ctx, consAddr.Bytes()); err != nil { + return nil + } + } + + // calculate the age of the evidence + infractionHeight := evidence.GetHeight() + infractionTime := evidence.GetTime() + ageDuration := sdkCtx.BlockHeader().Time.Sub(infractionTime) + ageBlocks := sdkCtx.BlockHeader().Height - infractionHeight + + // Reject evidence if the double-sign is too old. Evidence is considered stale + // if the difference in time and number of blocks is greater than the allowed + // parameters defined. + cp := sdkCtx.ConsensusParams() + if cp.Evidence != nil { + if ageDuration > cp.Evidence.MaxAgeDuration && ageBlocks > cp.Evidence.MaxAgeNumBlocks { + return nil + } + } + + if ok := slashingKeeper.HasValidatorSigningInfo(ctx, consAddr); !ok { + panic(fmt.Sprintf("expected signing info for validator %s but not found", consAddr)) + } + + // ignore if the validator is already tombstoned + if slashingKeeper.IsTombstoned(ctx, consAddr) { + return nil + } + + distributionHeight := infractionHeight - sdk.ValidatorUpdateDelay + slashFractionDoubleSign, err := slashingKeeper.SlashFractionDoubleSign(ctx) + if err != nil { + return err + } + + err = slashingKeeper.SlashWithInfractionReason( + ctx, + consAddr, + slashFractionDoubleSign, + evidence.GetValidatorPower(), distributionHeight, + stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, + ) + if err != nil { + return err + } + + // Jail the validator if not already jailed. This will begin unbonding the + // validator if not already unbonding (tombstoned). + if !validator.IsJailed() { + err = slashingKeeper.Jail(ctx, consAddr) + if err != nil { + return err + } + } + + err = slashingKeeper.JailUntil(ctx, consAddr, types.DoubleSignJailEndTime) + if err != nil { + return err + } + + err = slashingKeeper.Tombstone(ctx, consAddr) + if err != nil { + return err + } + return evidenceKeeper.Evidences.Set(ctx, evidence.Hash(), evidence) +} + +``` + diff --git a/docs/upgrades_reference/app_provider.md b/docs/upgrades_reference/app_provider.md new file mode 100644 index 0000000000..ced15f1478 --- /dev/null +++ b/docs/upgrades_reference/app_provider.md @@ -0,0 +1,104 @@ +# provider/app.go +* use ibc-go/modules/capability +* interfaces registration +```go +interfaceRegistry, _ := types.NewInterfaceRegistryWithOptions(types.InterfaceRegistryOptions{ + ProtoFiles: proto.HybridResolver, + SigningOptions: signing.Options{ + AddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), + }, + ValidatorAddressCodec: address.Bech32Codec{ + Bech32Prefix: sdk.GetConfig().GetBech32ValidatorAddrPrefix(), + }, + }, +}) +appCodec := codec.NewProtoCodec(interfaceRegistry) +legacyAmino := codec.NewLegacyAmino() +txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) + +std.RegisterLegacyAminoCodec(legacyAmino) +std.RegisterInterfaces(interfaceRegistry) +// ABCI++, v50 +voteExtOp := func(bApp *baseapp.BaseApp) { + voteExtHandler := NewVoteExtensionHandler() + voteExtHandler.SetHandlers(bApp) +} +baseAppOptions = append(baseAppOptions, voteExtOp) + +bApp := baseapp.NewBaseApp(AppName, logger, db, txConfig.TxDecoder(), baseAppOptions...) +``` + +* register streaming services so ibc-testing can listen for packets +```go +// register streaming services +if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { + panic(err) +} + +``` + +* function additions +```go + +func (app *App) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + return app.MM.PreBlock(ctx) +} + +// Configurator returns the configurator for the app +func (app *App) Configurator() module.Configurator { + return app.configurator +} + +func (app *App) setPostHandler() { + postHandler, err := posthandler.NewPostHandler( + posthandler.HandlerOptions{}, + ) + if err != nil { + panic(err) + } + + app.SetPostHandler(postHandler) +} + +// AutoCliOpts returns the autocli options for the app. +func (app *App) AutoCliOpts() autocli.AppOptions { + modules := make(map[string]appmodule.AppModule, 0) + for _, m := range app.MM.Modules { + if moduleWithName, ok := m.(module.HasName); ok { + moduleName := moduleWithName.Name() + if appModule, ok := moduleWithName.(appmodule.AppModule); ok { + modules[moduleName] = appModule + } + } + } + + return autocli.AppOptions{ + Modules: modules, + ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.MM.Modules), + AddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), + ValidatorAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()), + ConsensusAddressCodec: authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()), + } +} + +``` + +* function updates +```go +func (app *App) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + return app.MM.BeginBlock(ctx) +} + +func (app *App) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error) { + return app.MM.EndBlock(ctx) +} + +func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {...} + +func (app *App) RegisterNodeService(clientCtx client.Context, cfg config.Config) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) +} +``` + +* `cmd/nterchain-security-p/root.go was wired to autoCLI diff --git a/docs/upgrades_reference/consumer.md b/docs/upgrades_reference/consumer.md new file mode 100644 index 0000000000..506fd86f62 --- /dev/null +++ b/docs/upgrades_reference/consumer.md @@ -0,0 +1,17 @@ +# consumer app +```go +func (k Keeper) UpdateSlashingSigningInfo(ctx sdk.Context) +``` +* GetValidatorSigningInfo has extra panics that were not there before + +In `app/consumer/app.go` the configuration options were updated to allow using a different consumer chain address prefix: +```go +func init() { + ... + cfg := sdk.GetConfig() + cfg.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32MainPrefix+"pub") + cfg.SetBech32PrefixForValidator(Bech32MainPrefix+"valoper", Bech32MainPrefix+"valoperpub") + cfg.SetBech32PrefixForConsensusNode(Bech32MainPrefix+"valcons", Bech32MainPrefix+"valconspub") + cfg.Seal() +} +``` \ No newline at end of file diff --git a/docs/upgrades_reference/democracy.md b/docs/upgrades_reference/democracy.md new file mode 100644 index 0000000000..4c89199627 --- /dev/null +++ b/docs/upgrades_reference/democracy.md @@ -0,0 +1,77 @@ +# Democracy modules changes + +## Distribution +Module now implements `appmodule.HasBeginBlocker` + +`BeginBlock` method was refactored to implement the `appmodule.HasBeginBlocker` interface. +```go +func (am AppModule) BeginBlock(goCtx context.Context) error { // this now returns an error + ctx := sdk.UnwrapSDKContext(goCtx) + defer telemetry.ModuleMeasureSince(distrtypes.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + // TODO this is Tendermint-dependent + // ref https://github.com/cosmos/cosmos-sdk/issues/3095 + if ctx.BlockHeight() > 1 { + return am.AllocateTokens(ctx) + } + + return nil +} +``` + +`AllocateTokens` returns errors after refactoring it to match the cosmos-sdk/distribution `AllocateTokens`. + +## Staking +Module now implements `appmodule.HasABCIGenesis` interface. + +`InitGenesis` was refactored to implement the `appmodule.HasABCIGenesis` interface. +```diff ++ func (am AppModule) InitGenesis(ctx context.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate +- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate +``` + +`EndBlocker` was changed to `EndBlock` to support `module.HasABCIEndBlock` interface. Overriding `EndBlocker` and not `EndBlock` caused the validator changes to be propagated to comet by the staking module instead of the ccv-consumer module. + +## Governance +Module now implements `appmodule.HasEndBlocker` interface. + +`EndBlock` was refactored to implement `appmodule.HasEndBlocker` interface. +```diff ++ func (am AppModule) EndBlock(c context.Context) error +- func (am AppModule) EndBlock(ctx sdk.Context, request abci.RequestEndBlock) []abci.ValidatorUpdate +``` + +The inner workings of `EndBlock` were refactored to allow using the cosmos-sdk governance collection types instead of iterators (there no longer is a way to use raw iterators for iterating gov proposals). +```go + func (am AppModule) EndBlock(c context.Context) error { + ctx := sdk.UnwrapSDKContext(c) + rng := collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.BlockTime()) + keeper := am.keeper + // if there are forbidden proposals in active proposals queue, refund deposit, delete votes for that proposal + // and delete proposal from all storages + err := am.keeper.ActiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { + proposal, err := keeper.Proposals.Get(ctx, key.K2()) + if err != nil { + return false, err + } + deleteForbiddenProposal(ctx, am, proposal) + return false, nil + }) + + if err != nil { + return err + } + return am.AppModule.EndBlock(ctx) +} +``` + +## App wiring & tests + +Whitelisted proposal list was changed because `param-change` proposals were deprecated for most modules (they cannot be submitted). + +Added to whitelists: +* `/cosmos.gov.v1beta1.TextProposal` + + +e2e tests were refactored to send the `TextProposal` instead of a `param-change` because there are no modules that can process `param-change` so we cannot use those proposals any longer. + diff --git a/docs/upgrades_reference/imports_only.md b/docs/upgrades_reference/imports_only.md new file mode 100644 index 0000000000..f8f0ab08b5 --- /dev/null +++ b/docs/upgrades_reference/imports_only.md @@ -0,0 +1,56 @@ +# import change only [file list] +* app/consumer-democracy/ante_handler.go +* app/consumer-democracy/proposals_whitelisting.go +* app/consumer-democracy/proposals_whitelisting_test.go +* app/consumer/ante/disabled_modules_ante_test.go +* app/consumer/ante/msg_filter_ante_test.go +* app/consumer/ante_handler.go +* app/provider/ante_handler.go +* app/sovereign/ante_handler.go +* cmd/interchain-security-cdd/cmd/root.go + +## tests + +### Integration +* tests/integration/changeover.go + + +### E2E +* tests/e2e/trace_handlers_test.go +* tests/e2e/json_marshal_test.go +* tests/e2e/state_rapid_test.go +* tests/e2e/steps_consumer_misbehaviour.go + +### Util +* testutil/crypto/evidence.go +* testutil/simibc/ordered_outbox.go +* testutil/simibc/relayed_path.go + + +### Modules +* x/ccv/consumer/ibc_module.go +* x/ccv/consumer/ibc_module_test.go +* x/ccv/consumer/keeper/genesis_test.go +* x/ccv/consumer/keeper/provider_info.go +* x/ccv/consumer/keeper/relay.go +* x/ccv/consumer/keeper/soft_opt_out_test.go [seems long but it's just imports and name updates] +* x/ccv/consumer/types/genesis.go +* x/ccv/consumer/types/genesis_test.go + + +* x/ccv/provider/ibc_module.go +* x/ccv/provider/ibc_module_test.go +* x/ccv/provider/types/genesis.go +* x/ccv/provider/types/legacy_proposal_test.go [rename from proposal_test.go and update imports] +* x/ccv/types/genesis.go +* x/ccv/types/params.go +* x/ccv/types/shared_params.go +* x/ccv/types/utils.go +* x/ccv/types/utils_test.go + + +# Additions +# Sovereign/Standalone chain + +Standalone simapp is modeled after the `app/consumer/app.go`. It must support all features that `app/consumer/app.go` supports so we can use it in standalone to consumer changeover procedures in our test suites. + diff --git a/docs/upgrades_reference/logic_changes.md b/docs/upgrades_reference/logic_changes.md new file mode 100644 index 0000000000..72009cd2c2 --- /dev/null +++ b/docs/upgrades_reference/logic_changes.md @@ -0,0 +1,306 @@ +# logic changes [file list] +Order of changes: +1. x/ +2. app -> integration test setup requires a working app +3. tests/integration & mbt +4. tests/e2e + +* app/consumer-democracy/abci.go +* app/consumer-democracy/export.go +* app/consumer/abci.go [important] +* app/consumer/export.go +* app/params/proto.go [important] +* app/provider/abci.go [important] +* app/provider/export.go [important] +* app/sovereign/abci.go [important] +* app/sovereign/export.go [important] +* cmd/interchain-security-cd/cmd/root.go [important; app setup] +* cmd/interchain-security-pd/cmd/root.go + + +# test changes +* app/consumer-democracy/ante/forbidden_proposals_ante_test.go +* tests/e2e/actions.go +* tests/e2e/config.go [add expedited period] + +* tests/e2e/state.go [important; changes marshalling] +* tests/e2e/state_rapid_test.go +* tests/e2e/steps.go + +### [proposal voting changed -> must provide numeric] +* tests/e2e/steps_democracy.go +* tests/e2e/steps_reward_denom.go +* tests/e2e/steps_sovereign_changeover.go +* tests/e2e/steps_start_chains.go +* tests/e2e/steps_stop_chain.go + +## Update e2e scripts +[must provide `q block --height 0` to force fetching current block] +* tests/e2e/testnet-scripts/start-chain.sh +* tests/e2e/testnet-scripts/start-changeover.sh +* tests/e2e/testnet-scripts/start-sovereign.sh + +## Update integration test setup +* tests/integration/common.go +* tests/integration/setup.go [updates to packet listening and initialization due to interface changes] + +## update assertions (change types etc) +* tests/integration/democracy.go +* tests/integration/distribution.go +* tests/integration/double_vote.go +* tests/integration/expired_client.go +* tests/integration/key_assignment.go +* tests/integration/misbehaviour.go +* tests/integration/normal_operations.go +* tests/integration/slashing.go +* tests/integration/stop_consumer.go +* tests/integration/unbonding.go +* tests/integration/valset_update.go + +MBT Driver +* tests/mbt/driver/common.go +* tests/mbt/driver/core.go +* tests/mbt/driver/mbt_test.go +* tests/mbt/driver/setup.go + + +Not sure needed? +* tests/integration/throttle.go +* tests/integration/throttle_retry.go + +Utils +* testutil/crypto/crypto.go [imports, fetching info] +* testutil/crypto/evidence.go [imports, fetching info] + * MakeVote() interface has changed + +* testutil/ibc_testing/generic_setup.go [init & proposal updates] +* testutil/ibc_testing/specific_setup.go [init & proposal updates] +-> interfaces +* testutil/integration/interfaces.go [support updated interfaces and enforce them] +* testutil/keeper/expectations.go [support updated interfaces and enforce them] +* testutil/keeper/mocks.go [run `make mocks` after updating expectations by hand and expected keepers] +* testutil/keeper/unit_test_helpers.go [imports & setup] +* testutil/simibc/chain_util.go [imports & setup] + * use `FinalizeBlock` and update parsing +* testutil/simibc/relay_util.go + +## Expected keepers +* x/ccv/types/expected_keepers.go [affects mocks and all tests] + + + +## Modules (mostly adapting to new interfaces, checking errs and updating names) + +### Consumer +* x/ccv/consumer/keeper/changeover.go +* x/ccv/consumer/keeper/changeover_test.go +* x/ccv/consumer/keeper/distribution.go +* x/ccv/consumer/keeper/distribution_test.go +* x/ccv/consumer/keeper/hooks.go + +* x/ccv/consumer/keeper/keeper.go +* update `iterator` initialization +```diff +- iterator := sdk.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) ++ iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) +``` +* `func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context)` now returns a value and err + + +* x/ccv/consumer/keeper/keeper_test.go +* x/ccv/consumer/keeper/legacy_params.go [addition] +* x/ccv/consumer/keeper/migration.go +* x/ccv/consumer/keeper/migration_test.go +* x/ccv/consumer/keeper/params.go +* x/ccv/consumer/keeper/relay_test.go + +* x/ccv/consumer/keeper/soft_opt_out_test.go +* x/ccv/consumer/keeper/soft_opt_out.go +* interfaces changed `UpdateSlashingSigningInfo` + +* x/ccv/consumer/keeper/validators.go [!important] +* changed all staking interface methods to match cosmos-sdk v50 +* some methods return errs so handling was added + +* x/ccv/consumer/keeper/validators_test.go [imports, err checks, extra assertions] +* x/ccv/consumer/module.go [important!] + +* x/ccv/consumer/types/keys.go [important! params key added to store] +* x/ccv/consumer/types/keys_test.go + + +## Democracy +* x/ccv/democracy/distribution/module.go [important] +* refactor `AllocateTokens` + * adds panics in multiple places due to err handling + +* x/ccv/democracy/governance/module.go [important] +* x/ccv/democracy/staking/module.go [important] + +## Provider +* x/ccv/provider/client/cli/query.go [add params query] +* x/ccv/provider/client/cli/query.go [imports, signer field in NewAssignConsumerKeyCmd] +* x/ccv/provider/client/legacy_proposal_handler.go [rename proposal_handler.go - deprecated] +* x/ccv/provider/client/legacy_proposals.go [added but deprecated] +* x/ccv/provider/handler.go [imports] +* x/ccv/provider/handler_test.go + + + +[sensitive] +* x/ccv/provider/keeper/consumer_equivocation.go [tricky - changes to cometBFT sign.Absent() flags => sign.Absent() changed to comparison sign.BlockIDFlag == tmtypes.BlockIDFlagAbsent] +* added error checks in `JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress)` +* added err checks in `SlashValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress)` + + + +* x/ccv/provider/keeper/consumer_equivocation_test.go + + +-> check that endblock returns correct errors +* x/ccv/provider/module.go [important] +* x/ccv/provider/module_test.go + + +* x/ccv/provider/types/codec.go [double check RegisterLegacyAminoCodec and RegisterInterfaces] +* x/ccv/provider/types/keys.go [adds parameters bytekey -> make sure you don't override it!!] +* x/ccv/provider/types/keys_test.go +* x/ccv/provider/types/legacy_proposal.go [rename from proposal.go, update logic] +* x/ccv/provider/types/legacy_proposal_test.go [check some weird comments about comparisons] +* x/ccv/provider/types/msg.go [new message type] +* x/ccv/provider/types/params.go +* x/ccv/provider/types/params_test.go + + +#### Change to store access +``` +// changes store module imports and iterator initialization + +- iterator := sdk.KVStorePrefixIterator(store, []byte{types.ConsumerRewardDenomsBytePrefix}) ++ iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ConsumerRewardDenomsBytePrefix}) +``` + +* x/ccv/provider/keeper/distribution.go +* update iterator + + +* x/ccv/provider/keeper/keeper_test.go +* x/ccv/provider/keeper/keeper.go +* updated `NewKeeper` and the `types Keeper struct` with v50 types (authority, storeKey, storeService, validatorAddressCodec, consensusAddressCodec) +* rm `SetParamSpace [DEPRECATED]` +* use v50 logger +* update all iterators: +```go +- iterator := sdk.KVStorePrefixIterator(store, []byte{types.ProposedConsumerChainByteKey}) ++ iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ProposedConsumerChainByteKey}) +``` + + +* x/ccv/provider/keeper/key_assignment.go [ also logic changes regarding key assignment and validator access ] +```go +- iterator := sdk.KVStorePrefixIterator(store, prefix) ++ iterator := storetypes.KVStorePrefixIterator(store, prefix) +``` + +Updates changing the logic slightly: +```go +func (k Keeper) AssignConsumerKey( + ctx sdk.Context, + chainID string, + validator stakingtypes.Validator, + consumerKey tmprotocrypto.PublicKey, +) error +``` + +```go +func (k Keeper) ValidatorConsensusKeyInUse(ctx sdk.Context, valAddr sdk.ValAddress) bool +``` + + +* x/ccv/provider/keeper/key_assignment_test.go -> partial + + +#### Other changes +* x/ccv/provider/keeper/genesis_test.go +* x/ccv/provider/keeper/grpc_query.go [adds params query] + +* x/ccv/provider/keeper/hooks.go +* update all methods to use `context.Context` instead of `sdk.Context` +* double check returned values in `func (h Hooks) GetConsumerAdditionLegacyPropFromProp` + +* x/ccv/provider/keeper/hooks_test.go +* x/ccv/provider/keeper/legacy_params.go + +* x/ccv/provider/keeper/migration_test.go +* x/ccv/provider/keeper/migration.go + * was re-done + +* x/ccv/provider/keeper/msg_server.go + +* x/ccv/provider/keeper/params_test.go +* x/ccv/provider/keeper/params.go +* migrated params to the new interface and update all getters +* added legacy params file for accessing deprecated params subspace + +* x/ccv/provider/keeper/proposal_test.go +* x/ccv/provider/keeper/proposal.go +* prefixed deprecated handlers with `Legacy` +* updated `MakeConsumerGenesis`: added err checks +* moved deprecated handlers to `legacy_proposal.go` + + +* x/ccv/provider/keeper/relay_test.go -> generate after updating mocks +* x/ccv/provider/keeper/relay.go +* updated err handling to support new interfaces + * `completeMaturedUnbondingOps(ctx sdk.Context)` + + +* x/ccv/provider/keeper/throttle_test.go +* x/ccv/provider/keeper/throttle.go +* update err handling +* left myself a note: `@MSalopek double check this conversion and see if it's necessary` + + +* x/ccv/provider/proposal_handler.go +* x/ccv/provider/proposal_handler_test.go +* x/ccv/provider/types/codec.go +* x/ccv/provider/types/errors.go +* x/ccv/provider/types/genesis.go + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# less important +* cmd/interchain-security-cd/main.go +* cmd/interchain-security-cdd/main.go +* cmd/interchain-security-pd/main.go +* cmd/interchain-security-sd/main.go \ No newline at end of file diff --git a/go.mod b/go.mod index c56809a94a..2e102870af 100644 --- a/go.mod +++ b/go.mod @@ -1,78 +1,67 @@ -module github.com/cosmos/interchain-security/v4 +module github.com/cosmos/interchain-security/v5 -go 1.21.1 +go 1.22.2 require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 - github.com/cometbft/cometbft v0.37.6 - github.com/cometbft/cometbft-db v0.11.0 - github.com/cosmos/cosmos-sdk v0.47.12 - github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/ibc-go/v7 v7.6.0 + github.com/cometbft/cometbft v0.38.9 + github.com/cometbft/cometbft-db v0.12.0 // indirect + github.com/cosmos/cosmos-sdk v0.50.7 + github.com/cosmos/gogoproto v1.4.12 github.com/cosmos/ics23/go v0.10.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 - github.com/gorilla/mux v1.8.0 // indirect + github.com/gorilla/mux v1.8.1 // 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.2.0 - github.com/rakyll/statik v0.1.7 // indirect github.com/spf13/cast v1.6.0 - github.com/spf13/cobra v1.8.1 + github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.9.0 github.com/tidwall/gjson v1.17.1 - golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 + golang.org/x/net v0.24.0 // indirect + golang.org/x/sys v0.19.0 // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/grpc v1.65.0 - google.golang.org/protobuf v1.34.2 + google.golang.org/grpc v1.63.2 + google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect + cloud.google.com/go v0.112.0 // indirect + cloud.google.com/go/compute v1.24.0 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.6 // indirect - cloud.google.com/go/storage v1.38.0 // indirect - cosmossdk.io/api v0.3.1 - cosmossdk.io/core v0.5.1 // indirect + cloud.google.com/go/storage v1.36.0 // indirect + cosmossdk.io/api v0.7.5 + cosmossdk.io/core v0.11.0 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 github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/aws/aws-sdk-go v1.44.203 // indirect + github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect - github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect - github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v0.20.1 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect - github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect - github.com/creachadair/taskgroup v0.4.2 // indirect + github.com/cosmos/iavl v1.1.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -92,19 +81,16 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.3 // indirect - github.com/gorilla/handlers v1.5.1 // indirect + github.com/gorilla/handlers v1.5.2 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.5 // indirect + github.com/hashicorp/go-getter v1.7.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect @@ -112,28 +98,26 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.17.2 // indirect + github.com/klauspost/compress v1.17.7 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/linxGnu/grocksdb v1.8.12 // indirect + github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-isatty v0.0.20 // 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 github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.52.2 // indirect + github.com/prometheus/procfs v0.13.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/cors v1.8.3 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect @@ -142,17 +126,17 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tidwall/btree v1.6.0 // indirect + github.com/tidwall/btree v1.7.0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect - go.etcd.io/bbolt v1.3.8 // indirect + go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/term v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/term v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect google.golang.org/api v0.171.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -162,28 +146,56 @@ require ( ) require ( + cosmossdk.io/client/v2 v2.0.0-beta.1 + cosmossdk.io/collections v0.4.0 + cosmossdk.io/log v1.3.1 + cosmossdk.io/store v1.1.0 + cosmossdk.io/tools/confix v0.1.1 + cosmossdk.io/x/evidence v0.1.0 + cosmossdk.io/x/feegrant v0.1.0 + cosmossdk.io/x/tx v0.13.3 + cosmossdk.io/x/upgrade v0.1.1 + github.com/cosmos/cosmos-db v1.0.2 + github.com/cosmos/ibc-go/modules/capability v1.0.0 + github.com/cosmos/ibc-go/v8 v8.2.1 github.com/informalsystems/itf-go v0.0.1 - github.com/spf13/viper v1.19.0 - golang.org/x/mod v0.19.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 + github.com/spf13/viper v1.18.2 + golang.org/x/mod v0.17.0 + google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 ) require ( - cosmossdk.io/log v1.3.1 // indirect - github.com/DataDog/zstd v1.4.5 // indirect + cosmossdk.io/x/circuit v0.1.0 // indirect + github.com/DataDog/datadog-go v3.2.0+incompatible // indirect + github.com/DataDog/zstd v1.5.5 // indirect + github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/getsentry/sentry-go v0.23.0 // indirect + github.com/creachadair/atomicfile v0.3.1 // indirect + github.com/creachadair/tomledit v0.0.24 // indirect + github.com/dgraph-io/badger/v4 v4.2.0 // indirect + github.com/emicklei/dot v1.6.1 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/flatbuffers v1.12.1 // indirect github.com/google/s2a-go v0.1.7 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-metrics v0.5.3 // indirect + github.com/hashicorp/go-plugin v1.5.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect + github.com/iancoleman/strcase v0.3.0 // 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/rogpeppe/go-internal v1.11.0 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect + github.com/oklog/run v1.1.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.32.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -193,15 +205,14 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - go.uber.org/atomic v1.10.0 // indirect go.uber.org/mock v0.2.0 // indirect - go.uber.org/multierr v1.9.0 // indirect + go.uber.org/multierr v1.10.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/time v0.5.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect + gotest.tools/v3 v3.5.1 // indirect ) // following versions might cause unexpected behavior replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - -replace golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb diff --git a/go.sum b/go.sum index be3b1b1902..4f3e6b9d86 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,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.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= -cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= +cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= +cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= 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= @@ -68,8 +68,10 @@ 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/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= +cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40= +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= cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= @@ -169,8 +171,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 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.38.0 h1:Az68ZRGlnNTpIBbLjSMIV2BDcwwXYlRlQzis0llkpJg= -cloud.google.com/go/storage v1.38.0/go.mod h1:tlUADB0mAb9BgYls9lq+8MGkfzOXuLrnHXlpHmvFJoY= +cloud.google.com/go/storage v1.36.0 h1:P0mOkAcaJxhCTvAkMhxMfrTKiNcub4YmmPBtlhAyTr8= +cloud.google.com/go/storage v1.36.0/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= 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= @@ -182,10 +184,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -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/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= +cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= +cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= +cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= +cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= +cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= 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.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -194,28 +200,40 @@ cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= -cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= -cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= +cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= +cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= +cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8= +cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ= +cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= +cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= +cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= +cosmossdk.io/x/evidence v0.1.0/go.mod h1:hTaiiXsoiJ3InMz1uptgF0BnGqROllAN8mwisOMMsfw= +cosmossdk.io/x/feegrant v0.1.0 h1:c7s3oAq/8/UO0EiN1H5BIjwVntujVTkYs35YPvvrdQk= +cosmossdk.io/x/feegrant v0.1.0/go.mod h1:4r+FsViJRpcZif/yhTn+E0E6OFfg4n0Lx+6cCtnZElU= +cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= +cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= +cosmossdk.io/x/upgrade v0.1.1 h1:aoPe2gNvH+Gwt/Pgq3dOxxQVU3j5P6Xf+DaUJTDZATc= +cosmossdk.io/x/upgrade v0.1.1/go.mod h1:MNLptLPcIFK9CWt7Ra//8WUZAxweyRDNcbs5nkOcQy0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= -github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -233,18 +251,16 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.203 h1:pcsP805b9acL3wUqa4JR2vg1k2wnItkDYNvfmcy6F+U= -github.com/aws/aws-sdk-go v1.44.203/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= +github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -254,14 +270,16 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= +github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= -github.com/btcsuite/btcd/btcutil v1.1.2/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= -github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= +github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -269,7 +287,6 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -313,51 +330,47 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.6 h1:2BSD0lGPbcIyRd99Pf1zH0Sa8o0pbfqVWEDbZ4Ec2Uc= -github.com/cometbft/cometbft v0.37.6/go.mod h1:5FRkFil9uagHZogIX9x8z51c3GIPpQmdIN8Mq46HfzY= -github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= -github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= -github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= -github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= +github.com/cometbft/cometbft v0.38.9 h1:cJBJBG0mPKz+sqelCi/hlfZjadZQGdDNnu6YQ1ZsUHQ= +github.com/cometbft/cometbft v0.38.9/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ= +github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0= +github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 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-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= +github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.47.12 h1:KOZHAVWrcilHywBN/FabBaXbDFMzoFmtdX0hqy5Ory8= -github.com/cosmos/cosmos-sdk v0.47.12/go.mod h1:ADjORYzUQqQv/FxDi0H0K5gW/rAk1CiDR3ZKsExfJV0= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-sdk v0.50.7 h1:LsBGKxifENR/DN4E1RZaitsyL93HU44x0p8EnMHp4V4= +github.com/cosmos/cosmos-sdk v0.50.7/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= -github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v0.20.1 h1:rM1kqeG3/HBT85vsZdoSNsehciqUQPWrR4BYmqE2+zg= -github.com/cosmos/iavl v0.20.1/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/v7 v7.6.0 h1:S1G5hcIVe9go+jQV6F9+I9yy+hylbJeLiVHUmktQNrM= -github.com/cosmos/ibc-go/v7 v7.6.0/go.mod h1:LifBA7JHRHl95ujjHIaBEHmUqy2qCGyqDCXB7qmAsZk= +github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= +github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +github.com/cosmos/iavl v1.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y= +github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM= +github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= +github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= +github.com/cosmos/ibc-go/v8 v8.2.1 h1:MTsnZZjxvGD4Fv5pYyx5UkELafSX0rlPt6IfsE2BpTQ= +github.com/cosmos/ibc-go/v8 v8.2.1/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8= 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.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= -github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= -github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= -github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= +github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8= -github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= +github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= +github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= +github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= 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/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -366,15 +379,14 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= +github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -395,6 +407,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= +github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -407,7 +421,9 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= @@ -420,8 +436,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -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/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.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= @@ -430,11 +446,15 @@ github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -527,6 +547,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -598,31 +620,26 @@ github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBH github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -630,13 +647,19 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= -github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= +github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= +github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= +github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -653,14 +676,18 @@ github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -669,6 +696,8 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -679,8 +708,8 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/informalsystems/itf-go v0.0.1 h1:lVvdg3v+IMWOsVfIvOOGy1hHFO5KxoS8b8EiwKLbQDg= github.com/informalsystems/itf-go v0.0.1/go.mod h1:wgqaQ/yl2kbNlgw6GaleuHEefpZvkZo6Hc0jc8cGG9M= -github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= -github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= +github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= +github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -708,10 +737,9 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -733,20 +761,22 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.8.12 h1:1/pCztQUOa3BX/1gR3jSZDoaKFpeHFvQ1XrqZpSvZVo= -github.com/linxGnu/grocksdb v1.8.12/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= +github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= +github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.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.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -754,12 +784,7 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= -github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -799,8 +824,12 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a h1:dlRvE5fWabOchtH7znfiFCcOvmIYgOeAS5ifBXBlh9Q= +github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= +github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -811,8 +840,8 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q= -github.com/onsi/gomega v1.20.0/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -837,13 +866,12 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 h1:hDSdbBuw3Lefr6R18ax0tZ2BJeNB3NehB3trOwYBsdU= -github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= +github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= 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= @@ -864,34 +892,32 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= +github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= -github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= +github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= +github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= 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= @@ -899,15 +925,14 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/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/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= 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.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -933,26 +958,18 @@ github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= -github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= +github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -969,6 +986,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -980,8 +998,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= -github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= +github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -992,17 +1010,15 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1015,8 +1031,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1037,42 +1053,54 @@ go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= -go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= 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/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -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/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +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-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1085,8 +1113,12 @@ golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -1094,10 +1126,8 @@ 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.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1158,8 +1188,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.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= 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= @@ -1185,8 +1215,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.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= 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= @@ -1211,19 +1241,19 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1273,7 +1303,9 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1297,13 +1329,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc 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.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= 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= @@ -1313,9 +1345,10 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/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.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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= @@ -1329,6 +1362,7 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1337,9 +1371,12 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1352,6 +1389,7 @@ golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1380,9 +1418,8 @@ 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.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1390,9 +1427,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -1452,6 +1488,8 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1560,10 +1598,10 @@ google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= -google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= -google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 h1:rIo7ocm2roD9DcFIX67Ym8icoGCKSARAiPljFhh5suQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= 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= @@ -1605,8 +1643,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.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= 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= @@ -1623,8 +1661,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1657,7 +1695,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proto/buf.lock b/proto/buf.lock index 1c8fbbc13a..01c20e880a 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -5,23 +5,29 @@ deps: owner: cosmos repository: cosmos-proto commit: 1935555c206d4afb9e94615dfd0fad31 + digest: shake256:c74d91a3ac7ae07d579e90eee33abf9b29664047ac8816500cf22c081fec0d72d62c89ce0bebafc1f6fec7aa5315be72606717740ca95007248425102c365377 - remote: buf.build owner: cosmos repository: cosmos-sdk - commit: 954f7b05f38440fc8250134b15adec47 + commit: aa25660f4ff746388669ce36b3778442 + digest: shake256:a20eb29eb7284d9d0b76e94324a6e24e3665d13682bed0d5beac647d7109b7b2f22080301276779a91f394c97dab334da36dfc01d4252d9f869b090bfc8248aa - remote: buf.build owner: cosmos repository: gogo-proto commit: 34d970b699f84aa382f3c29773a60836 + digest: shake256:3d3bee5229ba579e7d19ffe6e140986a228b48a8c7fe74348f308537ab95e9135210e81812489d42cd8941d33ff71f11583174ccc5972e86e6112924b6ce9f04 - remote: buf.build owner: cosmos repository: ibc - commit: fbb44f5ad3194450af479a615fa715d9 + commit: 7ab44ae956a0488ea04e04511efa5f70 + digest: shake256:95cc5472ddf692d23654b7e5adfd79149469dcc90657f9a1f80ee3fea8af639cff59cd849efca0567d270118eea7c7ff2f7e60c562545bace410b8eece27577e - remote: buf.build owner: cosmos repository: ics23 commit: 55085f7c710a45f58fa09947208eb70b + digest: shake256:9bf0bc495b5a11c88d163d39ef521bc4b00bc1374a05758c91d82821bdc61f09e8c2c51dda8452529bf80137f34d852561eacbe9550a59015d51cecb0dacb628 - remote: buf.build owner: googleapis repository: googleapis - commit: 5ae7f88519b04fe1965da0f8a375a088 + commit: 8d7204855ec14631a499bd7393ce1970 + digest: shake256:40bf4112960cad01281930beed85829910768e32e80e986791596853eccd42c0cbd9d96690b918f658020d2d427e16f8b6514e2ac7f4a10306fd32e77be44329 diff --git a/proto/buf.yaml b/proto/buf.yaml index 5ef6b4b743..b3f16381eb 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -6,11 +6,12 @@ version: v1 name: buf.build/cosmos/interchain-security deps: - - buf.build/cosmos/gogo-proto - - buf.build/cosmos/cosmos-sdk:v0.47.0 - - buf.build/cosmos/ibc:fbb44f5ad3194450af479a615fa715d9 - - buf.build/googleapis/googleapis + - buf.build/cosmos/cosmos-sdk:aa25660f4ff746388669ce36b3778442 + - buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31 + - buf.build/cosmos/gogo-proto:a14993478f40695898ed8a86931094b6656e8a5d - buf.build/cosmos/ics23:b1abd8678aab07165efd453c96796a179eb3131f + - buf.build/cosmos/ibc:26f7fe338f6d5d1d587887e94aa473302bb26a1a + - buf.build/googleapis/googleapis:8d7204855ec14631a499bd7393ce1970 breaking: use: diff --git a/proto/interchain_security/ccv/consumer/v1/consumer.proto b/proto/interchain_security/ccv/consumer/v1/consumer.proto index 0d42d2d16e..e77b5c9a13 100644 --- a/proto/interchain_security/ccv/consumer/v1/consumer.proto +++ b/proto/interchain_security/ccv/consumer/v1/consumer.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package interchain_security.ccv.consumer.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"; import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; diff --git a/proto/interchain_security/ccv/consumer/v1/genesis.proto b/proto/interchain_security/ccv/consumer/v1/genesis.proto index a2ceb0f9f6..642b78451d 100644 --- a/proto/interchain_security/ccv/consumer/v1/genesis.proto +++ b/proto/interchain_security/ccv/consumer/v1/genesis.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.consumer.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"; import "interchain_security/ccv/v1/shared_consumer.proto"; import "ibc/lightclients/tendermint/v1/tendermint.proto"; diff --git a/proto/interchain_security/ccv/consumer/v1/query.proto b/proto/interchain_security/ccv/consumer/v1/query.proto index eb8eb29a3d..0e9b088e1d 100644 --- a/proto/interchain_security/ccv/consumer/v1/query.proto +++ b/proto/interchain_security/ccv/consumer/v1/query.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.consumer.v1; import "interchain_security/ccv/v1/shared_consumer.proto"; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; diff --git a/proto/interchain_security/ccv/consumer/v1/tx.proto b/proto/interchain_security/ccv/consumer/v1/tx.proto new file mode 100644 index 0000000000..e76b8dd3b9 --- /dev/null +++ b/proto/interchain_security/ccv/consumer/v1/tx.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package interchain_security.ccv.consumer.v1; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"; + +import "amino/amino.proto"; +import "google/api/annotations.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "interchain_security/ccv/v1/shared_consumer.proto"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUpdateParams is the Msg/UpdateParams request type +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // signer is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/provider parameters to update. + interchain_security.ccv.v1.ConsumerParams params = 2 [(gogoproto.nullable) = false]; +} + +message MsgUpdateParamsResponse {} diff --git a/proto/interchain_security/ccv/provider/v1/genesis.proto b/proto/interchain_security/ccv/provider/v1/genesis.proto index 443ea26b32..269743721e 100644 --- a/proto/interchain_security/ccv/provider/v1/genesis.proto +++ b/proto/interchain_security/ccv/provider/v1/genesis.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.provider.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"; import "gogoproto/gogo.proto"; import "interchain_security/ccv/v1/shared_consumer.proto"; diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index e31b3a150f..26648c3fc5 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.provider.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"; import "interchain_security/ccv/v1/wire.proto"; import "gogoproto/gogo.proto"; @@ -13,9 +13,9 @@ import "ibc/lightclients/tendermint/v1/tendermint.proto"; import "tendermint/crypto/keys.proto"; import "cosmos/evidence/v1beta1/evidence.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; import "amino/amino.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. @@ -26,9 +26,11 @@ import "amino/amino.proto"; // chain are expected to validate the consumer chain at spawn time or get // slashed. It is recommended that spawn time occurs after the proposal end // time. +// Use MsgConsumerAddition to submit this proposal type. message ConsumerAdditionProposal { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; // the title of the proposal string title = 1; @@ -110,7 +112,10 @@ message ConsumerAdditionProposal { // remove (and stop) a consumer chain. If it passes, all the consumer chain's // state is removed from the provider chain. The outstanding unbonding operation // funds are released. +// Use MsgConsumerRemoval to submit this proposal type. message ConsumerRemovalProposal { + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + // the title of the proposal string title = 1; // the description of the proposal @@ -172,7 +177,10 @@ message EquivocationProposal { // ChangeRewardDenomsProposal is a governance proposal on the provider chain to // mutate the set of denoms accepted by the provider as rewards. +// Use MsgChangeRewardDenoms to submit this proposal type. message ChangeRewardDenomsProposal { + option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content"; + // the title of the proposal string title = 1; // the description of the proposal diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index b982cea667..9ea3aa6bec 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package interchain_security.ccv.provider.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"; import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; @@ -315,10 +315,9 @@ message QueryValidatorConsumerCommissionRateRequest { message QueryValidatorConsumerCommissionRateResponse { // The rate to charge delegators on the consumer chain, as a fraction string rate = 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } message QueryOldestUnconfirmedVscRequest { string chain_id = 1; } diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 8e8aab5408..a417aab3c0 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -1,28 +1,44 @@ syntax = "proto3"; package interchain_security.ccv.provider.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/provider/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"; +import "amino/amino.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -import "google/protobuf/any.proto"; +import "cosmos/msg/v1/msg.proto"; +import "ibc/core/client/v1/client.proto"; +import "interchain_security/ccv/provider/v1/provider.proto"; import "ibc/lightclients/tendermint/v1/tendermint.proto"; import "tendermint/types/evidence.proto"; - // Msg defines the Msg service. service Msg { + option (cosmos.msg.v1.service) = true; + rpc AssignConsumerKey(MsgAssignConsumerKey) returns (MsgAssignConsumerKeyResponse); rpc SubmitConsumerMisbehaviour(MsgSubmitConsumerMisbehaviour) returns (MsgSubmitConsumerMisbehaviourResponse); rpc SubmitConsumerDoubleVoting(MsgSubmitConsumerDoubleVoting) returns (MsgSubmitConsumerDoubleVotingResponse); + rpc ConsumerAddition(MsgConsumerAddition) returns (MsgConsumerAdditionResponse); + rpc ConsumerRemoval(MsgConsumerRemoval) returns (MsgConsumerRemovalResponse); + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc OptIn(MsgOptIn) returns (MsgOptInResponse); rpc OptOut(MsgOptOut) returns (MsgOptOutResponse); rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); + rpc ConsumerModification(MsgConsumerModification) returns (MsgConsumerModificationResponse); } + message MsgAssignConsumerKey { + option (cosmos.msg.v1.signer) = "signer"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; + + // The chain id of the consumer chain to assign a consensus public key to string chain_id = 1; // The validator address on the provider @@ -31,6 +47,9 @@ message MsgAssignConsumerKey { // in json string format corresponding to proto-any, ex: // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` string consumer_key = 3; + + // Tx signer address + string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } message MsgAssignConsumerKeyResponse {} @@ -39,24 +58,28 @@ message MsgAssignConsumerKeyResponse {} // MsgSubmitConsumerMisbehaviour defines a message that reports a light client attack, // also known as a misbehaviour, observed on a consumer chain message MsgSubmitConsumerMisbehaviour { + option (cosmos.msg.v1.signer) = "submitter"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string submitter = 1; - // The Misbehaviour of the consumer chain wrapping - // two conflicting IBC headers + + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The Misbehaviour of the consumer chain wrapping + // two conflicting IBC headers ibc.lightclients.tendermint.v1.Misbehaviour misbehaviour = 2; } message MsgSubmitConsumerMisbehaviourResponse {} -// MsgSubmitConsumerDoubleVoting defines a message that reports +// MsgSubmitConsumerDoubleVoting defines a message that reports // a double signing infraction observed on a consumer chain message MsgSubmitConsumerDoubleVoting { + option (cosmos.msg.v1.signer) = "submitter"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string submitter = 1; - // The equivocation of the consumer chain wrapping + + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The equivocation of the consumer chain wrapping // an evidence of a validator that signed two conflicting votes tendermint.types.DuplicateVoteEvidence duplicate_vote_evidence = 2; // The light client header of the infraction block @@ -65,9 +88,152 @@ message MsgSubmitConsumerDoubleVoting { message MsgSubmitConsumerDoubleVotingResponse {} +// MsgUpdateParams is the Msg/UpdateParams request type +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // signer is the address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the x/provider parameters to update. + Params params = 2 [(gogoproto.nullable) = false]; +} + +message MsgUpdateParamsResponse {} + + +// MsgConsumerAddition defines the message used to spawn a new consumer chain using a v1 governance proposal. +// If it passes, then all validators on the provider chain are expected to validate +// the consumer chain at spawn time or get slashed. +// It is recommended that spawn time occurs after the proposal end time. +// +// Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon +message MsgConsumerAddition { + option (cosmos.msg.v1.signer) = "authority"; + + // the proposed chain-id of the new consumer chain, must be different from all + // other consumer chain ids of the executing provider chain. + string chain_id = 1; + // the proposed initial height of new consumer chain. + // For a completely new chain, this will be {0,1}. However, it may be + // different if this is a chain that is converting to a consumer chain. + ibc.core.client.v1.Height initial_height = 2 [ (gogoproto.nullable) = false ]; + // The hash of the consumer chain genesis state without the consumer CCV + // module genesis params. It is used for off-chain confirmation of + // genesis.json validity by validators and other parties. + bytes genesis_hash = 3; + // The hash of the consumer chain binary that should be run by validators on + // chain initialization. It is used for off-chain confirmation of binary + // validity by validators and other parties. + bytes binary_hash = 4; + // spawn time is the time on the provider chain at which the consumer chain + // genesis is finalized and all validators will be responsible for starting + // their consumer chain validator node. + google.protobuf.Timestamp spawn_time = 5 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + google.protobuf.Duration unbonding_period = 6 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + // Sent CCV related IBC packets will timeout after this duration + google.protobuf.Duration ccv_timeout_period = 7 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + // Sent transfer related IBC packets will timeout after this duration + google.protobuf.Duration transfer_timeout_period = 8 + [ (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 = 9; + // BlocksPerDistributionTransmission is the number of blocks between + // ibc-token-transfers from the consumer chain to the provider chain. On + // sending transmission event, `consumer_redistribution_fraction` of the + // accumulated tokens are sent to the consumer redistribution address. + int64 blocks_per_distribution_transmission = 10; + // 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 = 11; + // The ID of a token transfer channel used for the Reward Distribution + // sub-protocol. If DistributionTransmissionChannel == "", a new transfer + // channel is created on top of the same connection as the CCV channel. + // Note that transfer_channel_id is the ID of the channel end on the consumer + // chain. it is most relevant for chains performing a sovereign to consumer + // changeover in order to maintan the existing ibc transfer channel + string distribution_transmission_channel = 12; + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + uint32 top_N = 13; + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + uint32 validators_power_cap = 14; + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + uint32 validator_set_cap = 15; + // Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + // the consumer chain. + repeated string allowlist = 16; + // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. + repeated string denylist = 17; + // signer address + string authority = 18 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages +message MsgConsumerAdditionResponse {} + + +// MsgConsumerRemoval message contains a governance proposal on the provider chain to +// remove (and stop) a consumer chain. If it passes, all the consumer chain's +// state is removed from the provider chain. The outstanding unbonding operation +// funds are released. +// +// Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon +message MsgConsumerRemoval { + option (cosmos.msg.v1.signer) = "authority"; + + // the chain-id of the consumer chain to be stopped + string chain_id = 1; + // the time on the provider chain at which all validators are responsible to + // stop their consumer chain validator node + google.protobuf.Timestamp stop_time = 2 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + // signer address + string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgConsumerRemovalResponse defines response type for MsgConsumerRemoval messages +message MsgConsumerRemovalResponse {} + +// ChangeRewardDenomsProposal is a governance proposal on the provider chain to +// mutate the set of denoms accepted by the provider as rewards. +// +// Note: this replaces ChangeRewardDenomsProposal which is deprecated and will be removed soon +message MsgChangeRewardDenoms { + option (cosmos.msg.v1.signer) = "authority"; + + // the list of consumer reward denoms to add + repeated string denoms_to_add = 1; + // the list of consumer reward denoms to remove + repeated string denoms_to_remove = 2; + // signer address + string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + +} + +// MsgChangeRewardDenomsResponse defines response type for MsgChangeRewardDenoms messages +message MsgChangeRewardDenomsResponse {} + message MsgOptIn { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "signer"; // the chain id of the consumer chain to opt in to string chain_id = 1; // the validator address on the provider @@ -77,6 +243,9 @@ message MsgOptIn { // This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the // consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. string consumer_key = 3; + // signer address + string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + } message MsgOptInResponse {} @@ -84,15 +253,19 @@ message MsgOptInResponse {} message MsgOptOut { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; + option (cosmos.msg.v1.signer) = "signer"; // the chain id of the consumer chain to opt out from string chain_id = 1; // the validator address on the provider string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + // signer address + string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + } message MsgOptOutResponse {} -// MsgSetConsumerCommissionRate allows validators to set +// MsgSetConsumerCommissionRate allows validators to set // a per-consumer chain commission rate message MsgSetConsumerCommissionRate { option (gogoproto.equal) = false; @@ -102,12 +275,50 @@ message MsgSetConsumerCommissionRate { // The chain id of the consumer chain to set a commission rate string chain_id = 2; // The rate to charge delegators on the consumer chain, as a fraction + // TODO: migrate rate from sdk.Dec to math.LegacyDec string rate = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + } message MsgSetConsumerCommissionRateResponse {} + +// MsgConsumerModification message contains a governance proposal on the provider chain to +// modify a running consumer chain. If it passes, the consumer chain's +// parameters are updated. +// +// Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon +message MsgConsumerModification { + // the title of the proposal + string title = 1; + // the description of the proposal + string description = 2; + // the chain-id of the consumer chain to be modified + string chain_id = 3; + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + uint32 top_N = 4; + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + uint32 validators_power_cap = 5; + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + uint32 validator_set_cap = 6; + // Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + // the consumer chain. + repeated string allowlist = 7; + // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. + repeated string denylist = 8; + // signer address + string authority = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +message MsgConsumerModificationResponse {} diff --git a/proto/interchain_security/ccv/v1/shared_consumer.proto b/proto/interchain_security/ccv/v1/shared_consumer.proto index 6c8cccfe86..f1535df010 100644 --- a/proto/interchain_security/ccv/v1/shared_consumer.proto +++ b/proto/interchain_security/ccv/v1/shared_consumer.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/types"; import "tendermint/abci/types.proto"; import "ibc/lightclients/tendermint/v1/tendermint.proto"; diff --git a/proto/interchain_security/ccv/v1/wire.proto b/proto/interchain_security/ccv/v1/wire.proto index 7382b9d0da..f0ba6ab41a 100644 --- a/proto/interchain_security/ccv/v1/wire.proto +++ b/proto/interchain_security/ccv/v1/wire.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package interchain_security.ccv.v1; -option go_package = "github.com/cosmos/interchain-security/v4/x/ccv/types"; +option go_package = "github.com/cosmos/interchain-security/v5/x/ccv/types"; import "cosmos/staking/v1beta1/staking.proto"; diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 67ae158143..fdf6a894c1 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -16,6 +16,6 @@ done cd .. # move proto files to the right places -cp -r github.com/cosmos/interchain-security/v4/* ./ +cp -r github.com/cosmos/interchain-security/v5/* ./ rm -rf github.com diff --git a/tests/e2e/action_rapid_test.go b/tests/e2e/action_rapid_test.go index 366f7f61c0..b720d3557c 100644 --- a/tests/e2e/action_rapid_test.go +++ b/tests/e2e/action_rapid_test.go @@ -269,15 +269,12 @@ func GetSubmitConsumerRemovalProposalActionGen() *rapid.Generator[SubmitConsumer }) } -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 GetSubmitParamChangeProposalActionGen() *rapid.Generator[SubmitEnableTransfersProposalAction] { + return rapid.Custom(func(t *rapid.T) SubmitEnableTransfersProposalAction { + return SubmitEnableTransfersProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), } }) } diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 9628338019..4a3e59876d 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -15,13 +15,14 @@ import ( "sync" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/tidwall/gjson" "golang.org/x/mod/semver" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/client" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -40,13 +41,12 @@ type SendTokensAction struct { Amount uint } -func (tr TestConfig) sendTokens( +func (tr Chain) sendTokens( action SendTokensAction, - target ExecutionTarget, verbose bool, ) { - fromValCfg := tr.validatorConfigs[action.From] - toValCfg := tr.validatorConfigs[action.To] + fromValCfg := tr.testConfig.validatorConfigs[action.From] + toValCfg := tr.testConfig.validatorConfigs[action.To] fromAddress := fromValCfg.DelAddress toAddress := toValCfg.DelAddress if action.Chain != ChainID("provi") { @@ -65,15 +65,15 @@ func (tr TestConfig) sendTokens( } } - binaryName := tr.chainConfigs[action.Chain].BinaryName - cmd := target.ExecCommand(binaryName, + binaryName := tr.testConfig.chainConfigs[action.Chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, "tx", "bank", "send", fromAddress, toAddress, fmt.Sprint(action.Amount)+`stake`, - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, @@ -105,12 +105,11 @@ type StartChainValidator struct { Stake uint } -func (tr *TestConfig) startChain( +func (tr *Chain) startChain( action StartChainAction, - target ExecutionTarget, verbose bool, ) { - chainConfig := tr.chainConfigs[action.Chain] + chainConfig := tr.testConfig.chainConfigs[action.Chain] type jsonValAttrs struct { Mnemonic string `json:"mnemonic"` Allocation string `json:"allocation"` @@ -128,18 +127,18 @@ func (tr *TestConfig) startChain( var validators []jsonValAttrs for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, - NodeKey: tr.validatorConfigs[val.Id].NodeKey, + Mnemonic: tr.testConfig.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.testConfig.validatorConfigs[val.Id].NodeKey, ValId: fmt.Sprint(val.Id), - PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + PrivValidatorKey: tr.testConfig.validatorConfigs[val.Id].PrivValidatorKey, Allocation: fmt.Sprint(val.Allocation) + "stake", Stake: fmt.Sprint(val.Stake) + "stake", - IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + IpSuffix: tr.testConfig.validatorConfigs[val.Id].IpSuffix, - ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, + ConsumerMnemonic: tr.testConfig.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.testConfig.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.testConfig.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -157,14 +156,14 @@ func (tr *TestConfig) startChain( } var cometmockArg string - if tr.useCometmock { + if tr.testConfig.useCometmock { cometmockArg = "true" } else { cometmockArg = "false" } - startChainScript := target.GetTestScriptPath(action.IsConsumer, "start-chain.sh") - cmd := target.ExecCommand("/bin/bash", + startChainScript := tr.target.GetTestScriptPath(action.IsConsumer, "start-chain.sh") + cmd := tr.target.ExecCommand("/bin/bash", startChainScript, chainConfig.BinaryName, string(vals), string(chainConfig.ChainId), chainConfig.IpPrefix, genesisChanges, fmt.Sprint(action.IsConsumer), @@ -172,7 +171,7 @@ func (tr *TestConfig) startChain( // 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 // with short timeout_commit (eg. timeout_commit = 1s) some nodes may miss blocks causing the test run to fail - tr.tendermintConfigOverride, + tr.testConfig.tendermintConfigOverride, cometmockArg, ) @@ -205,14 +204,14 @@ func (tr *TestConfig) startChain( Chain: action.Chain, Validator: action.Validators[0].Id, IsConsumer: action.IsConsumer, - }, target, verbose) + }, verbose) // store the fact that we started the chain - tr.runningChains[action.Chain] = true + tr.testConfig.runningChains[action.Chain] = true fmt.Println("Started chain", action.Chain) - if tr.timeOffset != 0 { + if tr.testConfig.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.testConfig.timeOffset) } } @@ -224,20 +223,19 @@ type SubmitTextProposalAction struct { Description string } -func (tr TestConfig) submitTextProposal( +func (tr Chain) submitTextProposal( action SubmitTextProposalAction, - target ExecutionTarget, verbose bool, ) { // TEXT PROPOSAL - bz, err := target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + bz, err := tr.target.ExecCommand( + tr.testConfig.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), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, @@ -267,17 +265,16 @@ type SubmitConsumerAdditionProposalAction struct { Denylist []string } -func (tr TestConfig) submitConsumerAdditionProposal( +func (tr Chain) submitConsumerAdditionProposal( action SubmitConsumerAdditionProposalAction, - target ExecutionTarget, verbose bool, ) { - spawnTime := tr.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) + spawnTime := tr.testConfig.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), + ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), InitialHeight: action.InitialHeight, GenesisHash: []byte("gen_hash"), BinaryHash: []byte("bin_hash"), @@ -308,11 +305,9 @@ func (tr TestConfig) submitConsumerAdditionProposal( } //#nosec G204 -- bypass unsafe quoting warning (no production code) - cmd := target.ExecCommand( - "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json"), - ) + cmd := tr.target.ExecCommand( + "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json")) bz, err = cmd.CombinedOutput() - if verbose { log.Println("submitConsumerAdditionProposal cmd: ", cmd.String()) } @@ -322,21 +317,32 @@ func (tr TestConfig) submitConsumerAdditionProposal( } // CONSUMER ADDITION PROPOSAL - bz, err = target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + cmd = tr.target.ExecCommand( + tr.testConfig.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), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--gas`, `900000`, `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, `-y`, - ).CombinedOutput() + ) + + if verbose { + fmt.Println("submitConsumerAdditionProposal cmd:", cmd.String()) + fmt.Println("submitConsumerAdditionProposal json:", jsonStr) + } + bz, err = cmd.CombinedOutput() + if err != nil { log.Fatal(err, "\n", string(bz)) } + if verbose { + fmt.Println("submitConsumerAdditionProposal output:", string(bz)) + } + // wait for inclusion in a block -> '--broadcast-mode block' is deprecated tr.waitBlocks(ChainID("provi"), 2, 10*time.Second) } @@ -349,16 +355,15 @@ type SubmitConsumerRemovalProposalAction struct { StopTimeOffset time.Duration // offset from time.Now() } -func (tr TestConfig) submitConsumerRemovalProposal( +func (tr Chain) submitConsumerRemovalProposal( action SubmitConsumerRemovalProposalAction, - target ExecutionTarget, verbose bool, ) { - stopTime := tr.containerConfig.Now.Add(action.StopTimeOffset) + stopTime := tr.testConfig.containerConfig.Now.Add(action.StopTimeOffset) prop := client.ConsumerRemovalProposalJSON{ 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.testConfig.chainConfigs[action.ConsumerChain].ChainId), StopTime: stopTime, Deposit: fmt.Sprint(action.Deposit) + `stake`, } @@ -373,18 +378,18 @@ func (tr TestConfig) submitConsumerRemovalProposal( log.Fatal("prop json contains single quote") } - bz, err = target.ExecCommand( + bz, err = tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json")).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - bz, err = target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + bz, err = tr.target.ExecCommand( + tr.testConfig.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), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--node`, tr.getValidatorNode(action.Chain, action.From), `--gas`, "900000", @@ -411,15 +416,14 @@ type SubmitConsumerModificationProposalAction struct { Denylist []string } -func (tr TestConfig) submitConsumerModificationProposal( +func (tr Chain) submitConsumerModificationProposal( action SubmitConsumerModificationProposalAction, - target ExecutionTarget, verbose bool, ) { prop := client.ConsumerModificationProposalJSON{ Title: "Propose the modification of the PSS parameters of a chain", Summary: "summary of a modification proposal", - ChainId: string(tr.chainConfigs[action.ConsumerChain].ChainId), + ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), Deposit: fmt.Sprint(action.Deposit) + `stake`, TopN: action.TopN, ValidatorsPowerCap: action.ValidatorsPowerCap, @@ -439,7 +443,7 @@ func (tr TestConfig) submitConsumerModificationProposal( } //#nosec G204 -- bypass unsafe quoting warning (no production code) - bz, err = target.ExecCommand( + bz, err = tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json"), ).CombinedOutput() if err != nil { @@ -447,11 +451,11 @@ func (tr TestConfig) submitConsumerModificationProposal( } // CONSUMER MODIFICATION PROPOSAL - cmd := target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + cmd := tr.target.ExecCommand( + tr.testConfig.chainConfigs[action.Chain].BinaryName, "tx", "gov", "submit-legacy-proposal", "consumer-modification", "/temp-proposal.json", `--from`, `validator`+fmt.Sprint(action.From), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--gas`, `900000`, `--node`, tr.getValidatorNode(action.Chain, action.From), @@ -460,78 +464,70 @@ func (tr TestConfig) submitConsumerModificationProposal( ) if verbose { log.Println("submitConsumerModificationProposal cmd: ", cmd.String()) + log.Println("submitConsumerModificationProposal json: ", jsonStr) } bz, err = cmd.CombinedOutput() + if err != nil { log.Fatal(err, "\n", string(bz)) } + if verbose { + log.Println("submitConsumerModificationProposal output: ", string(bz)) + } + // wait for inclusion in a block -> '--broadcast-mode block' is deprecated tr.waitBlocks(ChainID("provi"), 2, 10*time.Second) } -type SubmitParamChangeLegacyProposalAction struct { - Chain ChainID - From ValidatorID - Deposit uint - Subspace string - Key string - Value interface{} -} - -type paramChangeProposalJSON struct { - Title string `json:"title"` - Summary string `json:"summary"` - Description string `json:"description"` - Changes []paramChangeJSON `json:"changes"` - Deposit string `json:"deposit"` -} - -type paramChangeJSON struct { - Subspace string `json:"subspace"` - Key string `json:"key"` - Value interface{} `json:"value"` +type SubmitEnableTransfersProposalAction struct { + Chain ChainID + From ValidatorID + Title string + Deposit uint } -func (tr TestConfig) submitParamChangeProposal( - action SubmitParamChangeLegacyProposalAction, - target ExecutionTarget, +func (tr Chain) submitEnableTransfersProposalAction( + action SubmitEnableTransfersProposalAction, verbose bool, ) { - prop := paramChangeProposalJSON{ - 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`, - } - - 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") - } + // gov signed address got by checking the gov module acc address in the test container + // interchain-security-cdd q auth module-account gov --node tcp://7.7.9.253:26658 + template := ` + { + "messages": [ + { + "@type": "/ibc.applications.transfer.v1.MsgUpdateParams", + "signer": "consumer10d07y265gmmuvt4z0w9aw880jnsr700jlh7295", + "params": { + "send_enabled": true, + "receive_enabled": true + } + } + ], + "metadata": "ipfs://CID", + "deposit": "%dstake", + "title": "%s", + "summary": "Enable transfer send", + "expedited": false + } + ` + jsonStr := fmt.Sprintf(template, action.Deposit, action.Title) //#nosec G204 -- bypass unsafe quoting warning (no production code) - bz, err = target.ExecCommand( + bz, err := tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/params-proposal.json"), ).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - cmd := target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, - - "tx", "gov", "submit-legacy-proposal", "param-change", "/params-proposal.json", - + cmd := tr.target.ExecCommand( + tr.testConfig.chainConfigs[action.Chain].BinaryName, + "tx", "gov", "submit-proposal", "/params-proposal.json", `--from`, `validator`+fmt.Sprint(action.From), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--node`, tr.getValidatorNode(action.Chain, action.From), `--gas`, "900000", @@ -555,9 +551,8 @@ type VoteGovProposalAction struct { PropNumber uint } -func (tr *TestConfig) voteGovProposal( +func (tr *Chain) voteGovProposal( action VoteGovProposalAction, - target ExecutionTarget, verbose bool, ) { var wg sync.WaitGroup @@ -566,14 +561,14 @@ func (tr *TestConfig) voteGovProposal( vote := action.Vote[i] go func(val ValidatorID, vote string) { defer wg.Done() - bz, err := target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + bz, err := tr.target.ExecCommand( + tr.testConfig.chainConfigs[action.Chain].BinaryName, "tx", "gov", "vote", fmt.Sprint(action.PropNumber), vote, `--from`, `validator`+fmt.Sprint(val), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, val), `--node`, tr.getValidatorNode(action.Chain, val), `--keyring-backend`, `test`, @@ -589,7 +584,7 @@ func (tr *TestConfig) 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.WaitTime(time.Duration(tr.testConfig.chainConfigs[action.Chain].VotingWaitTime) * time.Second) } type StartConsumerChainAction struct { @@ -599,15 +594,13 @@ type StartConsumerChainAction struct { GenesisChanges string } -func (tr *TestConfig) startConsumerChain( +func (tr *Chain) startConsumerChain( action StartConsumerChainAction, - target ExecutionTarget, verbose bool, ) { fmt.Println("Starting consumer chain ", action.ConsumerChain) - - consumerGenesis := ".app_state.ccvconsumer = " + tr.getConsumerGenesis(action.ProviderChain, action.ConsumerChain, target) - consumerGenesisChanges := tr.chainConfigs[action.ConsumerChain].GenesisChanges + consumerGenesis := ".app_state.ccvconsumer = " + tr.getConsumerGenesis(action.ProviderChain, action.ConsumerChain) + consumerGenesisChanges := tr.testConfig.chainConfigs[action.ConsumerChain].GenesisChanges if consumerGenesisChanges != "" { consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges } @@ -620,21 +613,21 @@ func (tr *TestConfig) startConsumerChain( Validators: action.Validators, GenesisChanges: consumerGenesis, IsConsumer: true, - }, target, verbose) + }, verbose) } // Get consumer genesis from provider -func (tr *TestConfig) getConsumerGenesis(providerChain, consumerChain ChainID, target ExecutionTarget) string { +func (tr *Chain) getConsumerGenesis(providerChain, consumerChain ChainID) string { fmt.Println("Exporting consumer genesis from provider") - providerBinaryName := tr.chainConfigs[providerChain].BinaryName + providerBinaryName := tr.testConfig.chainConfigs[providerChain].BinaryName - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( providerBinaryName, "query", "provider", "consumer-genesis", - string(tr.chainConfigs[consumerChain].ChainId), + string(tr.testConfig.chainConfigs[consumerChain].ChainId), - `--node`, tr.getQueryNode(providerChain), + `--node`, tr.target.GetQueryNode(providerChain), `-o`, `json`, ) @@ -643,8 +636,8 @@ func (tr *TestConfig) getConsumerGenesis(providerChain, consumerChain ChainID, t log.Fatal(err, "\n", string(bz)) } - if tr.transformGenesis || needsGenesisTransform(target.GetTargetConfig()) { - return string(tr.transformConsumerGenesis(consumerChain, bz, target)) + if tr.testConfig.transformGenesis || needsGenesisTransform(tr.testConfig) { + return string(tr.transformConsumerGenesis(consumerChain, bz)) } else { fmt.Println("No genesis transformation performed") } @@ -652,7 +645,7 @@ func (tr *TestConfig) getConsumerGenesis(providerChain, consumerChain ChainID, t } // needsGenesisTransform tries to identify if a genesis transformation should be performed -func needsGenesisTransform(cfg TargetConfig) bool { +func needsGenesisTransform(cfg TestConfig) bool { // no genesis transformation needed for same versions if cfg.consumerVersion == cfg.providerVersion { return false @@ -757,7 +750,7 @@ func getTransformParameter(consumerVersion string) (string, error) { } // Transform consumer genesis content from older version -func (tr *TestConfig) transformConsumerGenesis(consumerChain ChainID, genesis []byte, target ExecutionTarget) []byte { +func (tr *Chain) transformConsumerGenesis(consumerChain ChainID, genesis []byte) []byte { fmt.Println("Transforming consumer genesis") fileName := "consumer_genesis.json" @@ -771,7 +764,7 @@ func (tr *TestConfig) transformConsumerGenesis(consumerChain ChainID, genesis [] log.Panicf("Failed writing consumer genesis to file: %v", err) } - containerInstance := tr.containerConfig.InstanceName + containerInstance := tr.testConfig.containerConfig.InstanceName targetFile := fmt.Sprintf("/tmp/%s", fileName) sourceFile := file.Name() //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. @@ -783,20 +776,19 @@ func (tr *TestConfig) transformConsumerGenesis(consumerChain ChainID, genesis [] } // check if genesis transform supports --to target - bz, err := target.ExecCommand( + bz, err := tr.target.ExecCommand( "interchain-security-transformer", "genesis", "transform", "--to").CombinedOutput() if err != nil && !strings.Contains(string(bz), "unknown flag: --to") { - cfg := target.GetTargetConfig() - targetVersion, err := getTransformParameter(cfg.consumerVersion) + targetVersion, err := getTransformParameter(tr.testConfig.consumerVersion) if err != nil { log.Panic("Failed getting genesis transformation parameter: ", err) } - cmd = target.ExecCommand( + cmd = tr.target.ExecCommand( "interchain-security-transformer", "genesis", "transform", targetVersion, targetFile) } else { - cmd = target.ExecCommand( + cmd = tr.target.ExecCommand( "interchain-security-transformer", "genesis", "transform", targetFile) } @@ -815,20 +807,19 @@ type ChangeoverChainAction struct { GenesisChanges string } -func (tr TestConfig) changeoverChain( +func (tr Chain) changeoverChain( action ChangeoverChainAction, - target ExecutionTarget, verbose bool, ) { // sleep until the consumer chain genesis is ready on consumer time.Sleep(5 * time.Second) - cmd := target.ExecCommand( - tr.chainConfigs[action.ProviderChain].BinaryName, + cmd := tr.target.ExecCommand( + tr.testConfig.chainConfigs[action.ProviderChain].BinaryName, "query", "provider", "consumer-genesis", - string(tr.chainConfigs[action.SovereignChain].ChainId), + string(tr.testConfig.chainConfigs[action.SovereignChain].ChainId), - `--node`, tr.getQueryNode(action.ProviderChain), + `--node`, tr.target.GetQueryNode(action.ProviderChain), `-o`, `json`, ) @@ -842,7 +833,7 @@ func (tr TestConfig) changeoverChain( } consumerGenesis := ".app_state.ccvconsumer = " + string(bz) - consumerGenesisChanges := tr.chainConfigs[action.SovereignChain].GenesisChanges + consumerGenesisChanges := tr.testConfig.chainConfigs[action.SovereignChain].GenesisChanges if consumerGenesisChanges != "" { consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges } @@ -853,15 +844,14 @@ func (tr TestConfig) changeoverChain( tr.startChangeover(ChangeoverChainAction{ Validators: action.Validators, GenesisChanges: consumerGenesis, - }, target, verbose) + }, verbose) } -func (tr TestConfig) startChangeover( +func (tr Chain) startChangeover( action ChangeoverChainAction, - target ExecutionTarget, verbose bool, ) { - chainConfig := tr.chainConfigs[ChainID("sover")] + chainConfig := tr.testConfig.chainConfigs[ChainID("sover")] type jsonValAttrs struct { Mnemonic string `json:"mnemonic"` Allocation string `json:"allocation"` @@ -879,18 +869,18 @@ func (tr TestConfig) startChangeover( var validators []jsonValAttrs for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, - NodeKey: tr.validatorConfigs[val.Id].NodeKey, + Mnemonic: tr.testConfig.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.testConfig.validatorConfigs[val.Id].NodeKey, ValId: fmt.Sprint(val.Id), - PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + PrivValidatorKey: tr.testConfig.validatorConfigs[val.Id].PrivValidatorKey, Allocation: fmt.Sprint(val.Allocation) + "stake", Stake: fmt.Sprint(val.Stake) + "stake", - IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + IpSuffix: tr.testConfig.validatorConfigs[val.Id].IpSuffix, - ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, + ConsumerMnemonic: tr.testConfig.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.testConfig.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.testConfig.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -908,12 +898,12 @@ func (tr TestConfig) startChangeover( } isConsumer := true - changeoverScript := target.GetTestScriptPath(isConsumer, "start-changeover.sh") - cmd := target.ExecCommand( + changeoverScript := tr.target.GetTestScriptPath(isConsumer, "start-changeover.sh") + cmd := tr.target.ExecCommand( "/bin/bash", changeoverScript, chainConfig.UpgradeBinary, string(vals), "sover", chainConfig.IpPrefix, genesisChanges, - tr.tendermintConfigOverride, + tr.testConfig.tendermintConfigOverride, ) cmdReader, err := cmd.StdoutPipe() @@ -970,34 +960,32 @@ const gorelayerChainConfigTemplate = ` } }` -func (tr TestConfig) addChainToRelayer( +func (tr Chain) addChainToRelayer( action AddChainToRelayerAction, - target ExecutionTarget, verbose bool, ) { - if !tr.useGorelayer { - tr.addChainToHermes(action, target, verbose) + if !tr.testConfig.useGorelayer { + tr.addChainToHermes(action, verbose) } else { - tr.addChainToGorelayer(action, target, verbose) + tr.addChainToGorelayer(action, verbose) } } -func (tr TestConfig) addChainToGorelayer( +func (tr Chain) addChainToGorelayer( action AddChainToRelayerAction, - target ExecutionTarget, verbose bool, ) { - queryNodeIP := tr.getQueryNodeIP(action.Chain) - ChainId := tr.chainConfigs[action.Chain].ChainId + queryNodeIP := tr.target.GetQueryNodeIP(action.Chain) + ChainId := tr.testConfig.chainConfigs[action.Chain].ChainId rpcAddr := "http://" + queryNodeIP + ":26658" chainConfig := fmt.Sprintf(gorelayerChainConfigTemplate, ChainId, rpcAddr, - tr.chainConfigs[action.Chain].AccountPrefix, + tr.testConfig.chainConfigs[action.Chain].AccountPrefix, ) - bz, err := target.ExecCommand( + bz, err := tr.target.ExecCommand( "rly", "config", "init").CombinedOutput() if err != nil && !strings.Contains(string(bz), "config already exists") { log.Fatal(err, "\n", string(bz)) @@ -1006,25 +994,25 @@ func (tr TestConfig) addChainToGorelayer( chainConfigFileName := fmt.Sprintf("/root/%s_config.json", ChainId) bashCommand := fmt.Sprintf(`echo '%s' >> %s`, chainConfig, chainConfigFileName) - bz, err = target.ExecCommand("bash", "-c", + bz, err = tr.target.ExecCommand("bash", "-c", bashCommand).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - addChainCommand := target.ExecCommand("rly", "chains", "add", "--file", chainConfigFileName, string(ChainId)) - executeCommand(addChainCommand, "add chain") + addChainCommand := tr.target.ExecCommand("rly", "chains", "add", "--file", chainConfigFileName, string(ChainId)) + e2e.ExecuteCommand(addChainCommand, "add chain") - keyRestoreCommand := target.ExecCommand("rly", "keys", "restore", string(ChainId), "default", tr.validatorConfigs[action.Validator].Mnemonic) - executeCommand(keyRestoreCommand, "restore keys") + keyRestoreCommand := tr.target.ExecCommand("rly", "keys", "restore", string(ChainId), "default", tr.testConfig.validatorConfigs[action.Validator].Mnemonic) + e2e.ExecuteCommand(keyRestoreCommand, "restore keys") } -func (tr TestConfig) addChainToHermes( +func (tr Chain) addChainToHermes( action AddChainToRelayerAction, - target ExecutionTarget, verbose bool, ) { - bz, err := target.ExecCommand("bash", "-c", "hermes", "version").CombinedOutput() + + bz, err := tr.target.ExecCommand("bash", "-c", "hermes", "version").CombinedOutput() if err != nil { log.Fatal(err, "\n error getting hermes version", string(bz)) } @@ -1035,34 +1023,34 @@ func (tr TestConfig) addChainToHermes( } hermesVersion := match[1] - queryNodeIP := tr.getQueryNodeIP(action.Chain) - hermesConfig := GetHermesConfig(hermesVersion, queryNodeIP, tr.chainConfigs[action.Chain], action.IsConsumer) + queryNodeIP := tr.target.GetQueryNodeIP(action.Chain) + hermesConfig := GetHermesConfig(hermesVersion, queryNodeIP, tr.testConfig.chainConfigs[action.Chain], action.IsConsumer) bashCommand := fmt.Sprintf(`echo '%s' >> %s`, hermesConfig, "/root/.hermes/config.toml") - bz, err = target.ExecCommand("bash", "-c", bashCommand).CombinedOutput() + bz, err = tr.target.ExecCommand("bash", "-c", bashCommand).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } // Save mnemonic to file within container var mnemonic string - if tr.validatorConfigs[action.Validator].UseConsumerKey && action.IsConsumer { - mnemonic = tr.validatorConfigs[action.Validator].ConsumerMnemonic + if tr.testConfig.validatorConfigs[action.Validator].UseConsumerKey && action.IsConsumer { + mnemonic = tr.testConfig.validatorConfigs[action.Validator].ConsumerMnemonic } else { - mnemonic = tr.validatorConfigs[action.Validator].Mnemonic + mnemonic = tr.testConfig.validatorConfigs[action.Validator].Mnemonic } saveMnemonicCommand := fmt.Sprintf(`echo '%s' > %s`, mnemonic, "/root/.hermes/mnemonic.txt") fmt.Println("Add to hermes", action.Validator) - bz, err = target.ExecCommand("bash", "-c", saveMnemonicCommand).CombinedOutput() + bz, err = tr.target.ExecCommand("bash", "-c", saveMnemonicCommand).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - bz, err = target.ExecCommand("hermes", + bz, err = tr.target.ExecCommand("hermes", "keys", "add", - "--chain", string(tr.chainConfigs[action.Chain].ChainId), + "--chain", string(tr.testConfig.chainConfigs[action.Chain].ChainId), "--mnemonic-file", "/root/.hermes/mnemonic.txt", ).CombinedOutput() if err != nil { @@ -1097,21 +1085,19 @@ type AddIbcConnectionAction struct { ClientB uint } -func (tr TestConfig) addIbcConnection( +func (tr Chain) addIbcConnection( action AddIbcConnectionAction, - target ExecutionTarget, verbose bool, ) { - if !tr.useGorelayer { - tr.addIbcConnectionHermes(action, target, verbose) + if !tr.testConfig.useGorelayer { + tr.addIbcConnectionHermes(action, verbose) } else { - tr.addIbcConnectionGorelayer(action, target, verbose) + tr.addIbcConnectionGorelayer(action, verbose) } } -func (tr TestConfig) addIbcConnectionGorelayer( +func (tr Chain) addIbcConnectionGorelayer( action AddIbcConnectionAction, - target ExecutionTarget, verbose bool, ) { pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) @@ -1123,32 +1109,32 @@ func (tr TestConfig) addIbcConnectionGorelayer( bashCommand := fmt.Sprintf(`echo '%s' >> %s`, pathConfig, pathConfigFileName) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - pathConfigCommand := target.ExecCommand("bash", "-c", bashCommand) - executeCommand(pathConfigCommand, "add path config") + pathConfigCommand := tr.target.ExecCommand("bash", "-c", bashCommand) + e2e.ExecuteCommand(pathConfigCommand, "add path config") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - newPathCommand := target.ExecCommand("rly", + newPathCommand := tr.target.ExecCommand("rly", "paths", "add", - string(tr.chainConfigs[action.ChainA].ChainId), - string(tr.chainConfigs[action.ChainB].ChainId), + string(tr.testConfig.chainConfigs[action.ChainA].ChainId), + string(tr.testConfig.chainConfigs[action.ChainB].ChainId), pathName, "--file", pathConfigFileName, ) - executeCommand(newPathCommand, "new path") + e2e.ExecuteCommand(newPathCommand, "new path") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - newClientsCommand := target.ExecCommand("rly", "transact", "clients", pathName) + newClientsCommand := tr.target.ExecCommand("rly", "transact", "clients", pathName) - executeCommand(newClientsCommand, "new clients") + e2e.ExecuteCommand(newClientsCommand, "new clients") 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 := target.ExecCommand("rly", "transact", "connection", pathName) + newConnectionCommand := tr.target.ExecCommand("rly", "transact", "connection", pathName) - executeCommand(newConnectionCommand, "new connection") + e2e.ExecuteCommand(newConnectionCommand, "new connection") tr.waitBlocks(action.ChainA, 1, 10*time.Second) tr.waitBlocks(action.ChainB, 1, 10*time.Second) @@ -1162,15 +1148,14 @@ type CreateIbcClientsAction struct { // 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 TestConfig) createIbcClientsHermes( +func (tr Chain) createIbcClientsHermes( action CreateIbcClientsAction, - target ExecutionTarget, verbose bool, ) { - cmd := target.ExecCommand("hermes", + cmd := tr.target.ExecCommand("hermes", "create", "connection", - "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), - "--b-chain", string(tr.chainConfigs[action.ChainB].ChainId), + "--a-chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId), + "--b-chain", string(tr.testConfig.chainConfigs[action.ChainB].ChainId), ) cmdReader, err := cmd.StdoutPipe() @@ -1199,14 +1184,13 @@ func (tr TestConfig) createIbcClientsHermes( } } -func (tr TestConfig) addIbcConnectionHermes( +func (tr Chain) addIbcConnectionHermes( action AddIbcConnectionAction, - target ExecutionTarget, verbose bool, ) { - cmd := target.ExecCommand("hermes", + cmd := tr.target.ExecCommand("hermes", "create", "connection", - "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--a-chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId), "--a-client", "07-tendermint-"+fmt.Sprint(action.ClientA), "--b-client", "07-tendermint-"+fmt.Sprint(action.ClientB), ) @@ -1249,25 +1233,23 @@ type AddIbcChannelAction struct { type StartRelayerAction struct{} -func (tr TestConfig) startRelayer( +func (tr Chain) startRelayer( action StartRelayerAction, - target ExecutionTarget, verbose bool, ) { - if tr.useGorelayer { - tr.startGorelayer(action, target, verbose) + if tr.testConfig.useGorelayer { + tr.startGorelayer(action, verbose) } else { - tr.startHermes(action, target, verbose) + tr.startHermes(action, verbose) } } -func (tr TestConfig) startGorelayer( +func (tr Chain) startGorelayer( action StartRelayerAction, - target ExecutionTarget, verbose bool, ) { // gorelayer start is running in detached mode - cmd := target.ExecDetachedCommand("rly", "start") + cmd := tr.target.ExecDetachedCommand("rly", "start") if err := cmd.Start(); err != nil { log.Fatal(err) @@ -1278,13 +1260,12 @@ func (tr TestConfig) startGorelayer( } } -func (tr TestConfig) startHermes( +func (tr Chain) startHermes( action StartRelayerAction, - target ExecutionTarget, verbose bool, ) { // hermes start is running in detached mode - cmd := target.ExecDetachedCommand("hermes", "start") + cmd := tr.target.ExecDetachedCommand("hermes", "start") if err := cmd.Start(); err != nil { log.Fatal(err) @@ -1295,51 +1276,48 @@ func (tr TestConfig) startHermes( } } -func (tr TestConfig) addIbcChannel( +func (tr Chain) addIbcChannel( action AddIbcChannelAction, - target ExecutionTarget, verbose bool, ) { - if tr.useGorelayer { - tr.addIbcChannelGorelayer(action, target, verbose) + if tr.testConfig.useGorelayer { + tr.addIbcChannelGorelayer(action, verbose) } else { - tr.addIbcChannelHermes(action, target, verbose) + tr.addIbcChannelHermes(action, verbose) } } -func (tr TestConfig) addIbcChannelGorelayer( +func (tr Chain) addIbcChannelGorelayer( action AddIbcChannelAction, - target ExecutionTarget, verbose bool, ) { pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) - cmd := target.ExecCommand("rly", + cmd := tr.target.ExecCommand("rly", "transact", "channel", pathName, "--src-port", action.PortA, "--dst-port", action.PortB, - "--version", tr.containerConfig.CcvVersion, + "--version", tr.testConfig.containerConfig.CcvVersion, "--order", action.Order, "--debug", ) - executeCommand(cmd, "addChannel") + e2e.ExecuteCommand(cmd, "addChannel") } -func (tr TestConfig) addIbcChannelHermes( +func (tr Chain) addIbcChannelHermes( action AddIbcChannelAction, - target ExecutionTarget, 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 if chanVersion == "" { - chanVersion = tr.containerConfig.CcvVersion + chanVersion = tr.testConfig.containerConfig.CcvVersion } - cmd := target.ExecCommand("hermes", + cmd := tr.target.ExecCommand("hermes", "create", "channel", - "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--a-chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId), "--a-connection", "connection-"+fmt.Sprint(action.ConnectionA), "--a-port", action.PortA, "--b-port", action.PortB, @@ -1388,30 +1366,29 @@ type TransferChannelCompleteAction struct { ChannelB uint } -func (tr TestConfig) transferChannelComplete( +func (tr Chain) transferChannelComplete( action TransferChannelCompleteAction, - target ExecutionTarget, verbose bool, ) { - if tr.useGorelayer { + if tr.testConfig.useGorelayer { log.Fatal("transferChannelComplete is not implemented for rly") } - chanOpenTryCmd := target.ExecCommand("hermes", + chanOpenTryCmd := tr.target.ExecCommand("hermes", "tx", "chan-open-try", - "--dst-chain", string(tr.chainConfigs[action.ChainB].ChainId), - "--src-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--dst-chain", string(tr.testConfig.chainConfigs[action.ChainB].ChainId), + "--src-chain", string(tr.testConfig.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") + e2e.ExecuteCommand(chanOpenTryCmd, "transferChanOpenTry") - chanOpenAckCmd := target.ExecCommand("hermes", + chanOpenAckCmd := tr.target.ExecCommand("hermes", "tx", "chan-open-ack", - "--dst-chain", string(tr.chainConfigs[action.ChainA].ChainId), - "--src-chain", string(tr.chainConfigs[action.ChainB].ChainId), + "--dst-chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId), + "--src-chain", string(tr.testConfig.chainConfigs[action.ChainB].ChainId), "--dst-connection", "connection-"+fmt.Sprint(action.ConnectionA), "--dst-port", action.PortA, "--src-port", action.PortB, @@ -1419,52 +1396,19 @@ func (tr TestConfig) transferChannelComplete( "--src-channel", "channel-"+fmt.Sprint(action.ChannelB), ) - executeCommand(chanOpenAckCmd, "transferChanOpenAck") + e2e.ExecuteCommand(chanOpenAckCmd, "transferChanOpenAck") - chanOpenConfirmCmd := target.ExecCommand("hermes", + chanOpenConfirmCmd := tr.target.ExecCommand("hermes", "tx", "chan-open-confirm", - "--dst-chain", string(tr.chainConfigs[action.ChainB].ChainId), - "--src-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--dst-chain", string(tr.testConfig.chainConfigs[action.ChainB].ChainId), + "--src-chain", string(tr.testConfig.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") -} - -func executeCommandWithVerbosity(cmd *exec.Cmd, cmdName string, verbose bool) { - if verbose { - fmt.Println(cmdName+" cmd:", cmd.String()) - } - - cmdReader, err := cmd.StdoutPipe() - if err != nil { - log.Fatal(err) - } - cmd.Stderr = cmd.Stdout - - if err := cmd.Start(); err != nil { - log.Fatal(err) - } - - scanner := bufio.NewScanner(cmdReader) - - for scanner.Scan() { - out := scanner.Text() - if verbose { - fmt.Println(cmdName + ": " + out) - } - } - if err := scanner.Err(); err != nil { - log.Fatal(err) - } -} - -// Executes a command with verbosity specified by CLI flag -func executeCommand(cmd *exec.Cmd, cmdName string) { - executeCommandWithVerbosity(cmd, cmdName, *verbose) + e2e.ExecuteCommand(chanOpenConfirmCmd, "transferChanOpenConfirm") } type RelayPacketsAction struct { @@ -1474,21 +1418,19 @@ type RelayPacketsAction struct { Channel uint } -func (tr TestConfig) relayPackets( +func (tr Chain) relayPackets( action RelayPacketsAction, - target ExecutionTarget, verbose bool, ) { - if tr.useGorelayer { - tr.relayPacketsGorelayer(action, target, verbose) + if tr.testConfig.useGorelayer { + tr.relayPacketsGorelayer(action, verbose) } else { - tr.relayPacketsHermes(action, target, verbose) + tr.relayPacketsHermes(action, verbose) } } -func (tr TestConfig) relayPacketsGorelayer( +func (tr Chain) relayPacketsGorelayer( action RelayPacketsAction, - target ExecutionTarget, verbose bool, ) { // Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 3 blocks @@ -1500,7 +1442,7 @@ func (tr TestConfig) relayPacketsGorelayer( pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) // rly transact relay-packets [path-name] --channel [channel-id] - cmd := target.ExecCommand("rly", "transact", "flush", + cmd := tr.target.ExecCommand("rly", "transact", "flush", pathName, "channel-"+fmt.Sprint(action.Channel), ) @@ -1516,9 +1458,8 @@ func (tr TestConfig) relayPacketsGorelayer( tr.waitBlocks(action.ChainB, 1, 30*time.Second) } -func (tr TestConfig) relayPacketsHermes( +func (tr Chain) relayPacketsHermes( action RelayPacketsAction, - target ExecutionTarget, verbose bool, ) { // Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 3 blocks @@ -1528,8 +1469,8 @@ func (tr TestConfig) relayPacketsHermes( tr.waitBlocks(action.ChainB, 3, 90*time.Second) // hermes clear packets ibc0 transfer channel-13 - cmd := target.ExecCommand("hermes", "clear", "packets", - "--chain", string(tr.chainConfigs[action.ChainA].ChainId), + cmd := tr.target.ExecCommand("hermes", "clear", "packets", + "--chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId), "--port", action.Port, "--channel", "channel-"+fmt.Sprint(action.Channel), ) @@ -1553,18 +1494,17 @@ type RelayRewardPacketsToProviderAction struct { Channel uint } -func (tr TestConfig) relayRewardPacketsToProvider( +func (tr Chain) relayRewardPacketsToProvider( action RelayRewardPacketsToProviderAction, - target ExecutionTarget, 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.target.GetParam(action.ConsumerChain, Param{Subspace: "ccvconsumer", Key: "BlocksPerDistributionTransmission"}), "\""), 10, 64) + currentBlock := uint64(tr.target.GetBlockHeight(action.ConsumerChain)) if currentBlock <= blockPerDistribution { 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}, target, verbose) + tr.relayPackets(RelayPacketsAction{ChainA: action.ConsumerChain, ChainB: action.ProviderChain, Port: action.Port, Channel: action.Channel}, verbose) tr.waitBlocks(action.ProviderChain, 1, 10*time.Second) } @@ -1575,12 +1515,11 @@ type DelegateTokensAction struct { Amount uint } -func (tr TestConfig) delegateTokens( +func (tr Chain) delegateTokens( action DelegateTokensAction, - target ExecutionTarget, verbose bool, ) { - toValCfg := tr.validatorConfigs[action.To] + toValCfg := tr.testConfig.validatorConfigs[action.To] validatorAddress := toValCfg.ValoperAddress if action.Chain != ChainID("provi") { // use binary with Bech32Prefix set to ConsumerAccountPrefix @@ -1592,12 +1531,13 @@ func (tr TestConfig) delegateTokens( } } - cmd := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + cmd := tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, + "tx", "staking", "delegate", validatorAddress, fmt.Sprint(action.Amount)+`stake`, `--from`, `validator`+fmt.Sprint(action.From), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, @@ -1624,12 +1564,11 @@ type UnbondTokensAction struct { Amount uint } -func (tr TestConfig) unbondTokens( +func (tr Chain) unbondTokens( action UnbondTokensAction, - target ExecutionTarget, verbose bool, ) { - unbondFromValCfg := tr.validatorConfigs[action.UnbondFrom] + unbondFromValCfg := tr.testConfig.validatorConfigs[action.UnbondFrom] validatorAddress := unbondFromValCfg.ValoperAddress if action.Chain != ChainID("provi") { // use binary with Bech32Prefix set to ConsumerAccountPrefix @@ -1641,14 +1580,14 @@ func (tr TestConfig) unbondTokens( } } - cmd := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + cmd := tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, "tx", "staking", "unbond", validatorAddress, fmt.Sprint(action.Amount)+`stake`, `--from`, `validator`+fmt.Sprint(action.Sender), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.Sender), `--node`, tr.getValidatorNode(action.Chain, action.Sender), `--gas`, "900000", @@ -1676,13 +1615,12 @@ type CancelUnbondTokensAction struct { Amount uint } -func (tr TestConfig) cancelUnbondTokens( +func (tr Chain) cancelUnbondTokens( action CancelUnbondTokensAction, - target ExecutionTarget, verbose bool, ) { - valCfg := tr.validatorConfigs[action.Validator] - delCfg := tr.validatorConfigs[action.Delegator] + valCfg := tr.testConfig.validatorConfigs[action.Validator] + delCfg := tr.testConfig.validatorConfigs[action.Delegator] validatorAddress := valCfg.ValoperAddress delegatorAddress := delCfg.DelAddress if action.Chain != ChainID("provi") { @@ -1702,7 +1640,7 @@ func (tr TestConfig) cancelUnbondTokens( } // get creation-height from state - cmd := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + cmd := tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, "q", "staking", "unbonding-delegation", delegatorAddress, validatorAddress, @@ -1718,18 +1656,18 @@ func (tr TestConfig) cancelUnbondTokens( if err != nil { log.Fatal(err, "\n", string(bz)) } - creationHeight := gjson.Get(string(bz), "entries.0.creation_height").Int() + creationHeight := gjson.Get(string(bz), "unbond.entries.0.creation_height").Int() if creationHeight == 0 { log.Fatal("invalid creation height") } - cmd = target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + cmd = tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, "tx", "staking", "cancel-unbond", validatorAddress, fmt.Sprint(action.Amount)+`stake`, fmt.Sprint(creationHeight), `--from`, `validator`+fmt.Sprint(action.Delegator), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.Delegator), `--node`, tr.getValidatorNode(action.Chain, action.Delegator), `--gas`, "900000", @@ -1759,9 +1697,9 @@ type RedelegateTokensAction struct { Amount uint } -func (tr TestConfig) redelegateTokens(action RedelegateTokensAction, target ExecutionTarget, verbose bool) { - srcCfg := tr.validatorConfigs[action.Src] - dstCfg := tr.validatorConfigs[action.Dst] +func (tr Chain) redelegateTokens(action RedelegateTokensAction, verbose bool) { + srcCfg := tr.testConfig.validatorConfigs[action.Src] + dstCfg := tr.testConfig.validatorConfigs[action.Dst] redelegateSrc := srcCfg.ValoperAddress redelegateDst := dstCfg.ValoperAddress if action.Chain != ChainID("provi") { @@ -1780,14 +1718,15 @@ func (tr TestConfig) redelegateTokens(action RedelegateTokensAction, target Exec } } - cmd := target.ExecCommand( - tr.chainConfigs[action.Chain].BinaryName, + cmd := tr.target.ExecCommand( + tr.testConfig.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), + `--chain-id`, string(tr.testConfig.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 @@ -1817,7 +1756,7 @@ type DowntimeSlashAction struct { // 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 TestConfig) getValidatorKeyAddressFromString(keystring string) string { +func (tr Chain) getValidatorKeyAddressFromString(keystring string) string { var key struct { Address string `json:"address"` } @@ -1828,17 +1767,17 @@ func (tr TestConfig) getValidatorKeyAddressFromString(keystring string) string { return key.Address } -func (tr TestConfig) invokeDowntimeSlash(action DowntimeSlashAction, target ExecutionTarget, verbose bool) { +func (tr Chain) invokeDowntimeSlash(action DowntimeSlashAction, verbose bool) { // Bring validator down - tr.setValidatorDowntime(action.Chain, action.Validator, true, target, verbose) + tr.setValidatorDowntime(action.Chain, action.Validator, true, verbose) // Wait appropriate amount of blocks for validator to be slashed tr.waitBlocks(action.Chain, 11, 3*time.Minute) // Bring validator back up - tr.setValidatorDowntime(action.Chain, action.Validator, false, target, 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 TestConfig) setValidatorDowntime(chain ChainID, validator ValidatorID, down bool, target ExecutionTarget, verbose bool) { +func (tr Chain) setValidatorDowntime(chain ChainID, validator ValidatorID, down bool, verbose bool) { var lastArg string if down { lastArg = "down" @@ -1846,20 +1785,20 @@ func (tr TestConfig) setValidatorDowntime(chain ChainID, validator ValidatorID, lastArg = "up" } - if tr.useCometmock { + if tr.testConfig.useCometmock { // send set_signing_status either to down or up for validator validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(chain, validator) method := "set_signing_status" params := fmt.Sprintf(`{"private_key_address":"%s","status":"%s"}`, validatorPrivateKeyAddress, lastArg) - address := tr.getQueryNodeRPCAddress(chain) + address := tr.target.GetQueryNodeRPCAddress(chain) tr.curlJsonRPCRequest(method, params, address) tr.waitBlocks(chain, 1, 10*time.Second) return } - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( "ip", "link", "set", @@ -1877,16 +1816,16 @@ func (tr TestConfig) setValidatorDowntime(chain ChainID, validator ValidatorID, } } -func (tr TestConfig) GetValidatorPrivateKeyAddress(chain ChainID, validator ValidatorID) string { +func (tr Chain) GetValidatorPrivateKeyAddress(chain ChainID, validator ValidatorID) string { var validatorPrivateKeyAddress string if chain == ChainID("provi") { - validatorPrivateKeyAddress = tr.getValidatorKeyAddressFromString(tr.validatorConfigs[validator].PrivValidatorKey) + validatorPrivateKeyAddress = tr.getValidatorKeyAddressFromString(tr.testConfig.validatorConfigs[validator].PrivValidatorKey) } else { var valAddressString string - if tr.validatorConfigs[validator].UseConsumerKey { - valAddressString = tr.validatorConfigs[validator].ConsumerPrivValidatorKey + if tr.testConfig.validatorConfigs[validator].UseConsumerKey { + valAddressString = tr.testConfig.validatorConfigs[validator].ConsumerPrivValidatorKey } else { - valAddressString = tr.validatorConfigs[validator].PrivValidatorKey + valAddressString = tr.testConfig.validatorConfigs[validator].PrivValidatorKey } validatorPrivateKeyAddress = tr.getValidatorKeyAddressFromString(valAddressString) } @@ -1899,20 +1838,21 @@ type UnjailValidatorAction struct { } // Sends an unjail transaction to the provider chain -func (tr TestConfig) unjailValidator(action UnjailValidatorAction, target ExecutionTarget, verbose bool) { +func (tr Chain) 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) - cmd := target.ExecCommand( - tr.chainConfigs[action.Provider].BinaryName, + cmd := tr.target.ExecCommand( + tr.testConfig.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), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Provider].ChainId), `--home`, tr.getValidatorHome(action.Provider, action.Validator), `--node`, tr.getValidatorNode(action.Provider, action.Validator), `--gas`, "900000", `--keyring-backend`, `test`, + `--keyring-dir`, tr.getValidatorHome(action.Provider, action.Validator), `-y`, ) @@ -1936,11 +1876,23 @@ type RegisterRepresentativeAction struct { Stakes []uint } -func (tr TestConfig) registerRepresentative( +func (tr Chain) registerRepresentative( action RegisterRepresentativeAction, - target ExecutionTarget, verbose bool, ) { + fileTempl := `{ + "pubkey": %s, + "amount": "%s", + "moniker": "%s", + "identity": "", + "website": "", + "security": "", + "details": "", + "commission-rate": "0.1", + "commission-max-rate": "0.2", + "commission-max-change-rate": "0.01", + "min-self-delegation": "1" + }` var wg sync.WaitGroup for i, val := range action.Representatives { wg.Add(1) @@ -1948,7 +1900,7 @@ func (tr TestConfig) registerRepresentative( go func(val ValidatorID, stake uint) { defer wg.Done() - pubKeycmd := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + pubKeycmd := tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, "tendermint", "show-validator", `--home`, tr.getValidatorHome(action.Chain, val), ) @@ -1958,22 +1910,46 @@ func (tr TestConfig) registerRepresentative( log.Fatal(err, "\n", string(bzPubKey)) } - bz, err := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, + fileContent := fmt.Sprintf(fileTempl, string(bzPubKey), fmt.Sprint(stake)+"stake", fmt.Sprint(val)) + fileName := fmt.Sprintf("%s_democracy_representative.json", val) + file, err := os.CreateTemp("", fileName) + if err != nil { + panic(fmt.Sprintf("failed writing ccv consumer file : %v", err)) + } + defer file.Close() + err = os.WriteFile(file.Name(), []byte(fileContent), 0600) + if err != nil { + log.Fatalf("Failed writing consumer genesis to file: %v", err) + } + + containerInstance := tr.testConfig.containerConfig.InstanceName + targetFile := fmt.Sprintf("/tmp/%s", fileName) + sourceFile := file.Name() + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + copyCmd := exec.Command("docker", "cp", sourceFile, + fmt.Sprintf("%s:%s", containerInstance, targetFile)) + writeResult, err := copyCmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(writeResult)) + } + + cmd := tr.target.ExecCommand(tr.testConfig.chainConfigs[action.Chain].BinaryName, "tx", "staking", "create-validator", - `--amount`, fmt.Sprint(stake)+"stake", - `--pubkey`, string(bzPubKey), - `--moniker`, fmt.Sprint(val), - `--commission-rate`, "0.1", - `--commission-max-rate`, "0.2", - `--commission-max-change-rate`, "0.01", - `--min-self-delegation`, "1", + targetFile, `--from`, `validator`+fmt.Sprint(val), - `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, val), `--node`, tr.getValidatorNode(action.Chain, val), `--keyring-backend`, `test`, `-y`, - ).CombinedOutput() + ) + + if verbose { + fmt.Println("register representative cmd:", cmd.String()) + fmt.Println("Tx json:", fileContent) + } + + bz, err := cmd.CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } @@ -1992,8 +1968,8 @@ type SubmitChangeRewardDenomsProposalAction struct { From ValidatorID } -func (tr TestConfig) submitChangeRewardDenomsProposal(action SubmitChangeRewardDenomsProposalAction, target ExecutionTarget, verbose bool) { - providerChain := tr.chainConfigs[ChainID("provi")] +func (tr Chain) submitChangeRewardDenomsProposal(action SubmitChangeRewardDenomsProposalAction, verbose bool) { + providerChain := tr.testConfig.chainConfigs[ChainID("provi")] prop := client.ChangeRewardDenomsProposalJSON{ Summary: "Change reward denoms", @@ -2016,14 +1992,14 @@ func (tr TestConfig) submitChangeRewardDenomsProposal(action SubmitChangeRewardD log.Fatal("prop json contains single quote") } - bz, err = target.ExecCommand( + bz, err = tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/change-reward-denoms-proposal.json")).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } // CHANGE REWARDS DENOM PROPOSAL - bz, err = target.ExecCommand(providerChain.BinaryName, + bz, err = tr.target.ExecCommand(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), @@ -2057,15 +2033,14 @@ type DoublesignSlashAction struct { Chain ChainID } -func (tr TestConfig) invokeDoublesignSlash( +func (tr Chain) invokeDoublesignSlash( action DoublesignSlashAction, - target ExecutionTarget, verbose bool, ) { - if !tr.useCometmock { - chainConfig := tr.chainConfigs[action.Chain] - doubleSignScript := target.GetTestScriptPath(false, "cause-doublesign.sh") - bz, err := target.ExecCommand("/bin/bash", + if !tr.testConfig.useCometmock { + chainConfig := tr.testConfig.chainConfigs[action.Chain] + doubleSignScript := tr.target.GetTestScriptPath(false, "cause-doublesign.sh") + bz, err := tr.target.ExecCommand("/bin/bash", doubleSignScript, chainConfig.BinaryName, string(action.Validator), string(chainConfig.ChainId), chainConfig.IpPrefix).CombinedOutput() if err != nil { @@ -2078,7 +2053,7 @@ func (tr TestConfig) invokeDoublesignSlash( method := "cause_double_sign" params := fmt.Sprintf(`{"private_key_address":"%s"}`, validatorPrivateKeyAddress) - address := tr.getQueryNodeRPCAddress(action.Chain) + address := tr.target.GetQueryNodeRPCAddress(action.Chain) tr.curlJsonRPCRequest(method, params, address) tr.waitBlocks(action.Chain, 1, 10*time.Second) @@ -2095,7 +2070,7 @@ type LightClientEquivocationAttackAction struct { Chain ChainID } -func (tr TestConfig) lightClientEquivocationAttack( +func (tr Chain) lightClientEquivocationAttack( action LightClientEquivocationAttackAction, verbose bool, ) { @@ -2111,7 +2086,7 @@ type LightClientAmnesiaAttackAction struct { Chain ChainID } -func (tr TestConfig) lightClientAmnesiaAttack( +func (tr Chain) lightClientAmnesiaAttack( action LightClientAmnesiaAttackAction, verbose bool, ) { @@ -2127,7 +2102,7 @@ type LightClientLunaticAttackAction struct { Chain ChainID } -func (tr TestConfig) lightClientLunaticAttack( +func (tr Chain) lightClientLunaticAttack( action LightClientLunaticAttackAction, verbose bool, ) { @@ -2142,12 +2117,12 @@ const ( LightClientLunaticAttack LightClientAttackType = "Lunatic" ) -func (tr TestConfig) lightClientAttack( +func (tr Chain) lightClientAttack( validator ValidatorID, chain ChainID, attackType LightClientAttackType, ) { - if !tr.useCometmock { + if !tr.testConfig.useCometmock { log.Fatal("light client attack is only supported with CometMock") } validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(chain, validator) @@ -2155,7 +2130,7 @@ func (tr TestConfig) lightClientAttack( method := "cause_light_client_attack" params := fmt.Sprintf(`{"private_key_address":"%s", "misbehaviour_type": "%s"}`, validatorPrivateKeyAddress, attackType) - address := tr.getQueryNodeRPCAddress(chain) + address := tr.target.GetQueryNodeRPCAddress(chain) tr.curlJsonRPCRequest(method, params, address) tr.waitBlocks(chain, 1, 10*time.Second) @@ -2172,28 +2147,28 @@ type AssignConsumerPubKeyAction struct { ExpectedError string } -func (tr TestConfig) assignConsumerPubKey(action AssignConsumerPubKeyAction, target ExecutionTarget, verbose bool) { - valCfg := tr.validatorConfigs[action.Validator] +func (tr Chain) assignConsumerPubKey(action AssignConsumerPubKeyAction, verbose bool) { + valCfg := tr.testConfig.validatorConfigs[action.Validator] // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then - if tr.useCometmock { + if tr.testConfig.useCometmock { gas = "9000000" } 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), + tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, + string(tr.testConfig.chainConfigs[action.Chain].ChainId), action.ConsumerPubkey, action.Validator, - tr.chainConfigs[ChainID("provi")].ChainId, + tr.testConfig.chainConfigs[ChainID("provi")].ChainId, tr.getValidatorHome(ChainID("provi"), action.Validator), tr.getValidatorNode(ChainID("provi"), action.Validator), gas, ) - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( "/bin/bash", "-c", assignKey, ) @@ -2207,7 +2182,7 @@ func (tr TestConfig) assignConsumerPubKey(action AssignConsumerPubKeyAction, tar log.Fatalf("unexpected error during key assignment - output: %s, err: %s", string(bz), err) } - if action.ExpectError && !tr.useCometmock { // error report only works with --gas auto, which does not work with CometMock, so ignore + if action.ExpectError && !tr.testConfig.useCometmock { // error report only 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)) } @@ -2220,12 +2195,12 @@ func (tr TestConfig) assignConsumerPubKey(action AssignConsumerPubKeyAction, tar // node was started with provider key // we swap the nodes's keys for consumer keys and restart it if action.ReconfigureNode { - isConsumer := tr.chainConfigs[action.Chain].BinaryName != "interchain-security-pd" - reconfigureScript := target.GetTestScriptPath(isConsumer, "reconfigure-node.sh") - configureNodeCmd := target.ExecCommand("/bin/bash", - reconfigureScript, tr.chainConfigs[action.Chain].BinaryName, + isConsumer := tr.testConfig.chainConfigs[action.Chain].BinaryName != "interchain-security-pd" + reconfigureScript := tr.target.GetTestScriptPath(isConsumer, "reconfigure-node.sh") + configureNodeCmd := tr.target.ExecCommand("/bin/bash", + reconfigureScript, tr.testConfig.chainConfigs[action.Chain].BinaryName, string(action.Validator), string(action.Chain), - tr.chainConfigs[action.Chain].IpPrefix, valCfg.IpSuffix, + tr.testConfig.chainConfigs[action.Chain].IpPrefix, valCfg.IpSuffix, valCfg.ConsumerMnemonic, valCfg.ConsumerPrivValidatorKey, valCfg.ConsumerNodeKey, ) @@ -2264,7 +2239,7 @@ func (tr TestConfig) assignConsumerPubKey(action AssignConsumerPubKeyAction, tar // @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 + tr.testConfig.validatorConfigs[action.Validator] = valCfg } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated @@ -2278,19 +2253,19 @@ type SlashMeterReplenishmentAction struct { Timeout time.Duration } -func (tr TestConfig) waitForSlashMeterReplenishment( +func (tr Chain) waitForSlashMeterReplenishment( action SlashMeterReplenishmentAction, verbose bool, ) { timeout := time.Now().Add(action.Timeout) - initialSlashMeter := tr.getSlashMeter() + initialSlashMeter := tr.target.GetSlashMeter() if initialSlashMeter >= 0 { panic(fmt.Sprintf("No need to wait for slash meter replenishment, current value: %d", initialSlashMeter)) } for { - slashMeter := tr.getSlashMeter() + slashMeter := tr.target.GetSlashMeter() if verbose { fmt.Printf("waiting for slash meter to be replenished, current value: %d\n", slashMeter) } @@ -2312,7 +2287,7 @@ type WaitTimeAction struct { WaitTime time.Duration } -func (tr TestConfig) waitForTime( +func (tr Chain) waitForTime( action WaitTimeAction, verbose bool, ) { @@ -2322,7 +2297,7 @@ func (tr TestConfig) waitForTime( // 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 TestConfig) GetPathNameForGorelayer(chainA, chainB ChainID) string { +func (tr Chain) GetPathNameForGorelayer(chainA, chainB ChainID) string { var pathName string if string(chainA) < string(chainB) { pathName = string(chainA) + "-" + string(chainB) @@ -2341,19 +2316,18 @@ type StartConsumerEvidenceDetectorAction struct { Chain ChainID } -func (tc TestConfig) startConsumerEvidenceDetector( +func (tr Chain) startConsumerEvidenceDetector( action StartConsumerEvidenceDetectorAction, - target ExecutionTarget, verbose bool, ) { - chainConfig := tc.chainConfigs[action.Chain] + chainConfig := tr.testConfig.chainConfigs[action.Chain] // run in detached mode so it will keep running in the background - bz, err := target.ExecDetachedCommand( + bz, err := tr.target.ExecDetachedCommand( "hermes", "evidence", "--chain", string(chainConfig.ChainId)).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - tc.waitBlocks("provi", 10, 2*time.Minute) + tr.waitBlocks("provi", 10, 2*time.Minute) } type OptInAction struct { @@ -2361,21 +2335,21 @@ type OptInAction struct { Validator ValidatorID } -func (tr TestConfig) optIn(action OptInAction, target ExecutionTarget, verbose bool) { +func (tr Chain) optIn(action OptInAction, target ExecutionTarget, verbose bool) { // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then - if tr.useCometmock { + if tr.testConfig.useCometmock { gas = "9000000" } // Use: "opt-in [consumer-chain-id] [consumer-pubkey]", optIn := fmt.Sprintf( `%s tx provider opt-in %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), + tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, + string(tr.testConfig.chainConfigs[action.Chain].ChainId), action.Validator, - tr.chainConfigs[ChainID("provi")].ChainId, + tr.testConfig.chainConfigs[ChainID("provi")].ChainId, tr.getValidatorHome(ChainID("provi"), action.Validator), tr.getValidatorNode(ChainID("provi"), action.Validator), gas, @@ -2395,7 +2369,7 @@ func (tr TestConfig) optIn(action OptInAction, target ExecutionTarget, verbose b log.Fatal(err, "\n", string(bz)) } - if !tr.useCometmock { // error report only works with --gas auto, which does not work with CometMock, so ignore + if !tr.testConfig.useCometmock { // error report only works with --gas auto, which does not work with CometMock, so ignore if err != nil && verbose { fmt.Printf("got error during opt in | err: %s | output: %s \n", err, string(bz)) } @@ -2411,21 +2385,21 @@ type OptOutAction struct { ExpectError bool } -func (tr TestConfig) optOut(action OptOutAction, target ExecutionTarget, verbose bool) { +func (tr Chain) optOut(action OptOutAction, target ExecutionTarget, verbose bool) { // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then - if tr.useCometmock { + if tr.testConfig.useCometmock { gas = "9000000" } // Use: "opt-out [consumer-chain-id]", optIn := fmt.Sprintf( `%s tx provider opt-out %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), + tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, + string(tr.testConfig.chainConfigs[action.Chain].ChainId), action.Validator, - tr.chainConfigs[ChainID("provi")].ChainId, + tr.testConfig.chainConfigs[ChainID("provi")].ChainId, tr.getValidatorHome(ChainID("provi"), action.Validator), tr.getValidatorNode(ChainID("provi"), action.Validator), gas, @@ -2465,12 +2439,12 @@ func (tr TestConfig) optOut(action OptOutAction, target ExecutionTarget, verbose // 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 TestConfig. -func (tr *TestConfig) WaitTime(duration time.Duration) { - if !tr.useCometmock { +func (tr *Chain) WaitTime(duration time.Duration) { + if !tr.testConfig.useCometmock { time.Sleep(duration) } else { - tr.timeOffset += duration - for chain, running := range tr.runningChains { + tr.testConfig.timeOffset += duration + for chain, running := range tr.testConfig.runningChains { if !running { continue } @@ -2480,12 +2454,12 @@ func (tr *TestConfig) WaitTime(duration time.Duration) { } } -func (tr TestConfig) AdvanceTimeForChain(chain ChainID, duration time.Duration) { +func (tr Chain) 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()))) - address := tr.getQueryNodeRPCAddress(chain) + address := tr.target.GetQueryNodeRPCAddress(chain) tr.curlJsonRPCRequest(method, params, address) diff --git a/tests/e2e/actions_consumer_misbehaviour.go b/tests/e2e/actions_consumer_misbehaviour.go index 10cd4ea5c6..6c2fc74304 100644 --- a/tests/e2e/actions_consumer_misbehaviour.go +++ b/tests/e2e/actions_consumer_misbehaviour.go @@ -3,7 +3,6 @@ package main import ( "bufio" "log" - "os/exec" "strconv" "time" ) @@ -17,15 +16,13 @@ type ForkConsumerChainAction struct { RelayerConfig string } -func (tc TestConfig) forkConsumerChain(action ForkConsumerChainAction, verbose bool) { - valCfg := tc.validatorConfigs[action.Validator] - - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - configureNodeCmd := exec.Command("docker", "exec", tc.containerConfig.InstanceName, "/bin/bash", - "/testnet-scripts/fork-consumer.sh", tc.chainConfigs[action.ConsumerChain].BinaryName, +func (tc Chain) forkConsumerChain(action ForkConsumerChainAction, verbose bool) { + valCfg := tc.testConfig.validatorConfigs[action.Validator] + configureNodeCmd := tc.target.ExecCommand("/bin/bash", + "/testnet-scripts/fork-consumer.sh", tc.testConfig.chainConfigs[action.ConsumerChain].BinaryName, string(action.Validator), string(action.ConsumerChain), - tc.chainConfigs[action.ConsumerChain].IpPrefix, - tc.chainConfigs[action.ProviderChain].IpPrefix, + tc.testConfig.chainConfigs[action.ConsumerChain].IpPrefix, + tc.testConfig.chainConfigs[action.ProviderChain].IpPrefix, valCfg.Mnemonic, action.RelayerConfig, ) @@ -69,21 +66,20 @@ type UpdateLightClientAction struct { ClientID string } -func (tc TestConfig) updateLightClient( +func (tc Chain) updateLightClient( action UpdateLightClientAction, verbose bool, ) { // retrieve a trusted height of the consumer light client - trustedHeight := tc.getTrustedHeight(action.HostChain, action.ClientID, 2) + revHeight, _ := tc.target.GetTrustedHeight(action.HostChain, action.ClientID, 2) - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tc.containerConfig.InstanceName, "hermes", + cmd := tc.target.ExecCommand("hermes", "--config", action.RelayerConfig, "update", "client", "--client", action.ClientID, "--host-chain", string(action.HostChain), - "--trusted-height", strconv.Itoa(int(trustedHeight.RevisionHeight)), + "--trusted-height", strconv.Itoa(int(revHeight)), ) if verbose { log.Println("UpdateLightClientAction cmd:", cmd.String()) diff --git a/tests/e2e/actions_sovereign_chain.go b/tests/e2e/actions_sovereign_chain.go index 3e5035aa5c..96d308ba57 100644 --- a/tests/e2e/actions_sovereign_chain.go +++ b/tests/e2e/actions_sovereign_chain.go @@ -17,12 +17,11 @@ type StartSovereignChainAction struct { // 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 TestConfig) startSovereignChain( +func (tr Chain) startSovereignChain( action StartSovereignChainAction, - target ExecutionTarget, verbose bool, ) { - chainConfig := tr.chainConfigs["sover"] + chainConfig := tr.testConfig.chainConfigs["sover"] type jsonValAttrs struct { Mnemonic string `json:"mnemonic"` Allocation string `json:"allocation"` @@ -40,18 +39,18 @@ func (tr TestConfig) startSovereignChain( var validators []jsonValAttrs for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, - NodeKey: tr.validatorConfigs[val.Id].NodeKey, + Mnemonic: tr.testConfig.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.testConfig.validatorConfigs[val.Id].NodeKey, ValId: fmt.Sprint(val.Id), - PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + PrivValidatorKey: tr.testConfig.validatorConfigs[val.Id].PrivValidatorKey, Allocation: fmt.Sprint(val.Allocation) + "stake", Stake: fmt.Sprint(val.Stake) + "stake", - IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + IpSuffix: tr.testConfig.validatorConfigs[val.Id].IpSuffix, - ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, + ConsumerMnemonic: tr.testConfig.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.testConfig.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.testConfig.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -69,10 +68,10 @@ func (tr TestConfig) startSovereignChain( } isConsumer := chainConfig.BinaryName != "interchain-security-pd" - testScriptPath := target.GetTestScriptPath(isConsumer, "start-sovereign.sh") - cmd := target.ExecCommand("/bin/bash", testScriptPath, chainConfig.BinaryName, string(vals), + testScriptPath := tr.target.GetTestScriptPath(isConsumer, "start-sovereign.sh") + cmd := tr.target.ExecCommand("/bin/bash", testScriptPath, chainConfig.BinaryName, string(vals), string(chainConfig.ChainId), chainConfig.IpPrefix, genesisChanges, - tr.tendermintConfigOverride) + tr.testConfig.tendermintConfigOverride) cmdReader, err := cmd.StdoutPipe() if err != nil { @@ -101,7 +100,7 @@ func (tr TestConfig) startSovereignChain( tr.addChainToRelayer(AddChainToRelayerAction{ Chain: action.Chain, Validator: action.Validators[0].Id, - }, target, verbose) + }, verbose) } type LegacyUpgradeProposalAction struct { @@ -111,7 +110,7 @@ type LegacyUpgradeProposalAction struct { UpgradeHeight uint64 } -func (tr *TestConfig) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAction, target ExecutionTarget, verbose bool) { +func (tr *Chain) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAction, verbose bool) { submit := fmt.Sprintf( `%s tx gov submit-legacy-proposal software-upgrade %s \ --title %s \ @@ -127,16 +126,16 @@ func (tr *TestConfig) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAc --node %s \ --no-validate \ -y`, - tr.chainConfigs[ChainID("sover")].BinaryName, + tr.testConfig.chainConfigs[ChainID("sover")].BinaryName, action.UpgradeTitle, action.UpgradeTitle, fmt.Sprint(action.UpgradeHeight), action.Proposer, - tr.chainConfigs[ChainID("sover")].ChainId, + tr.testConfig.chainConfigs[ChainID("sover")].ChainId, tr.getValidatorHome(ChainID("sover"), action.Proposer), tr.getValidatorNode(ChainID("sover"), action.Proposer), ) - cmd := target.ExecCommand("/bin/bash", "-c", submit) + cmd := tr.target.ExecCommand("/bin/bash", "-c", submit) if verbose { fmt.Println("submitUpgradeProposal cmd:", cmd.String()) @@ -155,7 +154,7 @@ type WaitUntilBlockAction struct { Chain ChainID } -func (tr *TestConfig) waitUntilBlockOnChain(action WaitUntilBlockAction) { +func (tr *Chain) 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 0655b34806..4bb8d1c494 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -8,6 +8,7 @@ import ( "strings" "time" + e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" "golang.org/x/mod/semver" ) @@ -70,10 +71,13 @@ var hermesTemplates = map[string]string{ `, } -// TODO: Determine if user defined type (wrapping a primitive string) is desired in long run +// type aliases for shared types from e2e package type ( - ChainID string - ValidatorID string + ChainID = e2e.ChainID + ValidatorID = e2e.ValidatorID + ValidatorConfig = e2e.ValidatorConfig + ChainConfig = e2e.ChainConfig + ContainerConfig = e2e.ContainerConfig // will be moved back ) // Supported Test configurations to be used with GetTestConfig @@ -91,98 +95,6 @@ const ( SmallMaxValidatorsTestCfg TestConfigType = "small-max-validators" ) -// 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 { - // Seed phrase to generate a secp256k1 key used by the validator on the provider - Mnemonic string - // Validator account address on provider marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix - DelAddress string - // Validator account address on provider marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix - DelAddressOnConsumer string - // Validator operator address on provider marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix - ValoperAddress string - // Validator operator address on provider marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix - ValoperAddressOnConsumer string - // Validator consensus address on provider marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix. It matches the PrivValidatorKey below. - ValconsAddress string - // Validator consensus address on provider marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix. - ValconsAddressOnConsumer string - // Key used for consensus on provider - PrivValidatorKey string - NodeKey string - // Must be an integer greater than 0 and less than 253 - IpSuffix string - - // consumer chain key assignment data - // keys are used on a new node - - // Seed phrase to generate a secp256k1 key used by the validator on the consumer - ConsumerMnemonic string - // Validator account address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix - ConsumerDelAddress string - // Validator account address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix - ConsumerDelAddressOnProvider string - // Validator operator address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix - ConsumerValoperAddress string - // Validator operator address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix - ConsumerValoperAddressOnProvider string - // Validator consensus address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ConsumerAccountPrefix. It matches the PrivValidatorKey below. - ConsumerValconsAddress string - // Validator consensus address on consumer marshaled to string using Bech32 - // with Bech32Prefix = ProviderAccountPrefix. - ConsumerValconsAddressOnProvider string - ConsumerValPubKey string - // Key used for consensus on consumer - 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 - // The account prefix configured on the chain. For example, on the Hub, this is "cosmos" - AccountPrefix string - // Must be unique per chain - 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 - - // binary to use after upgrade height - UpgradeBinary string -} - -type ContainerConfig struct { - ContainerName string - InstanceName string - CcvVersion string - Now time.Time -} - -type TargetConfig struct { - gaiaTag string - localSdkPath string - useGaia bool - providerVersion string - consumerVersion string -} - 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. @@ -223,7 +135,8 @@ func getIcsVersion(reference string) string { // remove build suffix return semver.Canonical(reference) } - for _, tag := range []string{"v2.0.0", "v2.4.0", "v2.4.0-lsm", "v3.1.0", "v3.2.0", "v3.3.0", "v4.0.0"} { + + for _, tag := range []string{"v2.0.0", "v2.4.0", "v2.4.0-lsm", "v3.1.0", "v3.2.0", "v3.3.0", "v4.0.0", "v4.1.1", "v4.1.1-lsm"} { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments cmd := exec.Command("git", "merge-base", "--is-ancestor", reference, tag) out, err := cmd.CombinedOutput() @@ -374,6 +287,7 @@ func SlashThrottleTestConfig() TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // 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\" | " + @@ -415,7 +329,7 @@ func CompatibilityTestConfig(providerVersion, consumerVersion string) TestConfig var providerConfig, consumerConfig ChainConfig if !semver.IsValid(consumerVersion) { - fmt.Println("Using default provider chain config") + fmt.Printf("Invalid sem-version '%s' for provider.Using default provider chain config\n", consumerVersion) consumerConfig = testCfg.chainConfigs[ChainID("consu")] } else if semver.Compare(consumerVersion, "v3.0.0") < 0 { fmt.Println("Using consumer chain config for v2.0.0") @@ -445,6 +359,20 @@ func CompatibilityTestConfig(providerVersion, consumerVersion string) TestConfig ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"", } + } else if semver.Compare(consumerVersion, "v5.0.0-alpha1") < 0 { // TODO: change this to first published v5 release - once it's out + fmt.Println("Using consumer chain config for v4.x.x") + consumerConfig = ChainConfig{ + ChainId: ChainID("consu"), + AccountPrefix: ConsumerAccountPrefix, + 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 = \"20\" | " + + ".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\"", + } } else { fmt.Println("Using default consumer chain config") consumerConfig = testCfg.chainConfigs[ChainID("consu")] @@ -452,7 +380,7 @@ func CompatibilityTestConfig(providerVersion, consumerVersion string) TestConfig // Get the provider chain config for a specific version if !semver.IsValid(providerVersion) { - fmt.Println("Using default provider chain config") + fmt.Printf("Invalid sem-version '%s' for provider. Using default provider chain config\n", providerVersion) providerConfig = testCfg.chainConfigs[ChainID("provi")] } else if semver.Compare(providerVersion, "v3.0.0") < 0 { fmt.Println("Using provider chain config for v2.x.x") @@ -543,6 +471,7 @@ func DefaultTestConfig() TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // 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\" | " + @@ -605,6 +534,7 @@ func DemocracyTestConfig(allowReward bool) TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // 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\" | " + @@ -664,6 +594,7 @@ func MultiConsumerTestConfig() TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // 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\" | " + @@ -723,6 +654,7 @@ func ChangeoverTestConfig() TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // 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\" | " + @@ -980,7 +912,7 @@ func getValidatorConfigFromVersion(providerVersion, consumerVersion string) map[ }, } case "v4.0.0": - fmt.Println("Using current default validator configs: ", providerVersion) + fmt.Println("Using current validator configs v4.0.0: ", providerVersion) validatorCfg = 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", diff --git a/tests/e2e/json_marshal_test.go b/tests/e2e/json_marshal_test.go index 5ee91dcb66..1265063e69 100644 --- a/tests/e2e/json_marshal_test.go +++ b/tests/e2e/json_marshal_test.go @@ -3,10 +3,13 @@ package main import ( "encoding/json" "reflect" + "strconv" "strings" "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" "github.com/davecgh/go-spew/spew" ) @@ -20,7 +23,7 @@ func TestProposalUnmarshal(t *testing.T) { "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" } }` @@ -29,7 +32,7 @@ func TestProposalUnmarshal(t *testing.T) { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), } type ProposalAndType struct { @@ -43,7 +46,7 @@ func TestProposalUnmarshal(t *testing.T) { t.Errorf("Unexpected error while unmarshalling: %v", err) } - actualProposal, err := UnmarshalProposalWithType(propAndType.RawProposal, propAndType.Type) + actualProposal, err := e2e.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) } @@ -79,7 +82,7 @@ var testCases = []ChainStateTestCase{ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" } } } @@ -96,7 +99,7 @@ var testCases = []ChainStateTestCase{ Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -125,7 +128,7 @@ var testCases = []ChainStateTestCase{ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" } } }, diff --git a/tests/e2e/json_utils.go b/tests/e2e/json_utils.go index aeb59eee3a..e1e0b67fc6 100644 --- a/tests/e2e/json_utils.go +++ b/tests/e2e/json_utils.go @@ -6,23 +6,6 @@ import ( "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) @@ -95,8 +78,8 @@ func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string if err == nil { return a, nil } - case "main.SubmitParamChangeLegacyProposalAction": - var a SubmitParamChangeLegacyProposalAction + case "main.SubmitEnableTransfersProposalAction": + var a SubmitEnableTransfersProposalAction err := json.Unmarshal(rawAction, &a) if err == nil { return a, nil @@ -298,89 +281,3 @@ func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string } 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.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/main.go b/tests/e2e/main.go index 2cf0f33a6f..d0b13ddd94 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -192,18 +192,18 @@ var stepChoices = map[string]StepChoice{ description: "test partial set security for an Opt-In chain that has a validator denylisted", testConfig: DefaultTestCfg, }, - "active-set-changes": { - name: "active-set-changes", - steps: stepsActiveSetChanges(), - description: "This is a regression test related to the issue discussed here: https://forum.cosmos.network/t/cosmos-hub-v17-1-chain-halt-post-mortem/13899. The test ensures that the protocol works as expected when MaxValidators is smaller than the number of potential validators.", - testConfig: SmallMaxValidatorsTestCfg, - }, "partial-set-security-modification-proposal": { name: "partial-set-security-modification-proposal", steps: stepsModifyChain(), description: "test partial set security parameters can be changed through a modification proposal", testConfig: DefaultTestCfg, }, + "active-set-changes": { + name: "active-set-changes", + steps: stepsActiveSetChanges(), + description: "This is a regression test related to the issue discussed here: https://forum.cosmos.network/t/cosmos-hub-v17-1-chain-halt-post-mortem/13899. The test ensures that the protocol works as expected when MaxValidators is smaller than the number of potential validators.", + testConfig: SmallMaxValidatorsTestCfg, + }, } func getTestCaseUsageString() string { @@ -292,8 +292,8 @@ func getTestCases(selectedPredefinedTests, selectedTestFiles TestSet, providerVe "consumer-double-downtime", "partial-set-security-opt-in", "partial-set-security-top-n", "partial-set-security-validator-set-cap", "partial-set-security-validators-power-cap", "partial-set-security-validators-allowlisted", "partial-set-security-validators-denylisted", - "active-set-changes", "partial-set-security-modification-proposal", + "active-set-changes", } if includeMultiConsumer != nil && *includeMultiConsumer { selectedPredefinedTests = append(selectedPredefinedTests, "multiconsumer") @@ -509,6 +509,19 @@ Summary: len(remainingTests), numTotalTests, ) + report += fmt.Sprintln("\nFAILED TESTS:") + for _, t := range failedTests { + report += t.Report() + } + report += fmt.Sprintln("\n\nPASSED TESTS:") + for _, t := range passedTests { + report += t.Report() + } + + report += fmt.Sprintln("\n\nREMAINING TESTS:") + for _, t := range remainingTests { + report += t.Report() + } report += "==================================================" fmt.Print(report) } diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 1b3e0795b4..c7d5baf99f 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "encoding/json" "fmt" "log" "os/exec" @@ -9,182 +10,100 @@ import ( "strconv" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" "github.com/kylelemons/godebug/pretty" "github.com/tidwall/gjson" "gopkg.in/yaml.v2" ) -type State map[ChainID]ChainState - -type ChainState struct { - ValBalances *map[ValidatorID]uint - Proposals *map[uint]Proposal - ProposedConsumerChains *[]string - 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 - ConsumerPendingPacketQueueSize *uint // Only relevant to consumer chains - RegisteredConsumerRewardDenoms *[]string - ClientsFrozenHeights *map[string]clienttypes.Height - HasToValidate *map[ValidatorID][]ChainID // only relevant to provider chain -} - -type Proposal interface { - isProposal() -} -type TextProposal struct { - Title string - Description string - Deposit uint - Status string -} - -func (p TextProposal) isProposal() {} - -type ConsumerAdditionProposal struct { - Deposit uint - Chain ChainID - SpawnTime int - InitialHeight clienttypes.Height - Status string -} - -type UpgradeProposal struct { - Title string - Description string - UpgradeHeight uint64 - Type string - Deposit uint - Status string -} - -func (p UpgradeProposal) isProposal() {} - -func (p ConsumerAdditionProposal) isProposal() {} - -type ConsumerRemovalProposal struct { - Deposit uint - Chain ChainID - StopTime int - Status string -} - -func (p ConsumerRemovalProposal) isProposal() {} - -type ConsumerModificationProposal struct { - Deposit uint - Chain ChainID - Status string -} - -func (p ConsumerModificationProposal) isProposal() {} - -type Rewards struct { - 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 - // if true checks rewards for "stake" token, otherwise checks rewards from - // other chains (e.g. false is used to check if provider received rewards from a consumer chain) - IsNativeDenom bool -} - -type ParamsProposal struct { - Deposit uint - Status string - Subspace string - Key string - Value string -} - -func (p ParamsProposal) isProposal() {} - -type Param struct { - Subspace string - Key string - Value string -} +// type aliases +type ( + ChainState = e2e.ChainState + Proposal = e2e.Proposal + Rewards = e2e.Rewards + TextProposal = e2e.TextProposal + UpgradeProposal = e2e.UpgradeProposal + ConsumerAdditionProposal = e2e.ConsumerAdditionProposal + ConsumerRemovalProposal = e2e.ConsumerRemovalProposal + ConsumerModificationProposal = e2e.ConsumerModificationProposal + IBCTransferParams = e2e.IBCTransferParams + IBCTransferParamsProposal = e2e.IBCTransferParamsProposal + Param = e2e.Param + ParamsProposal = e2e.ParamsProposal + TargetDriver = e2e.TargetDriver +) -func (tr TestConfig) getState(modelState State, verbose bool) State { - systemState := State{} - for k, modelState := range modelState { - if verbose { - fmt.Println("Getting model state for chain: ", k) - } - systemState[k] = tr.getChainState(k, modelState) - } +type State map[ChainID]ChainState - return systemState +type Chain struct { + target e2e.TargetDriver + testConfig TestConfig } -func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainState { +func (tr Chain) GetChainState(chain ChainID, modelState ChainState) ChainState { chainState := ChainState{} if modelState.ValBalances != nil { - valBalances := tr.getBalances(chain, *modelState.ValBalances) + valBalances := tr.GetBalances(chain, *modelState.ValBalances) chainState.ValBalances = &valBalances } if modelState.Proposals != nil { - proposals := tr.getProposals(chain, *modelState.Proposals) + proposals := tr.GetProposals(chain, *modelState.Proposals) chainState.Proposals = &proposals } if modelState.ProposedConsumerChains != nil { - proposedConsumerChains := tr.getProposedConsumerChains(chain) + proposedConsumerChains := tr.GetProposedConsumerChains(chain) chainState.ProposedConsumerChains = &proposedConsumerChains } if modelState.ValPowers != nil { tr.waitBlocks(chain, 1, 10*time.Second) - powers := tr.getValPowers(chain, *modelState.ValPowers) + powers := tr.GetValPowers(chain, *modelState.ValPowers) chainState.ValPowers = &powers } if modelState.StakedTokens != nil { - representPowers := tr.getStakedTokens(chain, *modelState.StakedTokens) + representPowers := tr.GetStakedTokens(chain, *modelState.StakedTokens) chainState.StakedTokens = &representPowers } - if modelState.Params != nil { - params := tr.getParams(chain, *modelState.Params) - chainState.Params = ¶ms + if modelState.IBCTransferParams != nil { + params := tr.target.GetIBCTransferParams(chain) + chainState.IBCTransferParams = ¶ms } if modelState.Rewards != nil { - rewards := tr.getRewards(chain, *modelState.Rewards) + rewards := tr.GetRewards(chain, *modelState.Rewards) chainState.Rewards = &rewards } if modelState.ConsumerChains != nil { - chains := tr.getConsumerChains(chain) + chains := tr.target.GetConsumerChains(chain) chainState.ConsumerChains = &chains } if modelState.AssignedKeys != nil { - assignedKeys := tr.getConsumerAddresses(chain, *modelState.AssignedKeys) + assignedKeys := tr.GetConsumerAddresses(chain, *modelState.AssignedKeys) chainState.AssignedKeys = &assignedKeys } if modelState.ProviderKeys != nil { - providerKeys := tr.getProviderAddresses(chain, *modelState.ProviderKeys) + providerKeys := tr.GetProviderAddresses(chain, *modelState.ProviderKeys) chainState.ProviderKeys = &providerKeys } if modelState.RegisteredConsumerRewardDenoms != nil { - registeredConsumerRewardDenoms := tr.getRegisteredConsumerRewardDenoms(chain) + registeredConsumerRewardDenoms := tr.target.GetRegisteredConsumerRewardDenoms(chain) chainState.RegisteredConsumerRewardDenoms = ®isteredConsumerRewardDenoms } if modelState.ClientsFrozenHeights != nil { chainClientsFrozenHeights := map[string]clienttypes.Height{} for id := range *modelState.ClientsFrozenHeights { - chainClientsFrozenHeights[id] = tr.getClientFrozenHeight(chain, id) + chainClientsFrozenHeights[id] = tr.GetClientFrozenHeight(chain, id) } chainState.ClientsFrozenHeights = &chainClientsFrozenHeights } @@ -192,13 +111,13 @@ func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainSt if modelState.HasToValidate != nil { hasToValidate := map[ValidatorID][]ChainID{} for validatorId := range *modelState.HasToValidate { - hasToValidate[validatorId] = tr.getHasToValidate(validatorId) + hasToValidate[validatorId] = tr.target.GetHasToValidate(validatorId) } chainState.HasToValidate = &hasToValidate } if modelState.ConsumerPendingPacketQueueSize != nil { - pendingPacketQueueSize := tr.getPendingPacketQueueSize(chain) + pendingPacketQueueSize := tr.target.GetPendingPacketQueueSize(chain) chainState.ConsumerPendingPacketQueueSize = &pendingPacketQueueSize } @@ -209,44 +128,22 @@ func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainSt return chainState } -var blockHeightRegex = regexp.MustCompile(`block_height: "(\d+)"`) - -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, - - "query", "tendermint-validator-set", - - `--node`, tr.getQueryNode(chain), - ).CombinedOutput() - if err != nil { - log.Fatal(err, "\n", string(bz)) - } - - blockHeight, err := strconv.Atoi(blockHeightRegex.FindStringSubmatch(string(bz))[1]) - if err != nil { - log.Fatal(err) - } - - return uint(blockHeight) -} - -func (tr TestConfig) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) { - if tr.useCometmock { +func (tr Chain) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) { + if tr.testConfig.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 - tcpAddress := tr.getQueryNodeRPCAddress(chain) + tcpAddress := tr.target.GetQueryNodeRPCAddress(chain) method := "advance_blocks" params := fmt.Sprintf(`{"num_blocks": "%d"}`, blocks) tr.curlJsonRPCRequest(method, params, tcpAddress) return } - startBlock := tr.getBlockHeight(chain) + startBlock := tr.target.GetBlockHeight(chain) start := time.Now() for { - thisBlock := tr.getBlockHeight(chain) + thisBlock := tr.target.GetBlockHeight(chain) if thisBlock >= startBlock+blocks { return } @@ -257,10 +154,10 @@ func (tr TestConfig) waitBlocks(chain ChainID, blocks uint, timeout time.Duratio } } -func (tr TestConfig) waitUntilBlock(chain ChainID, block uint, timeout time.Duration) { +func (tr Chain) waitUntilBlock(chain ChainID, block uint, timeout time.Duration) { start := time.Now() for { - thisBlock := tr.getBlockHeight(chain) + thisBlock := tr.target.GetBlockHeight(chain) if thisBlock >= block { return } @@ -271,147 +168,225 @@ func (tr TestConfig) waitUntilBlock(chain ChainID, block uint, timeout time.Dura } } -func (tr TestConfig) getBalances(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { +func (tr Chain) GetBalances(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { actualState := map[ValidatorID]uint{} for k := range modelState { - actualState[k] = tr.getBalance(chain, k) + actualState[k] = tr.target.GetBalance(chain, k) } return actualState } -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) - } +func (tr Chain) GetClientFrozenHeight(chain ChainID, clientID string) clienttypes.Height { + revNumber, revHeight := tr.target.GetClientFrozenHeight(chain, clientID) + return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} +} - return actualState +func (tr Chain) GetProposedConsumerChains(chain ChainID) []string { + tr.waitBlocks(chain, 1, 10*time.Second) + return tr.target.GetProposedConsumerChains(chain) } -func (tr TestConfig) getValPowers(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { - actualState := map[ValidatorID]uint{} +func (tr Chain) GetProposals(chain ChainID, modelState map[uint]Proposal) map[uint]Proposal { + actualState := map[uint]Proposal{} for k := range modelState { - actualState[k] = tr.getValPower(chain, k) + actualState[k] = tr.target.GetProposal(chain, k) } return actualState } -func (tr TestConfig) getStakedTokens(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { +func (tr Chain) GetValPowers(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { actualState := map[ValidatorID]uint{} + validatorConfigs := tr.testConfig.validatorConfigs for k := range modelState { - actualState[k] = tr.getValStakedTokens(chain, k) + valAddresses := map[string]bool{} + if chain == ChainID("provi") { + // use binary with Bech32Prefix set to ProviderAccountPrefix + valAddresses[validatorConfigs[k].ValconsAddress] = true + } else { + // use binary with Bech32Prefix set to ConsumerAccountPrefix + valAddresses[validatorConfigs[k].ValconsAddressOnConsumer] = true + valAddresses[validatorConfigs[k].ConsumerValconsAddress] = true + } + actualState[k] = tr.target.GetValPower(chain, k) } return actualState } -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)}) +func (tr Chain) GetStakedTokens(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { + actualState := map[ValidatorID]uint{} + for validator := range modelState { + validatorConfigs := tr.testConfig.validatorConfigs + valoperAddress := validatorConfigs[validator].ValoperAddress + if chain != ChainID("provi") { + // use binary with Bech32Prefix set to ConsumerAccountPrefix + if validatorConfigs[validator].UseConsumerKey { + valoperAddress = validatorConfigs[validator].ConsumerValoperAddress + } else { + // use the same address as on the provider but with different prefix + valoperAddress = validatorConfigs[validator].ValoperAddressOnConsumer + } + } + + actualState[validator] = tr.target.GetValStakedTokens(chain, valoperAddress) } return actualState } -func (tr TestConfig) getRewards(chain ChainID, modelState Rewards) Rewards { +func (tr Chain) GetRewards(chain ChainID, modelState Rewards) Rewards { receivedRewards := map[ValidatorID]bool{} - currentBlock := tr.getBlockHeight(chain) + currentBlock := tr.target.GetBlockHeight(chain) tr.waitBlocks(chain, 1, 10*time.Second) - nextBlock := tr.getBlockHeight(chain) + nextBlock := tr.target.GetBlockHeight(chain) tr.waitBlocks(chain, 1, 10*time.Second) if !modelState.IsIncrementalReward { currentBlock = 1 } for k := range modelState.IsRewarded { - receivedRewards[k] = tr.getReward(chain, k, nextBlock, modelState.IsNativeDenom) > tr.getReward(chain, k, currentBlock, modelState.IsNativeDenom) + receivedRewards[k] = tr.target.GetReward(chain, k, nextBlock, modelState.IsNativeDenom) > tr.target.GetReward(chain, k, currentBlock, modelState.IsNativeDenom) } return Rewards{IsRewarded: receivedRewards, IsIncrementalReward: modelState.IsIncrementalReward, IsNativeDenom: modelState.IsNativeDenom} } -func (tr TestConfig) getReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 { - valCfg := tr.validatorConfigs[validator] - delAddresss := valCfg.DelAddress - if chain != ChainID("provi") { - // use binary with Bech32Prefix set to ConsumerAccountPrefix - if valCfg.UseConsumerKey { - delAddresss = valCfg.ConsumerDelAddress - } else { - // use the same address as on the provider but with different prefix - delAddresss = valCfg.DelAddressOnConsumer - } +func (tr Chain) GetConsumerAddresses(chain ChainID, modelState map[ValidatorID]string) map[ValidatorID]string { + actualState := map[ValidatorID]string{} + for k := range modelState { + actualState[k] = tr.target.GetConsumerAddress(chain, k) + } + + return actualState +} + +func (tr Chain) GetProviderAddresses(chain ChainID, modelState map[ValidatorID]string) map[ValidatorID]string { + actualState := map[ValidatorID]string{} + for k := range modelState { + actualState[k] = tr.target.GetProviderAddressFromConsumer(chain, k) + } + + return actualState +} + +func (tr Chain) getValidatorNode(chain ChainID, validator ValidatorID) string { + // for CometMock, validatorNodes are all the same address as the query node (which is CometMocks address) + if tr.testConfig.useCometmock { + return tr.target.GetQueryNode(chain) } - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, + return "tcp://" + tr.getValidatorIP(chain, validator) + ":26658" +} - "query", "distribution", "rewards", - delAddresss, +func (tr Chain) getValidatorIP(chain ChainID, validator ValidatorID) string { + return tr.testConfig.chainConfigs[chain].IpPrefix + "." + tr.testConfig.validatorConfigs[validator].IpSuffix +} - `--height`, fmt.Sprint(blockHeight), - `--node`, tr.getQueryNode(chain), - `-o`, `json`, +func (tr Chain) getValidatorHome(chain ChainID, validator ValidatorID) string { + return `/` + string(tr.testConfig.chainConfigs[chain].ChainId) + `/validator` + fmt.Sprint(validator) +} + +func (tr Chain) 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` + + cmd := tr.target.ExecCommand("bash", "-c", fmt.Sprintf(cmd_template, method, params, address)) + + verbosity := false + e2e.ExecuteCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) +} + +func uintPtr(i uint) *uint { + return &i +} + +type Commands struct { + containerConfig ContainerConfig // FIXME only needed for 'Now' time tracking + validatorConfigs map[ValidatorID]ValidatorConfig + chainConfigs map[ChainID]ChainConfig + target e2e.PlatformDriver +} + +func (tr Commands) ExecCommand(name string, arg ...string) *exec.Cmd { + return tr.target.ExecCommand(name, arg...) +} + +func (tr Commands) ExecDetachedCommand(name string, args ...string) *exec.Cmd { + return tr.target.ExecDetachedCommand(name, args...) +} + +func (tr Commands) GetTestScriptPath(isConsumer bool, script string) string { + return tr.target.GetTestScriptPath(isConsumer, script) +} + +func (tr Commands) GetBlockHeight(chain ChainID) uint { + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, + + "query", "tendermint-validator-set", + + `--node`, tr.GetQueryNode(chain), ).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - denomCondition := `total.#(denom!="stake").amount` - if isNativeDenom { - denomCondition = `total.#(denom=="stake").amount` + blockHeightRegex := regexp.MustCompile(`block_height: "(\d+)"`) + blockHeight, err := strconv.Atoi(blockHeightRegex.FindStringSubmatch(string(bz))[1]) + if err != nil { + log.Fatal(err) } - return gjson.Get(string(bz), denomCondition).Float() + return uint(blockHeight) } -func (tr TestConfig) getBalance(chain ChainID, validator ValidatorID) uint { - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. +func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 { valCfg := tr.validatorConfigs[validator] - valDelAddress := valCfg.DelAddress + delAddresss := valCfg.DelAddress if chain != ChainID("provi") { // use binary with Bech32Prefix set to ConsumerAccountPrefix if valCfg.UseConsumerKey { - valDelAddress = valCfg.ConsumerDelAddress + delAddresss = valCfg.ConsumerDelAddress } else { // use the same address as on the provider but with different prefix - valDelAddress = valCfg.DelAddressOnConsumer + delAddresss = valCfg.DelAddressOnConsumer } } - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, - "query", "bank", "balances", - valDelAddress, - - `--node`, tr.getQueryNode(chain), + binaryName := tr.chainConfigs[chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, + "query", "distribution", "delegation-total-rewards", + "--delegator-address", delAddresss, + `--height`, fmt.Sprint(blockHeight), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ) + bz, err := cmd.CombinedOutput() + if err != nil { - log.Fatal("getBalance() failed: ", cmd, ": ", err, "\n", string(bz)) + log.Fatal("failed getting rewards: ", err, "\n", string(bz)) } - amount := gjson.Get(string(bz), `balances.#(denom=="stake").amount`) + denomCondition := `total.#(denom!="stake").amount` + if isNativeDenom { + denomCondition = `total.#(denom=="stake").amount` + } - return uint(amount.Uint()) + return gjson.Get(string(bz), denomCondition).Float() } -var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`) - // interchain-securityd query gov proposals -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, +func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { + var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`) + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, "query", "gov", "proposal", fmt.Sprint(proposal), - - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ).CombinedOutput() @@ -425,14 +400,24 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { log.Fatal(err, "\n", string(bz)) } - propType := gjson.Get(string(bz), `messages.0.content.@type`).String() - deposit := gjson.Get(string(bz), `total_deposit.#(denom=="stake").amount`).Uint() - status := gjson.Get(string(bz), `status`).String() + // for legacy proposal types submitted using "tx submit-legacyproposal" (cosmos-sdk/v1/MsgExecLegacyContent) + propType := gjson.Get(string(bz), `proposal.messages.0.value.content.type`).String() + rawContent := gjson.Get(string(bz), `proposal.messages.0.value.content.value`) + + // for current (>= v47) prop types submitted using "tx submit-proposal" + if propType == "" { + propType = gjson.Get(string(bz), `proposal.messages.0.type`).String() + rawContent = gjson.Get(string(bz), `proposal.messages.0.value`) + } + + title := gjson.Get(string(bz), `proposal.title`).String() + deposit := gjson.Get(string(bz), `proposal.total_deposit.#(denom=="stake").amount`).Uint() + status := gjson.Get(string(bz), `proposal.status`).String() switch propType { case "/cosmos.gov.v1beta1.TextProposal": - title := gjson.Get(string(bz), `content.title`).String() - description := gjson.Get(string(bz), `content.description`).String() + title := rawContent.Get("title").String() + description := rawContent.Get("description").String() return TextProposal{ Deposit: uint(deposit), @@ -441,8 +426,8 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { Description: description, } 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) + chainId := rawContent.Get("chain_id").String() + spawnTime := rawContent.Get("spawn_time").Time().Sub(tr.containerConfig.Now) var chain ChainID for i, conf := range tr.chainConfigs { @@ -458,13 +443,13 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { Chain: chain, SpawnTime: int(spawnTime.Milliseconds()), InitialHeight: clienttypes.Height{ - RevisionNumber: gjson.Get(string(bz), `messages.0.content.initial_height.revision_number`).Uint(), - RevisionHeight: gjson.Get(string(bz), `messages.0.content.initial_height.revision_height`).Uint(), + RevisionNumber: rawContent.Get("initial_height.revision_number").Uint(), + RevisionHeight: rawContent.Get("initial_height.revision_height").Uint(), }, } case "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal": - height := gjson.Get(string(bz), `messages.0.content.plan.height`).Uint() - title := gjson.Get(string(bz), `messages.0.content.plan.name`).String() + height := rawContent.Get("plan.height").Uint() + title := rawContent.Get("plan.name").String() return UpgradeProposal{ Deposit: uint(deposit), Status: status, @@ -473,8 +458,8 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", } 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) + chainId := rawContent.Get("chain_id").String() + stopTime := rawContent.Get("stop_time").Time().Sub(tr.containerConfig.Now) var chain ChainID for i, conf := range tr.chainConfigs { @@ -490,8 +475,21 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { Chain: chain, StopTime: int(stopTime.Milliseconds()), } + case "/ibc.applications.transfer.v1.MsgUpdateParams": + var params IBCTransferParams + if err := json.Unmarshal([]byte(rawContent.Get("params").String()), ¶ms); err != nil { + log.Fatal("cannot unmarshal ibc-transfer params: ", err, "\n", string(bz)) + } + + return IBCTransferParamsProposal{ + Deposit: uint(deposit), + Status: status, + Title: title, + Params: params, + } + case "/interchain_security.ccv.provider.v1.ConsumerModificationProposal": - chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String() + chainId := rawContent.Get("chain_id").String() var chain ChainID for i, conf := range tr.chainConfigs { @@ -516,13 +514,17 @@ func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { } } - log.Fatal("unknown proposal type", string(bz)) + log.Fatal("received unknown proposal type: ", propType, "proposal JSON:", string(bz)) return nil } type TmValidatorSetYaml struct { - Total string `yaml:"total"` + BlockHeight string `yaml:"block_height"` + Pagination struct { + NextKey string `yaml:"next_key"` + Total string `yaml:"total"` + } `yaml:"pagination"` Validators []struct { Address string `yaml:"address"` VotingPower string `yaml:"voting_power"` @@ -535,16 +537,16 @@ type ValPubKey struct { } // TODO (mpoke) Return powers for multiple validators -func (tr TestConfig) getValPower(chain ChainID, validator ValidatorID) uint { +func (tr Commands) 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. - command := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, + binaryName := tr.chainConfigs[chain].BinaryName + command := tr.target.ExecCommand(binaryName, "query", "tendermint-validator-set", - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), ) bz, err := command.CombinedOutput() if err != nil { @@ -558,14 +560,15 @@ func (tr TestConfig) getValPower(chain ChainID, validator ValidatorID) uint { log.Fatalf("yaml.Unmarshal returned an error while unmarshalling validator set: %v, input: %s", err, string(bz)) } - total, err := strconv.Atoi(valset.Total) + total, err := strconv.Atoi(valset.Pagination.Total) if err != nil { - log.Fatalf("strconv.Atoi returned an error while converting total for validator set: %v, input: %s, validator set: %s", err, valset.Total, pretty.Sprint(valset)) + log.Fatalf("strconv.Atoi returned an error while converting total for validator set: %v, input: %s, validator set: %s, src:%s", + err, valset.Pagination.Total, pretty.Sprint(valset), string(bz)) } 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. Validator set: %v", - valset.Total, uint(len(valset.Validators)), pretty.Sprint(valset)) + valset.Pagination.Total, uint(len(valset.Validators)), pretty.Sprint(valset)) } for _, val := range valset.Validators { @@ -594,45 +597,65 @@ func (tr TestConfig) getValPower(chain ChainID, validator ValidatorID) uint { return 0 } -func (tr TestConfig) getValStakedTokens(chain ChainID, validator ValidatorID) uint { - valoperAddress := tr.validatorConfigs[validator].ValoperAddress +func (tr Commands) GetBalance(chain ChainID, validator ValidatorID) uint { + valCfg := tr.validatorConfigs[validator] + valDelAddress := valCfg.DelAddress if chain != ChainID("provi") { // use binary with Bech32Prefix set to ConsumerAccountPrefix - if tr.validatorConfigs[validator].UseConsumerKey { - valoperAddress = tr.validatorConfigs[validator].ConsumerValoperAddress + if valCfg.UseConsumerKey { + valDelAddress = valCfg.ConsumerDelAddress } else { // use the same address as on the provider but with different prefix - valoperAddress = tr.validatorConfigs[validator].ValoperAddressOnConsumer + valDelAddress = valCfg.DelAddressOnConsumer } } - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, + binaryName := tr.chainConfigs[chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, + + "query", "bank", "balances", + valDelAddress, + + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal("getBalance() failed: ", cmd, ": ", err, "\n", string(bz)) + } + + amount := gjson.Get(string(bz), `balances.#(denom=="stake").amount`) + + return uint(amount.Uint()) +} + +func (tr Commands) GetValStakedTokens(chain ChainID, valoperAddress string) uint { + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, "query", "staking", "validator", valoperAddress, - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - amount := gjson.Get(string(bz), `tokens`) + amount := gjson.Get(string(bz), `validator.tokens`) return uint(amount.Uint()) } -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, - +func (tr Commands) GetParam(chain ChainID, param Param) string { + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, "query", "params", "subspace", param.Subspace, param.Key, - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ).CombinedOutput() if err != nil { @@ -644,14 +667,33 @@ func (tr TestConfig) getParam(chain ChainID, param Param) string { return value.String() } -// getConsumerChains returns a list of consumer chains that're being secured by the provider chain, +func (tr Commands) GetIBCTransferParams(chain ChainID) IBCTransferParams { + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, + "query", "ibc-transfer", "params", + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + var params IBCTransferParams + if err := json.Unmarshal(bz, ¶ms); err != nil { + log.Fatal("cannot unmarshal ibc-transfer params: ", err, "\n", string(bz)) + } + + return params +} + +// GetConsumerChains returns a list of consumer chains that're being secured by the provider chain, // determined by querying the provider chain. -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, +func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { + binaryName := tr.chainConfigs[chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "list-consumer-chains", - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ) @@ -670,31 +712,13 @@ func (tr TestConfig) getConsumerChains(chain ChainID) map[ChainID]bool { return chains } -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) - } - - return actualState -} - -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) - } - - return actualState -} - -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, +func (tr Commands) GetConsumerAddress(consumerChain ChainID, validator ValidatorID) string { + binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "validator-consumer-key", string(consumerChain), tr.validatorConfigs[validator].ValconsAddress, - `--node`, tr.getQueryNode(ChainID("provi")), + `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -706,13 +730,13 @@ func (tr TestConfig) getConsumerAddress(consumerChain ChainID, validator Validat return addr } -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, +func (tr Commands) GetProviderAddressFromConsumer(consumerChain ChainID, validator ValidatorID) string { + binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "validator-provider-key", string(consumerChain), tr.validatorConfigs[validator].ConsumerValconsAddressOnProvider, - `--node`, tr.getQueryNode(ChainID("provi")), + `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) @@ -726,13 +750,12 @@ func (tr TestConfig) getProviderAddressFromConsumer(consumerChain ChainID, valid return addr } -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, +func (tr Commands) GetSlashMeter() int64 { + binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "throttle-state", - `--node`, tr.getQueryNode(ChainID("provi")), + `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -744,12 +767,12 @@ func (tr TestConfig) getSlashMeter() int64 { return slashMeter.Int() } -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[chain].BinaryName, +func (tr Commands) GetRegisteredConsumerRewardDenoms(chain ChainID) []string { + binaryName := tr.chainConfigs[chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "registered-consumer-reward-denoms", - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -766,12 +789,12 @@ func (tr TestConfig) getRegisteredConsumerRewardDenoms(chain ChainID) []string { return rewardDenoms } -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, +func (tr Commands) GetPendingPacketQueueSize(chain ChainID) uint { + binaryName := tr.chainConfigs[chain].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "ccvconsumer", "throttle-state", - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -787,62 +810,13 @@ func (tr TestConfig) getPendingPacketQueueSize(chain ChainID) uint { return uint(len(packetData)) } -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) - } - - return "tcp://" + tr.getValidatorIP(chain, validator) + ":26658" -} - -func (tr TestConfig) getValidatorIP(chain ChainID, validator ValidatorID) string { - return tr.chainConfigs[chain].IpPrefix + "." + tr.validatorConfigs[validator].IpSuffix -} - -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 TestConfig) getQueryNode(chain ChainID) string { - return fmt.Sprintf("tcp://%s", tr.getQueryNodeRPCAddress(chain)) -} - -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 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) - } - return fmt.Sprintf("%s.253", tr.chainConfigs[chain].IpPrefix) -} - -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)) - - verbosity := false - executeCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) -} - -// getClientFrozenHeight returns the frozen height for a client with the given client ID +// GetClientFrozenHeight returns the frozen height for a client with the given client ID // by querying the hosting chain with the given chainID -func (tc TestConfig) getClientFrozenHeight(chain ChainID, clientID string) clienttypes.Height { - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tc.containerConfig.InstanceName, tc.chainConfigs[ChainID("provi")].BinaryName, +func (tr Commands) GetClientFrozenHeight(chain ChainID, clientID string) (uint64, uint64) { + binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + cmd := tr.target.ExecCommand(binaryName, "query", "ibc", "client", "state", clientID, - `--node`, tc.getQueryNode(ChainID("provi")), + `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) @@ -863,17 +837,17 @@ func (tc TestConfig) getClientFrozenHeight(chain ChainID, clientID string) clien log.Fatal(err, "\n", string(bz)) } - return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} + return uint64(revHeight), uint64(revNumber) } -func (tr TestConfig) getHasToValidate( +func (tr Commands) GetHasToValidate( validatorId ValidatorID, ) []ChainID { - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[ChainID("provi")].BinaryName, + binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + bz, err := tr.target.ExecCommand(binaryName, "query", "provider", "has-to-validate", tr.validatorConfigs[validatorId].ValconsAddress, - `--node`, tr.getQueryNode(ChainID("provi")), + `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ).CombinedOutput() if err != nil { @@ -889,13 +863,12 @@ func (tr TestConfig) getHasToValidate( return chains } -func (tc TestConfig) getTrustedHeight( +func (tr Commands) GetTrustedHeight( chain ChainID, clientID string, index int, -) clienttypes.Height { - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - configureNodeCmd := exec.Command("docker", "exec", tc.containerConfig.InstanceName, "hermes", +) (uint64, uint64) { + configureNodeCmd := tr.target.ExecCommand("hermes", "--json", "query", "client", "consensus", "--chain", string(chain), `--client`, clientID, ) @@ -933,15 +906,14 @@ func (tc TestConfig) getTrustedHeight( if err != nil { log.Fatal(err) } - return clienttypes.Height{RevisionHeight: uint64(revHeight), RevisionNumber: uint64(revNumber)} + return uint64(revHeight), uint64(revNumber) } -func (tr TestConfig) getProposedConsumerChains(chain ChainID) []string { - tr.waitBlocks(chain, 1, 10*time.Second) - //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, +func (tr Commands) GetProposedConsumerChains(chain ChainID) []string { + binaryName := tr.chainConfigs[chain].BinaryName + bz, err := tr.target.ExecCommand(binaryName, "query", "provider", "list-proposed-consumer-chains", - `--node`, tr.getQueryNode(chain), + `--node`, tr.GetQueryNode(chain), `-o`, `json`, ).CombinedOutput() if err != nil { @@ -958,6 +930,24 @@ func (tr TestConfig) getProposedConsumerChains(chain ChainID) []string { return chains } -func uintPtr(i uint) *uint { - return &i +// getQueryNode returns query node tcp address on chain. +func (tr Commands) GetQueryNode(chain ChainID) string { + return fmt.Sprintf("tcp://%s", tr.GetQueryNodeRPCAddress(chain)) +} + +func (tr Commands) 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 Commands) 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) + } + return fmt.Sprintf("%s.253", tr.chainConfigs[chain].IpPrefix) } diff --git a/tests/e2e/state_rapid_test.go b/tests/e2e/state_rapid_test.go index 3192662d27..1ca36d5578 100644 --- a/tests/e2e/state_rapid_test.go +++ b/tests/e2e/state_rapid_test.go @@ -3,7 +3,7 @@ package main import ( "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "pgregory.net/rapid" ) @@ -40,7 +40,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] { proposals := GetProposalsGen().Draw(t, "Proposals") valPowers := GetValPowersGen().Draw(t, "ValPowers") stakedTokens := GetStakedTokensGen().Draw(t, "StakedTokens") - params := GetParamsGen().Draw(t, "Params") + ibctransferparams := GetIBCTransferParamsGen().Draw(t, "IBCTransferParams") rewards := GetRewardsGen().Draw(t, "Rewards") consumerChains := GetConsumerChainsGen().Draw(t, "ConsumerChains") assignedKeys := GetAssignedKeysGen().Draw(t, "AssignedKeys") @@ -53,7 +53,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] { Proposals: &proposals, ValPowers: &valPowers, StakedTokens: &stakedTokens, - Params: ¶ms, + IBCTransferParams: &ibctransferparams, Rewards: &rewards, ConsumerChains: &consumerChains, AssignedKeys: &assignedKeys, @@ -110,17 +110,26 @@ func GetRewardsGen() *rapid.Generator[Rewards] { }) } -func GetParamsGen() *rapid.Generator[[]Param] { - return rapid.Custom(func(t *rapid.T) []Param { - return rapid.SliceOf(GetParamGen()).Draw(t, "Params") +func GetIBCTransferParamsGen() *rapid.Generator[IBCTransferParams] { + return rapid.Custom(func(t *rapid.T) IBCTransferParams { + return IBCTransferParams{ + SendEnabled: rapid.Bool().Draw(t, "SendEnabled"), + ReceiveEnabled: rapid.Bool().Draw(t, "ReceiveEnabled"), + } }) + } -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 GetIBCTransferParamsProposalGen() *rapid.Generator[IBCTransferParamsProposal] { + return rapid.Custom(func(t *rapid.T) IBCTransferParamsProposal { + return IBCTransferParamsProposal{ + Title: rapid.String().Draw(t, "Title"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + Params: IBCTransferParams{ + SendEnabled: rapid.Bool().Draw(t, "SendEnabled"), + ReceiveEnabled: rapid.Bool().Draw(t, "ReceiveEnabled"), + }, } }) } @@ -173,7 +182,7 @@ func GetProposalGen() *rapid.Generator[Proposal] { GetConsumerAdditionProposalGen().AsAny(), GetConsumerRemovalProposalGen().AsAny(), GetTextProposalGen().AsAny(), - GetParamsProposalGen().AsAny(), + GetIBCTransferParamsProposalGen().AsAny(), ) return gen.Draw(t, "Proposal").(Proposal) }) @@ -213,18 +222,6 @@ func GetTextProposalGen() *rapid.Generator[TextProposal] { }) } -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{ diff --git a/tests/e2e/steps_active_set_changes.go b/tests/e2e/steps_active_set_changes.go index a29bd831d4..1fc06a73b6 100644 --- a/tests/e2e/steps_active_set_changes.go +++ b/tests/e2e/steps_active_set_changes.go @@ -1,6 +1,11 @@ package main -import clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" +import ( + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" +) // stepsActiveSetChanges starts a top N provider chain and causes a change in the active set func stepsActiveSetChanges() []Step { @@ -43,7 +48,7 @@ func stepsActiveSetChanges() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -69,7 +74,7 @@ func stepsActiveSetChanges() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -86,6 +91,12 @@ func stepsActiveSetChanges() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 700000000, 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\"", }, State: State{}, }, diff --git a/tests/e2e/steps_compatibility.go b/tests/e2e/steps_compatibility.go index c5754aef43..dfcf14cd58 100644 --- a/tests/e2e/steps_compatibility.go +++ b/tests/e2e/steps_compatibility.go @@ -4,7 +4,10 @@ package main // sanity checks across different ICS versions. import ( - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ) func compstepStartProviderChain() []Step { @@ -55,7 +58,7 @@ func compstepsStartConsumerChain(consumerName string, proposalIndex, chainIndex Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), // breaking change in SDK: gov.ProposalStatus(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD).String(), }, }, // not supported across major versions @@ -124,7 +127,7 @@ func compstepsStartConsumerChain(consumerName string, proposalIndex, chainIndex Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), //TODO: CHECK if this is bug on SDK SIDE!!!: should be as before gov.ProposalStatus(gov.ProposalStatus_PROPOSAL_STATUS_PASSED).String(), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/steps_consumer_misbehaviour.go b/tests/e2e/steps_consumer_misbehaviour.go index ab0c474a41..1071da368a 100644 --- a/tests/e2e/steps_consumer_misbehaviour.go +++ b/tests/e2e/steps_consumer_misbehaviour.go @@ -1,7 +1,10 @@ package main import ( - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ) // starts a provider chain and an Opt-In consumer chain with one validator @@ -34,7 +37,7 @@ func stepsStartChainsForConsumerMisbehaviour(consumerName string) []Step { ConsumerChain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, + TopN: 100, }, State: State{ ChainID("provi"): ChainState{ @@ -48,7 +51,7 @@ func stepsStartChainsForConsumerMisbehaviour(consumerName string) []Step { Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -99,7 +102,7 @@ func stepsStartChainsForConsumerMisbehaviour(consumerName string) []Step { Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/steps_democracy.go b/tests/e2e/steps_democracy.go index 30288e7ba9..82e1d237af 100644 --- a/tests/e2e/steps_democracy.go +++ b/tests/e2e/steps_democracy.go @@ -1,5 +1,11 @@ package main +import ( + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" +) + const consumerRewardDenom = "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9" func stepsDemocracy(consumerName string, expectRegisteredRewardDistribution bool) []Step { @@ -25,6 +31,12 @@ func stepsDemocracy(consumerName string, expectRegisteredRewardDistribution bool IsIncrementalReward: true, IsNativeDenom: true, }, + // Check that delegating on gov-consumer does not change validator powers + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, + }, }, }, }, @@ -62,14 +74,12 @@ func stepsDemocracy(consumerName string, expectRegisteredRewardDistribution bool }, }, { - // this proposal will allow ibc transfer by setting SendEnabled to true - Action: SubmitParamChangeLegacyProposalAction{ - Chain: ChainID(consumerName), - From: ValidatorID("alice"), - Deposit: 10000001, - Subspace: "transfer", - Key: "SendEnabled", - Value: true, + // whitelisted legacy proposal can only handle ibctransfer.SendEnabled/ReceiveEnabled + Action: SubmitEnableTransfersProposalAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + Deposit: 10000001, + Title: "Enable IBC Send", }, State: State{ ChainID(consumerName): ChainState{ @@ -77,15 +87,13 @@ func stepsDemocracy(consumerName string, expectRegisteredRewardDistribution bool ValidatorID("alice"): 9889999998, ValidatorID("bob"): 9960000001, }, - // Check that the "SendEnabled" transfer parameter is set to false - Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "false"}}), + // confirm the Proposals: &map[uint]Proposal{ - 1: ParamsProposal{ - Deposit: 10000001, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", - Subspace: "transfer", - Key: "SendEnabled", - Value: "true", + 1: IBCTransferParamsProposal{ + Deposit: 10000001, + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), + Title: "Enable IBC Send", + Params: IBCTransferParams{SendEnabled: true, ReceiveEnabled: true}, }, }, }, @@ -108,16 +116,13 @@ func stepsDemocracy(consumerName string, expectRegisteredRewardDistribution bool }, // Check that the prop passed Proposals: &map[uint]Proposal{ - 1: ParamsProposal{ - Deposit: 10000001, - Status: "PROPOSAL_STATUS_PASSED", - Subspace: "transfer", - Key: "SendEnabled", - Value: "true", + 1: IBCTransferParamsProposal{ + Deposit: 10000001, + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), + Title: "Enable IBC Send", + Params: IBCTransferParams{SendEnabled: true, ReceiveEnabled: true}, }, }, - // Check that the parameter is changed on gov-consumer chain - Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "true"}}), }, }, }, diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go index 77a76a0dd2..9a0daa5acf 100644 --- a/tests/e2e/steps_partial_set_security.go +++ b/tests/e2e/steps_partial_set_security.go @@ -1,6 +1,11 @@ package main -import clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" +import ( + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" +) // stepsOptInChain starts a provider chain and an Opt-In chain and opts in and out validators func stepsOptInChain() []Step { @@ -42,7 +47,7 @@ func stepsOptInChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -101,7 +106,7 @@ func stepsOptInChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -118,6 +123,12 @@ func stepsOptInChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -557,7 +568,7 @@ func stepsTopNChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -590,7 +601,7 @@ func stepsTopNChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -607,6 +618,12 @@ func stepsTopNChain() []Step { {Id: ValidatorID("bob"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -1031,7 +1048,7 @@ func stepsValidatorSetCappedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -1117,7 +1134,7 @@ func stepsValidatorSetCappedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -1132,6 +1149,12 @@ func stepsValidatorSetCappedChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -1262,7 +1285,7 @@ func stepsValidatorsPowerCappedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -1347,7 +1370,7 @@ func stepsValidatorsPowerCappedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -1362,6 +1385,12 @@ func stepsValidatorsPowerCappedChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -1482,10 +1511,8 @@ func stepsValidatorsAllowlistedChain() []Step { InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, // only "alice" and "bob" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Allowlist: []string{ - "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - }, + Allowlist: []string{"cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"}, }, State: State{ ChainID("provi"): ChainState{ @@ -1495,7 +1522,7 @@ func stepsValidatorsAllowlistedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -1580,7 +1607,7 @@ func stepsValidatorsAllowlistedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -1595,6 +1622,12 @@ func stepsValidatorsAllowlistedChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -1698,7 +1731,7 @@ func stepsValidatorsDenylistedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -1783,7 +1816,7 @@ func stepsValidatorsDenylistedChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -1798,6 +1831,12 @@ func stepsValidatorsDenylistedChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -1900,7 +1939,7 @@ func stepsModifyChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, HasToValidate: &map[ValidatorID][]ChainID{ @@ -1985,7 +2024,7 @@ func stepsModifyChain() []Step { Chain: ChainID("consu"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2000,6 +2039,12 @@ func stepsModifyChain() []Step { {Id: ValidatorID("bob"), Stake: 200000000, Allocation: 10000000000}, {Id: ValidatorID("carol"), Stake: 300000000, 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\"", }, State: State{ ChainID("consu"): ChainState{ @@ -2078,7 +2123,7 @@ func stepsModifyChain() []Step { 2: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -2097,7 +2142,7 @@ func stepsModifyChain() []Step { 2: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2144,7 +2189,7 @@ func stepsModifyChain() []Step { 3: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -2163,7 +2208,7 @@ func stepsModifyChain() []Step { 3: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2204,10 +2249,8 @@ func stepsModifyChain() []Step { Deposit: 10000001, ConsumerChain: ChainID("consu"), // only "alice" and "carol" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Allowlist: []string{ - "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", - }, + Allowlist: []string{"cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6"}, }, State: State{ ChainID("provi"): ChainState{ @@ -2215,7 +2258,7 @@ func stepsModifyChain() []Step { 4: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -2234,7 +2277,7 @@ func stepsModifyChain() []Step { 4: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2281,7 +2324,7 @@ func stepsModifyChain() []Step { 5: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -2300,7 +2343,7 @@ func stepsModifyChain() []Step { 5: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2346,7 +2389,7 @@ func stepsModifyChain() []Step { 6: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -2365,7 +2408,7 @@ func stepsModifyChain() []Step { 6: ConsumerModificationProposal{ Deposit: 10000001, Chain: ChainID("consu"), - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, @@ -2394,8 +2437,7 @@ func stepsModifyChain() []Step { ExpectError: true, // because this chain is now Top 100%, no validator can opt out }, State: State{}, - }, - } + }} return s } diff --git a/tests/e2e/steps_sovereign_changeover.go b/tests/e2e/steps_sovereign_changeover.go index 3cdbc38dac..500120bbf0 100644 --- a/tests/e2e/steps_sovereign_changeover.go +++ b/tests/e2e/steps_sovereign_changeover.go @@ -1,6 +1,11 @@ package main -import clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" +import ( + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" +) // this creates new clients on both chains and a connection (connection-0) between them // connection-0 is used to create a transfer channel between the chains @@ -62,7 +67,7 @@ func stepsChangeoverToConsumer(consumerName string) []Step { Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -83,7 +88,7 @@ func stepsChangeoverToConsumer(consumerName string) []Step { Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ @@ -206,7 +211,7 @@ func stepsUpgradeChain() []Step { UpgradeHeight: 110, Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", Deposit: 10000000, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -227,7 +232,7 @@ func stepsUpgradeChain() []Step { UpgradeHeight: 110, Title: "sovereign-changeover", Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, }, diff --git a/tests/e2e/steps_start_chains.go b/tests/e2e/steps_start_chains.go index 67fbc585a4..898f562dc0 100644 --- a/tests/e2e/steps_start_chains.go +++ b/tests/e2e/steps_start_chains.go @@ -1,7 +1,10 @@ package main import ( - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "strconv" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ) func stepStartProviderChain() []Step { @@ -52,7 +55,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, ProposedConsumerChains: &[]string{consumerName}, @@ -140,7 +143,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/steps_stop_chain.go b/tests/e2e/steps_stop_chain.go index 36c0788901..fbf86e4733 100644 --- a/tests/e2e/steps_stop_chain.go +++ b/tests/e2e/steps_stop_chain.go @@ -1,6 +1,11 @@ package main -import "time" +import ( + "strconv" + "time" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" +) // start relayer so that all messages are relayed func stepsStartRelayer() []Step { @@ -33,7 +38,7 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { Deposit: 10000001, Chain: ChainID(consumerName), StopTime: 0, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not yet removed @@ -54,7 +59,7 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { Deposit: 10000001, Chain: ChainID(consumerName), StopTime: 0, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ @@ -91,7 +96,7 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) [] Deposit: 10000001, Chain: ChainID(consumerName), StopTime: 0, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed @@ -112,7 +117,7 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) [] Deposit: 10000001, Chain: ChainID(consumerName), StopTime: 0, - Status: "PROPOSAL_STATUS_REJECTED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_REJECTED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/test_driver.go b/tests/e2e/test_driver.go index 245d70020b..9c59411ac7 100644 --- a/tests/e2e/test_driver.go +++ b/tests/e2e/test_driver.go @@ -5,7 +5,9 @@ import ( "log" "reflect" + v4 "github.com/cosmos/interchain-security/v5/tests/e2e/v4" "github.com/kylelemons/godebug/pretty" + "golang.org/x/mod/semver" ) // TestCaseDriver knows how different TC can be executed @@ -47,7 +49,7 @@ func (td *DefaultDriver) runStep(step Step) error { return err } modelState := step.State - actualState := td.testCfg.getState(modelState, td.verbose) + actualState := td.getState(modelState) // Check state if !reflect.DeepEqual(actualState, modelState) { @@ -60,90 +62,151 @@ func (td *DefaultDriver) runStep(step Step) error { return nil } +func (td *DefaultDriver) getIcsVersion(chainID ChainID) string { + version := "" + if td.testCfg.chainConfigs[chainID].BinaryName == "interchain-security-pd" { + version = td.testCfg.providerVersion + } else { + version = td.testCfg.consumerVersion + } + ics := getIcsVersion(version) + if !semver.IsValid(ics) { + return "" + } else { + return semver.Major(ics) + } +} + +func (td *DefaultDriver) getTargetDriver(chainID ChainID) Chain { + target := Chain{ + testConfig: td.testCfg, + } + icsVersion := td.getIcsVersion(chainID) + switch icsVersion { + case "v4": + if td.verbose { + fmt.Println("Using 'v4' driver for chain ", chainID) + } + target.target = v4.Commands{ + ContainerConfig: td.testCfg.containerConfig, + ValidatorConfigs: td.testCfg.validatorConfigs, + ChainConfigs: td.testCfg.chainConfigs, + Target: td.target, + } + default: + target.target = Commands{ + containerConfig: td.testCfg.containerConfig, + validatorConfigs: td.testCfg.validatorConfigs, + chainConfigs: td.testCfg.chainConfigs, + target: td.target, + } + if td.verbose { + fmt.Println("Using default driver ", icsVersion, " for chain ", chainID) + } + } + + return target +} + +func (td *DefaultDriver) getState(modelState State) State { + systemState := State{} + for chainID, modelState := range modelState { + target := td.getTargetDriver(chainID) + + if td.verbose { + fmt.Println("Getting model state for chain: ", chainID) + } + systemState[chainID] = target.GetChainState(chainID, modelState) + } + + return systemState +} + func (td *DefaultDriver) runAction(action interface{}) error { + target := td.getTargetDriver("") switch action := action.(type) { case StartChainAction: - td.testCfg.startChain(action, td.target, td.verbose) + target.startChain(action, td.verbose) case StartSovereignChainAction: - td.testCfg.startSovereignChain(action, td.target, td.verbose) + target.startSovereignChain(action, td.verbose) case LegacyUpgradeProposalAction: - td.testCfg.submitLegacyUpgradeProposal(action, td.target, td.verbose) + target.submitLegacyUpgradeProposal(action, td.verbose) case WaitUntilBlockAction: - td.testCfg.waitUntilBlockOnChain(action) + target.waitUntilBlockOnChain(action) case ChangeoverChainAction: - td.testCfg.changeoverChain(action, td.target, td.verbose) + target.changeoverChain(action, td.verbose) case SendTokensAction: - td.testCfg.sendTokens(action, td.target, td.verbose) + target.sendTokens(action, td.verbose) case SubmitTextProposalAction: - td.testCfg.submitTextProposal(action, td.target, td.verbose) + target.submitTextProposal(action, td.verbose) case SubmitConsumerAdditionProposalAction: - td.testCfg.submitConsumerAdditionProposal(action, td.target, td.verbose) + target.submitConsumerAdditionProposal(action, td.verbose) case SubmitConsumerRemovalProposalAction: - td.testCfg.submitConsumerRemovalProposal(action, td.target, td.verbose) + target.submitConsumerRemovalProposal(action, td.verbose) + case SubmitEnableTransfersProposalAction: + target.submitEnableTransfersProposalAction(action, td.verbose) case SubmitConsumerModificationProposalAction: - td.testCfg.submitConsumerModificationProposal(action, td.target, td.verbose) - case SubmitParamChangeLegacyProposalAction: - td.testCfg.submitParamChangeProposal(action, td.target, td.verbose) + target.submitConsumerModificationProposal(action, td.verbose) case VoteGovProposalAction: - td.testCfg.voteGovProposal(action, td.target, td.verbose) + target.voteGovProposal(action, td.verbose) case StartConsumerChainAction: - td.testCfg.startConsumerChain(action, td.target, td.verbose) + target.startConsumerChain(action, td.verbose) case AddChainToRelayerAction: - td.testCfg.addChainToRelayer(action, td.target, td.verbose) + target.addChainToRelayer(action, td.verbose) case CreateIbcClientsAction: - td.testCfg.createIbcClientsHermes(action, td.target, td.verbose) + target.createIbcClientsHermes(action, td.verbose) case AddIbcConnectionAction: - td.testCfg.addIbcConnection(action, td.target, td.verbose) + target.addIbcConnection(action, td.verbose) case AddIbcChannelAction: - td.testCfg.addIbcChannel(action, td.target, td.verbose) + target.addIbcChannel(action, td.verbose) case TransferChannelCompleteAction: - td.testCfg.transferChannelComplete(action, td.target, td.verbose) + target.transferChannelComplete(action, td.verbose) case RelayPacketsAction: - td.testCfg.relayPackets(action, td.target, td.verbose) + target.relayPackets(action, td.verbose) case RelayRewardPacketsToProviderAction: - td.testCfg.relayRewardPacketsToProvider(action, td.target, td.verbose) + target.relayRewardPacketsToProvider(action, td.verbose) case DelegateTokensAction: - td.testCfg.delegateTokens(action, td.target, td.verbose) + target.delegateTokens(action, td.verbose) case UnbondTokensAction: - td.testCfg.unbondTokens(action, td.target, td.verbose) + target.unbondTokens(action, td.verbose) case CancelUnbondTokensAction: - td.testCfg.cancelUnbondTokens(action, td.target, td.verbose) + target.cancelUnbondTokens(action, td.verbose) case RedelegateTokensAction: - td.testCfg.redelegateTokens(action, td.target, td.verbose) + target.redelegateTokens(action, td.verbose) case DowntimeSlashAction: - td.testCfg.invokeDowntimeSlash(action, td.target, td.verbose) + target.invokeDowntimeSlash(action, td.verbose) case UnjailValidatorAction: - td.testCfg.unjailValidator(action, td.target, td.verbose) + target.unjailValidator(action, td.verbose) case DoublesignSlashAction: - td.testCfg.invokeDoublesignSlash(action, td.target, td.verbose) + target.invokeDoublesignSlash(action, td.verbose) case LightClientAmnesiaAttackAction: - td.testCfg.lightClientAmnesiaAttack(action, td.verbose) + target.lightClientAmnesiaAttack(action, td.verbose) case LightClientEquivocationAttackAction: - td.testCfg.lightClientEquivocationAttack(action, td.verbose) + target.lightClientEquivocationAttack(action, td.verbose) case LightClientLunaticAttackAction: - td.testCfg.lightClientLunaticAttack(action, td.verbose) + target.lightClientLunaticAttack(action, td.verbose) case RegisterRepresentativeAction: - td.testCfg.registerRepresentative(action, td.target, td.verbose) + target.registerRepresentative(action, td.verbose) case AssignConsumerPubKeyAction: - td.testCfg.assignConsumerPubKey(action, td.target, td.verbose) + target.assignConsumerPubKey(action, td.verbose) case SlashMeterReplenishmentAction: - td.testCfg.waitForSlashMeterReplenishment(action, td.verbose) + target.waitForSlashMeterReplenishment(action, td.verbose) case WaitTimeAction: - td.testCfg.waitForTime(action, td.verbose) + target.waitForTime(action, td.verbose) case StartRelayerAction: - td.testCfg.startRelayer(action, td.target, td.verbose) + target.startRelayer(action, td.verbose) case ForkConsumerChainAction: - td.testCfg.forkConsumerChain(action, td.verbose) + target.forkConsumerChain(action, td.verbose) case UpdateLightClientAction: - td.testCfg.updateLightClient(action, td.verbose) + target.updateLightClient(action, td.verbose) case StartConsumerEvidenceDetectorAction: - td.testCfg.startConsumerEvidenceDetector(action, td.target, td.verbose) + target.startConsumerEvidenceDetector(action, td.verbose) case SubmitChangeRewardDenomsProposalAction: - td.testCfg.submitChangeRewardDenomsProposal(action, td.target, td.verbose) + target.submitChangeRewardDenomsProposal(action, td.verbose) case OptInAction: - td.testCfg.optIn(action, td.target, td.verbose) + target.optIn(action, td.target, td.verbose) case OptOutAction: - td.testCfg.optOut(action, td.target, td.verbose) + target.optOut(action, td.target, td.verbose) default: log.Fatalf("unknown action in testRun %s: %#v", td.testCfg.name, action) } diff --git a/tests/e2e/test_target.go b/tests/e2e/test_target.go index 421be1d1fa..140ed565e6 100644 --- a/tests/e2e/test_target.go +++ b/tests/e2e/test_target.go @@ -24,7 +24,13 @@ type ExecutionTarget interface { Delete() error Info() string } - +type TargetConfig struct { + gaiaTag string + localSdkPath string + useGaia bool + providerVersion string + consumerVersion string +} type DockerContainer struct { targetConfig TargetConfig containerCfg ContainerConfig diff --git a/tests/e2e/testlib/types.go b/tests/e2e/testlib/types.go new file mode 100644 index 0000000000..135f07a6a8 --- /dev/null +++ b/tests/e2e/testlib/types.go @@ -0,0 +1,349 @@ +package e2e + +import ( + "encoding/json" + "fmt" + "os/exec" + "reflect" + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" +) + +type ( + ChainID string + ValidatorID string +) + +type ChainCommands interface { + GetBlockHeight(chain ChainID) uint + GetBalance(chain ChainID, validator ValidatorID) uint + GetConsumerChains(chain ChainID) map[ChainID]bool + GetConsumerAddress(consumerChain ChainID, validator ValidatorID) string + GetClientFrozenHeight(chain ChainID, clientID string) (RevisionNumber, RevisionHeight uint64) + GetHasToValidate(validator ValidatorID) []ChainID + GetIBCTransferParams(chain ChainID) IBCTransferParams + GetProposal(chain ChainID, proposal uint) Proposal + GetParam(chain ChainID, param Param) string + GetProviderAddressFromConsumer(consumerChain ChainID, validator ValidatorID) string + GetReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 + GetRegisteredConsumerRewardDenoms(chain ChainID) []string + GetSlashMeter() int64 + GetPendingPacketQueueSize(chain ChainID) uint + GetProposedConsumerChains(chain ChainID) []string + GetQueryNode(chain ChainID) string + GetQueryNodeRPCAddress(chain ChainID) string + GetTrustedHeight(chain ChainID, clientID string, index int) (uint64, uint64) + GetValPower(chain ChainID, validator ValidatorID) uint + GetValStakedTokens(chain ChainID, validatorAddress string) uint + GetQueryNodeIP(chain ChainID) string +} + +// TODO: replace ExecutionTarget with new TargetDriver interface +type PlatformDriver interface { + ExecCommand(name string, arg ...string) *exec.Cmd + // ExecDetachedCommand: when executed the command will be run in the background and call will return immediately + ExecDetachedCommand(name string, args ...string) *exec.Cmd + GetTestScriptPath(isConsumer bool, script string) string +} +type TargetDriver interface { + // ChainCommands + ChainCommands + PlatformDriver +} + +// TODO: this should not be here. mv 'Now' to a better suited type here and then move ContainerConfig back +type ContainerConfig struct { + ContainerName string + InstanceName string + CcvVersion string + Now time.Time +} + +// 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 { + // Seed phrase to generate a secp256k1 key used by the validator on the provider + Mnemonic string + // Validator account address on provider marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix + DelAddress string + // Validator account address on provider marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix + DelAddressOnConsumer string + // Validator operator address on provider marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix + ValoperAddress string + // Validator operator address on provider marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix + ValoperAddressOnConsumer string + // Validator consensus address on provider marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix. It matches the PrivValidatorKey below. + ValconsAddress string + // Validator consensus address on provider marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix. + ValconsAddressOnConsumer string + // Key used for consensus on provider + PrivValidatorKey string + NodeKey string + // Must be an integer greater than 0 and less than 253 + IpSuffix string + + // consumer chain key assignment data + // keys are used on a new node + + // Seed phrase to generate a secp256k1 key used by the validator on the consumer + ConsumerMnemonic string + // Validator account address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix + ConsumerDelAddress string + // Validator account address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix + ConsumerDelAddressOnProvider string + // Validator operator address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix + ConsumerValoperAddress string + // Validator operator address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix + ConsumerValoperAddressOnProvider string + // Validator consensus address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ConsumerAccountPrefix. It matches the PrivValidatorKey below. + ConsumerValconsAddress string + // Validator consensus address on consumer marshaled to string using Bech32 + // with Bech32Prefix = ProviderAccountPrefix. + ConsumerValconsAddressOnProvider string + ConsumerValPubKey string + // Key used for consensus on consumer + 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 + // The account prefix configured on the chain. For example, on the Hub, this is "cosmos" + AccountPrefix string + // Must be unique per chain + 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 + + // binary to use after upgrade height + UpgradeBinary 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 + } +) + +// stores a proposal as a raw json, together with its type +type ProposalAndType struct { + RawProposal json.RawMessage + Type string +} + +type ChainState struct { + ValBalances *map[ValidatorID]uint + Proposals *map[uint]Proposal + ProposedConsumerChains *[]string + ValPowers *map[ValidatorID]uint + StakedTokens *map[ValidatorID]uint + IBCTransferParams *IBCTransferParams + Params *[]Param + Rewards *Rewards + 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 + ClientsFrozenHeights *map[string]clienttypes.Height + HasToValidate *map[ValidatorID][]ChainID // only relevant to provider chain +} + +// 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.IBCTransferParamsProposal": + prop := IBCTransferParamsProposal{} + 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 +} + +type Proposal interface { + isProposal() +} +type TextProposal struct { + Title string + Description string + Deposit uint + Status string +} + +func (p TextProposal) isProposal() {} + +type IBCTransferParamsProposal struct { + Title string + Deposit uint + Status string + Params IBCTransferParams +} + +func (ibct IBCTransferParamsProposal) isProposal() {} + +type ConsumerAdditionProposal struct { + Deposit uint + Chain ChainID + SpawnTime int + InitialHeight clienttypes.Height + Status string +} + +type UpgradeProposal struct { + Title string + Description string + UpgradeHeight uint64 + Type string + Deposit uint + Status string +} + +func (p UpgradeProposal) isProposal() {} + +func (p ConsumerAdditionProposal) isProposal() {} + +type ConsumerRemovalProposal struct { + Deposit uint + Chain ChainID + StopTime int + Status string +} + +func (p ConsumerRemovalProposal) isProposal() {} + +type ConsumerModificationProposal struct { + Deposit uint + Chain ChainID + Status string +} + +func (p ConsumerModificationProposal) isProposal() {} + +type Rewards struct { + 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 + // if true checks rewards for "stake" token, otherwise checks rewards from + // other chains (e.g. false is used to check if provider received rewards from a consumer chain) + IsNativeDenom bool +} + +type ParamsProposal struct { + Deposit uint + Status string + Subspace string + Key string + Value string +} + +func (p ParamsProposal) isProposal() {} + +type Param struct { + Subspace string + Key string + Value string +} + +type IBCTransferParams struct { + SendEnabled bool `json:"send_enabled"` + ReceiveEnabled bool `json:"receive_enabled"` +} diff --git a/tests/e2e/testlib/utils.go b/tests/e2e/testlib/utils.go new file mode 100644 index 0000000000..8b68c25947 --- /dev/null +++ b/tests/e2e/testlib/utils.go @@ -0,0 +1,43 @@ +package e2e + +import ( + "bufio" + "fmt" + "log" + "os/exec" +) + +var verbose *bool //TODO: remove hack + +func ExecuteCommandWithVerbosity(cmd *exec.Cmd, cmdName string, verbose bool) { + if verbose { + fmt.Println(cmdName+" cmd:", cmd.String()) + } + + cmdReader, err := cmd.StdoutPipe() + if err != nil { + log.Fatal(err) + } + cmd.Stderr = cmd.Stdout + + if err := cmd.Start(); err != nil { + log.Fatal(err) + } + + scanner := bufio.NewScanner(cmdReader) + + for scanner.Scan() { + out := scanner.Text() + if verbose { + fmt.Println(cmdName + ": " + out) + } + } + if err := scanner.Err(); err != nil { + log.Fatal(err) + } +} + +// Executes a command with verbosity specified by CLI flag +func ExecuteCommand(cmd *exec.Cmd, cmdName string) { + ExecuteCommandWithVerbosity(cmd, cmdName, *verbose) +} diff --git a/tests/e2e/testnet-scripts/start-chain.sh b/tests/e2e/testnet-scripts/start-chain.sh index 50ac05f75b..29091d8b19 100644 --- a/tests/e2e/testnet-scripts/start-chain.sh +++ b/tests/e2e/testnet-scripts/start-chain.sh @@ -377,11 +377,11 @@ fi # poll for chain start if [[ "$USE_COMETMOCK" == "true" ]]; then set +e - until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done + until $BIN query block --type=height 0 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658"; do sleep 0.3 ; done set -e else set +e - until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash": + until $BIN query block --type=height 0 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash": ""}},"block":null}'; do sleep 0.3 ; done set -e fi diff --git a/tests/e2e/testnet-scripts/start-changeover.sh b/tests/e2e/testnet-scripts/start-changeover.sh index c8a8e698ae..f41b6ce626 100644 --- a/tests/e2e/testnet-scripts/start-changeover.sh +++ b/tests/e2e/testnet-scripts/start-changeover.sh @@ -179,7 +179,7 @@ QUERY_NODE_SUFFIX=$(echo "$VALIDATORS" | jq -r ".[0].ip_suffix") echo "NODE SUFFIX: $QUERY_NODE_SUFFIX" # poll for chain start set +e -until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$QUERY_NODE_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done +until $BIN query block query block --type=height 0 --node "tcp://$CHAIN_IP_PREFIX.$QUERY_NODE_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done set -e echo "done!!!!!!!!" diff --git a/tests/e2e/testnet-scripts/start-sovereign.sh b/tests/e2e/testnet-scripts/start-sovereign.sh index 443b8ab6b0..54e14dfcf3 100644 --- a/tests/e2e/testnet-scripts/start-sovereign.sh +++ b/tests/e2e/testnet-scripts/start-sovereign.sh @@ -125,7 +125,7 @@ ip netns exec $NET_NAMESPACE_NAME $BIN $ARGS start &> /$CHAIN_ID/validator$VAL_I # poll for chain start set +e -until $BIN query block --node "tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done +until $BIN query block --type=height 0 --node "tcp://$CHAIN_IP_PREFIX.$VAL_IP_SUFFIX:26658" | grep -q -v '{"block_id":{"hash":"","parts":{"total":0,"hash":""}},"block":null}'; do sleep 0.3 ; done set -e echo "done!!!!!!!!" diff --git a/tests/e2e/trace_handlers_test.go b/tests/e2e/trace_handlers_test.go index 9b83d1c774..8fcbb60c67 100644 --- a/tests/e2e/trace_handlers_test.go +++ b/tests/e2e/trace_handlers_test.go @@ -6,9 +6,11 @@ import ( "log" "os" "path/filepath" + "strconv" "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/google/go-cmp/cmp" ) @@ -28,7 +30,7 @@ var proposalInStateSteps = []Step{ Deposit: 10000001, Chain: ChainID("foo"), StopTime: 0, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -114,22 +116,20 @@ func TestMarshalAndUnmarshalChainState(t *testing.T) { Chain: ChainID("test"), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 5, RevisionHeight: 5}, - Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }}, - "params-proposal": {ChainState{ + "IBC trasfer update params": {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", + 1: IBCTransferParamsProposal{ + Deposit: 10000001, + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), + Params: IBCTransferParams{true, true}, }, }, }}, @@ -139,7 +139,7 @@ func TestMarshalAndUnmarshalChainState(t *testing.T) { Deposit: 10000001, Chain: ChainID("test123"), StopTime: 5000000000, - Status: "PROPOSAL_STATUS_PASSED", + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/tracehandler_testdata/changeover.json b/tests/e2e/tracehandler_testdata/changeover.json index 79601b4a2d..91b53a87cd 100644 --- a/tests/e2e/tracehandler_testdata/changeover.json +++ b/tests/e2e/tracehandler_testdata/changeover.json @@ -20,7 +20,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -51,7 +51,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -98,7 +98,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -146,7 +146,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -163,7 +163,7 @@ "UpgradeHeight": 110, "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", "Deposit": 10000000, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.UpgradeProposal" } @@ -189,7 +189,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -206,7 +206,7 @@ "UpgradeHeight": 110, "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", "Deposit": 10000000, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.UpgradeProposal" } @@ -235,11 +235,7 @@ "revision_height": 111 }, "DistributionChannel": "channel-0", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -250,7 +246,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -268,7 +264,7 @@ "InitialHeight": { "revision_height": 111 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -301,7 +297,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -319,7 +315,7 @@ "InitialHeight": { "revision_height": 111 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -361,7 +357,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -381,7 +377,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -433,7 +429,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -464,7 +460,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -484,7 +480,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -515,7 +511,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -544,7 +540,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -575,7 +571,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -595,7 +591,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -626,7 +622,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/consumer-double-sign.json b/tests/e2e/tracehandler_testdata/consumer-double-sign.json index c47b259465..7551c2c77d 100644 --- a/tests/e2e/tracehandler_testdata/consumer-double-sign.json +++ b/tests/e2e/tracehandler_testdata/consumer-double-sign.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -359,7 +355,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -383,7 +379,7 @@ "bob": 500000000, "carol": 500000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -411,7 +407,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -435,7 +431,7 @@ "bob": 475000000, "carol": 500000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -466,7 +462,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -490,7 +486,7 @@ "bob": 475000000, "carol": 500000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json b/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json index 926b58b561..c7f68b5273 100644 --- a/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json +++ b/tests/e2e/tracehandler_testdata/consumer-misbehaviour.json @@ -27,7 +27,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -53,11 +53,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 0, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -68,7 +64,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -110,7 +106,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -158,7 +154,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -176,7 +172,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -206,7 +202,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -225,7 +221,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -277,7 +273,7 @@ "alice": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -296,7 +292,7 @@ "bob": 20 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -325,7 +321,7 @@ "alice": 511 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -367,7 +363,7 @@ "bob": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -389,7 +385,7 @@ "alice": 511000000, "bob": 20000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -419,7 +415,7 @@ "bob": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -441,7 +437,7 @@ "alice": 485450000, "bob": 20000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/democracy.json b/tests/e2e/tracehandler_testdata/democracy.json index bb9a861af4..2dc179c0da 100644 --- a/tests/e2e/tracehandler_testdata/democracy.json +++ b/tests/e2e/tracehandler_testdata/democracy.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -375,7 +371,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -395,7 +391,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -425,7 +421,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -456,7 +452,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -486,7 +482,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -516,12 +512,16 @@ "democ": { "ValBalances": null, "ProposedConsumerChains": null, - "ValPowers": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, "StakedTokens": { "alice": 100000000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": true, @@ -563,7 +563,7 @@ "alice": 100500000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": true, @@ -585,14 +585,12 @@ } }, { - "ActionType": "main.SubmitParamChangeLegacyProposalAction", + "ActionType": "main.SubmitEnableTransfersProposalAction", "Action": { "Chain": "democ", "From": "alice", - "Deposit": 10000001, - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": true + "Title": "Enable IBC Send", + "Deposit": 10000001 }, "State": { "democ": { @@ -603,13 +601,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": [ - { - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "false" - } - ], + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -621,13 +613,15 @@ "Proposals": { "1": { "RawProposal": { + "Title": "Enable IBC Send", "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD", - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" + "Status": "2", + "Params": { + "send_enabled": true, + "receive_enabled": true + } }, - "Type": "main.ParamsProposal" + "Type": "main.IBCTransferParamsProposal" } } } @@ -656,13 +650,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": [ - { - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" - } - ], + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -674,13 +662,15 @@ "Proposals": { "1": { "RawProposal": { + "Title": "Enable IBC Send", "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_PASSED", - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" + "Status": "3", + "Params": { + "send_enabled": true, + "receive_enabled": true + } }, - "Type": "main.ParamsProposal" + "Type": "main.IBCTransferParamsProposal" } } } @@ -700,7 +690,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": false, @@ -734,7 +724,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -769,7 +759,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -798,7 +788,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": false, @@ -835,7 +825,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -855,7 +845,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -886,7 +876,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -906,7 +896,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -937,7 +927,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -966,7 +956,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -986,7 +976,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1020,7 +1010,7 @@ "alice": 100500000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json index 137199c483..b270031542 100644 --- a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json +++ b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -375,7 +371,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -395,7 +391,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -425,7 +421,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -456,7 +452,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -486,7 +482,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -516,12 +512,16 @@ "democ": { "ValBalances": null, "ProposedConsumerChains": null, - "ValPowers": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, "StakedTokens": { "alice": 100000000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": true, @@ -563,7 +563,7 @@ "alice": 100500000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": true, @@ -585,14 +585,12 @@ } }, { - "ActionType": "main.SubmitParamChangeLegacyProposalAction", + "ActionType": "main.SubmitEnableTransfersProposalAction", "Action": { "Chain": "democ", "From": "alice", - "Deposit": 10000001, - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": true + "Title": "Enable IBC Send", + "Deposit": 10000001 }, "State": { "democ": { @@ -603,13 +601,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": [ - { - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "false" - } - ], + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -621,13 +613,15 @@ "Proposals": { "1": { "RawProposal": { + "Title": "Enable IBC Send", "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD", - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" + "Status": "2", + "Params": { + "send_enabled": true, + "receive_enabled": true + } }, - "Type": "main.ParamsProposal" + "Type": "main.IBCTransferParamsProposal" } } } @@ -656,13 +650,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": [ - { - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" - } - ], + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -674,13 +662,15 @@ "Proposals": { "1": { "RawProposal": { + "Title": "Enable IBC Send", "Deposit": 10000001, - "Status": "PROPOSAL_STATUS_PASSED", - "Subspace": "transfer", - "Key": "SendEnabled", - "Value": "true" + "Status": "3", + "Params": { + "send_enabled": true, + "receive_enabled": true + } }, - "Type": "main.ParamsProposal" + "Type": "main.IBCTransferParamsProposal" } } } @@ -700,7 +690,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": false, @@ -734,7 +724,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -769,7 +759,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -798,7 +788,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": { "IsRewarded": { "alice": true, @@ -835,7 +825,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -855,7 +845,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -886,7 +876,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -906,7 +896,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -937,7 +927,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -966,7 +956,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -986,7 +976,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1020,7 +1010,7 @@ "alice": 100500000, "bob": 40000000 }, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/happyPath.json b/tests/e2e/tracehandler_testdata/happyPath.json index 33e7815108..fea88c2e92 100644 --- a/tests/e2e/tracehandler_testdata/happyPath.json +++ b/tests/e2e/tracehandler_testdata/happyPath.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -361,7 +357,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -381,7 +377,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -411,7 +407,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -442,7 +438,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -472,7 +468,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -505,7 +501,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -531,7 +527,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -562,7 +558,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -588,7 +584,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -619,7 +615,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -639,7 +635,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -670,7 +666,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -701,7 +697,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -721,7 +717,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -752,7 +748,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -783,7 +779,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -803,7 +799,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -834,7 +830,190 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.RedelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 450000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.RelayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.DowntimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "alice" + }, + "State": { + "consu": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.RelayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "ClientsFrozenHeights": null, + "HasToValidate": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ProposedConsumerChains": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -866,7 +1045,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -886,7 +1065,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -917,7 +1096,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -946,7 +1125,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -966,7 +1145,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -996,7 +1175,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1016,7 +1195,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1047,7 +1226,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1076,7 +1255,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1096,7 +1275,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1127,7 +1306,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1156,7 +1335,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1176,7 +1355,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1207,7 +1386,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1236,7 +1415,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1256,7 +1435,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1287,7 +1466,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1316,7 +1495,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1336,7 +1515,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1367,7 +1546,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1387,7 +1566,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1422,7 +1601,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1439,7 +1618,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerRemovalProposal" } @@ -1471,7 +1650,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1488,7 +1667,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_REJECTED" + "Status": "4" }, "Type": "main.ConsumerRemovalProposal" } @@ -1513,7 +1692,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1530,7 +1709,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerRemovalProposal" } @@ -1562,7 +1741,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": {}, "AssignedKeys": null, @@ -1577,7 +1756,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerRemovalProposal" } diff --git a/tests/e2e/tracehandler_testdata/multipleConsumers.json b/tests/e2e/tracehandler_testdata/multipleConsumers.json index 34626ebbe8..3dbac1f88d 100644 --- a/tests/e2e/tracehandler_testdata/multipleConsumers.json +++ b/tests/e2e/tracehandler_testdata/multipleConsumers.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -356,11 +352,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -373,7 +365,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -391,7 +383,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -415,7 +407,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -481,7 +473,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -524,7 +516,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -542,7 +534,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -584,7 +576,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -604,7 +596,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -658,7 +650,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -678,7 +670,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -698,7 +690,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -729,7 +721,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -749,7 +741,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -769,7 +761,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -800,7 +792,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -820,7 +812,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -840,7 +832,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -871,7 +863,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -891,7 +883,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -911,7 +903,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -942,7 +934,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -962,7 +954,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -982,7 +974,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1013,7 +1005,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1033,7 +1025,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1053,7 +1045,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1085,7 +1077,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1105,7 +1097,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1125,7 +1117,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1156,7 +1148,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1176,7 +1168,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1196,7 +1188,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1227,7 +1219,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1247,7 +1239,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1267,7 +1259,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1296,7 +1288,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1316,7 +1308,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1336,7 +1328,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1367,7 +1359,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1387,7 +1379,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1407,7 +1399,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1438,7 +1430,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1458,7 +1450,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1489,7 +1481,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1509,7 +1501,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1538,7 +1530,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1558,7 +1550,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1578,7 +1570,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1609,7 +1601,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1629,7 +1621,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1649,7 +1641,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1680,7 +1672,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1700,7 +1692,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1720,7 +1712,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1749,7 +1741,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1769,7 +1761,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1789,7 +1781,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1820,7 +1812,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1840,7 +1832,7 @@ "carol": 501 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1860,7 +1852,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1891,7 +1883,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1911,7 +1903,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1931,7 +1923,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1960,7 +1952,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1980,7 +1972,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2000,7 +1992,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2031,7 +2023,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2051,7 +2043,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2071,7 +2063,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2102,7 +2094,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2122,7 +2114,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2142,7 +2134,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2171,7 +2163,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2191,7 +2183,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2211,7 +2203,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2242,7 +2234,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2262,7 +2254,7 @@ "carol": 495 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2282,7 +2274,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2313,7 +2305,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2333,7 +2325,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2353,7 +2345,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2382,7 +2374,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2402,7 +2394,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2422,7 +2414,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2453,7 +2445,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2473,7 +2465,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2493,7 +2485,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2524,7 +2516,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2544,7 +2536,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2564,7 +2556,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2595,7 +2587,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -2615,7 +2607,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, diff --git a/tests/e2e/tracehandler_testdata/shorthappy.json b/tests/e2e/tracehandler_testdata/shorthappy.json index 0d4973862e..4a93c4b713 100644 --- a/tests/e2e/tracehandler_testdata/shorthappy.json +++ b/tests/e2e/tracehandler_testdata/shorthappy.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -361,7 +357,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -381,7 +377,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -411,7 +407,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -442,7 +438,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -472,7 +468,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -503,7 +499,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -523,7 +519,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -554,7 +550,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -586,7 +582,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -606,7 +602,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -637,7 +633,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -666,7 +662,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -686,7 +682,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -716,7 +712,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -736,7 +732,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -767,7 +763,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -796,7 +792,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -816,7 +812,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -847,7 +843,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -876,7 +872,7 @@ "carol": 100 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -896,7 +892,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -927,7 +923,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -956,7 +952,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -976,7 +972,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1007,7 +1003,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1036,7 +1032,7 @@ "carol": 99 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1056,7 +1052,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1087,7 +1083,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1107,7 +1103,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -1142,7 +1138,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1159,7 +1155,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerRemovalProposal" } @@ -1191,7 +1187,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1208,7 +1204,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_REJECTED" + "Status": "4" }, "Type": "main.ConsumerRemovalProposal" } @@ -1233,7 +1229,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -1250,7 +1246,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerRemovalProposal" } @@ -1282,7 +1278,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": {}, "AssignedKeys": null, @@ -1297,7 +1293,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerRemovalProposal" } diff --git a/tests/e2e/tracehandler_testdata/slashThrottle.json b/tests/e2e/tracehandler_testdata/slashThrottle.json index eb413af7e5..68ce3a0c6d 100644 --- a/tests/e2e/tracehandler_testdata/slashThrottle.json +++ b/tests/e2e/tracehandler_testdata/slashThrottle.json @@ -33,7 +33,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -59,11 +59,7 @@ "revision_height": 1 }, "DistributionChannel": "", - "TopN": 100, - "ValidatorsPowerCap": 0, - "ValidatorSetCap": 0, - "Allowlist": null, - "Denylist": null + "TopN": 100 }, "State": { "provi": { @@ -76,7 +72,7 @@ ], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -94,7 +90,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerAdditionProposal" } @@ -118,7 +114,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -184,7 +180,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": { @@ -227,7 +223,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -245,7 +241,7 @@ "InitialHeight": { "revision_height": 1 }, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerAdditionProposal" } @@ -287,7 +283,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -307,7 +303,7 @@ "ProposedConsumerChains": [], "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -361,7 +357,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -381,7 +377,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -411,7 +407,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -442,7 +438,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -472,7 +468,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -501,7 +497,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -521,7 +517,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -552,7 +548,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -572,7 +568,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -601,7 +597,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -621,7 +617,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -652,7 +648,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -672,7 +668,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -701,7 +697,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -721,7 +717,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -745,7 +741,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -765,7 +761,7 @@ "carol": 500 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -792,7 +788,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -812,7 +808,7 @@ "carol": 0 }, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": null, "AssignedKeys": null, @@ -842,7 +838,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": { "consu": true @@ -859,7 +855,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + "Status": "2" }, "Type": "main.ConsumerRemovalProposal" } @@ -891,7 +887,7 @@ "ProposedConsumerChains": null, "ValPowers": null, "StakedTokens": null, - "Params": null, + "IBCTransferParams": null, "Rewards": null, "ConsumerChains": {}, "AssignedKeys": null, @@ -906,7 +902,7 @@ "Deposit": 10000001, "Chain": "consu", "StopTime": 0, - "Status": "PROPOSAL_STATUS_PASSED" + "Status": "3" }, "Type": "main.ConsumerRemovalProposal" } diff --git a/tests/e2e/v4/state.go b/tests/e2e/v4/state.go new file mode 100644 index 0000000000..70ca8afe7c --- /dev/null +++ b/tests/e2e/v4/state.go @@ -0,0 +1,658 @@ +package v4 + +import ( + "bufio" + "fmt" + "log" + "os/exec" + "regexp" + "strconv" + "time" + + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" + "gopkg.in/yaml.v2" + + "github.com/kylelemons/godebug/pretty" + "github.com/tidwall/gjson" +) + +type ( + ChainID = e2e.ChainID + ValidatorID = e2e.ValidatorID + ChainState = e2e.ChainState + Proposal = e2e.Proposal + Rewards = e2e.Rewards + TextProposal = e2e.TextProposal + UpgradeProposal = e2e.UpgradeProposal + ConsumerAdditionProposal = e2e.ConsumerAdditionProposal + ConsumerRemovalProposal = e2e.ConsumerRemovalProposal + IBCTransferParams = e2e.IBCTransferParams + IBCTransferParamsProposal = e2e.IBCTransferParamsProposal + Param = e2e.Param + ParamsProposal = e2e.ParamsProposal + ValidatorConfig = e2e.ValidatorConfig + ChainConfig = e2e.ChainConfig + ContainerConfig = e2e.ContainerConfig + TargetDriver = e2e.TargetDriver +) + +type State map[ChainID]ChainState + +type Commands struct { + ContainerConfig ContainerConfig // FIXME only needed for 'Now' time tracking + ValidatorConfigs map[ValidatorID]ValidatorConfig + ChainConfigs map[ChainID]ChainConfig + Target e2e.PlatformDriver +} + +func (tr Commands) ExecCommand(name string, arg ...string) *exec.Cmd { + return tr.Target.ExecCommand(name, arg...) +} + +func (tr Commands) ExecDetachedCommand(name string, args ...string) *exec.Cmd { + return tr.Target.ExecDetachedCommand(name, args...) +} + +func (tr Commands) GetTestScriptPath(isConsumer bool, script string) string { + return tr.Target.GetTestScriptPath(isConsumer, script) +} + +func (tr Commands) GetBlockHeight(chain ChainID) uint { + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + + "query", "tendermint-validator-set", + + `--node`, tr.GetQueryNode(chain), + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + blockHeightRegex := regexp.MustCompile(`block_height: "(\d+)"`) + blockHeight, err := strconv.Atoi(blockHeightRegex.FindStringSubmatch(string(bz))[1]) + if err != nil { + log.Fatal(err) + } + + return uint(blockHeight) +} + +func (tr Commands) waitUntilBlock(chain ChainID, block uint, timeout time.Duration) { + start := time.Now() + for { + thisBlock := tr.GetBlockHeight(chain) + if thisBlock >= block { + return + } + if time.Since(start) > timeout { + panic(fmt.Sprintf("\n\n\nwaitBlocks method has timed out after: %s\n\n", timeout)) + } + time.Sleep(500 * time.Millisecond) + } +} + +type ValPubKey struct { + Value string `yaml:"value"` +} + +type TmValidatorSetYaml struct { + Total string `yaml:"total"` + Validators []struct { + Address string `yaml:"address"` + VotingPower string `yaml:"voting_power"` + PubKey ValPubKey `yaml:"pub_key"` + } +} + +func (tr Commands) GetValPower(chain ChainID, validator ValidatorID) uint { + /* if *verbose { + log.Println("getting validator power for chain: ", chain, " validator: ", validator) + } + */ + binaryName := tr.ChainConfigs[chain].BinaryName + command := tr.Target.ExecCommand(binaryName, + + "query", "tendermint-validator-set", + + `--node`, tr.GetQueryNode(chain), + ) + bz, err := command.CombinedOutput() + if err != nil { + 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("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("v4: strconv.Atoi returned an error while converting total for validator set: %v, input: %s, validator set: %s, src: %s", + err, valset.Total, pretty.Sprint(valset), string(bz)) + } + + 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. Validator set: %v", + valset.Total, uint(len(valset.Validators)), pretty.Sprint(valset)) + } + + for _, val := range valset.Validators { + if chain == ChainID("provi") { + // use binary with Bech32Prefix set to ProviderAccountPrefix + if val.Address != tr.ValidatorConfigs[validator].ValconsAddress { + continue + } + } else { + // use binary with Bech32Prefix set to ConsumerAccountPrefix + if val.Address != tr.ValidatorConfigs[validator].ValconsAddressOnConsumer && + val.Address != tr.ValidatorConfigs[validator].ConsumerValconsAddress { + continue + } + } + + votingPower, err := strconv.Atoi(val.VotingPower) + if err != nil { + log.Fatalf("strconv.Atoi returned an error while converting validator voting power: %v, voting power string: %s, validator set: %s", err, val.VotingPower, pretty.Sprint(valset)) + } + + return uint(votingPower) + } + + // Validator not in set, its validator power is zero. + return 0 +} + +func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 { + valCfg := tr.ValidatorConfigs[validator] + delAddresss := valCfg.DelAddress + if chain != ChainID("provi") { + // use binary with Bech32Prefix set to ConsumerAccountPrefix + if valCfg.UseConsumerKey { + delAddresss = valCfg.ConsumerDelAddress + } else { + // use the same address as on the provider but with different prefix + delAddresss = valCfg.DelAddressOnConsumer + } + } + + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + + "query", "distribution", "rewards", + delAddresss, + + `--height`, fmt.Sprint(blockHeight), + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + denomCondition := `total.#(denom!="stake").amount` + if isNativeDenom { + denomCondition = `total.#(denom=="stake").amount` + } + + return gjson.Get(string(bz), denomCondition).Float() +} + +func (tr Commands) GetBalance(chain ChainID, validator ValidatorID) uint { + valCfg := tr.ValidatorConfigs[validator] + valDelAddress := valCfg.DelAddress + if chain != ChainID("provi") { + // use binary with Bech32Prefix set to ConsumerAccountPrefix + if valCfg.UseConsumerKey { + valDelAddress = valCfg.ConsumerDelAddress + } else { + // use the same address as on the provider but with different prefix + valDelAddress = valCfg.DelAddressOnConsumer + } + } + + binaryName := tr.ChainConfigs[chain].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + + "query", "bank", "balances", + valDelAddress, + + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal("getBalance() failed: ", cmd, ": ", err, "\n", string(bz)) + } + + amount := gjson.Get(string(bz), `balances.#(denom=="stake").amount`) + + return uint(amount.Uint()) +} + +// interchain-securityd query gov proposals +func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { + var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`) + + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + + "query", "gov", "proposal", + fmt.Sprint(proposal), + + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + + prop := TextProposal{} + + if err != nil { + if noProposalRegex.Match(bz) { + return prop + } + + log.Fatal(err, "\n", string(bz)) + } + + propType := gjson.Get(string(bz), `messages.0.content.@type`).String() + deposit := gjson.Get(string(bz), `total_deposit.#(denom=="stake").amount`).Uint() + status := gjson.Get(string(bz), `status`).String() + + // This is a breaking change in the query output for proposals: bug in SDK?? + proposal_value, exists := gov.ProposalStatus_value[status] + if !exists { + panic("invalid proposal status value: " + status) + } + status = strconv.Itoa(int(proposal_value)) + + chainConfigs := tr.ChainConfigs + containerConfig := tr.ContainerConfig + + switch propType { + case "/cosmos.gov.v1beta1.TextProposal": + title := gjson.Get(string(bz), `content.title`).String() + description := gjson.Get(string(bz), `content.description`).String() + + return TextProposal{ + Deposit: uint(deposit), + Status: status, + Title: title, + Description: description, + } + 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(containerConfig.Now) + + var chain ChainID + for i, conf := range chainConfigs { + if string(conf.ChainId) == chainId { + chain = i + break + } + } + + return ConsumerAdditionProposal{ + Deposit: uint(deposit), + Status: status, + Chain: chain, + SpawnTime: int(spawnTime.Milliseconds()), + InitialHeight: clienttypes.Height{ + RevisionNumber: gjson.Get(string(bz), `messages.0.content.initial_height.revision_number`).Uint(), + RevisionHeight: gjson.Get(string(bz), `messages.0.content.initial_height.revision_height`).Uint(), + }, + } + case "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal": + height := gjson.Get(string(bz), `messages.0.content.plan.height`).Uint() + title := gjson.Get(string(bz), `messages.0.content.plan.name`).String() + return UpgradeProposal{ + Deposit: uint(deposit), + Status: status, + UpgradeHeight: height, + Title: title, + Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + } + 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(containerConfig.Now) + + var chain ChainID + for i, conf := range chainConfigs { + if string(conf.ChainId) == chainId { + chain = i + break + } + } + + return ConsumerRemovalProposal{ + Deposit: uint(deposit), + Status: status, + Chain: chain, + StopTime: int(stopTime.Milliseconds()), + } + case "/cosmos.params.v1beta1.ParameterChangeProposal": + return ParamsProposal{ + Deposit: uint(deposit), + Status: status, + Subspace: gjson.Get(string(bz), `messages.0.content.changes.0.subspace`).String(), + Key: gjson.Get(string(bz), `messages.0.content.changes.0.key`).String(), + Value: gjson.Get(string(bz), `messages.0.content.changes.0.value`).String(), + } + } + + log.Fatal("unknown proposal type", string(bz)) + + return nil +} + +func (tr Commands) GetValStakedTokens(chain ChainID, valoperAddress string) uint { + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + + "query", "staking", "validator", + valoperAddress, + + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + amount := gjson.Get(string(bz), `tokens`) + + return uint(amount.Uint()) +} + +func (tr Commands) GetParam(chain ChainID, param Param) string { + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + "query", "params", "subspace", + param.Subspace, + param.Key, + + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + value := gjson.Get(string(bz), `value`) + + return value.String() +} + +// GetConsumerChains returns a list of consumer chains that're being secured by the provider chain, +// determined by querying the provider chain. +func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { + binaryName := tr.ChainConfigs[chain].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + + "query", "provider", "list-consumer-chains", + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ) + + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + arr := gjson.Get(string(bz), "chains").Array() + chains := make(map[ChainID]bool) + for _, c := range arr { + id := c.Get("chain_id").String() + chains[ChainID(id)] = true + } + + return chains +} +func (tr Commands) GetConsumerAddress(consumerChain ChainID, validator ValidatorID) string { + binaryName := tr.ChainConfigs[ChainID("provi")].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + + "query", "provider", "validator-consumer-key", + string(consumerChain), tr.ValidatorConfigs[validator].ValconsAddress, + `--node`, tr.GetQueryNode(ChainID("provi")), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + addr := gjson.Get(string(bz), "consumer_address").String() + return addr +} + +func (tr Commands) GetProviderAddressFromConsumer(consumerChain ChainID, validator ValidatorID) string { + binaryName := tr.ChainConfigs[ChainID("provi")].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + + "query", "provider", "validator-provider-key", + string(consumerChain), tr.ValidatorConfigs[validator].ConsumerValconsAddressOnProvider, + `--node`, tr.GetQueryNode(ChainID("provi")), + `-o`, `json`, + ) + + bz, err := cmd.CombinedOutput() + if err != nil { + log.Println("error running ", cmd) + log.Fatal(err, "\n", string(bz)) + } + + addr := gjson.Get(string(bz), "provider_address").String() + return addr +} + +func (tr Commands) GetSlashMeter() int64 { + binaryName := tr.ChainConfigs[ChainID("provi")].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + + "query", "provider", "throttle-state", + `--node`, tr.GetQueryNode(ChainID("provi")), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + slashMeter := gjson.Get(string(bz), "slash_meter") + return slashMeter.Int() +} + +func (tr Commands) GetRegisteredConsumerRewardDenoms(chain ChainID) []string { + binaryName := tr.ChainConfigs[chain].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + "query", "provider", "registered-consumer-reward-denoms", + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + 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() + } + + return rewardDenoms +} + +func (tr Commands) GetPendingPacketQueueSize(chain ChainID) uint { + binaryName := tr.ChainConfigs[chain].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + "query", "ccvconsumer", "throttle-state", + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ) + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + if !gjson.ValidBytes(bz) { + panic("invalid json response from query ccvconsumer throttle-state: " + string(bz)) + } + + packetData := gjson.Get(string(bz), "packet_data_queue").Array() + return uint(len(packetData)) +} + +func (tr Commands) GetValidatorIP(chain ChainID, validator ValidatorID) string { + return tr.ChainConfigs[chain].IpPrefix + "." + tr.ValidatorConfigs[validator].IpSuffix +} + +// getQueryNode returns query node tcp address on chain. +func (tr Commands) GetQueryNode(chain ChainID) string { + return fmt.Sprintf("tcp://%s", tr.GetQueryNodeRPCAddress(chain)) +} + +func (tr Commands) 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 Commands) 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) + } + return fmt.Sprintf("%s.253", tr.ChainConfigs[chain].IpPrefix) +} + +func (tr Commands) 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` + cmd := tr.Target.ExecCommand("bash", "-c", fmt.Sprintf(cmd_template, method, params, address)) + + verbosity := false + e2e.ExecuteCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) +} + +// GetClientFrozenHeight returns the frozen height for a client with the given client ID +// by querying the hosting chain with the given chainID +func (tr Commands) GetClientFrozenHeight(chain ChainID, clientID string) (uint64, uint64) { + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + //cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[ChainID("provi")].BinaryName, + binaryName := tr.ChainConfigs[ChainID("provi")].BinaryName + cmd := tr.Target.ExecCommand(binaryName, + "query", "ibc", "client", "state", clientID, + `--node`, tr.GetQueryNode(ChainID("provi")), + `-o`, `json`, + ) + + bz, err := cmd.CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + frozenHeight := gjson.Get(string(bz), "client_state.frozen_height") + + revHeight, err := strconv.Atoi(frozenHeight.Get("revision_height").String()) + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + revNumber, err := strconv.Atoi(frozenHeight.Get("revision_number").String()) + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + return uint64(revHeight), uint64(revNumber) +} + +func (tr Commands) GetTrustedHeight( + chain ChainID, + clientID string, + index int, +) (uint64, uint64) { + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + //configureNodeCmd := exec.Command("docker", "exec", tc.testConfig.containerConfig.InstanceName, "hermes", + configureNodeCmd := tr.Target.ExecCommand("hermes", + "--json", "query", "client", "consensus", "--chain", string(chain), + `--client`, clientID, + ) + + cmdReader, err := configureNodeCmd.StdoutPipe() + if err != nil { + log.Fatal(err) + } + + configureNodeCmd.Stderr = configureNodeCmd.Stdout + + if err := configureNodeCmd.Start(); err != nil { + log.Fatal(err) + } + + scanner := bufio.NewScanner(cmdReader) + + var trustedHeight gjson.Result + // iterate on the relayer's response + // and parse the the command "result" + for scanner.Scan() { + out := scanner.Text() + if len(gjson.Get(out, "result").Array()) > 0 { + trustedHeight = gjson.Get(out, "result").Array()[index] + break + } + } + + revHeight, err := strconv.Atoi(trustedHeight.Get("revision_height").String()) + if err != nil { + log.Fatal(err) + } + + revNumber, err := strconv.Atoi(trustedHeight.Get("revision_number").String()) + if err != nil { + log.Fatal(err) + } + return uint64(revHeight), uint64(revNumber) +} + +func (tr Commands) GetProposedConsumerChains(chain ChainID) []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, + binaryName := tr.ChainConfigs[chain].BinaryName + bz, err := tr.Target.ExecCommand(binaryName, + "query", "provider", "list-proposed-consumer-chains", + `--node`, tr.GetQueryNode(chain), + `-o`, `json`, + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + arr := gjson.Get(string(bz), "proposedChains").Array() + chains := []string{} + for _, c := range arr { + cid := c.Get("chainID").String() + chains = append(chains, cid) + } + + return chains +} + +// Breaking forward compatibility +func (tr Commands) GetIBCTransferParams(chain ChainID) IBCTransferParams { + panic("'GetIBCTransferParams' is not implemented in this version") +} + +func (tr Commands) GetHasToValidate(validator ValidatorID) []ChainID { + panic("''GetHasToValidate' is not implemented in this version") +} + +func uintPtr(i uint) *uint { + return &i +} diff --git a/tests/integration/changeover.go b/tests/integration/changeover.go index bd94857598..3c258dfc24 100644 --- a/tests/integration/changeover.go +++ b/tests/integration/changeover.go @@ -1,8 +1,8 @@ package integration import ( - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) func (suite *CCVTestSuite) TestRecycleTransferChannel() { diff --git a/tests/integration/common.go b/tests/integration/common.go index 18b657ae56..cc8a0e86a5 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -4,12 +4,12 @@ import ( "fmt" "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" - "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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" "cosmossdk.io/math" @@ -22,10 +22,10 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // ChainType defines the type of chain (either provider or consumer) @@ -54,7 +54,7 @@ func (s *CCVTestSuite) consumerCtx() sdk.Context { return s.consumerChain.GetContext() } -func (s *CCVTestSuite) providerBondDenom() string { +func (s *CCVTestSuite) providerBondDenom() (string, error) { return s.providerApp.GetTestStakingKeeper().BondDenom(s.providerCtx()) } @@ -67,8 +67,8 @@ func (s *CCVTestSuite) getValByIdx(index int) (validator stakingtypes.Validator, } func (s *CCVTestSuite) getVal(ctx sdk.Context, valAddr sdk.ValAddress) stakingtypes.Validator { - validator, found := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), valAddr) - s.Require().True(found) + validator, err := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), valAddr) + s.Require().NoError(err) return validator } @@ -90,7 +90,9 @@ func (s *CCVTestSuite) setDefaultValSigningInfo(tmVal tmtypes.Validator) { } func getBalance(s *CCVTestSuite, providerCtx sdk.Context, delAddr sdk.AccAddress) math.Int { - return s.providerApp.GetTestBankKeeper().GetBalance(providerCtx, delAddr, s.providerBondDenom()).Amount + denom, err := s.providerBondDenom() + s.Require().NoError(err) + return s.providerApp.GetTestBankKeeper().GetBalance(providerCtx, delAddr, denom).Amount } // delegateAndUndelegate delegates bondAmt from delAddr to the first validator @@ -147,12 +149,12 @@ func delegateAndRedelegate(s *CCVTestSuite, delAddr sdk.AccAddress, } // delegate delegates bondAmt to the first validator -func delegate(s *CCVTestSuite, delAddr sdk.AccAddress, bondAmt math.Int) (initBalance math.Int, shares sdk.Dec, valAddr sdk.ValAddress) { +func delegate(s *CCVTestSuite, delAddr sdk.AccAddress, bondAmt math.Int) (initBalance math.Int, shares math.LegacyDec, valAddr sdk.ValAddress) { return delegateByIdx(s, delAddr, bondAmt, 0) } // delegateByIdx delegates bondAmt to the validator at specified index in provider val set -func delegateByIdx(s *CCVTestSuite, delAddr sdk.AccAddress, bondAmt math.Int, idx int) (initBalance math.Int, shares sdk.Dec, valAddr sdk.ValAddress) { +func delegateByIdx(s *CCVTestSuite, delAddr sdk.AccAddress, bondAmt math.Int, idx int) (initBalance math.Int, shares math.LegacyDec, valAddr sdk.ValAddress) { initBalance = getBalance(s, s.providerCtx(), delAddr) // choose a validator validator, valAddr := s.getValByIdx(idx) @@ -172,8 +174,8 @@ func delegateByIdx(s *CCVTestSuite, delAddr sdk.AccAddress, bondAmt math.Int, id } // undelegate unbonds an amount of delegator shares from a given validator -func undelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) (valsetUpdateId uint64) { - _, err := s.providerApp.GetTestStakingKeeper().Undelegate(s.providerCtx(), delAddr, valAddr, sharesAmount) +func undelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount math.LegacyDec) (valsetUpdateId uint64) { + _, _, err := s.providerApp.GetTestStakingKeeper().Undelegate(s.providerCtx(), delAddr, valAddr, sharesAmount) s.Require().NoError(err) // save the current valset update ID @@ -185,7 +187,7 @@ func undelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valAddr sdk.ValAddress, // Executes a BeginRedelegation (unbonding and redelegation) operation // on the provider chain using delegated funds from delAddr func redelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valSrcAddr sdk.ValAddress, - valDstAddr sdk.ValAddress, sharesAmount sdk.Dec, + valDstAddr sdk.ValAddress, sharesAmount math.LegacyDec, ) { stakingKeeper := s.providerApp.GetTestStakingKeeper() ctx := s.providerCtx() @@ -200,10 +202,11 @@ func redelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valSrcAddr sdk.ValAddre ) s.Require().NoError(err) - providerUnbondingPeriod := stakingKeeper.UnbondingTime(ctx) + providerUnbondingPeriod, err := stakingKeeper.UnbondingTime(ctx) + s.Require().NoError(err) - valSrc, found := stakingKeeper.GetValidator(ctx, valSrcAddr) - s.Require().True(found) + valSrc, err := stakingKeeper.GetValidator(ctx, valSrcAddr) + s.Require().NoError(err) // Completion time of redelegation operation will be after unbonding period if source val is bonded if valSrc.IsBonded() { @@ -272,7 +275,7 @@ func relayAllCommittedPackets( s.Require().Equal( expectedPackets, len(commitments), - fmt.Sprintf("actual number of packet commitments does not match expectation; %s", msgAndArgs...), + fmt.Sprintf("actual number of packet commitments does not match expectation; expected: %d - got: %d", expectedPackets, len(commitments)), ) // relay all packets from srcChain to counterparty @@ -287,7 +290,7 @@ func relayAllCommittedPackets( err := path.RelayPacket(packet) s.Require().NoError( err, - fmt.Sprintf("error while relaying packets; %s", msgAndArgs...), + fmt.Sprintf("error while relaying packets; %v", err), ) } } @@ -300,7 +303,8 @@ func relayAllCommittedPackets( // to be one day larger than the consumer unbonding period. func incrementTimeByUnbondingPeriod(s *CCVTestSuite, chainType ChainType) { // Get unboding periods - providerUnbondingPeriod := s.providerApp.GetTestStakingKeeper().UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := s.providerApp.GetTestStakingKeeper().UnbondingTime(s.providerCtx()) + s.Require().NoError(err) consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerCtx()) var jumpPeriod time.Duration if chainType == Provider { @@ -353,8 +357,8 @@ func checkCCVUnbondingOp(s *CCVTestSuite, providerCtx sdk.Context, chainID strin func checkRedelegations(s *CCVTestSuite, delAddr sdk.AccAddress, expect uint16, ) []stakingtypes.Redelegation { - redelegations := s.providerApp.GetTestStakingKeeper().GetRedelegations(s.providerCtx(), delAddr, 2) - + redelegations, err := s.providerApp.GetTestStakingKeeper().GetRedelegations(s.providerCtx(), delAddr, 2) + s.Require().NoError(err) s.Require().Len(redelegations, int(expect)) return redelegations } @@ -367,7 +371,10 @@ func checkRedelegationEntryCompletionTime( } func getStakingUnbondingDelegationEntry(ctx sdk.Context, k testutil.TestStakingKeeper, id uint64) (stakingUnbondingOp stakingtypes.UnbondingDelegationEntry, found bool) { - stakingUbd, found := k.GetUnbondingDelegationByUnbondingID(ctx, id) + stakingUbd, err := k.GetUnbondingDelegationByUnbondingID(ctx, id) + if err != nil { + return + } for _, entry := range stakingUbd.Entries { if entry.UnbondingId == id { @@ -547,11 +554,11 @@ func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unb suite.Require().Equal(exported.Tendermint, endpoint.ClientConfig.GetClientType(), "only Tendermint client supported") tmConfig, ok := endpoint.ClientConfig.(*ibctesting.TendermintConfig) - require.True(endpoint.Chain.T, ok) + require.True(endpoint.Chain.TB, ok) tmConfig.UnbondingPeriod = unbondingPeriod trustPeriod, err := ccv.CalculateTrustPeriod(unbondingPeriod, providertypes.DefaultTrustingPeriodFraction) - require.NoError(endpoint.Chain.T, err) + require.NoError(endpoint.Chain.TB, err) tmConfig.TrustingPeriod = trustPeriod height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height) @@ -565,13 +572,13 @@ func (suite *CCVTestSuite) CreateCustomClient(endpoint *ibctesting.Endpoint, unb msg, err := clienttypes.NewMsgCreateClient( clientState, consensusState, endpoint.Chain.SenderAccount.GetAddress().String(), ) - require.NoError(endpoint.Chain.T, err) + require.NoError(endpoint.Chain.TB, err) res, err := endpoint.Chain.SendMsgs(msg) - require.NoError(endpoint.Chain.T, err) + require.NoError(endpoint.Chain.TB, err) endpoint.ClientID, err = ibctesting.ParseClientIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) + require.NoError(endpoint.Chain.TB, err) } // GetConsumerEndpointClientAndConsState returns the client and consensus state @@ -601,8 +608,8 @@ func (s *CCVTestSuite) setupValidatorPowers(powers []int64) { delAddr := s.providerChain.SenderAccount.GetAddress() s.Require().Equal(len(powers), len(s.providerChain.Vals.Validators)) for idx := range s.providerChain.Vals.Validators { - bondAmt := sdk.NewInt(powers[idx]).Mul(sdk.DefaultPowerReduction) - bondAmt = bondAmt.Sub(sdk.NewInt(1)) // 1 token is bonded during the initial setup + bondAmt := math.NewInt(powers[idx]).Mul(sdk.DefaultPowerReduction) + bondAmt = bondAmt.Sub(math.NewInt(1)) // 1 token is bonded during the initial setup delegateByIdx(s, delAddr, bondAmt, idx) } @@ -611,18 +618,22 @@ func (s *CCVTestSuite) setupValidatorPowers(powers []int64) { stakingKeeper := s.providerApp.GetTestStakingKeeper() expectedTotalPower := int64(0) for idx, val := range s.providerChain.Vals.Validators { - actualPower := stakingKeeper.GetLastValidatorPower(s.providerCtx(), sdk.ValAddress(val.Address)) + actualPower, err := stakingKeeper.GetLastValidatorPower(s.providerCtx(), sdk.ValAddress(val.Address)) + s.Require().NoError(err) s.Require().Equal(powers[idx], actualPower) expectedTotalPower += powers[idx] } - s.Require().Equal(expectedTotalPower, stakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) + + totalPower, err := stakingKeeper.GetLastTotalPower(s.providerCtx()) + s.Require().NoError(err) + s.Require().Equal(expectedTotalPower, totalPower.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) + stakingVal, err := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), sdk.ConsAddress(tmVal.Address)) + s.Require().NoError(err) return stakingVal } diff --git a/tests/integration/democracy.go b/tests/integration/democracy.go index bbada900a8..5fe7e9eb6d 100644 --- a/tests/integration/democracy.go +++ b/tests/integration/democracy.go @@ -3,20 +3,23 @@ package integration import ( "time" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/suite" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + sdkdistrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) type ConsumerDemocracyTestSuite struct { @@ -27,7 +30,7 @@ type ConsumerDemocracyTestSuite struct { setupCallback DemocSetupCallback } -// NewCCVTestSuite returns a new instance of ConsumerDemocracyTestSuite, +// NewConsumerDemocracyTestSuite returns a new instance of ConsumerDemocracyTestSuite, // ready to be tested against using suite.Run(). func NewConsumerDemocracyTestSuite[T testutil.DemocConsumerApp]( democConsumerAppIniter icstestingutils.ValSetAppIniter, @@ -74,100 +77,131 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() { accountKeeper := s.consumerApp.GetTestAccountKeeper() distrKeeper := s.consumerApp.GetTestDistributionKeeper() bankKeeper := s.consumerApp.GetTestBankKeeper() - bondDenom := stakingKeeper.BondDenom(s.consumerCtx()) + bondDenom, err := stakingKeeper.BondDenom(s.consumerCtx()) + s.Require().NoError(err) - currentRepresentativesRewards := map[string]sdk.Dec{} - nextRepresentativesRewards := map[string]sdk.Dec{} + previousRepresentativesRewards := map[string]math.LegacyDec{} + nextRepresentativesRewards := map[string]math.LegacyDec{} representativesTokens := map[string]math.Int{} - for _, representative := range stakingKeeper.GetAllValidators(s.consumerCtx()) { - currentRepresentativesRewards[representative.OperatorAddress] = sdk.NewDec(0) - nextRepresentativesRewards[representative.OperatorAddress] = sdk.NewDec(0) + representatives, err := stakingKeeper.GetAllValidators(s.consumerCtx()) + s.Require().NoError(err) + for _, representative := range representatives { + previousRepresentativesRewards[representative.OperatorAddress] = math.LegacyNewDec(0) + nextRepresentativesRewards[representative.OperatorAddress] = math.LegacyNewDec(0) representativesTokens[representative.OperatorAddress] = representative.GetTokens() } distrModuleAccount := distrKeeper.GetDistributionAccount(s.consumerCtx()) providerRedistributeAccount := accountKeeper.GetModuleAccount(s.consumerCtx(), consumertypes.ConsumerToSendToProviderName) - // balance of consumer redistribute address will always be 0 when checked between 2 NextBlock() calls - - currentDistrModuleAccountBalance := sdk.NewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), distrModuleAccount.GetAddress(), bondDenom).Amount) - currentProviderFeeAccountBalance := sdk.NewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), providerRedistributeAccount.GetAddress(), bondDenom).Amount) - currentCommunityPoolBalance := distrKeeper.GetFeePoolCommunityCoins(s.consumerCtx()).AmountOf(bondDenom) - for key := range currentRepresentativesRewards { + consumerRedistributeAccount := accountKeeper.GetModuleAccount(s.consumerCtx(), consumertypes.ConsumerRedistributeName) + + dk, ok := distrKeeper.(sdkdistrkeeper.Keeper) + s.Require().True(ok) + feePool, err := dk.FeePool.Get(s.consumerCtx()) + s.Require().NoError(err) + s.Require().NotEmpty(feePool) + + // take balance of relevant accounts before advancing to the next block + previousDistrModuleAccountBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), distrModuleAccount.GetAddress(), bondDenom).Amount) + previousProviderFeeAccountBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), providerRedistributeAccount.GetAddress(), bondDenom).Amount) + previousConsumerRedistributeBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), consumerRedistributeAccount.GetAddress(), bondDenom).Amount) + previousCommunityPoolBalance := feePool.GetCommunityPool().AmountOf(bondDenom) + for key := range previousRepresentativesRewards { representativeAddr, _ := sdk.ValAddressFromBech32(key) - representativeReward := distrKeeper.GetValidatorOutstandingRewards(s.consumerCtx(), representativeAddr).Rewards.AmountOf(bondDenom) - currentRepresentativesRewards[key] = representativeReward + representativeReward, err := distrKeeper.GetValidatorOutstandingRewards(s.consumerCtx(), representativeAddr) + s.Require().NoError(err) + previousRepresentativesRewards[key] = representativeReward.Rewards.AmountOf(bondDenom) } + // NextBlock will call the begin block and end block, respectively. Democracy module in the begin blocker sends the tokens from + // the consumer redistribute address to the distribution module, giving representatives and community fee pool its portion of rewards. + // Consumer module in endblocker, sends the fees from fee collector(auth module) to the consumer redistribute address and to + // provider rewards address s.consumerChain.NextBlock() - nextDistrModuleAccountBalance := sdk.NewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), distrModuleAccount.GetAddress(), bondDenom).Amount) - nextProviderFeeAccountBalance := sdk.NewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), providerRedistributeAccount.GetAddress(), bondDenom).Amount) - nextCommunityPoolBalance := distrKeeper.GetFeePoolCommunityCoins(s.consumerCtx()).AmountOf(bondDenom) + // take balance of relevant accounts after new block is created + nextDistrModuleAccountBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), distrModuleAccount.GetAddress(), bondDenom).Amount) + nextProviderFeeAccountBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), providerRedistributeAccount.GetAddress(), bondDenom).Amount) + nextConsumerRedistributeBalance := math.LegacyNewDecFromInt(bankKeeper.GetBalance(s.consumerCtx(), consumerRedistributeAccount.GetAddress(), bondDenom).Amount) + feePool, err = dk.FeePool.Get(s.consumerCtx()) + s.Require().NoError(err) + s.Require().NotEmpty(feePool) + nextCommunityPoolBalance := feePool.GetCommunityPool().AmountOf(bondDenom) for key := range nextRepresentativesRewards { representativeAddr, _ := sdk.ValAddressFromBech32(key) - representativeReward := distrKeeper.GetValidatorOutstandingRewards(s.consumerCtx(), representativeAddr).Rewards.AmountOf(bondDenom) - nextRepresentativesRewards[key] = representativeReward + representativeReward, err := distrKeeper.GetValidatorOutstandingRewards(s.consumerCtx(), representativeAddr) + s.Require().NoError(err) + nextRepresentativesRewards[key] = representativeReward.Rewards.AmountOf(bondDenom) } - distrModuleDifference := nextDistrModuleAccountBalance.Sub(currentDistrModuleAccountBalance) - providerDifference := nextProviderFeeAccountBalance.Sub(currentProviderFeeAccountBalance) - communityPoolDifference := nextCommunityPoolBalance.Sub(currentCommunityPoolBalance) - representativeDifference := map[string]sdk.Dec{} - consumerRedistributeDifference := communityPoolDifference - - for key, currentReward := range currentRepresentativesRewards { - representativeDifference[key] = nextRepresentativesRewards[key].Sub(currentReward) - consumerRedistributeDifference = consumerRedistributeDifference.Add(representativeDifference[key]) + distrModuleDifference := nextDistrModuleAccountBalance.Sub(previousDistrModuleAccountBalance) + providerDifference := nextProviderFeeAccountBalance.Sub(previousProviderFeeAccountBalance) + communityPoolDifference := nextCommunityPoolBalance.Sub(previousCommunityPoolBalance) + representativeDifference := map[string]math.LegacyDec{} + totalRepresentativeDifference := math.LegacyZeroDec() + for key, currentReward := range previousRepresentativesRewards { + diff := nextRepresentativesRewards[key].Sub(currentReward) + representativeDifference[key] = diff + totalRepresentativeDifference = totalRepresentativeDifference.Add(diff) } - consumerRedistributionFraction := sdk.MustNewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) - - // confirm that the total amount given to the community pool plus all representatives is equal to the total amount taken out of distribution - s.Require().Equal(distrModuleDifference, consumerRedistributeDifference) + // confirm endblocker changes: consumer module distributes fees from fee collector to consumer redistribute address + // and address aimed for provider rewards + consumerRedistributionFraction := math.LegacyMustNewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) + // since we cannot know the balance of the fee collector when the consumer module transfers the fees, we can only calculate the total fees + // as a sum of the provider and consumer rewards and check if the reward is distributed in the expected proportion + totalFees := nextConsumerRedistributeBalance.Add(providerDifference) + s.Require().Equal(totalFees.Mul(consumerRedistributionFraction), nextConsumerRedistributeBalance) + + // confirm begin blocker changes: democracy module distributes the fees from c onsumer redistribute address to representatives + // and community fee pool + // distribution module got tokens from previous consumer redistribute balance + s.Require().Equal(distrModuleDifference, previousConsumerRedistributeBalance) // confirm that the percentage given to the community pool is equal to the configured community tax percentage. - s.Require().Equal(communityPoolDifference.Quo(consumerRedistributeDifference), - distrKeeper.GetCommunityTax(s.consumerCtx())) - // check that the fraction actually kept by the consumer is the correct fraction. using InEpsilon because the math code uses truncations - s.Require().InEpsilon(distrModuleDifference.Quo( - providerDifference.Add(distrModuleDifference)).MustFloat64(), - consumerRedistributionFraction.MustFloat64(), float64(0.0001)) - // check that the fraction actually kept by the provider is the correct fraction. using InEpsilon because the math code uses truncations - s.Require().InEpsilon(providerDifference.Quo( - providerDifference.Add(distrModuleDifference)).MustFloat64(), - sdk.NewDec(1).Sub(consumerRedistributionFraction).MustFloat64(), float64(0.0001)) - - totalRepresentativePower := stakingKeeper.GetValidatorSet().TotalBondedTokens(s.consumerCtx()) + tax, err := distrKeeper.GetCommunityTax(s.consumerCtx()) + s.Require().NoError(err) + + s.Require().Equal(communityPoolDifference.Quo(previousConsumerRedistributeBalance), tax) + // confirm that the total amount given to the community pool plus all representatives is equal to the previous consumer redistribute balance + s.Require().Equal(previousConsumerRedistributeBalance, communityPoolDifference.Add(totalRepresentativeDifference)) // check that each representative has gotten the correct amount of rewards + totalRepresentativePower, err := stakingKeeper.GetValidatorSet().TotalBondedTokens(s.consumerCtx()) + s.Require().NoError(err) + for key, representativeTokens := range representativesTokens { - powerFraction := sdk.NewDecFromInt(representativeTokens).QuoTruncate(sdk.NewDecFromInt(totalRepresentativePower)) - s.Require().Equal(powerFraction, representativeDifference[key].Quo(consumerRedistributeDifference.Sub(communityPoolDifference))) + powerFraction := math.LegacyNewDecFromInt(representativeTokens).QuoTruncate(math.LegacyNewDecFromInt(totalRepresentativePower)) + s.Require().Equal(powerFraction, representativeDifference[key].Quo(previousConsumerRedistributeBalance.Sub(communityPoolDifference))) } } func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { govKeeper := s.consumerApp.GetTestGovKeeper() - params := govKeeper.GetParams(s.consumerCtx()) + params, err := govKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + stakingKeeper := s.consumerApp.GetTestStakingKeeper() bankKeeper := s.consumerApp.GetTestBankKeeper() accountKeeper := s.consumerApp.GetTestAccountKeeper() mintKeeper := s.consumerApp.GetTestMintKeeper() newAuthParamValue := uint64(128) - newMintParamValue := sdk.NewDecWithPrec(1, 1) // "0.100000000000000000" + newMintParamValue := math.LegacyNewDecWithPrec(1, 1) // "0.100000000000000000" votingAccounts := s.consumerChain.SenderAccounts - bondDenom := stakingKeeper.BondDenom(s.consumerCtx()) + bondDenom, err := stakingKeeper.BondDenom(s.consumerCtx()) + s.Require().NoError(err) depositAmount := params.MinDeposit duration := (3 * time.Second) params.VotingPeriod = &duration - err := govKeeper.SetParams(s.consumerCtx(), params) + err = govKeeper.Params.Set(s.consumerCtx(), params) s.Assert().NoError(err) proposer := s.consumerChain.SenderAccount s.consumerChain.NextBlock() votersOldBalances := getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts) // submit proposal with forbidden and allowed changes - mintParams := mintKeeper.GetParams(s.consumerCtx()) + mintParams, err := mintKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) mintParams.InflationMax = newMintParamValue msg_1 := &minttypes.MsgUpdateParams{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -184,14 +218,17 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { // set current header time to be equal or later than voting end time in order to process proposal from active queue, // once the proposal is added to the chain s.consumerChain.CurrentHeader.Time = s.consumerChain.CurrentHeader.Time.Add(*params.VotingPeriod) - s.consumerChain.NextBlock() // at this moment, proposal is added, but not yet executed. we are saving old param values for comparison oldAuthParamValue := accountKeeper.GetParams(s.consumerCtx()).MaxMemoCharacters - oldMintParamValue := mintKeeper.GetParams(s.consumerCtx()).InflationMax + oldMintParams, err := mintKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + oldMintParamValue := oldMintParams.InflationMax s.consumerChain.NextBlock() // at this moment, proposal is executed or deleted if forbidden currentAuthParamValue := accountKeeper.GetParams(s.consumerCtx()).MaxMemoCharacters - currentMintParamValue := mintKeeper.GetParams(s.consumerCtx()).InflationMax + currentMintParam, err := mintKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + currentMintParamValue := currentMintParam.InflationMax // check that parameters are not changed, since the proposal contained both forbidden and allowed changes s.Assert().Equal(oldAuthParamValue, currentAuthParamValue) s.Assert().NotEqual(newAuthParamValue, currentAuthParamValue) @@ -204,10 +241,14 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { err = submitProposalWithDepositAndVote(govKeeper, s.consumerCtx(), []sdk.Msg{msg_1}, votingAccounts, proposer.GetAddress(), depositAmount) s.Assert().NoError(err) s.consumerChain.CurrentHeader.Time = s.consumerChain.CurrentHeader.Time.Add(*params.VotingPeriod) + oldMintParam, err := mintKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + oldMintParamValue = oldMintParam.InflationMax s.consumerChain.NextBlock() - oldMintParamValue = mintKeeper.GetParams(s.consumerCtx()).InflationMax - s.consumerChain.NextBlock() - currentMintParamValue = mintKeeper.GetParams(s.consumerCtx()).InflationMax + currentMintParam, err = mintKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + + currentMintParamValue = currentMintParam.InflationMax // check that parameters are changed, since the proposal contained only allowed changes s.Assert().Equal(newMintParamValue, currentMintParamValue) s.Assert().NotEqual(oldMintParamValue, currentMintParamValue) @@ -230,10 +271,58 @@ func (s *ConsumerDemocracyTestSuite) TestDemocracyGovernanceWhitelisting() { s.Assert().Equal(votersOldBalances, getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts)) } -func submitProposalWithDepositAndVote(govKeeper testutil.TestGovKeeper, ctx sdk.Context, msgs []sdk.Msg, +func (s *ConsumerDemocracyTestSuite) TestDemocracyMsgUpdateParams() { + govKeeper := s.consumerApp.GetTestGovKeeper() + params, err := govKeeper.Params.Get(s.consumerCtx()) + s.Require().NoError(err) + + stakingKeeper := s.consumerApp.GetTestStakingKeeper() + bankKeeper := s.consumerApp.GetTestBankKeeper() + votingAccounts := s.consumerChain.SenderAccounts + bondDenom, err := stakingKeeper.BondDenom(s.consumerCtx()) + s.Require().NoError(err) + depositAmount := params.MinDeposit + duration := (3 * time.Second) + params.VotingPeriod = &duration + err = govKeeper.Params.Set(s.consumerCtx(), params) + s.Assert().NoError(err) + proposer := s.consumerChain.SenderAccount + s.consumerChain.NextBlock() + votersOldBalances := getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts) + + oldParams := s.consumerApp.GetConsumerKeeper().GetConsumerParams(s.consumerCtx()) + modifiedParams := oldParams + modifiedParams.RetryDelayPeriod = 7200 * time.Second + s.Require().NotEqual(oldParams.RetryDelayPeriod, modifiedParams.RetryDelayPeriod) + + msg := &consumertypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Params: modifiedParams, + } + + err = submitProposalWithDepositAndVote(govKeeper, s.consumerCtx(), []sdk.Msg{msg}, votingAccounts, proposer.GetAddress(), depositAmount) + s.Assert().NoError(err) + // set current header time to be equal or later than voting end time in order to process proposal from active queue, + // once the proposal is added to the chain + s.consumerChain.CurrentHeader.Time = s.consumerChain.CurrentHeader.Time.Add(*params.VotingPeriod) + + s.consumerChain.NextBlock() + + newParams := s.consumerApp.GetConsumerKeeper().GetConsumerParams(s.consumerCtx()) + s.Assert().NotEqual(oldParams, newParams) + s.Assert().Equal(modifiedParams, newParams) + s.Assert().NotEqual(oldParams.RetryDelayPeriod, newParams.RetryDelayPeriod) + s.Assert().Equal(modifiedParams.RetryDelayPeriod, newParams.RetryDelayPeriod) + + // deposit is refunded + s.Assert().Equal(votersOldBalances, getAccountsBalances(s.consumerCtx(), bankKeeper, bondDenom, votingAccounts)) + +} + +func submitProposalWithDepositAndVote(govKeeper govkeeper.Keeper, ctx sdk.Context, msgs []sdk.Msg, accounts []ibctesting.SenderAccount, proposer sdk.AccAddress, depositAmount sdk.Coins, ) error { - proposal, err := govKeeper.SubmitProposal(ctx, msgs, "", "title", "summary", proposer) + proposal, err := govKeeper.SubmitProposal(ctx, msgs, "", "title", "summary", proposer, false) if err != nil { return err } diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go index 2bea909c75..2e5f2f0bbb 100644 --- a/tests/integration/distribution.go +++ b/tests/integration/distribution.go @@ -3,24 +3,21 @@ package integration import ( "strings" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - abci "github.com/cometbft/cometbft/abci/types" - - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/integration" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + sdk "github.com/cosmos/cosmos-sdk/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/integration" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // This test is valid for minimal viable consumer chain @@ -28,7 +25,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // set up channel and delegate some tokens in order for validator set update to be sent to the consumer chain s.SetupCCVChannel(s.path) s.SetupTransferChannel() - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) s.nextEpoch() @@ -42,8 +39,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { relayAllCommittedPackets(s, s.providerChain, s.path, ccv.ProviderPortID, s.path.EndpointB.ChannelID, 1) // reward for the provider chain will be sent after each 2 blocks - consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(2)) + s.consumerApp.GetConsumerKeeper().SetBlocksPerDistributionTransmission(s.consumerCtx(), 2) s.consumerChain.NextBlock() consumerAccountKeeper := s.consumerApp.GetTestAccountKeeper() @@ -56,15 +52,15 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // send coins to the fee pool which is used for reward distribution consumerFeePoolAddr := consumerAccountKeeper.GetModuleAccount(s.consumerCtx(), authtypes.FeeCollectorName).GetAddress() feePoolTokensOld := consumerBankKeeper.GetAllBalances(s.consumerCtx(), consumerFeePoolAddr) - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) err := consumerBankKeeper.SendCoinsFromAccountToModule(s.consumerCtx(), s.consumerChain.SenderAccount.GetAddress(), authtypes.FeeCollectorName, fees) s.Require().NoError(err) feePoolTokens := consumerBankKeeper.GetAllBalances(s.consumerCtx(), consumerFeePoolAddr) - s.Require().Equal(sdk.NewInt(100).Add(feePoolTokensOld.AmountOf(sdk.DefaultBondDenom)), feePoolTokens.AmountOf(sdk.DefaultBondDenom)) + s.Require().Equal(math.NewInt(100).Add(feePoolTokensOld.AmountOf(sdk.DefaultBondDenom)), feePoolTokens.AmountOf(sdk.DefaultBondDenom)) // calculate the reward for consumer and provider chain. Consumer will receive ConsumerRedistributeFrac, the rest is going to provider - frac, err := sdk.NewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) + frac, err := math.LegacyNewDecFromStr(s.consumerApp.GetConsumerKeeper().GetConsumerRedistributionFrac(s.consumerCtx())) s.Require().NoError(err) consumerExpectedRewards, _ := sdk.NewDecCoinsFromCoins(feePoolTokens...).MulDec(frac).TruncateDecimal() providerExpectedRewards := feePoolTokens.Sub(consumerExpectedRewards...) @@ -130,19 +126,27 @@ func (s *CCVTestSuite) TestRewardsDistribution() { consumerValsOutstandingRewardsFunc := func(ctx sdk.Context) sdk.DecCoins { totalRewards := sdk.DecCoins{} for _, v := range providerKeeper.GetConsumerValSet(ctx, s.consumerChain.ChainID) { - val, ok := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(ctx, sdk.ConsAddress(v.ProviderConsAddr)) - s.Require().True(ok) - valReward := providerDistributionKeeper.GetValidatorOutstandingRewards(ctx, val.GetOperator()) + val, err := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(ctx, sdk.ConsAddress(v.ProviderConsAddr)) + s.Require().NoError(err) + valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) + s.Require().NoError(err) + valReward, _ := providerDistributionKeeper.GetValidatorOutstandingRewards(ctx, valAddr) totalRewards = totalRewards.Add(valReward.Rewards...) } return totalRewards } consuValsRewards := consumerValsOutstandingRewardsFunc(s.providerCtx()) - // Save community pool balance - communityPool := providerDistributionKeeper.GetFeePoolCommunityCoins(s.providerCtx()) + // increase the block height so validators are eligible for consumer rewards (see `IsEligibleForConsumerRewards`) + numberOfBlocksToStartReceivingRewards := + providerKeeper.GetNumberOfEpochsToStartReceivingRewards(s.providerCtx()) * providerKeeper.GetBlocksPerEpoch(s.providerCtx()) + + for s.providerCtx().BlockHeight() <= numberOfBlocksToStartReceivingRewards { + s.providerChain.NextBlock() + } - // Transfer rewards from consumer to provider + // Transfer rewards from consumer to provider and distribute rewards to + // validators and community pool by calling BeginBlockRD relayAllCommittedPackets( s, s.consumerChain, @@ -152,24 +156,30 @@ func (s *CCVTestSuite) TestRewardsDistribution() { 1, ) - // Check that the consumer rewards allocation are empty since relayAllCommittedPackets calls BeginBlockRD, - // which in turns calls AllocateTokens. + // Consumer allocations are distributed between the validators and the community pool. + // The decimals resulting from the distribution are expected to remain in the consumer allocations. rewardsAlloc := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.consumerChain.ChainID) - s.Require().Empty(rewardsAlloc.Rewards) + remainingAlloc := rewardsAlloc.Rewards.AmountOf(rewardsIBCdenom) + s.Require().True(remainingAlloc.LTE(math.LegacyOneDec())) - // Check that the reward pool still holds the coins from the first transfer, + // Check that the reward pool still holds the coins from the first transfer // which were never allocated since they were not whitelisted + // plus the remaining decimals from the second transfer. rewardCoins = providerBankKeeper.GetAllBalances(s.providerCtx(), rewardPool) - s.Require().Equal(rewardCoins.AmountOf(rewardsIBCdenom), providerExpRewardsAmount) + s.Require().Equal( + math.LegacyNewDecFromInt(rewardCoins.AmountOf(rewardsIBCdenom)), + math.LegacyNewDecFromInt(providerExpRewardsAmount).Add(remainingAlloc), + ) - // Check that summing the rewards received by the consumer validators and the community pool - // is equal to the expected provider rewards + // Check that the distribution module account balance is equal to the consumer rewards consuValsRewardsReceived := consumerValsOutstandingRewardsFunc(s.providerCtx()).Sub(consuValsRewards) - communityPoolDelta := providerDistributionKeeper.GetFeePoolCommunityCoins(s.providerCtx()).Sub(communityPool) + distrAcct := providerDistributionKeeper.GetDistributionAccount(s.providerCtx()) + distrAcctBalance := providerBankKeeper.GetAllBalances(s.providerCtx(), distrAcct.GetAddress()) s.Require().Equal( - sdk.NewDecFromInt(providerExpRewardsAmount), - consuValsRewardsReceived.AmountOf(rewardsIBCdenom).Add(communityPoolDelta.AmountOf(rewardsIBCdenom)), + // ceil the total consumer rewards since the validators allocation use some rounding + consuValsRewardsReceived.AmountOf(rewardsIBCdenom).Ceil(), + math.LegacyNewDecFromInt(distrAcctBalance.AmountOf(rewardsIBCdenom)), ) } @@ -180,7 +190,7 @@ func (s *CCVTestSuite) TestSendRewardsRetries() { // ccv and transmission channels setup s.SetupCCVChannel(s.path) s.SetupTransferChannel() - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) s.nextEpoch() @@ -197,11 +207,10 @@ func (s *CCVTestSuite) TestSendRewardsRetries() { consumerKeeper := s.consumerApp.GetConsumerKeeper() // reward for the provider chain will be sent after each 1000 blocks - consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(1000)) + s.consumerApp.GetConsumerKeeper().SetBlocksPerDistributionTransmission(s.consumerCtx(), 1000) // fill fee pool - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) err := consumerBankKeeper.SendCoinsFromAccountToModule(s.consumerCtx(), s.consumerChain.SenderAccount.GetAddress(), authtypes.FeeCollectorName, fees) s.Require().NoError(err) @@ -309,7 +318,7 @@ func (s *CCVTestSuite) TestEndBlockRD() { // ccv and transmission channels setup s.SetupCCVChannel(s.path) s.SetupTransferChannel() - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) s.nextEpoch() @@ -327,11 +336,10 @@ func (s *CCVTestSuite) TestEndBlockRD() { consumerBankKeeper := s.consumerApp.GetTestBankKeeper() // reward for the provider chain will be sent after each 1000 blocks - consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(1000)) + s.consumerApp.GetConsumerKeeper().SetBlocksPerDistributionTransmission(s.consumerCtx(), 1000) // fill fee pool - fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) + fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) err := consumerBankKeeper.SendCoinsFromAccountToModule(s.consumerCtx(), s.consumerChain.SenderAccount.GetAddress(), authtypes.FeeCollectorName, fees) s.Require().NoError(err) @@ -394,7 +402,7 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() { ctx, s.consumerChain.SenderAccount.GetAddress(), consumertypes.ConsumerToSendToProviderName, - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))), ) s.Require().NoError(err) }, @@ -448,7 +456,7 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() { ctx, s.consumerChain.SenderAccount.GetAddress(), consumertypes.ConsumerToSendToProviderName, - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))), ) s.Require().NoError(err) }, @@ -471,7 +479,7 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() { ctx, s.consumerChain.SenderAccount.GetAddress(), consumertypes.ConsumerToSendToProviderName, - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))), ) s.Require().NoError(err) }, @@ -485,7 +493,7 @@ func (s *CCVTestSuite) TestSendRewardsToProvider() { // ccv channels setup s.SetupCCVChannel(s.path) - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) s.providerChain.NextBlock() @@ -607,7 +615,7 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() { providerKeeper := s.providerApp.GetProviderKeeper() bankKeeper := s.providerApp.GetTestBankKeeper() - amount := sdk.NewInt(100) + amount := math.NewInt(100) data = transfertypes.NewFungibleTokenPacketData( // can be explicitly changed in setup sdk.DefaultBondDenom, @@ -702,12 +710,18 @@ func (s *CCVTestSuite) TestAllocateTokens() { providerKeeper := s.providerApp.GetProviderKeeper() bankKeeper := s.providerApp.GetTestBankKeeper() distributionKeeper := s.providerApp.GetTestDistributionKeeper() + accountKeeper := s.providerApp.GetTestAccountKeeper() + + getDistrAcctBalFn := func(ctx sdk.Context) sdk.DecCoins { + bal := bankKeeper.GetAllBalances(ctx, accountKeeper.GetModuleAccount(ctx, distrtypes.ModuleName).GetAddress()) + return sdk.NewDecCoinsFromCoins(bal...) + } - totalRewards := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))} + totalRewards := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))} // increase the block height so validators are eligible for consumer rewards (see `IsEligibleForConsumerRewards`) - numberOfBlocksToStartReceivingRewards := - providerKeeper.GetNumberOfEpochsToStartReceivingRewards(s.providerCtx()) * providerKeeper.GetBlocksPerEpoch(s.providerCtx()) + numberOfBlocksToStartReceivingRewards := providerKeeper.GetNumberOfEpochsToStartReceivingRewards( + s.providerCtx()) * providerKeeper.GetBlocksPerEpoch(s.providerCtx()) providerCtx := s.providerCtx().WithBlockHeight(numberOfBlocksToStartReceivingRewards + s.providerCtx().BlockHeight()) // fund consumer rewards pool @@ -719,193 +733,72 @@ func (s *CCVTestSuite) TestAllocateTokens() { ) // Allocate rewards evenly between consumers - rewardsPerConsumer := totalRewards.QuoInt(math.NewInt(int64(len(s.consumerBundles)))) + rewardsPerChain := totalRewards.QuoInt(math.NewInt(int64(len(s.consumerBundles)))) for chainID := range s.consumerBundles { // update consumer allocation providerKeeper.SetConsumerRewardsAllocation( providerCtx, chainID, providertypes.ConsumerRewardsAllocation{ - Rewards: sdk.NewDecCoinsFromCoins(rewardsPerConsumer...), + Rewards: sdk.NewDecCoinsFromCoins(rewardsPerChain...), }, ) } - // Iterate over the validators and - // store their current voting power and outstanding rewards - lastValOutRewards := map[string]sdk.DecCoins{} - votes := []abci.VoteInfo{} + // iterate over the validators and verify that no validator has outstanding rewards + totalValsRewards := sdk.DecCoins{} for _, val := range s.providerChain.Vals.Validators { - votes = append(votes, - abci.VoteInfo{ - Validator: abci.Validator{Address: val.Address, Power: val.VotingPower}, - SignedLastBlock: true, - }, - ) - - valRewards := distributionKeeper.GetValidatorOutstandingRewards(providerCtx, sdk.ValAddress(val.Address)) - lastValOutRewards[sdk.ValAddress(val.Address).String()] = valRewards.Rewards + valRewards, err := distributionKeeper.GetValidatorOutstandingRewards(providerCtx, sdk.ValAddress(val.Address)) + s.Require().NoError(err) + totalValsRewards = totalValsRewards.Add(valRewards.Rewards...) } - // store community pool balance - lastCommPool := distributionKeeper.GetFeePoolCommunityCoins(providerCtx) + s.Require().True(totalValsRewards.IsZero()) + + // At this point the distribution module account + // only holds the community pool's tokens + // since there are no validators with outstanding rewards + lastCommPool := getDistrAcctBalFn(providerCtx) // execute BeginBlock to trigger the token allocation - providerKeeper.BeginBlockRD( - providerCtx, - abci.RequestBeginBlock{ - LastCommitInfo: abci.CommitInfo{ - Votes: votes, - }, - }, - ) + providerKeeper.BeginBlockRD(providerCtx) valNum := len(s.providerChain.Vals.Validators) - consuNum := len(s.consumerBundles) + consNum := len(s.consumerBundles) // compute the expected validators token allocation by subtracting the community tax - rewardsPerConsumerDec := sdk.NewDecCoinsFromCoins(rewardsPerConsumer...) - communityTax := distributionKeeper.GetCommunityTax(providerCtx) - validatorsExpRewards := rewardsPerConsumerDec. - MulDecTruncate(math.LegacyOneDec().Sub(communityTax)). - // multiply by the number of consumers since all the validators opted in - MulDec(sdk.NewDec(int64(consuNum))) - perValExpReward := validatorsExpRewards.QuoDec(sdk.NewDec(int64(valNum))) + rewardsPerChainDec := sdk.NewDecCoinsFromCoins(rewardsPerChain...) + communityTax, err := distributionKeeper.GetCommunityTax(providerCtx) + s.Require().NoError(err) + + rewardsPerChainTrunc, _ := rewardsPerChainDec. + MulDecTruncate(math.LegacyOneDec().Sub(communityTax)).TruncateDecimal() + validatorsExpRewardsPerChain := sdk.NewDecCoinsFromCoins(rewardsPerChainTrunc...).QuoDec(math.LegacyNewDec(int64(valNum))) + // multiply by the number of consumers + validatorsExpRewards := validatorsExpRewardsPerChain.MulDec(math.LegacyNewDec(int64(consNum))) // verify the validator tokens allocation // note that the validators have the same voting power to keep things simple for _, val := range s.providerChain.Vals.Validators { - valRewards := distributionKeeper.GetValidatorOutstandingRewards(providerCtx, sdk.ValAddress(val.Address)) + valRewards, err := distributionKeeper.GetValidatorOutstandingRewards(providerCtx, sdk.ValAddress(val.Address)) + s.Require().NoError(err) + s.Require().Equal( valRewards.Rewards, - lastValOutRewards[sdk.ValAddress(val.Address).String()].Add(perValExpReward...), + validatorsExpRewards, ) } - commPoolExpRewards := sdk.NewDecCoinsFromCoins(totalRewards...).Sub(validatorsExpRewards) - currCommPool := distributionKeeper.GetFeePoolCommunityCoins(providerCtx) - - s.Require().Equal(currCommPool, (lastCommPool.Add(commPoolExpRewards...))) -} - -// TestAllocateTokens is a unit-test for TransferConsumerRewardsToDistributionModule() -// but is written as an integration test to avoid excessive mocking. -func (s *CCVTestSuite) TransferConsumerRewardsToDistributionModule() { - testCases := []struct { - name string - rewardsPool sdk.Coins - rewardsAlloc sdk.DecCoins - expErr bool - }{ - { - "empty consumer rewards pool", - sdk.Coins{}, - sdk.DecCoins{}, - false, - }, - { - "empty consumer allocation", - sdk.Coins{ - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - }, - sdk.DecCoins{}, - false, - }, - { - "equal consumer rewards pool and allocation", - sdk.Coins{ - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - }, - sdk.DecCoins{ - sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - }, - false, - }, - { - "less consumer rewards than allocation", - sdk.Coins{ - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(90)), - }, - sdk.DecCoins{ - sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - }, - true, - }, - { - "remaining consumer rewards allocation", - sdk.Coins{ - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - }, - sdk.DecCoins{ - sdk.DecCoin{ - Denom: sdk.DefaultBondDenom, - Amount: sdk.NewDecWithPrec(995, 1), - }, - }, - false, - }, - } - - providerKeeper := s.providerApp.GetProviderKeeper() - bankKeeper := s.providerApp.GetTestBankKeeper() - distributionKeeper := s.providerApp.GetTestDistributionKeeper() + // check that the total expected rewards are transferred to the distribution module account - chainID := s.consumerChain.ChainID + // store the decimal remainders in the consumer reward allocations + allocRemainderPerChain := providerKeeper.GetConsumerRewardsAllocation(providerCtx, s.consumerChain.ChainID).Rewards - for _, tc := range testCases { - s.Run(tc.name, func() { - ctx, _ := s.providerCtx().CacheContext() - // fund consumer rewards pool - bankKeeper.SendCoinsFromAccountToModule( - ctx, - s.providerChain.SenderAccount.GetAddress(), - providertypes.ConsumerRewardsPool, - tc.rewardsPool, - ) + // compute the total rewards distributed to the distribution module balance (validator outstanding rewards + community pool tax), + totalRewardsDistributed := sdk.NewDecCoinsFromCoins(totalRewards...).Sub(allocRemainderPerChain.MulDec(math.LegacyNewDec(int64(consNum)))) - // update consumer rewars allocation - providerKeeper.SetConsumerRewardsAllocation( - ctx, - chainID, - providertypes.ConsumerRewardsAllocation{ - Rewards: tc.rewardsAlloc, - }, - ) - - // store pool balance - oldPool := bankKeeper.GetAllBalances( - ctx, - distributionKeeper.GetDistributionAccount(ctx).GetAddress(), - ) - - // transfer consumer rewars to distribution module - coinsTransferred, err := providerKeeper.TransferConsumerRewardsToDistributionModule( - ctx, - chainID, - ) - if tc.expErr { - s.Require().Error(err) - return - } - - // check remaining consumer rewards allocation - expCoinTransferred, expRemaining := tc.rewardsAlloc.TruncateDecimal() - s.Require().Equal(expCoinTransferred, coinsTransferred) - - s.Require().Equal( - expRemaining, - providerKeeper.GetConsumerRewardsAllocation(ctx, chainID).Rewards, - ) - - // check updated consuemer rewards pool balance - newPool := bankKeeper.GetAllBalances( - ctx, - distributionKeeper.GetDistributionAccount(ctx).GetAddress(), - ) - - s.Require().Equal(newPool.Sub(oldPool...), coinsTransferred) - }) - } + // compare the expected total rewards against the distribution module balance + s.Require().Equal(lastCommPool.Add(totalRewardsDistributed...), getDistrAcctBalFn(providerCtx)) } // getEscrowBalance gets the current balances in the escrow account holding the transferred tokens to the provider @@ -951,33 +844,33 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { name string consuValLen int tokens sdk.DecCoins - rate sdk.Dec + rate math.LegacyDec expAllocated sdk.DecCoins }{ { name: "tokens are empty", tokens: sdk.DecCoins{}, - rate: sdk.ZeroDec(), + rate: math.LegacyZeroDec(), expAllocated: nil, }, { name: "consumer valset is empty - total voting power is zero", tokens: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(100_000))}, - rate: sdk.ZeroDec(), + rate: math.LegacyZeroDec(), expAllocated: nil, }, { name: "expect all tokens to be allocated to a single validator", consuValLen: 1, tokens: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(999))}, - rate: sdk.NewDecWithPrec(5, 1), + rate: math.LegacyNewDecWithPrec(5, 1), expAllocated: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(999))}, }, { name: "expect tokens to be allocated evenly between validators", consuValLen: 2, tokens: sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))}, - rate: sdk.OneDec(), + rate: math.LegacyOneDec(), expAllocated: sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))}, }, } @@ -1020,20 +913,21 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { if !tc.expAllocated.Empty() { // rewards are expected to be allocated evenly between validators - rewardsPerVal := tc.expAllocated.QuoDec(sdk.NewDec(int64(len(consuVals)))) + rewardsPerVal := tc.expAllocated.QuoDec(math.LegacyNewDec(int64(len(consuVals)))) // check that the rewards are allocated to validators for _, v := range consuVals { valAddr := sdk.ValAddress(v.ProviderConsAddr) - rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( + rewards, err := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( ctx, valAddr, ) + s.Require().NoError(err) s.Require().Equal(rewardsPerVal, rewards.Rewards) // send rewards to the distribution module valRewardsTrunc, _ := rewards.Rewards.TruncateDecimal() - err := bankKeeper.SendCoinsFromAccountToModule( + err = bankKeeper.SendCoinsFromAccountToModule( ctx, s.providerChain.SenderAccount.GetAddress(), distrtypes.ModuleName, @@ -1059,10 +953,11 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { } else { for _, v := range consuVals { valAddr := sdk.ValAddress(v.ProviderConsAddr) - rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( + rewards, err := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( ctx, valAddr, ) + s.Require().NoError(err) s.Require().Zero(rewards.Rewards) } } @@ -1082,7 +977,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida chainID := s.consumerChain.ChainID tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))} - rate := sdk.OneDec() + rate := math.LegacyOneDec() expAllocated := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))} ctx, _ := s.providerCtx().CacheContext() @@ -1129,20 +1024,21 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida s.Require().Equal(expAllocated, res) // rewards are expected to be allocated evenly between validators 3 and 4 - rewardsPerVal := expAllocated.QuoDec(sdk.NewDec(int64(2))) + rewardsPerVal := expAllocated.QuoDec(math.LegacyNewDec(int64(2))) // assert that the rewards are allocated to the first 2 validators for _, v := range consuVals[0:2] { valAddr := sdk.ValAddress(v.ProviderConsAddr) - rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( + rewards, err := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( ctx, valAddr, ) + s.Require().NoError(err) s.Require().Equal(rewardsPerVal, rewards.Rewards) // send rewards to the distribution module valRewardsTrunc, _ := rewards.Rewards.TruncateDecimal() - err := bankKeeper.SendCoinsFromAccountToModule( + err = bankKeeper.SendCoinsFromAccountToModule( ctx, s.providerChain.SenderAccount.GetAddress(), distrtypes.ModuleName, @@ -1170,10 +1066,11 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida // for at least `GetNumberOfEpochsToStartReceivingRewards * GetBlocksPerEpoch` blocks for _, v := range consuVals[2:4] { valAddr := sdk.ValAddress(v.ProviderConsAddr) - rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( + rewards, err := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( ctx, valAddr, ) + s.Require().NoError(err) s.Require().Zero(rewards.Rewards) } } @@ -1191,7 +1088,7 @@ func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() { rewardCoins := providerBankKeeper.GetAllBalances(s.providerCtx(), rewardPool) s.Require().Empty(rewardCoins) - totalConsumerRewards := sdk.Coins{} + // totalConsumerRewards := sdk.Coins{} // Iterate over the consumers and perform the reward distribution // to the provider @@ -1213,12 +1110,13 @@ func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() { // check the consumer pool balance // Note that for a democracy consumer chain the pool may already be filled - if pool := bankKeeper.GetAllBalances( + pool := bankKeeper.GetAllBalances( bundle.GetCtx(), accountKeeper.GetModuleAccount(bundle.GetCtx(), consumertypes.ConsumerToSendToProviderName).GetAddress(), - ); pool.Empty() { + ) + if pool.Empty() { // if pool is empty, fill it with some tokens - rewardsPerConsumer = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) + rewardsPerConsumer = sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100)) err := bankKeeper.SendCoinsFromAccountToModule( bundle.GetCtx(), bundle.Chain.SenderAccount.GetAddress(), @@ -1226,23 +1124,23 @@ func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() { sdk.NewCoins(rewardsPerConsumer), ) s.Require().NoError(err) - } else { - // execute the internal rewards distribution - // to save the pool's balance before - // it gets transferred to the provider in EndBlock - consumerKeeper.DistributeRewardsInternally(bundle.GetCtx()) - pool = bankKeeper.GetAllBalances( - bundle.GetCtx(), - accountKeeper.GetModuleAccount(bundle.GetCtx(), consumertypes.ConsumerToSendToProviderName).GetAddress(), - ) - s.Require().Len(pool, 1, "consumer reward pool cannot have multiple token denoms") - rewardsPerConsumer = pool[0] } // perform the reward transfer bundle.Chain.NextBlock() + // construct the denom of the reward tokens for the provider + prefixedDenom := transfertypes.GetPrefixedDenom( + transfertypes.PortID, + bundle.TransferPath.EndpointB.ChannelID, + rewardsPerConsumer.Denom, + ) + provIBCDenom := transfertypes.ParseDenomTrace(prefixedDenom).IBCDenom() + + providerRewards := providerBankKeeper.GetBalance(s.providerCtx(), rewardPool, prefixedDenom) + // relay IBC transfer packet from consumer to provider + // Note that relaying increases the pool rewards with the democracy consumers relayAllCommittedPackets( s, bundle.Chain, @@ -1252,20 +1150,8 @@ func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() { 1, ) - // construct the denom of the reward tokens for the provider - prefixedDenom := transfertypes.GetPrefixedDenom( - transfertypes.PortID, - bundle.TransferPath.EndpointB.ChannelID, - rewardsPerConsumer.Denom, - ) - provIBCDenom := transfertypes.ParseDenomTrace(prefixedDenom).IBCDenom() - - // sum the total rewards transferred to the provider - totalConsumerRewards = totalConsumerRewards. - Add(sdk.NewCoin(provIBCDenom, rewardsPerConsumer.Amount)) + // Check the provider received the rewards + providerRewardsDelta := providerBankKeeper.GetBalance(s.providerCtx(), rewardPool, prefixedDenom).Sub(providerRewards) + s.Require().True(providerRewardsDelta.Amount.GTE(pool.AmountOf(provIBCDenom))) } - - // Check that the provider receives the rewards of each consumer - rewardCoins = providerBankKeeper.GetAllBalances(s.providerCtx(), rewardPool) - s.Require().Equal(totalConsumerRewards, rewardCoins, totalConsumerRewards.String(), rewardCoins.String()) } diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index 5861982b23..2f275fd95c 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -1,14 +1,15 @@ package integration import ( + "cosmossdk.io/math" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" tmcrypto "github.com/cometbft/cometbft/crypto" tmtypes "github.com/cometbft/cometbft/types" - testutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestHandleConsumerDoubleVoting verifies that handling a double voting evidence @@ -218,7 +219,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, consuAddr) validator, _ := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) - initialTokens := sdk.NewDecFromInt(validator.GetTokens()) + initialTokens := math.LegacyNewDecFromInt(validator.GetTokens()) // reset context for each run provCtx, _ := s.providerCtx().CacheContext() @@ -250,8 +251,9 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { // verifies that the val gets slashed and has fewer tokens after the slashing val, _ := s.providerApp.GetTestStakingKeeper().GetValidator(provCtx, provAddr.ToSdkConsAddr().Bytes()) - slashFraction := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(provCtx) - actualTokens := sdk.NewDecFromInt(val.GetTokens()) + slashFraction, err := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(provCtx) + s.Require().NoError(err) + actualTokens := math.LegacyNewDecFromInt(val.GetTokens()) s.Require().True(initialTokens.Sub(initialTokens.Mul(slashFraction)).Equal(actualTokens)) } else { s.Require().Error(err) @@ -271,6 +273,8 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele // required to have the consumer client revision height greater than 0 s.SendEmptyVSCPacket() + providerKeeper := s.providerApp.GetProviderKeeper() + // create signing info for all validators for _, v := range s.providerChain.Vals.Validators { s.setDefaultValSigningInfo(*v) @@ -325,11 +329,11 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele consuAddr2 := types.NewConsumerConsAddress(sdk.ConsAddress(consuVal2.Address.Bytes())) provAddr2 := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, consuAddr2) - validator, found := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) - s.Require().True(found) + validator, err := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) + s.Require().NoError(err) - validator2, found := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr2.ToSdkConsAddr().Bytes()) - s.Require().True(found) + validator2, err := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr2.ToSdkConsAddr().Bytes()) + s.Require().NoError(err) s.Run("slash undelegations and redelegations when getting double voting evidence", func() { // convert validator public key @@ -337,7 +341,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele s.Require().NoError(err) // perform a delegation and an undelegation of the whole amount - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() // in order to perform a delegation we need to know the validator's `idx` (that might not be 0) @@ -356,24 +360,31 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele s.Require().NotZero(shares) // undelegate 1/2 of the bound amount - undelegate(s, delAddr, validator.GetOperator(), shares.Quo(sdk.NewDec(4))) - undelegate(s, delAddr, validator.GetOperator(), shares.Quo(sdk.NewDec(4))) + valAddr, err := providerKeeper.ValidatorAddressCodec().StringToBytes(validator.GetOperator()) + s.Require().NoError(err) + undelegate(s, delAddr, valAddr, shares.Quo(math.LegacyNewDec(4))) + undelegate(s, delAddr, valAddr, shares.Quo(math.LegacyNewDec(4))) // check that undelegations were successful - ubds, _ := s.providerApp.GetTestStakingKeeper().GetUnbondingDelegation(s.providerCtx(), delAddr, validator.GetOperator()) + ubds, _ := s.providerApp.GetTestStakingKeeper().GetUnbondingDelegation(s.providerCtx(), delAddr, valAddr) // should have a single entry since undelegations are merged s.Require().Len(ubds.Entries, 1) // save the delegation shares of the validator to redelegate to // Note this shares should not be slashed! - delShares := s.providerApp.GetTestStakingKeeper().Delegation(s.providerCtx(), delAddr, validator2.GetOperator()).GetShares() + valAddr2, err := providerKeeper.ValidatorAddressCodec().StringToBytes(validator2.GetOperator()) + s.Require().NoError(err) + del, err := s.providerApp.GetTestStakingKeeper().Delegation(s.providerCtx(), delAddr, valAddr2) + s.Require().NoError(err) + delShares := del.GetShares() // redelegate 1/2 of the bound amount - redelegate(s, delAddr, validator.GetOperator(), validator2.GetOperator(), shares.Quo(sdk.NewDec(4))) - redelegate(s, delAddr, validator.GetOperator(), validator2.GetOperator(), shares.Quo(sdk.NewDec(4))) + redelegate(s, delAddr, valAddr, valAddr2, shares.Quo(math.LegacyNewDec(4))) + redelegate(s, delAddr, valAddr, valAddr2, shares.Quo(math.LegacyNewDec(4))) // check that redelegation was successful - rdel := s.providerApp.GetTestStakingKeeper().GetRedelegations(s.providerCtx(), delAddr, uint16(10)) + rdel, err := s.providerApp.GetTestStakingKeeper().GetRedelegations(s.providerCtx(), delAddr, uint16(10)) + s.Require().NoError(err) s.Require().Len(rdel[0].Entries, 2) redelShares := rdel[0].Entries[0].SharesDst.Add(rdel[0].Entries[1].SharesDst) @@ -387,18 +398,20 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele ) s.Require().NoError(err) - slashFraction := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(s.providerCtx()) + slashFraction, err := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(s.providerCtx()) + s.Require().NoError(err) // check undelegations are slashed - ubds, _ = s.providerApp.GetTestStakingKeeper().GetUnbondingDelegation(s.providerCtx(), delAddr, validator.GetOperator()) + ubds, _ = s.providerApp.GetTestStakingKeeper().GetUnbondingDelegation(s.providerCtx(), delAddr, valAddr) s.Require().True(len(ubds.Entries) > 0) for _, unb := range ubds.Entries { - initialBalance := sdk.NewDecFromInt(unb.InitialBalance) - currentBalance := sdk.NewDecFromInt(unb.Balance) + initialBalance := math.LegacyNewDecFromInt(unb.InitialBalance) + currentBalance := math.LegacyNewDecFromInt(unb.Balance) s.Require().True(initialBalance.Sub(initialBalance.Mul(slashFraction)).Equal(currentBalance)) } // check that redelegations are slashed - delegations := s.providerApp.GetTestStakingKeeper().Delegation(s.providerCtx(), delAddr, validator2.GetOperator()) + delegations, err := s.providerApp.GetTestStakingKeeper().Delegation(s.providerCtx(), delAddr, valAddr2) + s.Require().NoError(err) s.Require().Equal(delegations.GetShares(), delShares.Add(redelShares).Sub(redelShares.Mul(slashFraction))) }) } diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go index a46df32d8e..5a55c75079 100644 --- a/tests/integration/expired_client.go +++ b/tests/integration/expired_client.go @@ -3,18 +3,18 @@ package integration import ( "time" - 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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestVSCPacketSendWithExpiredClient tests queueing of VSCPackets when the consumer client is expired. @@ -28,7 +28,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() { expireClient(s, Consumer) // bond some tokens on provider to change validator powers - bondAmt := sdk.NewInt(1000000) + bondAmt := math.NewInt(1000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) @@ -91,7 +91,7 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() { s.SetupCCVChannel(s.path) // bond some tokens on provider to change validator powers - bondAmt := sdk.NewInt(1000000) + bondAmt := math.NewInt(1000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) @@ -285,10 +285,11 @@ func upgradeExpiredClient(s *CCVTestSuite, clientTo ChainType) { tmClientState.AllowUpdateAfterExpiry = true hostChain.App.GetIBCKeeper().ClientKeeper.SetClientState(hostChain.GetContext(), substitute, tmClientState) - content := clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subject, substitute) + recoverMsg := clienttypes.NewMsgRecoverClient(hostChain.App.GetIBCKeeper().GetAuthority(), subject, substitute) + err = recoverMsg.ValidateBasic() + s.Require().NoError(err) - updateProp, ok := content.(*clienttypes.ClientUpdateProposal) - s.Require().True(ok) - err = hostChain.App.GetIBCKeeper().ClientKeeper.ClientUpdateProposal(hostChain.GetContext(), updateProp) + res, err := hostChain.App.GetIBCKeeper().RecoverClient(hostChain.GetContext(), recoverMsg) s.Require().NoError(err) + s.Require().NotNil(res) } diff --git a/tests/integration/instance_test.go b/tests/integration/instance_test.go index d2896ad964..424c6c85f5 100644 --- a/tests/integration/instance_test.go +++ b/tests/integration/instance_test.go @@ -5,11 +5,11 @@ import ( "github.com/stretchr/testify/suite" - appConsumer "github.com/cosmos/interchain-security/v4/app/consumer" - appConsumerDemocracy "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - appProvider "github.com/cosmos/interchain-security/v4/app/provider" - intg "github.com/cosmos/interchain-security/v4/tests/integration" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" + appConsumer "github.com/cosmos/interchain-security/v5/app/consumer" + appConsumerDemocracy "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + appProvider "github.com/cosmos/interchain-security/v5/app/provider" + intg "github.com/cosmos/interchain-security/v5/tests/integration" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" ) // This file can be used as an example integration testing instance for any provider/consumer applications. diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go index 799109c0d4..8d8826daf9 100644 --- a/tests/integration/key_assignment.go +++ b/tests/integration/key_assignment.go @@ -1,16 +1,16 @@ package integration import ( - "github.com/cosmos/ibc-go/v7/testing/mock" + "cosmossdk.io/math" + "github.com/cosmos/ibc-go/v8/testing/mock" - sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmencoding "github.com/cometbft/cometbft/crypto/encoding" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func (s *CCVTestSuite) TestKeyAssignment() { @@ -69,7 +69,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { } // Bond some tokens on provider to change validator powers - bondAmt := sdk.NewInt(1000000) + bondAmt := math.NewInt(1000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) @@ -253,12 +253,13 @@ func (s *CCVTestSuite) TestKeyAssignment() { if !tc.expError { // Bond some tokens on provider to change validator powers - bondAmt := sdk.NewInt(1000000) + bondAmt := math.NewInt(1000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) // Send CCV packet to consumer - s.providerChain.NextBlock() + // s.providerChain.NextBlock() + s.nextEpoch() // Relay all VSC packets from provider to consumer relayAllCommittedPackets( diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go index 1200ce7293..5924c90df1 100644 --- a/tests/integration/misbehaviour.go +++ b/tests/integration/misbehaviour.go @@ -3,14 +3,15 @@ package integration import ( "time" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "cosmossdk.io/math" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" sdk "github.com/cosmos/cosmos-sdk/types" tmtypes "github.com/cometbft/cometbft/types" - testutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestHandleConsumerMisbehaviour tests that handling a valid misbehaviour, @@ -58,7 +59,7 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() { // we assume that all validators have the same number of initial tokens validator, _ := s.getValByIdx(0) - initialTokens := sdk.NewDecFromInt(validator.GetTokens()) + initialTokens := math.LegacyNewDecFromInt(validator.GetTokens()) err := s.providerApp.GetProviderKeeper().HandleConsumerMisbehaviour(s.providerCtx(), *misb) s.NoError(err) @@ -67,14 +68,15 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() { for _, v := range clientTMValset.Validators { consuAddr := sdk.ConsAddress(v.Address.Bytes()) provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, types.NewConsumerConsAddress(consuAddr)) - val, ok := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), provAddr.Address) - s.Require().True(ok) + val, err := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), provAddr.Address) + s.Require().NoError(err) s.Require().True(val.Jailed) s.Require().True(s.providerApp.GetTestSlashingKeeper().IsTombstoned(s.providerCtx(), provAddr.ToSdkConsAddr())) validator, _ := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) - slashFraction := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(s.providerCtx()) - actualTokens := sdk.NewDecFromInt(validator.GetTokens()) + slashFraction, err := s.providerApp.GetTestSlashingKeeper().SlashFractionDoubleSign(s.providerCtx()) + s.Require().NoError(err) + actualTokens := math.LegacyNewDecFromInt(validator.GetTokens()) s.Require().True(initialTokens.Sub(initialTokens.Mul(slashFraction)).Equal(actualTokens)) } } diff --git a/tests/integration/normal_operations.go b/tests/integration/normal_operations.go index 81c742eeed..fc71fec247 100644 --- a/tests/integration/normal_operations.go +++ b/tests/integration/normal_operations.go @@ -5,8 +5,8 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Tests the tracking of historical info in the context of new blocks being committed @@ -35,14 +35,16 @@ func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so // testsetup create 2 validators and then call track historical info with header block height // increased by HistoricalEntries in order to prune the historical info less or equal to the current block height - // Note that historical info containing the created validators are stored during the next block BeginBlocker - // and thus are indexed with the respective block heights InitHeight+1 and InitHeight+2 + // Note that historical info containing the created validators were stored during the BeginBlocker of the current block + // at the moment of creation and thus are indexed with the respective block heights InitHeight and InitHeight+1 + // Last saved historical info was in the last commited block k.consumerChain.GetContext().BlockHeight(), meaning that + // if we want to prune old entries we need to start from the last saved historical info which is k.consumerChain.GetContext().BlockHeight() - 1 testSetup := []func(CCVTestSuite){ createVal, createVal, func(k CCVTestSuite) { //nolint:govet // this is a test so we can copy locks historicalEntries := k.consumerApp.GetConsumerKeeper().GetHistoricalEntries(k.consumerCtx()) - newHeight := k.consumerChain.GetContext().BlockHeight() + historicalEntries + newHeight := k.consumerChain.GetContext().BlockHeight() - 1 + historicalEntries header := tmproto.Header{ ChainID: "HelloChain", Height: newHeight, @@ -59,31 +61,31 @@ func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so // test cases verify that historical info entries are pruned when their height // is below CurrentHeight - HistoricalEntries, and check that their valset gets updated testCases := []struct { - height int64 - found bool - expLen int + height int64 + expectsError bool + expLen int }{ { - height: initHeight + 1, - found: false, - expLen: 0, + height: initHeight, + expectsError: true, + expLen: 0, }, { - height: initHeight + 2, - found: false, - expLen: 0, + height: initHeight + 1, + expectsError: true, + expLen: 0, }, { - height: initHeight + ccvtypes.DefaultHistoricalEntries + 2, - found: true, - expLen: initValsetLen + 2, + height: initHeight + ccvtypes.DefaultHistoricalEntries + 1, + expectsError: false, + expLen: initValsetLen + 2, }, } for _, tc := range testCases { cCtx().WithBlockHeight(tc.height) - hi, found := consumerKeeper.GetHistoricalInfo(cCtx().WithBlockHeight(tc.height), tc.height) - k.Require().Equal(tc.found, found) + hi, err := consumerKeeper.GetHistoricalInfo(cCtx().WithBlockHeight(tc.height), tc.height) + k.Require().Equal(tc.expectsError, err != nil) k.Require().Len(hi.Valset, tc.expLen) } } diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go new file mode 100644 index 0000000000..6c99f17c64 --- /dev/null +++ b/tests/integration/provider_gov_hooks.go @@ -0,0 +1,150 @@ +package integration + +import ( + "time" + + "cosmossdk.io/math" + 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" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" +) + +// tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks +// hooks require adding a proposal in the gov module and regitering a consumer chain with the provider module +func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() { + ctx := s.providerChain.GetContext() + providerKeeper := s.providerApp.GetProviderKeeper() + govKeeper := s.providerApp.GetTestGovKeeper() + proposer := s.providerChain.SenderAccount + + content := testkeeper.GetTestConsumerAdditionProp() + content.ChainId = "newchain-0" + legacyPropContent, err := v1.NewLegacyContent( + content, + authtypes.NewModuleAddress("gov").String(), + ) + s.Require().NoError(err) + + proposal, err := v1.NewProposal([]sdk.Msg{legacyPropContent}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + s.Require().NoError(err) + + err = govKeeper.SetProposal(ctx, proposal) + s.Require().NoError(err) + + providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) + + // verify that the proposal ID is created + proposalIdOnProvider, ok := providerKeeper.GetProposedConsumerChain(ctx, proposal.Id) + s.Require().True(ok) + s.Require().NotEmpty(proposalIdOnProvider) + s.Require().Equal(content.ChainId, proposalIdOnProvider) + + providerKeeper.Hooks().AfterProposalVotingPeriodEnded(ctx, proposal.Id) + // verify that the proposal ID is deleted + s.Require().Empty(providerKeeper.GetProposedConsumerChain(ctx, proposal.Id)) +} + +func (s *CCVTestSuite) TestGetConsumerAdditionLegacyPropFromProp() { + ctx := s.providerChain.GetContext() + proposer := s.providerChain.SenderAccount + + // create a dummy bank send message + dummyMsg := &banktypes.MsgSend{ + FromAddress: sdk.AccAddress(proposer.GetAddress()).String(), + ToAddress: sdk.AccAddress(proposer.GetAddress()).String(), + Amount: sdk.NewCoins(sdk.NewCoin("stake", math.OneInt())), + } + + textProp, err := v1.NewLegacyContent( + v1beta1.NewTextProposal("a title", "a legacy text prop"), + authtypes.NewModuleAddress("gov").String(), + ) + s.Require().NoError(err) + + addConsumerProp, err := v1.NewLegacyContent( + testkeeper.GetTestConsumerAdditionProp(), + authtypes.NewModuleAddress("gov").String(), + ) + s.Require().NoError(err) + + testCases := []struct { + name string + propMsg sdk.Msg + expectConsumerPropFound bool + expPanic bool + }{ + { + name: "prop not found", + propMsg: nil, + expectConsumerPropFound: false, + expPanic: false, + }, + { + name: "msgs in prop contain no legacy props", + propMsg: dummyMsg, + expectConsumerPropFound: false, + expPanic: false, + }, + { + name: "msgs contain a legacy prop but not of ConsumerAdditionProposal type", + propMsg: textProp, + expectConsumerPropFound: false, + }, + { + name: "msgs contain an invalid legacy prop", + propMsg: &v1.MsgExecLegacyContent{}, + expectConsumerPropFound: false, + expPanic: true, + }, + { + name: "msg contains a prop of ConsumerAdditionProposal type - hook should create a new proposed chain", + propMsg: addConsumerProp, + expectConsumerPropFound: true, + expPanic: false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + providerKeeper := s.providerApp.GetProviderKeeper() + govKeeper := s.providerApp.GetTestGovKeeper() + + var proposal v1.Proposal + var err error + + if tc.propMsg == nil { + // cover edgecase where proposal has no messages + proposal, err = v1.NewProposal([]sdk.Msg{}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + s.Require().NoError(err) + } else { + // cover variolus cases where proposal has messages but only some are consumer addition proposals + proposal, err = v1.NewProposal([]sdk.Msg{tc.propMsg}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + s.Require().NoError(err) + } + + err = govKeeper.SetProposal(ctx, proposal) + s.Require().NoError(err) + + if tc.expPanic { + s.Require().Panics(func() { + // this panics with a nil pointer dereference because the proposal is invalid and cannot be unmarshalled + providerKeeper.Hooks().GetConsumerAdditionLegacyPropFromProp(ctx, proposal.Id) + }) + return + } + + savedProp, found := providerKeeper.Hooks().GetConsumerAdditionLegacyPropFromProp(ctx, proposal.Id) + if tc.expectConsumerPropFound { + s.Require().True(found) + s.Require().NotEmpty(savedProp, savedProp) + } else { + s.Require().False(found) + s.Require().Empty(savedProp) + } + }) + } +} diff --git a/tests/integration/setup.go b/tests/integration/setup.go index cb7c78a3be..eeb980200f 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -3,29 +3,26 @@ 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" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + "github.com/cosmos/ibc-go/v8/testing/mock" "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/baseapp" - store "github.com/cosmos/cosmos-sdk/store/types" + store "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/cometbft/cometbft/abci/types" tmencoding "github.com/cometbft/cometbft/crypto/encoding" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - "github.com/cosmos/interchain-security/v4/testutil/simibc" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Callback for instantiating a new coordinator with a provider test chains @@ -148,11 +145,20 @@ func (suite *CCVTestSuite) SetupTest() { providerKeeper.SetParams(suite.providerCtx(), params) // re-assign all validator keys for the first consumer chain + // this has to be done before: + // 1. the consumer chain is added to the coordinator + // 2. MakeGenesis is called on the provider chain + // 3. ibc/testing sets the tendermint header for the consumer chain app providerKeeper.SetPendingConsumerAdditionProp(suite.providerCtx(), &types.ConsumerAdditionProposal{ ChainId: icstestingutils.FirstConsumerChainID, }) + ps := providerKeeper.GetAllPendingConsumerAdditionProps(suite.providerCtx()) preProposalKeyAssignment(suite, icstestingutils.FirstConsumerChainID) + // remove props so they don't interfere with the rest of the setup + // if not removed here, setupConsumerCallback will have 2 proposals for adding the first consumer chain + providerKeeper.DeletePendingConsumerAdditionProps(suite.providerCtx(), ps...) + // start consumer chains suite.consumerBundles = make(map[string]*icstestingutils.ConsumerBundle) for i := 0; i < icstestingutils.NumConsumers; i++ { @@ -173,6 +179,7 @@ func (suite *CCVTestSuite) SetupTest() { suite.providerCtx(), chainID, ) + suite.Require().True(found, "consumer genesis not found") genesisState := consumertypes.GenesisState{ Params: consumerGenesisState.Params, @@ -199,7 +206,9 @@ func (s *CCVTestSuite) registerPacketSniffer(chain *ibctesting.TestChain) { s.packetSniffers = make(map[*ibctesting.TestChain]*packetSniffer) } p := newPacketSniffer() - chain.App.GetBaseApp().SetStreamingService(p) + chain.App.GetBaseApp().SetStreamingManager(store.StreamingManager{ + ABCIListeners: []store.ABCIListener{p}, + }) s.packetSniffers[chain] = p } @@ -401,7 +410,8 @@ func (s CCVTestSuite) validateEndpointsClientConfig(consumerBundle icstestinguti "unexpected unbonding period in consumer client state", ) - providerUnbondingPeriod := providerStakingKeeper.UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := providerStakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) cs, ok = consumerBundle.App.GetIBCKeeper().ClientKeeper.GetClientState( consumerBundle.GetCtx(), consumerBundle.Path.EndpointA.ClientID) s.Require().True(ok) @@ -446,7 +456,7 @@ type packetSniffer struct { packets map[string]channeltypes.Packet } -var _ baseapp.StreamingService = &packetSniffer{} +var _ store.ABCIListener = &packetSniffer{} func newPacketSniffer() *packetSniffer { return &packetSniffer{ @@ -454,8 +464,8 @@ func newPacketSniffer() *packetSniffer { } } -func (ps *packetSniffer) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { - packets := simibc.ParsePacketsFromEvents(simibc.ABCIToSDKEvents(res.GetEvents())) +func (ps *packetSniffer) ListenFinalizeBlock(ctx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error { + packets := ParsePacketsFromEvents(res.GetEvents()) for _, packet := range packets { ps.packets[getSentPacketKey(packet.Sequence, packet.SourceChannel)] = packet } @@ -468,17 +478,20 @@ 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 { +func (*packetSniffer) ListenCommit(ctx context.Context, res abci.ResponseCommit, cs []*store.StoreKVPair) 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 +// ParsePacketsFromEvents returns all packets found in events. +func ParsePacketsFromEvents(events []abci.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 } -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 19805a49ad..9f29c2806c 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -1,16 +1,21 @@ package integration import ( + "context" "fmt" "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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + "cosmossdk.io/core/comet" + "cosmossdk.io/math" + "cosmossdk.io/x/evidence/types" + evidencetypes "cosmossdk.io/x/evidence/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkaddress "github.com/cosmos/cosmos-sdk/types/address" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -18,9 +23,10 @@ import ( "github.com/cometbft/cometbft/crypto/ed25519" tmtypes "github.com/cometbft/cometbft/types" - keepertestutil "github.com/cosmos/interchain-security/v4/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/integration" + keepertestutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestRelayAndApplyDowntimePacket tests that downtime slash packets can be properly relayed @@ -56,15 +62,15 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { ) s.Require().True(found) - stakingVal, found := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(found) + stakingVal, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) valOldBalance := stakingVal.Tokens // Setup first val with mapped consensus address to be jailed on provider by setting signing info // convert validator to TM type pk, err := stakingVal.ConsPubKey() s.Require().NoError(err) - tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) + tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk) s.Require().NoError(err) s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) @@ -97,7 +103,8 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { s.Require().NoError(err) s.Require().Equal(heightBefore+2, heightAfter) - // We've now advanced two blocks. + // this call was added starging cosmos-sdk v0.50.x + s.nextEpoch() // VSC packets should have been sent from provider during block N to each consumer expectedSentValsetUpdateId := valsetUpdateIdN @@ -122,11 +129,11 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { relayAllCommittedPackets(s, s.providerChain, bundle.Path, ccv.ProviderPortID, bundle.Path.EndpointB.ChannelID, 1) - // check that each consumer updated its VSC ID for the subsequent block + // check that each consumer updated its VSC ID for the subsequent not commited block ctx.BlockHeight() consumerKeeper := bundle.GetKeeper() ctx := bundle.GetCtx() actualValsetUpdateID := consumerKeeper.GetHeightValsetUpdateID( - ctx, uint64(ctx.BlockHeight())+1) + ctx, uint64(ctx.BlockHeight())) s.Require().Equal(expectedSentValsetUpdateId, actualValsetUpdateID) // check that jailed validator was removed from each consumer validator set @@ -134,16 +141,16 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { } // Get staking keeper's validator obj after the relayed slash packet - stakingValAfter, ok := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(ok) + stakingValAfter, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) // check that the validator's tokens were NOT slashed on provider valNewBalance := stakingValAfter.GetTokens() s.Require().Equal(valOldBalance, valNewBalance) // Get signing info for the validator - valSignInfo, found := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(found) + valSignInfo, err := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) // check that the validator is successfully jailed on provider s.Require().True(stakingValAfter.Jailed) @@ -181,7 +188,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { tmVal := s.consumerChain.Vals.Validators[0] val, err := tmVal.ToProto() s.Require().NoError(err) - pubkey, err := cryptocodec.FromTmProtoPublicKey(val.GetPubKey()) + pubkey, err := cryptocodec.FromCmtProtoPublicKey(val.GetPubKey()) s.Require().Nil(err) consumerConsAddr := providertypes.NewConsumerConsAddress(sdk.GetConsAddress(pubkey)) // map consumer consensus address to provider consensus address @@ -191,15 +198,15 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { consumerConsAddr) s.Require().True(found) - stakingVal, found := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(found) + stakingVal, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) valOldBalance := stakingVal.Tokens // Setup first val with mapped consensus address to be jailed on provider by setting signing info // convert validator to TM type pk, err := stakingVal.ConsPubKey() s.Require().NoError(err) - tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) + tmPk, err := cryptocodec.ToCmtPubKeyInterface(pk) s.Require().NoError(err) s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) @@ -220,16 +227,16 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { s.Require().Len(s.providerChain.Vals.Validators, validatorsPerChain) // Get staking keeper's validator obj after the relayed slash packet - stakingValAfter, ok := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(ok) + stakingValAfter, err := providerStakingKeeper.GetValidatorByConsAddr(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) // check that the validator's tokens were NOT slashed on provider valNewBalance := stakingValAfter.GetTokens() s.Require().Equal(valOldBalance, valNewBalance) // Get signing info for the validator - valSignInfo, found := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) - s.Require().True(found) + valSignInfo, err := providerSlashingKeeper.GetValidatorSigningInfo(s.providerCtx(), providerConsAddr.ToSdkConsAddr()) + s.Require().NoError(err) // check that the validator's unjailing time is NOT updated on provider s.Require().Zero(valSignInfo.JailedUntil) @@ -301,8 +308,8 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() { consAddr := sdk.ConsAddress(tmVal.Address) // check that validator bonded status - validator, found := providerStakingKeeper.GetValidatorByConsAddr(suite.providerCtx(), consAddr) - suite.Require().True(found) + validator, err := providerStakingKeeper.GetValidatorByConsAddr(suite.providerCtx(), consAddr) + suite.Require().NoError(err) suite.Require().Equal(stakingtypes.Bonded, validator.GetStatus()) // set init VSC id for chain0 @@ -327,7 +334,8 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() { suite.Require().True(providerStakingKeeper.IsValidatorJailed(suite.providerCtx(), consAddr)) signingInfo, _ := providerSlashingKeeper.GetValidatorSigningInfo(suite.providerCtx(), consAddr) - jailDuration := providerSlashingKeeper.DowntimeJailDuration(suite.providerCtx()) + jailDuration, err := providerSlashingKeeper.DowntimeJailDuration(suite.providerCtx()) + suite.Require().NoError(err) suite.Require().Equal(suite.providerCtx().BlockTime().Add(jailDuration), signingInfo.JailedUntil) } @@ -416,13 +424,13 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() { }) // Expect the packet to bounce if the slash meter is negative - providerKeeper.SetSlashMeter(ctx, sdk.NewInt(-1)) + providerKeeper.SetSlashMeter(ctx, math.NewInt(-1)) ackResult, err = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashPacketData) suite.Require().NoError(err, "no error expected") suite.Require().Equal(ccv.SlashPacketBouncedResult, ackResult, "expected successful ack") // Expect the packet to be handled if the slash meter is positive - providerKeeper.SetSlashMeter(ctx, sdk.NewInt(0)) + providerKeeper.SetSlashMeter(ctx, math.NewInt(0)) ackResult, err = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashPacketData) suite.Require().NoError(err, "no error expected") suite.Require().Equal(ccv.SlashPacketHandledResult, ackResult, "expected successful ack") @@ -456,13 +464,17 @@ func (suite *CCVTestSuite) TestValidatorDowntime() { // Sign 100 blocks (default value for slashing.SignedBlocksWindow param). valPower := int64(1) - height, signedBlocksWindow := int64(0), consumerSlashingKeeper.SignedBlocksWindow(ctx) + height := int64(0) + signedBlocksWindow, err := consumerSlashingKeeper.SignedBlocksWindow(ctx) + suite.Require().NoError(err) for ; height < signedBlocksWindow; height++ { ctx = ctx.WithBlockHeight(height) - consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, true) + consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, comet.BlockIDFlagCommit) } - missedBlockThreshold := (2 * signedBlocksWindow) - consumerSlashingKeeper.MinSignedPerWindow(ctx) + minSigned, err := consumerSlashingKeeper.MinSignedPerWindow(ctx) + suite.Require().NoError(err) + missedBlockThreshold := (2 * signedBlocksWindow) - minSigned ctx = suite.consumerCtx() // construct slash packet to be sent and get its commit @@ -477,7 +489,7 @@ func (suite *CCVTestSuite) TestValidatorDowntime() { // Miss 50 blocks and expect a slash packet to be sent for ; height <= missedBlockThreshold; height++ { ctx = ctx.WithBlockHeight(height) - consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, false) + consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, comet.BlockIDFlagAbsent) } ctx = suite.consumerCtx() @@ -485,11 +497,13 @@ func (suite *CCVTestSuite) TestValidatorDowntime() { // check validator signing info res, _ := consumerSlashingKeeper.GetValidatorSigningInfo(ctx, consAddr) // expect increased jail time - suite.Require().True(res.JailedUntil.Equal(ctx.BlockTime().Add(consumerSlashingKeeper.DowntimeJailDuration(ctx))), "did not update validator jailed until signing info") + jailDuration, err := consumerSlashingKeeper.DowntimeJailDuration(ctx) + suite.Require().NoError(err) + suite.Require().True(res.JailedUntil.Equal(ctx.BlockTime().Add(jailDuration)), "did not update validator jailed until signing info") // expect missed block counters reset suite.Require().Zero(res.MissedBlocksCounter, "did not reset validator missed block counter") suite.Require().Zero(res.IndexOffset) - consumerSlashingKeeper.IterateValidatorMissedBlockBitArray(ctx, consAddr, func(_ int64, missed bool) bool { + consumerSlashingKeeper.IterateMissedBlockBitmap(ctx, consAddr, func(_ int64, missed bool) bool { suite.Require().True(missed) return false }) @@ -523,14 +537,14 @@ func (suite *CCVTestSuite) TestValidatorDowntime() { // check that the outstanding slashing flag prevents the jailed validator to keep missing block for ; height < missedBlockThreshold+signedBlocksWindow; height++ { ctx = ctx.WithBlockHeight(height) - consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, false) + consumerSlashingKeeper.HandleValidatorSignature(ctx, vals[0].Address, valPower, comet.BlockIDFlagAbsent) } res, _ = consumerSlashingKeeper.GetValidatorSigningInfo(ctx, consAddr) suite.Require().Zero(res.MissedBlocksCounter, "did not reset validator missed block counter") suite.Require().Zero(res.IndexOffset) - consumerSlashingKeeper.IterateValidatorMissedBlockBitArray(ctx, consAddr, func(_ int64, missed bool) bool { + consumerSlashingKeeper.IterateMissedBlockBitmap(ctx, consAddr, func(_ int64, missed bool) bool { suite.Require().True(missed, "did not reset validator missed block bit array") return false }) @@ -584,8 +598,19 @@ func (suite *CCVTestSuite) TestValidatorDoubleSigning() { ) expCommit := suite.commitSlashPacket(ctx, *packetData) - // expect to send slash packet when handling double-sign evidence - suite.consumerApp.GetTestEvidenceKeeper().HandleEquivocationEvidence(ctx, e) + suite.consumerChain.NextBlock() + // // expect to send slash packet when handling double-sign evidence + // // NOTE: using IBCKeeper Authority as msg submitter (equal to gov module addr) + addr, err := sdk.AccAddressFromBech32(suite.consumerApp.GetIBCKeeper().GetAuthority()) + suite.Require().NoError(err) + evidenceMsg, err := evidencetypes.NewMsgSubmitEvidence(addr, e) + suite.Require().NoError(err) + suite.Require().NotEmpty(evidenceMsg) + + // this was previously done using suite.consumerApp.GetTestEvidenceKeeper().HandleEquivocationEvidence(ctx, e) + // HandleEquivocationEvidence is not exposed in the evidencekeeper interface starting cosmos-sdk v0.50.x + // suite.consumerApp.GetTestEvidenceKeeper().SubmitEvidence(ctx, e) + handleEquivocationEvidence(ctx, suite.consumerApp, e) // check slash packet is queued pendingPackets := suite.consumerApp.GetConsumerKeeper().GetPendingPackets(ctx) @@ -706,7 +731,7 @@ func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() { suite.Require().False(found) consumerKeeper.SlashWithInfractionReason(suite.consumerCtx(), []byte{0x01, 0x02, 0x3}, - 66, 4324, sdk.MustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_DOWNTIME) + 66, 4324, math.LegacyMustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_DOWNTIME) // Check slash packet was queued pendingPackets = consumerKeeper.GetPendingPackets(suite.consumerCtx()) @@ -736,3 +761,89 @@ func (suite *CCVTestSuite) TestCISBeforeCCVEstablished() { _, found = consumerKeeper.GetSlashRecord(suite.consumerCtx()) suite.Require().True(found) } + +// copy of the function from slashing/keeper.go +// in cosmos-sdk v0.50.x the function HandleEquivocationEvidence is not exposed (it was exposed for versions <= v0.47.x) +// https://github.com/cosmos/cosmos-sdk/blob/v0.50.4/x/evidence/keeper/infraction.go#L27 +func handleEquivocationEvidence(ctx context.Context, k integration.ConsumerApp, evidence *types.Equivocation) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + slashingKeeper := k.GetTestSlashingKeeper().(slashingkeeper.Keeper) + evidenceKeeper := k.GetTestEvidenceKeeper() + consAddr := evidence.GetConsensusAddress(k.GetConsumerKeeper().ConsensusAddressCodec()) + + validator, err := k.GetConsumerKeeper().ValidatorByConsAddr(ctx, consAddr) + if err != nil { + return err + } + if validator == nil || validator.IsUnbonded() { + return nil + } + + if len(validator.GetOperator()) != 0 { + if _, err := slashingKeeper.GetPubkey(ctx, consAddr.Bytes()); err != nil { + return nil + } + } + + // calculate the age of the evidence + infractionHeight := evidence.GetHeight() + infractionTime := evidence.GetTime() + ageDuration := sdkCtx.BlockHeader().Time.Sub(infractionTime) + ageBlocks := sdkCtx.BlockHeader().Height - infractionHeight + + // Reject evidence if the double-sign is too old. Evidence is considered stale + // if the difference in time and number of blocks is greater than the allowed + // parameters defined. + cp := sdkCtx.ConsensusParams() + if cp.Evidence != nil { + if ageDuration > cp.Evidence.MaxAgeDuration && ageBlocks > cp.Evidence.MaxAgeNumBlocks { + return nil + } + } + + if ok := slashingKeeper.HasValidatorSigningInfo(ctx, consAddr); !ok { + panic(fmt.Sprintf("expected signing info for validator %s but not found", consAddr)) + } + + // ignore if the validator is already tombstoned + if slashingKeeper.IsTombstoned(ctx, consAddr) { + return nil + } + + distributionHeight := infractionHeight - sdk.ValidatorUpdateDelay + slashFractionDoubleSign, err := slashingKeeper.SlashFractionDoubleSign(ctx) + if err != nil { + return err + } + + err = slashingKeeper.SlashWithInfractionReason( + ctx, + consAddr, + slashFractionDoubleSign, + evidence.GetValidatorPower(), distributionHeight, + stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, + ) + if err != nil { + return err + } + + // Jail the validator if not already jailed. This will begin unbonding the + // validator if not already unbonding (tombstoned). + if !validator.IsJailed() { + err = slashingKeeper.Jail(ctx, consAddr) + if err != nil { + return err + } + } + + err = slashingKeeper.JailUntil(ctx, consAddr, types.DoubleSignJailEndTime) + if err != nil { + return err + } + + err = slashingKeeper.Tombstone(ctx, consAddr) + if err != nil { + return err + } + return evidenceKeeper.Evidences.Set(ctx, evidence.Hash(), evidence) +} diff --git a/tests/integration/soft_opt_out.go b/tests/integration/soft_opt_out.go new file mode 100644 index 0000000000..4af1f79c94 --- /dev/null +++ b/tests/integration/soft_opt_out.go @@ -0,0 +1,286 @@ +package integration + +import ( + "bytes" + "sort" + + "cosmossdk.io/core/comet" + "cosmossdk.io/math" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + consumerKeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" + + cmttypes "github.com/cometbft/cometbft/proto/tendermint/types" +) + +// TestSoftOptOut tests the soft opt-out feature +// - if a validator in the top 95% doesn't sign 50 blocks on the consumer, a SlashPacket is sent to the provider +// - if a validator in the bottom 5% doesn't sign 50 blocks on the consumer, a SlashPacket is NOT sent to the provider +// - if a validator in the bottom 5% doesn't sign 49 blocks on the consumer, +// then it moves to the top 95% and doesn't sign one more block, a SlashPacket is NOT sent to the provider +func (suite *CCVTestSuite) TestSoftOptOut() { + var votes []abci.VoteInfo + + testCases := []struct { + name string + downtimeFunc func(*consumerKeeper.Keeper, *slashingkeeper.Keeper, []byte, int) + targetValidator int + expJailed bool + expSlashPacket bool + }{ + { + "downtime top 95%", + func(ck *consumerKeeper.Keeper, sk *slashingkeeper.Keeper, valAddr []byte, valIdx int) { + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].BlockIdFlag = cmttypes.BlockIDFlagAbsent + } + } + blocksToDowntime, err := sk.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + minSigned, err := sk.MinSignedPerWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + blocksToDowntime = blocksToDowntime - minSigned + 1 + + slashingBeginBlocker(suite, votes, blocksToDowntime) + }, + 0, + true, + true, + }, + { + "downtime bottom 5%", + func(ck *consumerKeeper.Keeper, sk *slashingkeeper.Keeper, valAddr []byte, valIdx int) { + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].BlockIdFlag = cmttypes.BlockIDFlagAbsent + } + } + blocksToDowntime, err := sk.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + minSigned, err := sk.MinSignedPerWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + blocksToDowntime = blocksToDowntime - minSigned + 1 + slashingBeginBlocker(suite, votes, blocksToDowntime) + }, + 3, + true, + false, + }, + { + "downtime bottom 5% first and then top 95%, but not enough", + func(ck *consumerKeeper.Keeper, sk *slashingkeeper.Keeper, valAddr []byte, valIdx int) { + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].BlockIdFlag = cmttypes.BlockIDFlagAbsent + } + } + blocksToDowntime, err := sk.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + minSigned, err := sk.MinSignedPerWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + blocksToDowntime = blocksToDowntime - minSigned + slashingBeginBlocker(suite, votes, blocksToDowntime) + + // Increase the power of this validator (to bring it in the top 95%) + delAddr := suite.providerChain.SenderAccount.GetAddress() + bondAmt := math.NewInt(100).Mul(sdk.DefaultPowerReduction) + delegateByIdx(suite, delAddr, bondAmt, valIdx) + + suite.nextEpoch() + + // Relay 1 VSC packet from provider to consumer + relayAllCommittedPackets(suite, suite.providerChain, suite.path, ccv.ProviderPortID, suite.path.EndpointB.ChannelID, 1) + + // Update validator from store + val, found := ck.GetCCValidator(suite.consumerCtx(), valAddr) + suite.Require().True(found) + smallestNonOptOutPower := ck.GetSmallestNonOptOutPower(suite.consumerCtx()) + suite.Require().Equal(val.Power, smallestNonOptOutPower) + + // Let the validator continue not signing, but not enough to get jailed + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].Validator.Power = val.Power + } + } + slashingBeginBlocker(suite, votes, 10) + }, + 2, + false, + false, + }, + { + "donwtime bottom 5% first and then top 95% until jailed", + func(ck *consumerKeeper.Keeper, sk *slashingkeeper.Keeper, valAddr []byte, valIdx int) { + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].BlockIdFlag = cmttypes.BlockIDFlagAbsent + } + } + blocksToDowntime, err := sk.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + minSigned, err := sk.MinSignedPerWindow(suite.consumerCtx()) + suite.Require().NoError(err) + + blocksToDowntime = blocksToDowntime - minSigned + slashingBeginBlocker(suite, votes, blocksToDowntime) + + // Increase the power of this validator (to bring it in the top 95%) + delAddr := suite.providerChain.SenderAccount.GetAddress() + bondAmt := math.NewInt(100).Mul(sdk.DefaultPowerReduction) + delegateByIdx(suite, delAddr, bondAmt, valIdx) + + suite.nextEpoch() + + // Relay 1 VSC packet from provider to consumer + relayAllCommittedPackets(suite, suite.providerChain, suite.path, ccv.ProviderPortID, suite.path.EndpointB.ChannelID, 1) + + // Update validator from store + val, found := ck.GetCCValidator(suite.consumerCtx(), valAddr) + suite.Require().True(found) + smallestNonOptOutPower := ck.GetSmallestNonOptOutPower(suite.consumerCtx()) + suite.Require().Equal(val.Power, smallestNonOptOutPower) + + // Let the validator continue not signing until it gets jailed. + // Due to the starting height being just updated, the signed blocked window needs to pass. + for i, voteInfo := range votes { + if bytes.Equal(voteInfo.Validator.Address, valAddr) { + votes[i].Validator.Power = val.Power + } + } + + sigBlockWindow, err := sk.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + slashingBeginBlocker(suite, votes, sigBlockWindow+1) + }, + 2, + true, + true, + }, + } + + for i, tc := range testCases { + // initial setup + suite.SetupCCVChannel(suite.path) + + consumerKeeper := suite.consumerApp.GetConsumerKeeper() + consumerSlashingKeeper := suite.consumerApp.GetTestSlashingKeeper() + + // Setup validator power s.t. the bottom 5% is non-empty + validatorPowers := []int64{1000, 500, 50, 10} + suite.setupValidatorPowers(validatorPowers) + + suite.nextEpoch() + + // Relay 1 VSC packet from provider to consumer + relayAllCommittedPackets(suite, suite.providerChain, suite.path, ccv.ProviderPortID, suite.path.EndpointB.ChannelID, 1) + + // Check that the third validator is the first in the top 95% + smallestNonOptOutPower := consumerKeeper.GetSmallestNonOptOutPower(suite.consumerCtx()) + suite.Require().Equal(validatorPowers[1], smallestNonOptOutPower, "test: "+tc.name) + + // Get the list of all CCV validators + vals := consumerKeeper.GetAllCCValidator(suite.consumerCtx()) + // Note that GetAllCCValidator is iterating over a map so the result need to be sorted + sort.Slice(vals, func(i, j int) bool { + if vals[i].Power != vals[j].Power { + return vals[i].Power > vals[j].Power + } + return bytes.Compare(vals[i].Address, vals[j].Address) > 0 + }) + + // Let everyone sign the first 100 blocks (default value for slahing.SignedBlocksWindow param). + // This populates the signingInfo of the slashing module so that + // the check for starting height passes. + votes = []abci.VoteInfo{} + for _, val := range vals { + votes = append(votes, abci.VoteInfo{ + Validator: abci.Validator{Address: val.Address, Power: val.Power}, + BlockIdFlag: cmttypes.BlockIDFlagCommit, + }) + } + + consuSlashingWindow, err := consumerSlashingKeeper.SignedBlocksWindow(suite.consumerCtx()) + suite.Require().NoError(err) + slashingBeginBlocker(suite, votes, consuSlashingWindow) + + // Downtime infraction + sk := consumerSlashingKeeper.(slashingkeeper.Keeper) + tc.downtimeFunc(&consumerKeeper, &sk, vals[tc.targetValidator].Address, tc.targetValidator) + + // Check the signing info for target validator + consAddr := sdk.ConsAddress(vals[tc.targetValidator].Address) + info, _ := consumerSlashingKeeper.GetValidatorSigningInfo(suite.consumerCtx(), consAddr) + if tc.expJailed { + // expect increased jail time + consumerJailDowntimeDuration, err := consumerSlashingKeeper.DowntimeJailDuration(suite.consumerCtx()) + suite.Require().NoError(err) + suite.Require().True( + info.JailedUntil.Equal(suite.consumerCtx().BlockTime().Add(consumerJailDowntimeDuration)), + "test: "+tc.name+"; did not update validator jailed until signing info", + ) + // expect missed block counters reset + suite.Require().Zero(info.MissedBlocksCounter, "test: "+tc.name+"; did not reset validator missed block counter") + suite.Require().Zero(info.IndexOffset, "test: "+tc.name) + consumerSlashingKeeper.IterateMissedBlockBitmap(suite.consumerCtx(), consAddr, func(_ int64, missed bool) bool { + suite.Require().True(missed, "test: "+tc.name) + return false + }) + } else { + suite.Require().True( + // expect not increased jail time + info.JailedUntil.Before(suite.consumerCtx().BlockTime()), + "test: "+tc.name+"; validator jailed until signing info was updated", + ) + suite.Require().Positive(info.IndexOffset, "test: "+tc.name) + } + + pendingPackets := consumerKeeper.GetPendingPackets(suite.consumerCtx()) + if tc.expSlashPacket { + // Check that slash packet is queued + suite.Require().NotEmpty(pendingPackets, "test: "+tc.name+"; pending packets empty") + suite.Require().Len(pendingPackets, 1, "test: "+tc.name+"; pending packets len should be 1 is %d", len(pendingPackets)) + cp := pendingPackets[0] + suite.Require().Equal(ccv.SlashPacket, cp.Type, "test: "+tc.name) + sp := cp.GetSlashPacketData() + suite.Require().Equal(stakingtypes.Infraction_INFRACTION_DOWNTIME, sp.Infraction, "test: "+tc.name) + suite.Require().Equal(vals[tc.targetValidator].Address, sp.Validator.Address, "test: "+tc.name) + } else { + suite.Require().Empty(pendingPackets, "test: "+tc.name+"; pending packets non-empty") + } + + if i+1 < len(testCases) { + // reset suite + suite.SetupTest() + } + } +} + +// slashingBeginBlocker is a mock for the slashing BeginBlocker. +// It applies the votes for a sequence of blocks +func slashingBeginBlocker(s *CCVTestSuite, votes []abci.VoteInfo, blocks int64) { + consumerSlashingKeeper := s.consumerApp.GetTestSlashingKeeper() + currentHeight := s.consumerCtx().BlockHeight() + for s.consumerCtx().BlockHeight() < currentHeight+blocks { + for _, voteInfo := range votes { + consumerSlashingKeeper.HandleValidatorSignature( + s.consumerCtx(), + voteInfo.Validator.Address, + voteInfo.Validator.Power, + comet.BlockIDFlag(voteInfo.GetBlockIdFlag()), + ) + } + s.consumerChain.NextBlock() + } +} diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index 6e72679ccd..f7b2d6ef96 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -1,12 +1,13 @@ package integration import ( - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "cosmossdk.io/math" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Tests the functionality of stopping a consumer chain at a higher level than unit tests @@ -21,8 +22,8 @@ func (s *CCVTestSuite) TestStopConsumerChain() { valAddr, err := sdk.ValAddressFromHex(tmValidator.Address.String()) s.Require().NoError(err) - validator, found := providerStakingKeeper.GetValidator(s.providerCtx(), valAddr) - s.Require().True(found) + validator, err := providerStakingKeeper.GetValidator(s.providerCtx(), valAddr) + s.Require().NoError(err) // get delegator address delAddr := s.providerChain.SenderAccount.GetAddress() @@ -30,11 +31,11 @@ func (s *CCVTestSuite) TestStopConsumerChain() { // define variables required for test setup var ( // bond amount - bondAmt = sdk.NewInt(1000000) + bondAmt = math.NewInt(1000000) // number of unbonding operations performed ubdOpsNum = 4 // store new shares created - testShares sdk.Dec + testShares math.LegacyDec ) // populate the provider chain states to setup the test using the following operations: @@ -62,7 +63,7 @@ func (s *CCVTestSuite) TestStopConsumerChain() { func(suite *CCVTestSuite) error { for i := 0; i < ubdOpsNum; i++ { // undelegate one quarter of the shares - _, err := providerStakingKeeper.Undelegate(s.providerCtx(), delAddr, valAddr, testShares.QuoInt64(int64(ubdOpsNum))) + _, _, err := providerStakingKeeper.Undelegate(s.providerCtx(), delAddr, valAddr, testShares.QuoInt64(int64(ubdOpsNum))) if err != nil { return err } diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go index ff2d32dade..f56228c56f 100644 --- a/tests/integration/throttle.go +++ b/tests/integration/throttle.go @@ -3,17 +3,18 @@ package integration import ( "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmtypes "github.com/cometbft/cometbft/types" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const fullSlashMeterString = "1.0" @@ -66,6 +67,7 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { s.SetupAllCCVChannels() s.setupValidatorPowers([]int64{1000, 1000, 1000, 1000}) + providerKeeper := s.providerApp.GetProviderKeeper() providerStakingKeeper := s.providerApp.GetTestStakingKeeper() // Use default params (incl replenish period), but set replenish fraction to tc value. @@ -79,7 +81,8 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { s.Require().Equal(tc.expectedMeterBeforeFirstSlash, slashMeter.Int64()) // Assert that we start out with no jailings - vals := providerStakingKeeper.GetAllValidators(s.providerCtx()) + vals, err := providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) for _, val := range vals { s.Require().False(val.IsJailed()) } @@ -95,10 +98,14 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) // Assert validator 0 is jailed and has no power - vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) + vals, err = providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) slashedVal := vals[0] s.Require().True(slashedVal.IsJailed()) - lastValPower := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), slashedVal.GetOperator()) + slashedValOperator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(slashedVal.GetOperator()) + s.Require().NoError(err) + lastValPower, err := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), slashedValOperator) + s.Require().NoError(err) s.Require().Equal(int64(0), lastValPower) // Assert expected slash meter and allowance value @@ -115,7 +122,8 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { // 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()) + vals, err = providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) s.Require().False(vals[2].IsJailed()) // Assert slash meter value is still the same @@ -176,7 +184,10 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { // Assert validator 2 has no power, this should be apparent next block, // since the staking endblocker runs before the ccv endblocker. s.providerChain.NextBlock() - lastValPower = providerStakingKeeper.GetLastValidatorPower(cacheCtx, slashedVal.GetOperator()) + slashedValOperator, err = providerKeeper.ValidatorAddressCodec().StringToBytes(slashedVal.GetOperator()) + s.Require().NoError(err) + lastValPower, err = providerStakingKeeper.GetLastValidatorPower(cacheCtx, slashedValOperator) + s.Require().NoError(err) s.Require().Equal(int64(0), lastValPower) } } @@ -237,8 +248,9 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.confirmValidatorNotJailed(valsToSlash[2], 1000) // Total power is now 3000 (as one validator was jailed) - s.Require().Equal(int64(3000), - providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) + power, err := providerStakingKeeper.GetLastTotalPower(s.providerCtx()) + s.Require().NoError(err) + s.Require().Equal(int64(3000), power.Int64()) // Now replenish the slash meter and confirm one of two queued slash // packet entries are then handled, when both are retried. @@ -269,8 +281,9 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.providerChain.NextBlock() // If one of the entries was handled, total power will be 2000 (1000 power was just slashed) - s.Require().Equal(int64(2000), - providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) + power, err = providerStakingKeeper.GetLastTotalPower(s.providerCtx()) + s.Require().NoError(err) + s.Require().Equal(int64(2000), power.Int64()) // Now replenish one more time, and handle final slash packet. s.replenishSlashMeterTillPositive() @@ -290,8 +303,9 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.providerChain.NextBlock() // Total power is now 1000 (just a single validator left) - s.Require().Equal(int64(1000), - providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) + power, err = providerStakingKeeper.GetLastTotalPower(s.providerCtx()) + s.Require().NoError(err) + s.Require().Equal(int64(1000), power.Int64()) // Now all 3 expected vals are jailed, and there are no more queued // slash/vsc matured packets. @@ -429,12 +443,11 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { stakingKeeper := s.providerApp.GetTestStakingKeeper() for _, val := range s.providerChain.Vals.Validators { - power := stakingKeeper.GetLastValidatorPower(s.providerCtx(), sdk.ValAddress(val.Address)) + power, err := stakingKeeper.GetLastValidatorPower(s.providerCtx(), sdk.ValAddress(val.Address)) + s.Require().NoError(err) s.Require().Equal(int64(1000), power) - stakingVal, found := stakingKeeper.GetValidatorByConsAddr(s.providerCtx(), sdk.ConsAddress(val.Address)) - if !found { - s.Require().Fail("validator not found") - } + stakingVal, err := stakingKeeper.GetValidatorByConsAddr(s.providerCtx(), sdk.ConsAddress(val.Address)) + s.Require().NoError(err) s.Require().False(stakingVal.Jailed) // 4th validator should have no slash log, all the others do @@ -452,13 +465,14 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { // power can be handled by the provider chain in a non-throttled manner. func (s *CCVTestSuite) TestSlashingSmallValidators() { s.SetupAllCCVChannels() + providerKeeper := s.providerApp.GetProviderKeeper() // Setup first val with 1000 power and the rest with 10 power. delAddr := s.providerChain.SenderAccount.GetAddress() - delegateByIdx(s, delAddr, sdk.NewInt(999999999), 0) - delegateByIdx(s, delAddr, sdk.NewInt(9999999), 1) - delegateByIdx(s, delAddr, sdk.NewInt(9999999), 2) - delegateByIdx(s, delAddr, sdk.NewInt(9999999), 3) + delegateByIdx(s, delAddr, math.NewInt(999999999), 0) + delegateByIdx(s, delAddr, math.NewInt(9999999), 1) + delegateByIdx(s, delAddr, math.NewInt(9999999), 2) + delegateByIdx(s, delAddr, math.NewInt(9999999), 3) s.providerChain.NextBlock() // Initialize slash meter @@ -466,7 +480,8 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() { // Assert that we start out with no jailings providerStakingKeeper := s.providerApp.GetTestStakingKeeper() - vals := providerStakingKeeper.GetAllValidators(s.providerCtx()) + vals, err := providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) for _, val := range vals { s.Require().False(val.IsJailed()) } @@ -492,19 +507,32 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() { 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()) - s.Require().False(vals[0].IsJailed()) - s.Require().Equal(int64(1000), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[0].GetOperator())) - s.Require().True(vals[1].IsJailed()) - s.Require().Equal(int64(0), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[1].GetOperator())) - s.Require().True(vals[2].IsJailed()) - s.Require().Equal(int64(0), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[2].GetOperator())) - s.Require().True(vals[3].IsJailed()) - s.Require().Equal(int64(0), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[3].GetOperator())) + vals, err = providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) + + val0Operator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(vals[0].GetOperator()) + s.Require().NoError(err) + power, err := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), val0Operator) + s.Require().NoError(err) + s.Require().Equal(int64(1000), power) + + val1Operator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(vals[1].GetOperator()) + s.Require().NoError(err) + power, err = providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), val1Operator) + s.Require().NoError(err) + s.Require().Equal(int64(0), power) + + val2Operator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(vals[2].GetOperator()) + s.Require().NoError(err) + power, err = providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), val2Operator) + s.Require().NoError(err) + s.Require().Equal(int64(0), power) + + val3Operator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(vals[3].GetOperator()) + s.Require().NoError(err) + power, err = providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), val3Operator) + s.Require().NoError(err) + s.Require().Equal(int64(0), power) } // TestSlashMeterAllowanceChanges tests scenarios where the slash meter allowance is expected to change. @@ -598,24 +626,32 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes } func (s *CCVTestSuite) confirmValidatorJailed(tmVal tmtypes.Validator, checkPower bool) { - sdkVal, found := s.providerApp.GetTestStakingKeeper().GetValidator( + providerKeeper := s.providerApp.GetProviderKeeper() + sdkVal, err := s.providerApp.GetTestStakingKeeper().GetValidator( s.providerCtx(), sdk.ValAddress(tmVal.Address)) - s.Require().True(found) + s.Require().NoError(err) s.Require().True(sdkVal.IsJailed()) if checkPower { - valPower := s.providerApp.GetTestStakingKeeper().GetLastValidatorPower( - s.providerCtx(), sdkVal.GetOperator()) + valOperator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(sdkVal.GetOperator()) + s.Require().NoError(err) + valPower, err := s.providerApp.GetTestStakingKeeper().GetLastValidatorPower( + s.providerCtx(), valOperator) + s.Require().NoError(err) s.Require().Equal(int64(0), valPower) } } func (s *CCVTestSuite) confirmValidatorNotJailed(tmVal tmtypes.Validator, expectedPower int64) { - sdkVal, found := s.providerApp.GetTestStakingKeeper().GetValidator( + providerKeeper := s.providerApp.GetProviderKeeper() + sdkVal, err := s.providerApp.GetTestStakingKeeper().GetValidator( s.providerCtx(), sdk.ValAddress(tmVal.Address)) - s.Require().True(found) - valPower := s.providerApp.GetTestStakingKeeper().GetLastValidatorPower( - s.providerCtx(), sdkVal.GetOperator()) + s.Require().NoError(err) + valOperator, err := providerKeeper.ValidatorAddressCodec().StringToBytes(sdkVal.GetOperator()) + s.Require().NoError(err) + valPower, err := s.providerApp.GetTestStakingKeeper().GetLastValidatorPower( + s.providerCtx(), valOperator) + s.Require().NoError(err) s.Require().Equal(expectedPower, valPower) s.Require().False(sdkVal.IsJailed()) } diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go index 36acad3602..fcc795bb27 100644 --- a/tests/integration/throttle_retry.go +++ b/tests/integration/throttle_retry.go @@ -3,11 +3,11 @@ package integration import ( "time" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestSlashRetries tests the throttling v2 retry logic at an integration level. @@ -24,7 +24,8 @@ func (s *CCVTestSuite) TestSlashRetries() { providerKeeper.InitializeSlashMeter(s.providerCtx()) // Assert that we start out with no jailings providerStakingKeeper := s.providerApp.GetTestStakingKeeper() - vals := providerStakingKeeper.GetAllValidators(s.providerCtx()) + vals, err := providerStakingKeeper.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) for _, val := range vals { s.Require().False(val.IsJailed()) } @@ -91,15 +92,18 @@ func (s *CCVTestSuite) TestSlashRetries() { // Default slash meter replenish fraction is 0.05, so packet should be handled on provider. stakingVal1 := s.mustGetStakingValFromTmVal(*tmval1) s.Require().True(stakingVal1.IsJailed()) - s.Require().Equal(int64(0), - s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal1.GetOperator())) + stakingVal1Addr, err := providerKeeper.ValidatorAddressCodec().StringToBytes(stakingVal1.GetOperator()) + s.Require().NoError(err) + stakingVal1LastPower, err := s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal1Addr) + s.Require().NoError(err) + s.Require().Equal(int64(0), stakingVal1LastPower) // Now slash meter should be negative on provider s.Require().True(s.providerApp.GetProviderKeeper().GetSlashMeter(s.providerCtx()).IsNegative()) // Apply ack back on consumer expectedAck := channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) - err := s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet1, expectedAck.Acknowledgement()) + 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, @@ -151,8 +155,10 @@ func (s *CCVTestSuite) TestSlashRetries() { // 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(), stakingVal2.GetOperator())) + stakingVal2Addr, err := providerKeeper.ValidatorAddressCodec().StringToBytes(stakingVal2.GetOperator()) + s.Require().NoError(err) + stakingVal2LastPower, err := providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), stakingVal2Addr) + s.Require().Equal(int64(1000), stakingVal2LastPower) // Apply ack on consumer expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketBouncedResult)) @@ -203,8 +209,10 @@ func (s *CCVTestSuite) TestSlashRetries() { // 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())) + stakingVal2Addr, err = providerKeeper.ValidatorAddressCodec().StringToBytes(stakingVal2.GetOperator()) + s.Require().NoError(err) + stakingVal2LastPower, err = providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), stakingVal2Addr) + s.Require().Equal(int64(0), stakingVal2LastPower) // Apply ack on consumer expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) diff --git a/tests/integration/unbonding.go b/tests/integration/unbonding.go index 3092d54ec8..6f027c3616 100644 --- a/tests/integration/unbonding.go +++ b/tests/integration/unbonding.go @@ -4,11 +4,10 @@ import ( "time" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestUndelegationNormalOperation tests that undelegations complete after @@ -84,12 +83,13 @@ func (s *CCVTestSuite) TestUndelegationNormalOperation() { s.SetupCCVChannel(s.path) // set VSC timeout period to not trigger the removal of the consumer chain - providerUnbondingPeriod := stakingKeeper.UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := stakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) consumerUnbondingPeriod := consumerKeeper.GetUnbondingPeriod(s.consumerCtx()) providerKeeper.SetVscTimeoutPeriod(s.providerCtx(), providerUnbondingPeriod+consumerUnbondingPeriod+24*time.Hour) // delegate bondAmt and undelegate tc.shareDiv of it - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() initBalance, valsetUpdateID := delegateAndUndelegate(s, delAddr, bondAmt, tc.shareDiv) // - check that staking unbonding op was created and onHold is true @@ -98,7 +98,7 @@ func (s *CCVTestSuite) TestUndelegationNormalOperation() { checkCCVUnbondingOp(s, s.providerCtx(), s.consumerChain.ChainID, valsetUpdateID, true, "test: "+tc.name) // call NextBlock on the provider (which increments the height) - s.providerChain.NextBlock() + s.nextEpoch() // unbond both on provider and consumer and check that // the balance remains unchanged in between @@ -110,7 +110,7 @@ func (s *CCVTestSuite) TestUndelegationNormalOperation() { // - check that staking unbonding op has been deleted checkStakingUnbondingOps(s, valsetUpdateID, false, false, "test: "+tc.name) // - check that necessary delegated coins have been returned - unbondAmt := bondAmt.Sub(bondAmt.Quo(sdk.NewInt(tc.shareDiv))) + unbondAmt := bondAmt.Sub(bondAmt.Quo(math.NewInt(tc.shareDiv))) s.Require().Equal( initBalance.Sub(unbondAmt), getBalance(s, s.providerCtx(), delAddr), @@ -137,7 +137,7 @@ func (s *CCVTestSuite) TestUndelegationVscTimeout() { vscTimeout := providerKeeper.GetVscTimeoutPeriod(s.providerCtx()) // delegate bondAmt and undelegate 1/2 of it - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() initBalance, valsetUpdateID := delegateAndUndelegate(s, delAddr, bondAmt, 2) // - check that staking unbonding op was created and onHold is true @@ -177,7 +177,7 @@ func (s *CCVTestSuite) TestUndelegationVscTimeout() { // - check that staking unbonding op has been deleted checkStakingUnbondingOps(s, valsetUpdateID, false, false) // - check that necessary delegated coins have been returned - unbondAmt := bondAmt.Sub(bondAmt.Quo(sdk.NewInt(2))) + unbondAmt := bondAmt.Sub(bondAmt.Quo(math.NewInt(2))) s.Require().Equal( initBalance.Sub(unbondAmt), getBalance(s, s.providerCtx(), delAddr), @@ -218,7 +218,7 @@ func (s *CCVTestSuite) TestUndelegationDuringInit() { stakingKeeper := s.providerApp.GetTestStakingKeeper() // delegate bondAmt and undelegate 1/2 of it - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() initBalance, valsetUpdateID := delegateAndUndelegate(s, delAddr, bondAmt, 2) // - check that staking unbonding op was created and onHold is true @@ -227,7 +227,8 @@ func (s *CCVTestSuite) TestUndelegationDuringInit() { checkCCVUnbondingOp(s, s.providerCtx(), s.consumerChain.ChainID, valsetUpdateID, true, "test: "+tc.name) // get provider unbonding period - providerUnbondingPeriod := stakingKeeper.UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := stakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) // update init timeout timestamp tc.updateInitTimeoutTimestamp(&providerKeeper, providerUnbondingPeriod) @@ -282,7 +283,7 @@ func (s *CCVTestSuite) TestUndelegationDuringInit() { checkStakingUnbondingOps(s, valsetUpdateID, false, false, "test: "+tc.name) // - check that one quarter the delegated coins have been returned s.Require().Equal( - initBalance.Sub(bondAmt).Sub(bondAmt.Quo(sdk.NewInt(2))), + initBalance.Sub(bondAmt).Sub(bondAmt.Quo(math.NewInt(2))), getBalance(s, s.providerCtx(), delAddr), "unexpected initial balance after unbonding; test: %s", tc.name, ) @@ -311,7 +312,7 @@ func (s *CCVTestSuite) TestUnbondingNoConsumer() { } // delegate bondAmt and undelegate 1/2 of it - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() initBalance, valsetUpdateID := delegateAndUndelegate(s, delAddr, bondAmt, 2) // - check that staking unbonding op was created and onHold is FALSE @@ -322,7 +323,8 @@ func (s *CCVTestSuite) TestUnbondingNoConsumer() { // increment time so that the unbonding period ends on the provider; // cannot use incrementTimeByUnbondingPeriod() since it tries // to also update the provider's client on the consumer - providerUnbondingPeriod := providerStakingKeeper.UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := providerStakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) s.coordinator.IncrementTimeBy(providerUnbondingPeriod + time.Hour) // call NextBlock on the provider (which increments the height) @@ -332,7 +334,7 @@ func (s *CCVTestSuite) TestUnbondingNoConsumer() { // - check that staking unbonding op has been deleted checkStakingUnbondingOps(s, valsetUpdateID, false, false) // - check that half the coins have been returned - s.Require().True(getBalance(s, s.providerCtx(), delAddr).Equal(initBalance.Sub(bondAmt.Quo(sdk.NewInt(2))))) + s.Require().True(getBalance(s, s.providerCtx(), delAddr).Equal(initBalance.Sub(bondAmt.Quo(math.NewInt(2))))) } // TestRedelegationNoConsumer tests a redelegate transaction @@ -346,7 +348,7 @@ func (s *CCVTestSuite) TestRedelegationNoConsumer() { s.Require().NoError(err) // Setup delegator, bond amount, and src/dst validators - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() _, srcVal := s.getValByIdx(0) _, dstVal := s.getValByIdx(1) @@ -363,10 +365,12 @@ func (s *CCVTestSuite) TestRedelegationNoConsumer() { redelegations := checkRedelegations(s, delAddr, 1) // Check that the only entry has appropriate maturation time, the unbonding period from now + unbondingTime, err := stakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) checkRedelegationEntryCompletionTime( s, redelegations[0].Entries[0], - s.providerCtx().BlockTime().Add(stakingKeeper.UnbondingTime(s.providerCtx())), + s.providerCtx().BlockTime().Add(unbondingTime), ) // required before call to incrementTimeByUnbondingPeriod or else a panic @@ -394,12 +398,13 @@ func (s *CCVTestSuite) TestRedelegationProviderFirst() { stakingKeeper := s.providerApp.GetTestStakingKeeper() // set VSC timeout period to not trigger the removal of the consumer chain - providerUnbondingPeriod := stakingKeeper.UnbondingTime(s.providerCtx()) + providerUnbondingPeriod, err := stakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) consumerUnbondingPeriod := consumerKeeper.GetUnbondingPeriod(s.consumerCtx()) providerKeeper.SetVscTimeoutPeriod(s.providerCtx(), providerUnbondingPeriod+consumerUnbondingPeriod+24*time.Hour) // Setup delegator, bond amount, and src/dst validators - bondAmt := sdk.NewInt(10000000) + bondAmt := math.NewInt(10000000) delAddr := s.providerChain.SenderAccount.GetAddress() _, srcVal := s.getValByIdx(0) _, dstVal := s.getValByIdx(1) @@ -416,10 +421,12 @@ func (s *CCVTestSuite) TestRedelegationProviderFirst() { redelegations := checkRedelegations(s, delAddr, 1) // Check that the only entry has appropriate maturation time, the unbonding period from now + unbondingTime, err := stakingKeeper.UnbondingTime(s.providerCtx()) + s.Require().NoError(err) checkRedelegationEntryCompletionTime( s, redelegations[0].Entries[0], - s.providerCtx().BlockTime().Add(stakingKeeper.UnbondingTime(s.providerCtx())), + s.providerCtx().BlockTime().Add(unbondingTime), ) // Save the current valset update ID @@ -469,12 +476,21 @@ func (s *CCVTestSuite) TestTooManyLastValidators() { sk := s.providerApp.GetTestStakingKeeper() pk := s.providerApp.GetProviderKeeper() + getLastValsFn := func(ctx sdk.Context) []stakingtypes.Validator { + lastVals, err := pk.GetLastBondedValidators(s.providerCtx()) + s.Require().NoError(err) + return lastVals + } + // get current staking params - p := sk.GetParams(s.providerCtx()) + p, err := sk.GetParams(s.providerCtx()) + s.Require().NoError(err) // get validators, which are all active at the moment - vals := sk.GetAllValidators(s.providerCtx()) - s.Require().Equal(len(vals), len(pk.GetLastBondedValidators(s.providerCtx()))) + vals, err := sk.GetAllValidators(s.providerCtx()) + s.Require().NoError(err) + + s.Require().Equal(len(vals), len(getLastValsFn(s.providerCtx()))) // jail a validator val := vals[0] @@ -483,17 +499,17 @@ func (s *CCVTestSuite) TestTooManyLastValidators() { sk.Jail(s.providerCtx(), consAddr) // save the current number of bonded vals - lastVals := pk.GetLastBondedValidators(s.providerCtx()) + lastVals := getLastValsFn(s.providerCtx()) // pass one block to apply the validator set changes - // (calls ApplyAndReturnValidatorSetUpdates in the staking module EndBlock) + // (calls ApplyAndReturnValidatorSetUpdates in the the staking module EndBlock) s.providerChain.NextBlock() // verify that the number of bonded validators is decreased by one - s.Require().Equal(len(lastVals)-1, len(pk.GetLastBondedValidators(s.providerCtx()))) + s.Require().Equal(len(lastVals)-1, len(getLastValsFn(s.providerCtx()))) // update maximum validator to equal the number of bonded validators - p.MaxValidators = uint32(len(pk.GetLastBondedValidators(s.providerCtx()))) + p.MaxValidators = uint32(len(getLastValsFn(s.providerCtx()))) sk.SetParams(s.providerCtx(), p) // pass one block to apply validator set changes @@ -509,5 +525,5 @@ func (s *CCVTestSuite) TestTooManyLastValidators() { // ApplyAndReturnValidatorSetUpdates where the staking module has a inconsistent state s.Require().NotPanics(s.providerChain.NextBlock) s.Require().NotPanics(func() { sk.ApplyAndReturnValidatorSetUpdates(s.providerCtx()) }) - s.Require().NotPanics(func() { pk.GetLastBondedValidators(s.providerCtx()) }) + s.Require().NotPanics(func() { getLastValsFn(s.providerCtx()) }) } diff --git a/tests/integration/valset_update.go b/tests/integration/valset_update.go index eb0560a35e..994dfab4af 100644 --- a/tests/integration/valset_update.go +++ b/tests/integration/valset_update.go @@ -3,14 +3,14 @@ package integration import ( "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/cometbft/cometbft/abci/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestPacketRoundtrip tests a CCV packet roundtrip when tokens are bonded on provider @@ -19,7 +19,7 @@ func (s *CCVTestSuite) TestPacketRoundtrip() { s.SetupTransferChannel() // Bond some tokens on provider to change validator powers - bondAmt := sdk.NewInt(1000000) + bondAmt := math.NewInt(1000000) delAddr := s.providerChain.SenderAccount.GetAddress() delegate(s, delAddr, bondAmt) @@ -45,13 +45,13 @@ func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets() { suite.SetupCCVChannel(suite.path) // send 3 packets to consumer chain at different times - pk, err := cryptocodec.FromTmPubKeyInterface(suite.providerChain.Vals.Validators[0].PubKey) + pk, err := cryptocodec.FromCmtPubKeyInterface(suite.providerChain.Vals.Validators[0].PubKey) suite.Require().NoError(err) - pk1, err := cryptocodec.ToTmProtoPublicKey(pk) + pk1, err := cryptocodec.ToCmtProtoPublicKey(pk) suite.Require().NoError(err) - pk, err = cryptocodec.FromTmPubKeyInterface(suite.providerChain.Vals.Validators[1].PubKey) + pk, err = cryptocodec.FromCmtPubKeyInterface(suite.providerChain.Vals.Validators[1].PubKey) suite.Require().NoError(err) - pk2, err := cryptocodec.ToTmProtoPublicKey(pk) + pk2, err := cryptocodec.ToCmtProtoPublicKey(pk) suite.Require().NoError(err) pd := ccv.NewValidatorSetChangePacketData( diff --git a/tests/mbt/driver/common.go b/tests/mbt/driver/common.go index 47d82833cc..51a3af0f45 100644 --- a/tests/mbt/driver/common.go +++ b/tests/mbt/driver/common.go @@ -1,6 +1,7 @@ package main import ( + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,5 +22,5 @@ func getIndexOfString(s string, slice []string) int { func init() { // tokens === power - sdk.DefaultPowerReduction = sdk.NewInt(1) + sdk.DefaultPowerReduction = math.NewInt(1) } diff --git a/tests/mbt/driver/core.go b/tests/mbt/driver/core.go index 422e282d2d..2cd618096f 100644 --- a/tests/mbt/driver/core.go +++ b/tests/mbt/driver/core.go @@ -3,34 +3,36 @@ package main import ( "fmt" "log" - "math" + gomath "math" "strings" "testing" "time" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + "cosmossdk.io/math" + + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" sdkmath "cosmossdk.io/math" + abcitypes "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - abcitypes "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/proto/tendermint/crypto" cmttypes "github.com/cometbft/cometbft/types" - appConsumer "github.com/cosmos/interchain-security/v4/app/consumer" - appProvider "github.com/cosmos/interchain-security/v4/app/provider" - simibc "github.com/cosmos/interchain-security/v4/testutil/simibc" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cometbft/cometbft/proto/tendermint/crypto" + appConsumer "github.com/cosmos/interchain-security/v5/app/consumer" + appProvider "github.com/cosmos/interchain-security/v5/app/provider" + simibc "github.com/cosmos/interchain-security/v5/testutil/simibc" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Define a new type for ChainIds to be more explicit @@ -139,21 +141,21 @@ func (s *Driver) consumerPower(i int64, chain ChainId) (int64, error) { return v.Power, nil } -func (s *Driver) stakingValidator(i int64) (stakingtypes.Validator, bool) { +func (s *Driver) stakingValidator(i int64) (stakingtypes.Validator, error) { return s.providerStakingKeeper().GetValidator(s.ctx(PROVIDER), s.validator(i)) } // providerPower returns the power(=number of bonded tokens) of the i-th validator on the provider. func (s *Driver) providerPower(i int64) (int64, error) { - v, found := s.stakingValidator(i) - if !found { + v, err := s.providerStakingKeeper().GetValidator(s.ctx(PROVIDER), s.validator(i)) + if err != nil { return 0, fmt.Errorf("validator with id %v not found on provider", i) } else { return v.BondedTokens().Int64(), nil } } -func (s *Driver) providerValidatorSet() []stakingtypes.Validator { +func (s *Driver) providerValidatorSet() ([]stakingtypes.Validator, error) { return s.providerStakingKeeper().GetAllValidators(s.ctx(PROVIDER)) } @@ -165,9 +167,9 @@ func (s *Driver) consumerValidatorSet(chain ChainId) []consumertypes.CrossChainV func (s *Driver) delegate(val, amt int64) { providerStaking := s.providerStakingKeeper() server := stakingkeeper.NewMsgServerImpl(&providerStaking) - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(amt)) - d := s.delegator() - v := s.validator(val) + coin := sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(amt)) + d := s.delegator().String() + v := s.validator(val).String() msg := stakingtypes.NewMsgDelegate(d, v, coin) _, err := server.Delegate(sdk.WrapSDKContext(s.ctx(PROVIDER)), msg) if err != nil { @@ -179,9 +181,9 @@ func (s *Driver) delegate(val, amt int64) { func (s *Driver) undelegate(val, amt int64) { providerStaking := s.providerStakingKeeper() server := stakingkeeper.NewMsgServerImpl(&providerStaking) - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(amt)) - d := s.delegator() - v := s.validator(val) + coin := sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(amt)) + d := s.delegator().String() + v := s.validator(val).String() msg := stakingtypes.NewMsgUndelegate(d, v, coin) _, err := server.Undelegate(sdk.WrapSDKContext(s.ctx(PROVIDER)), msg) if err != nil { @@ -333,7 +335,7 @@ func (s *Driver) endAndBeginBlock(chain ChainId, timeAdvancement time.Duration) testChain, found := s.coordinator.Chains[string(chain)] require.True(s.t, found, "chain %s not found", chain) - header, packets := simibc.EndBlock(testChain, func() {}) + header, packets := simibc.FinalizeBlock(testChain, timeAdvancement) s.DriverStats.numSentPackets += len(packets) s.DriverStats.numBlocks += 1 @@ -360,7 +362,6 @@ func (s *Driver) endAndBeginBlock(chain ChainId, timeAdvancement time.Duration) } } - simibc.BeginBlock(testChain, timeAdvancement) return header } @@ -383,13 +384,12 @@ func (s *Driver) setTime(chain ChainId, newTime time.Time) { require.True(s.t, found, "chain %s not found", chain) testChain.CurrentHeader.Time = newTime - testChain.App.BeginBlock(abcitypes.RequestBeginBlock{Header: testChain.CurrentHeader}) } func (s *Driver) AssignKey(chain ChainId, valIndex int64, value crypto.PublicKey) error { - stakingVal, found := s.stakingValidator(valIndex) - if !found { - return fmt.Errorf("validator with id %v not found on provider", valIndex) + stakingVal, err := s.stakingValidator(valIndex) + if err != nil { + return fmt.Errorf("error getting validator with id %v on provider", valIndex) } return s.providerKeeper().AssignConsumerKey(s.providerCtx(), string(chain), stakingVal, value) } @@ -444,8 +444,8 @@ func (s *Driver) RequestSlash( func (s *Driver) DeliverAcks() { for _, chainID := range s.runningConsumerChainIDs() { path := s.path(chainID) - path.DeliverAcks(path.Path.EndpointA.Chain.ChainID, math.MaxInt) - path.DeliverAcks(path.Path.EndpointB.Chain.ChainID, math.MaxInt) + path.DeliverAcks(path.Path.EndpointA.Chain.ChainID, gomath.MaxInt) + path.DeliverAcks(path.Path.EndpointB.Chain.ChainID, gomath.MaxInt) } } diff --git a/tests/mbt/driver/mbt_test.go b/tests/mbt/driver/mbt_test.go index 2acbd4a8f4..70fded614a 100644 --- a/tests/mbt/driver/mbt_test.go +++ b/tests/mbt/driver/mbt_test.go @@ -10,7 +10,8 @@ import ( "testing" "time" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + "cosmossdk.io/math" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/informalsystems/itf-go/itf" "github.com/kylelemons/godebug/pretty" "github.com/stretchr/testify/require" @@ -20,10 +21,10 @@ import ( tmencoding "github.com/cometbft/cometbft/crypto/encoding" cmttypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/interchain-security/v5/testutil/integration" - "github.com/cosmos/interchain-security/v4/testutil/integration" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const verbose = false @@ -161,8 +162,8 @@ func RunItfTrace(t *testing.T, path string) { trustingPeriodPerChain[ChainId(consumer)] = time.Duration(params["TrustingPeriodPerChain"].Value.(itf.MapExprType)[consumer].Value.(int64)) * time.Second ccvTimeoutPerChain[ChainId(consumer)] = time.Duration(params["CcvTimeout"].Value.(itf.MapExprType)[consumer].Value.(int64)) * time.Second } - downtimeSlashPercentage := sdk.NewDec(params["DowntimeSlashPercentage"].Value.(int64)) - doubleSignSlashPercentage := sdk.NewDec(params["DoubleSignSlashPercentage"].Value.(int64)) + downtimeSlashPercentage := math.LegacyNewDec(params["DowntimeSlashPercentage"].Value.(int64)) + doubleSignSlashPercentage := math.LegacyNewDec(params["DoubleSignSlashPercentage"].Value.(int64)) downtimeJailDuration := time.Duration(params["DowntimeJailDuration"].Value.(int64)) * time.Second modelParams := ModelParams{ @@ -220,7 +221,8 @@ func RunItfTrace(t *testing.T, path string) { driver.endAndBeginBlock("provider", 1*time.Nanosecond) } - slashingParams := driver.providerSlashingKeeper().GetParams(driver.providerCtx()) + slashingParams, err := driver.providerSlashingKeeper().GetParams(driver.providerCtx()) + require.NoError(t, err, "Error getting slashing params") slashingParams.DowntimeJailDuration = downtimeJailDuration driver.providerSlashingKeeper().SetParams(driver.providerCtx(), slashingParams) @@ -610,7 +612,8 @@ func CompareValidatorSets( t.Helper() modelValSet := ValidatorSet(currentModelState, "provider") - rawActualValSet := driver.providerValidatorSet() + rawActualValSet, err := driver.providerValidatorSet() + require.NoError(t, err, "Error getting provider validator set") actualValSet := make(map[string]int64, len(rawActualValSet)) @@ -646,7 +649,8 @@ func CompareValidatorSets( } // get the validator for that address on the provider - providerVal, found := driver.providerStakingKeeper().GetValidatorByConsAddr(driver.providerCtx(), providerConsAddr.Address) + providerVal, err := driver.providerStakingKeeper().GetValidatorByConsAddr(driver.providerCtx(), providerConsAddr.Address) + require.Nil(t, err, "Error getting provider validator") require.True(t, found, "Error getting provider validator") // use the moniker of that validator @@ -816,8 +820,8 @@ func CompareJailedValidators( modelJailEndTime := modelJailEndTimes[i] valConsAddr := sdk.ConsAddress(modelNamesToSystemConsAddr[modelJailedVal].Address) - valSigningInfo, found := driver.providerSlashingKeeper().GetValidatorSigningInfo(driver.providerCtx(), valConsAddr) - require.True(driver.t, found, "Error getting signing info for validator %v", modelJailedVal) + valSigningInfo, err := driver.providerSlashingKeeper().GetValidatorSigningInfo(driver.providerCtx(), valConsAddr) + require.NoError(driver.t, err, "Error getting signing info for validator %v", modelJailedVal) systemJailEndTime := valSigningInfo.JailedUntil actualTimeWithOffset := systemJailEndTime.Unix() - timeOffset.Unix() @@ -844,7 +848,11 @@ func CompareJailedValidators( func (s *Stats) EnterStats(driver *Driver) { // highest observed voting power - for _, val := range driver.providerValidatorSet() { + valSet, err := driver.providerValidatorSet() + if err != nil { + log.Fatalf("error getting validator set on provider: %v", err) + } + for _, val := range valSet { if val.Tokens.Int64() > s.highestObservedValPower { s.highestObservedValPower = val.Tokens.Int64() } diff --git a/tests/mbt/driver/setup.go b/tests/mbt/driver/setup.go index 9bf6459bf9..87b7b16e62 100644 --- a/tests/mbt/driver/setup.go +++ b/tests/mbt/driver/setup.go @@ -7,11 +7,12 @@ import ( "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" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/stretchr/testify/require" "cosmossdk.io/math" @@ -30,12 +31,11 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" - "github.com/cosmos/interchain-security/v4/testutil/integration" - simibc "github.com/cosmos/interchain-security/v4/testutil/simibc" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" + "github.com/cosmos/interchain-security/v5/testutil/integration" + simibc "github.com/cosmos/interchain-security/v5/testutil/simibc" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -119,7 +119,7 @@ func getAppBytesAndSenders( bal := banktypes.Balance{ Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, - sdk.NewIntFromUint64(INITIAL_ACCOUNT_BALANCE))), + math.NewIntFromUint64(INITIAL_ACCOUNT_BALANCE))), } accounts = append(accounts, acc) @@ -142,16 +142,16 @@ func getAppBytesAndSenders( delegations := make([]stakingtypes.Delegation, 0, len(nodes)) // Sum bonded is needed for BondedPool account - sumBonded := sdk.NewInt(0) + sumBonded := math.NewInt(0) initValPowers := []abcitypes.ValidatorUpdate{} for i, val := range nodes { _, valSetVal := initialValSet.GetByAddress(val.Address.Bytes()) var tokens math.Int if valSetVal == nil { - tokens = sdk.NewInt(0) + tokens = math.NewInt(0) } else { - tokens = sdk.NewInt(valSetVal.VotingPower) + tokens = math.NewInt(valSetVal.VotingPower) } sumBonded = sumBonded.Add(tokens) @@ -165,7 +165,7 @@ func getAppBytesAndSenders( log.Panicf("error getting pubkeyAny for val %v", val) } - delShares := sdk.NewDec(tokens.Int64()) // as many shares as tokens + delShares := math.LegacyNewDec(tokens.Int64()) // as many shares as tokens validator := stakingtypes.Validator{ OperatorAddress: sdk.ValAddress(val.Address).String(), @@ -179,14 +179,14 @@ func getAppBytesAndSenders( }, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + Commission: stakingtypes.NewCommission(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec()), + MinSelfDelegation: math.ZeroInt(), } stakingValidators = append(stakingValidators, validator) // Store delegation from the model delegator account - delegations = append(delegations, stakingtypes.NewDelegation(senderAccounts[0].SenderAccount.GetAddress(), val.Address.Bytes(), delShares)) + delegations = append(delegations, stakingtypes.NewDelegation(senderAccounts[0].SenderAccount.GetAddress().String(), val.Address.String(), delShares)) // add initial validator powers so consumer InitGenesis runs correctly pub, _ := val.ToProto() @@ -229,7 +229,7 @@ func getAppBytesAndSenders( // add unbonded amount balances = append(balances, banktypes.Balance{ Address: authtypes.NewModuleAddress(stakingtypes.NotBondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(bondDenom, sdk.ZeroInt())}, + Coins: sdk.Coins{sdk.NewCoin(bondDenom, math.ZeroInt())}, }) // update total funds supply @@ -264,7 +264,7 @@ func newChain( protoConsParams := CONSENSUS_PARAMS.ToProto() app.InitChain( - abcitypes.RequestInitChain{ + &abcitypes.RequestInitChain{ ChainId: chainID, Validators: cmttypes.TM2PB.ValidatorUpdates(validators), ConsensusParams: &protoConsParams, @@ -274,20 +274,16 @@ func newChain( app.Commit() - app.BeginBlock( - abcitypes.RequestBeginBlock{ - Header: cmtproto.Header{ - ChainID: chainID, - Height: app.LastBlockHeight() + 1, - AppHash: app.LastCommitID().Hash, - ValidatorsHash: validators.Hash(), - NextValidatorsHash: validators.Hash(), - }, + app.FinalizeBlock( + &abcitypes.RequestFinalizeBlock{ + Hash: app.LastCommitID().Hash, + Height: app.LastBlockHeight() + 1, + NextValidatorsHash: validators.Hash(), }, ) chain := &ibctesting.TestChain{ - T: t, + TB: t, Coordinator: coord, ChainID: chainID, App: app, @@ -371,14 +367,17 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC continue } - v, found := s.providerStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), consAddr) - if !found { + v, err := s.providerStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), consAddr) + // TODO: not sure why there was this code on ICS <= v5.x + // v, found := ... + // if !found { ... } + if err != nil { continue } stakingValidators = append(stakingValidators, v) } - considerAll := func(providerAddr types.ProviderConsAddress) bool { return true } + considerAll := func(providerAddr providertypes.ProviderConsAddress) bool { return true } nextValidators := s.providerKeeper().FilterValidators(s.providerCtx(), string(consumerChainId), stakingValidators, considerAll) s.providerKeeper().SetConsumerValSet(s.providerCtx(), string(consumerChainId), nextValidators) @@ -406,6 +405,19 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC // their channel, and are ready for anything to happen. s.consumerKeeper(consumerChainId).SetProviderChannel(s.ctx(consumerChainId), consumerEndPoint.ChannelID) + // TODO: @MSalopek remove if not needed post main merge on release/v5.x branch + // Commit a block on both chains, giving us two committed headers from + // the same time and height. This is the starting point for all our + // data driven testing. + // lastConsumerHeader, _ := simibc.FinalizeBlock(consumerChain, 5) + // lastProviderHeader, _ := simibc.FinalizeBlock(providerChain, 5) + + // // Update clients to the latest header. + // err = simibc.UpdateReceiverClient(consumerEndPoint, providerEndPoint, lastConsumerHeader, false) + // require.NoError(s.t, err, "Error updating client on consumer for chain %v", consumerChain.ChainID) + // err = simibc.UpdateReceiverClient(providerEndPoint, consumerEndPoint, lastProviderHeader, false) + // require.NoError(s.t, err, "Error updating client on provider for chain %v", consumerChain.ChainID) + // path is ready to go return path } @@ -448,8 +460,7 @@ func (s *Driver) setupProvider( } // produce a first block - simibc.EndBlock(providerChain, func() {}) - simibc.BeginBlock(providerChain, 0) + simibc.FinalizeBlock(providerChain, 0) } func (s *Driver) setupConsumer( @@ -488,6 +499,7 @@ func createConsumerGenesis(modelParams ModelParams, providerChain *ibctesting.Te ccvtypes.DefaultConsumerRedistributeFrac, ccvtypes.DefaultHistoricalEntries, modelParams.UnbondingPeriodPerChain[ChainId(consumerClientState.ChainId)], + ccvtypes.DefaultSoftOptOutThreshold, []string{}, []string{}, ccvtypes.DefaultRetryDelayPeriod, diff --git a/testutil/crypto/crypto.go b/testutil/crypto/crypto.go index a9c5341947..88fc8c6c01 100644 --- a/testutil/crypto/crypto.go +++ b/testutil/crypto/crypto.go @@ -15,7 +15,7 @@ import ( tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" tmtypes "github.com/cometbft/cometbft/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // CryptoIdentity is a test helper for generating keys and addresses of @@ -61,7 +61,7 @@ func (v *CryptoIdentity) TMValidator(power int64) *tmtypes.Validator { } func (v *CryptoIdentity) TMProtoCryptoPublicKey() tmprotocrypto.PublicKey { - ret, err := sdkcryptocodec.ToTmProtoPublicKey(v.ConsensusSDKPubKey()) + ret, err := sdkcryptocodec.ToCmtProtoPublicKey(v.ConsensusSDKPubKey()) if err != nil { panic(err) } @@ -69,7 +69,7 @@ func (v *CryptoIdentity) TMProtoCryptoPublicKey() tmprotocrypto.PublicKey { } func (v *CryptoIdentity) TMCryptoPubKey() tmcrypto.PubKey { - ret, err := sdkcryptocodec.ToTmPubKeyInterface(v.ConsensusSDKPubKey()) + ret, err := sdkcryptocodec.ToCmtPubKeyInterface(v.ConsensusSDKPubKey()) if err != nil { panic(err) } @@ -77,13 +77,17 @@ func (v *CryptoIdentity) TMCryptoPubKey() tmcrypto.PubKey { } func (v *CryptoIdentity) SDKStakingValidator() sdkstakingtypes.Validator { - ret, err := sdkstakingtypes.NewValidator(v.SDKValOpAddress(), v.ConsensusSDKPubKey(), sdkstakingtypes.Description{}) + ret, err := sdkstakingtypes.NewValidator(v.SDKValOpAddressString(), v.ConsensusSDKPubKey(), sdkstakingtypes.Description{}) if err != nil { panic(err) } return ret } +func (v *CryptoIdentity) SDKValOpAddressString() string { + return sdktypes.ValAddress(v.OperatorSDKPubKey().Address()).String() +} + func (v *CryptoIdentity) ConsensusSDKPubKey() sdkcryptotypes.PubKey { return v.consensus.PubKey() } diff --git a/testutil/crypto/evidence.go b/testutil/crypto/evidence.go index 653f20824e..786db9528a 100644 --- a/testutil/crypto/evidence.go +++ b/testutil/crypto/evidence.go @@ -1,12 +1,14 @@ package crypto import ( + "fmt" "time" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/cometbft/cometbft/crypto/tmhash" "github.com/cometbft/cometbft/libs/bytes" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" ) @@ -36,12 +38,20 @@ func MakeAndSignVote( signer tmtypes.PrivValidator, chainID string, ) *tmtypes.Vote { + pubKey, err := signer.GetPubKey() + if err != nil { + panic(fmt.Errorf("can't get pubkey: %w", err)) + } + addr := pubKey.Address() + idx, _ := valSet.GetByAddress(addr) vote, err := tmtypes.MakeVote( - blockHeight, - blockID, - valSet, signer, chainID, + idx, // val index + blockHeight, // height + 0, // round + tmproto.PrecommitType, // type (does not work if set to sth else) + blockID, blockTime, ) if err != nil { @@ -69,13 +79,22 @@ func MakeAndSignVoteWithForgedValAddress( valAddressSigner tmtypes.PrivValidator, chainID string, ) *tmtypes.Vote { + pubKey, err := signer.GetPubKey() + if err != nil { + panic(fmt.Errorf("can't get pubkey: %w", err)) + } + addr := pubKey.Address() + idx, _ := valSet.GetByAddress(addr) + // create the vote using a different key than the signing key vote, err := tmtypes.MakeVote( - blockHeight, - blockID, - valSet, valAddressSigner, chainID, + idx, + blockHeight, + 0, + tmproto.PrecommitType, + blockID, blockTime, ) if err != nil { diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 21e9d1326f..3aaae5702f 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -5,8 +5,9 @@ import ( "fmt" "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -16,10 +17,9 @@ import ( tmencoding "github.com/cometbft/cometbft/crypto/encoding" tmtypes "github.com/cometbft/cometbft/types" - testutil "github.com/cosmos/interchain-security/v4/testutil/integration" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/integration" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) type ( @@ -100,7 +100,7 @@ func AddDemocracyConsumer[T testutil.DemocConsumerApp]( s.T().Helper() // generate validators private/public key - valSet, valUpdates, signers, err := testutil.CreateValidators(4, "test") + valSet, valUpdates, signers, err := testutil.CreateValidators(4, "") require.NoError(s.T(), err) ibctesting.DefaultTestingAppInit = appIniter(valUpdates) @@ -142,26 +142,28 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( prop.ChainId = chainID prop.Top_N = consumerTopNParams[index] // isn't used in CreateConsumerClient - // opt-in all validators - for _, v := range providerKeeper.GetLastBondedValidators(providerChain.GetContext()) { - consAddr, _ := v.GetConsAddr() - providerKeeper.SetOptedIn(providerChain.GetContext(), chainID, providertypes.NewProviderConsAddress(consAddr)) - } - + // NOTE: we cannot use the time.Now() because the coordinator chooses a hardcoded start time + // using time.Now() could set the spawn time to be too far in the past or too far in the future + prop.SpawnTime = coordinator.CurrentTime // NOTE: the initial height passed to CreateConsumerClient // must be the height on the consumer when InitGenesis is called - prop.InitialHeight = clienttypes.Height{RevisionNumber: 0, RevisionHeight: 3} - err := providerKeeper.CreateConsumerClient( - providerChain.GetContext(), - prop, - ) + prop.InitialHeight = clienttypes.Height{RevisionNumber: 0, RevisionHeight: 2} + + providerKeeper.SetPendingConsumerAdditionProp(providerChain.GetContext(), prop) + props := providerKeeper.GetAllPendingConsumerAdditionProps(providerChain.GetContext()) + s.Require().Len(props, 1, "unexpected len consumer addition proposals in AddConsumer") + + // opt-in all validators + lastVals, err := providerApp.GetProviderKeeper().GetLastBondedValidators(providerChain.GetContext()) s.Require().NoError(err) - // set the consumer TopN here since the test suite setup only used the consumer addition prop - // to create the consumer genesis, see BeginBlockInit in /x/ccv/provider/keeper/proposal.go. - providerKeeper.SetTopN(providerChain.GetContext(), chainID, prop.Top_N) + for _, v := range lastVals { + consAddr, _ := v.GetConsAddr() + providerKeeper.SetOptedIn(providerChain.GetContext(), chainID, providertypes.NewProviderConsAddress(consAddr)) + } // commit the state on the provider chain + // and create the client and genesis of consumer coordinator.CommitBlock(providerChain) // get genesis state created by the provider @@ -169,14 +171,15 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerChain.GetContext(), chainID, ) - s.Require().True(found, "consumer genesis not found") + + s.Require().True(found, "consumer genesis not found in AddConsumer") // use InitialValSet as the valset on the consumer var valz []*tmtypes.Validator for _, update := range consumerGenesisState.Provider.InitialValSet { // tmPubKey update.PubKey tmPubKey, err := tmencoding.PubKeyFromProto(update.PubKey) - s.Require().NoError(err) + s.Require().NoError(err, "failed to convert tendermint pubkey") valz = append(valz, &tmtypes.Validator{ PubKey: tmPubKey, VotingPower: update.Power, diff --git a/testutil/ibc_testing/specific_setup.go b/testutil/ibc_testing/specific_setup.go index 2571346ca6..2ff06ca757 100644 --- a/testutil/ibc_testing/specific_setup.go +++ b/testutil/ibc_testing/specific_setup.go @@ -7,21 +7,21 @@ package ibc_testing import ( "encoding/json" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + db "github.com/cosmos/cosmos-db" + ibctesting "github.com/cosmos/ibc-go/v8/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" + "cosmossdk.io/log" "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - appConsumer "github.com/cosmos/interchain-security/v4/app/consumer" - appConsumerDemocracy "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - appProvider "github.com/cosmos/interchain-security/v4/app/provider" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + appConsumer "github.com/cosmos/interchain-security/v5/app/consumer" + appConsumerDemocracy "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + appProvider "github.com/cosmos/interchain-security/v5/app/provider" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) var ( @@ -33,7 +33,7 @@ var ( // ProviderAppIniter implements ibctesting.AppIniter for a provider app func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { encoding := appProvider.MakeTestEncodingConfig() - testApp := appProvider.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) + testApp := appProvider.New(log.NewNopLogger(), db.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) return testApp, appProvider.NewDefaultGenesisState(encoding.Codec) } @@ -41,9 +41,9 @@ func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { 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{}) + testApp := appConsumer.New(log.NewNopLogger(), db.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) genesisState := appConsumer.NewDefaultGenesisState(encoding.Codec) - // NOTE ibc-go/v7/testing.SetupWithGenesisValSet requires a staking module + // NOTE: starting from 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{ @@ -65,7 +65,7 @@ func ConsumerAppIniter(initValPowers []types.ValidatorUpdate) AppIniter { 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{}) + testApp := appConsumerDemocracy.New(log.NewNopLogger(), db.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) genesisState := appConsumerDemocracy.NewDefaultGenesisState(encoding.Codec) // Feed consumer genesis with provider validators // TODO See if useful for democracy diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 08728819bd..d26246dcf5 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -6,11 +6,11 @@ import ( "reflect" "testing" - appConsumer "github.com/cosmos/interchain-security/v4/app/consumer" - appConsumerDemocracy "github.com/cosmos/interchain-security/v4/app/consumer-democracy" - appProvider "github.com/cosmos/interchain-security/v4/app/provider" - integr "github.com/cosmos/interchain-security/v4/tests/integration" - icstestingutils "github.com/cosmos/interchain-security/v4/testutil/ibc_testing" + appConsumer "github.com/cosmos/interchain-security/v5/app/consumer" + appConsumerDemocracy "github.com/cosmos/interchain-security/v5/app/consumer-democracy" + appProvider "github.com/cosmos/interchain-security/v5/app/provider" + integr "github.com/cosmos/interchain-security/v5/tests/integration" + icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" ) // runCCVTestByName runs a single CCV integration test by name, using a CCVTestSuite @@ -69,6 +69,10 @@ func TestDemocracyGovernanceWhitelisting(t *testing.T) { runConsumerDemocracyTestByName(t, "TestDemocracyGovernanceWhitelisting") } +func TestDemocracyMsgUpdateParams(t *testing.T) { + runConsumerDemocracyTestByName(t, "TestDemocracyMsgUpdateParams") +} + // // Distribution tests // @@ -269,6 +273,7 @@ func TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations(t *testing runCCVTestByName(t, "TestHandleConsumerDoubleVotingSlashesUndelegationsAndRelegations") } +// // Throttle retry tests // @@ -276,6 +281,22 @@ func TestSlashRetries(t *testing.T) { runCCVTestByName(t, "TestSlashRetries") } +func TestKeyAssignment(t *testing.T) { + runCCVTestByName(t, "TestKeyAssignment") +} + +// +// Provider gov hooks test +// + +func TestAfterPropSubmissionAndVotingPeriodEnded(t *testing.T) { + runCCVTestByName(t, "TestAfterPropSubmissionAndVotingPeriodEnded") +} + +func TestGetConsumerAdditionLegacyPropFromProp(t *testing.T) { + runCCVTestByName(t, "TestGetConsumerAdditionLegacyPropFromProp") +} + func TestIBCTransferMiddleware(t *testing.T) { runCCVTestByName(t, "TestIBCTransferMiddleware") } diff --git a/testutil/integration/interfaces.go b/testutil/integration/interfaces.go index 2c4e3f9e3d..de9c3a6b0d 100644 --- a/testutil/integration/interfaces.go +++ b/testutil/integration/interfaces.go @@ -1,29 +1,30 @@ package integration import ( + "context" "time" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + abci "github.com/cometbft/cometbft/abci/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + "cosmossdk.io/core/comet" "cosmossdk.io/math" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + evidencekeeper "cosmossdk.io/x/evidence/keeper" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - abci "github.com/cometbft/cometbft/abci/types" - - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // The interface that any provider app must implement to be compatible with ccv integration tests. @@ -47,6 +48,8 @@ type ProviderApp interface { GetTestDistributionKeeper() TestDistributionKeeper // Returns an account keeper interface with more capabilities than the expected_keepers interface GetTestAccountKeeper() TestAccountKeeper + + GetTestGovKeeper() *govkeeper.Keeper } // The interface that any consumer app must implement to be compatible with integration tests @@ -54,7 +57,7 @@ type ProviderApp interface { type ConsumerApp interface { ibctesting.TestingApp - BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock + // BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock GetConsumerKeeper() consumerkeeper.Keeper GetSubspace(moduleName string) paramstypes.Subspace @@ -69,7 +72,7 @@ type ConsumerApp interface { // Tests a slashing keeper interface with more capabilities than the expected_keepers interface GetTestSlashingKeeper() TestSlashingKeeper // Tests an evidence keeper interface with more capabilities than the expected_keepers interface - GetTestEvidenceKeeper() TestEvidenceKeeper + GetTestEvidenceKeeper() evidencekeeper.Keeper } type DemocConsumerApp interface { @@ -79,9 +82,10 @@ type DemocConsumerApp interface { // Tests a staking keeper interface with more capabilities than the expected_keepers interface GetTestStakingKeeper() TestStakingKeeper // Tests a mint keeper interface with more capabilities than the expected_keepers interface - GetTestMintKeeper() TestMintKeeper - // Tests a gov keeper interface with more capabilities than the expected_keepers interface - GetTestGovKeeper() TestGovKeeper + GetTestMintKeeper() mintkeeper.Keeper + + // @MSalopek -> on v50 we need to access the Params collection which does not have a getter + GetTestGovKeeper() govkeeper.Keeper } // @@ -91,62 +95,57 @@ type DemocConsumerApp interface { type TestStakingKeeper interface { ccvtypes.StakingKeeper - Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc types.BondStatus, - validator types.Validator, subtractAccount bool) (newShares sdk.Dec, err error) - Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec, - ) (time.Time, error) - BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, - sharesAmount sdk.Dec) (completionTime time.Time, err error) - GetUnbondingDelegationByUnbondingID(ctx sdk.Context, id uint64, - ) (ubd types.UnbondingDelegation, found bool) - GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16) (redelegations []types.Redelegation) - BondDenom(ctx sdk.Context) (res string) - IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool - GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, - ) (ubd types.UnbondingDelegation, found bool) - GetAllValidators(ctx sdk.Context) (validators []types.Validator) - GetValidatorSet() types.ValidatorSet - GetParams(ctx sdk.Context) stakingtypes.Params - SetParams(ctx sdk.Context, p stakingtypes.Params) error - ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []abci.ValidatorUpdate, err error) + Delegate( + ctx context.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc stakingtypes.BondStatus, + validator stakingtypes.Validator, subtractAccount bool, + ) (newShares math.LegacyDec, err error) + Undelegate(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount math.LegacyDec, + ) (time.Time, math.Int, error) + BeginRedelegation( + ctx context.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount math.LegacyDec, + ) (completionTime time.Time, err error) + GetUnbondingDelegationByUnbondingID(ctx context.Context, id uint64) (ubd stakingtypes.UnbondingDelegation, err error) + GetRedelegations(ctx context.Context, delegator sdk.AccAddress, maxRetrieve uint16) (redelegations []stakingtypes.Redelegation, err error) + GetUnbondingDelegation(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (ubd stakingtypes.UnbondingDelegation, err error) + GetAllValidators(ctx context.Context) (validators []stakingtypes.Validator, err error) + GetValidatorSet() stakingtypes.ValidatorSet + GetParams(ctx context.Context) (stakingtypes.Params, error) + SetParams(ctx context.Context, p stakingtypes.Params) error + ApplyAndReturnValidatorSetUpdates(ctx context.Context) (updates []abci.ValidatorUpdate, err error) } type TestBankKeeper interface { ccvtypes.BankKeeper - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } type TestAccountKeeper interface { ccvtypes.AccountKeeper - GetParams(sdk.Context) authtypes.Params + GetParams(context.Context) authtypes.Params } type TestSlashingKeeper interface { ccvtypes.SlashingKeeper - SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress, - info slashingtypes.ValidatorSigningInfo) - SignedBlocksWindow(ctx sdk.Context) (res int64) - HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Address, power int64, signed bool) - MinSignedPerWindow(ctx sdk.Context) int64 - IterateValidatorMissedBlockBitArray(ctx sdk.Context, - address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool)) -} - -type TestEvidenceKeeper interface { - HandleEquivocationEvidence(ctx sdk.Context, evidence *evidencetypes.Equivocation) + SetValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) error + SignedBlocksWindow(ctx context.Context) (int64, error) + HandleValidatorSignature(ctx context.Context, addr cryptotypes.Address, power int64, signed comet.BlockIDFlag) error + MinSignedPerWindow(ctx context.Context) (int64, error) + // NOTE: @MSalopek deprecated in v50 + // IterateValidatorMissedBlockBitArray(ctx sdk.Context, + // address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool)) + IterateMissedBlockBitmap(ctx context.Context, addr sdk.ConsAddress, cb func(index int64, missed bool) (stop bool)) error } type TestDistributionKeeper interface { - GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins - GetDistributionAccount(ctx sdk.Context) authtypes.ModuleAccountI - GetValidatorOutstandingRewards(ctx sdk.Context, - val sdk.ValAddress) (rewards distributiontypes.ValidatorOutstandingRewards) - GetCommunityTax(ctx sdk.Context) (percent sdk.Dec) - WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) (sdk.Coins, error) + // NOTE: @MSalopek deprecated in v50 + // GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins + GetDistributionAccount(ctx context.Context) sdk.ModuleAccountI + GetValidatorOutstandingRewards(ctx context.Context, val sdk.ValAddress) (rewards distributiontypes.ValidatorOutstandingRewards, err error) + GetCommunityTax(ctx context.Context) (math.LegacyDec, error) + WithdrawValidatorCommission(ctx context.Context, valAddr sdk.ValAddress) (sdk.Coins, error) } type TestMintKeeper interface { diff --git a/testutil/integration/validators.go b/testutil/integration/validators.go index 513c40021a..c317c2cf22 100644 --- a/testutil/integration/validators.go +++ b/testutil/integration/validators.go @@ -1,11 +1,6 @@ package integration import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "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" @@ -26,7 +21,8 @@ func CreateValidators(n int, chainId string) ( signersByAddress = make(map[string]tmtypes.PrivValidator, n) ) for i := 0; i < n; i++ { - privVal := mock.PV{PrivKey: ed25519.GenPrivKeyFromSecret([]byte(chainId + fmt.Sprint(i)))} + privVal := tmtypes.NewMockPV() + // privVal := mock.PV{PrivKey: ed25519.GenPrivKeyFromSecret([]byte(chainId + fmt.Sprint(i)))} pubKey, err := privVal.GetPubKey() if err != nil { return nil, nil, nil, err diff --git a/testutil/keeper/expectations.go b/testutil/keeper/expectations.go index 0c6db62cf0..9b57643167 100644 --- a/testutil/keeper/expectations.go +++ b/testutil/keeper/expectations.go @@ -3,22 +3,22 @@ package keeper import ( time "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - 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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/mock/gomock" extra "github.com/oxyno-zeta/gomock-extra-matcher" math "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // @@ -53,8 +53,7 @@ func GetMocksForMakeConsumerGenesis(ctx sdk.Context, mocks *MockedKeepers, unbondingTimeToInject time.Duration, ) []*gomock.Call { return []*gomock.Call{ - mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Return(unbondingTimeToInject).Times(1), - + mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Return(unbondingTimeToInject, nil).Times(1), mocks.MockClientKeeper.EXPECT().GetSelfConsensusState(gomock.Any(), clienttypes.GetSelfHeight(ctx)).Return(&ibctmtypes.ConsensusState{}, nil).Times(1), } @@ -102,7 +101,7 @@ func GetMocksForHandleSlashPacket(ctx sdk.Context, mocks MockedKeepers, calls := []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, expectedProviderValConsAddr.ToSdkConsAddr()).Return( - valToReturn, true, + valToReturn, nil, ).Times(1), mocks.MockSlashingKeeper.EXPECT().IsTombstoned(ctx, @@ -113,12 +112,12 @@ func GetMocksForHandleSlashPacket(ctx sdk.Context, mocks MockedKeepers, calls = append(calls, mocks.MockStakingKeeper.EXPECT().Jail( gomock.Eq(ctx), gomock.Eq(expectedProviderValConsAddr.ToSdkConsAddr()), - ).Return()) + ).Return(nil)) // JailUntil is set in this code path. - calls = append(calls, mocks.MockSlashingKeeper.EXPECT().DowntimeJailDuration(ctx).Return(time.Hour).Times(1)) + calls = append(calls, mocks.MockSlashingKeeper.EXPECT().DowntimeJailDuration(ctx).Return(time.Hour, nil).Times(1)) calls = append(calls, mocks.MockSlashingKeeper.EXPECT().JailUntil(ctx, - expectedProviderValConsAddr.ToSdkConsAddr(), gomock.Any()).Times(1)) + expectedProviderValConsAddr.ToSdkConsAddr(), gomock.Any()).Return(nil).Times(1)) } return calls @@ -186,26 +185,26 @@ func GetMocksForSlashValidator( mocks.MockStakingKeeper.EXPECT(). SlashUnbondingDelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn( - func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ math.LegacyDec) math.Int { + sum := math.NewInt(0) for _, r := range undelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } return sum }).AnyTimes(), mocks.MockStakingKeeper.EXPECT(). SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn( - func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ math.LegacyDec) math.Int { + sum := math.NewInt(0) for _, r := range redelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } return sum }).AnyTimes(), @@ -223,14 +222,15 @@ func GetMocksForSlashValidator( // Times is the number of times the expectation should be called. Provide -1 for `AnyTimes“. func SetupMocksForLastBondedValidatorsExpectation(mockStakingKeeper *MockStakingKeeper, maxValidators uint32, vals []stakingtypes.Validator, powers []int64, times int) { iteratorCall := mockStakingKeeper.EXPECT().IterateLastValidatorPowers(gomock.Any(), gomock.Any()).DoAndReturn( - func(ctx sdk.Context, cb func(sdk.ValAddress, int64) bool) { + func(ctx sdk.Context, cb func(sdk.ValAddress, int64) bool) error { for i, val := range vals { if stop := cb(sdk.ValAddress(val.OperatorAddress), powers[i]); stop { break } } + return nil }) - maxValidatorsCall := mockStakingKeeper.EXPECT().MaxValidators(gomock.Any()).Return(maxValidators) + maxValidatorsCall := mockStakingKeeper.EXPECT().MaxValidators(gomock.Any()).Return(maxValidators, nil) if times == -1 { iteratorCall.AnyTimes() @@ -242,7 +242,7 @@ func SetupMocksForLastBondedValidatorsExpectation(mockStakingKeeper *MockStaking // set up mocks for GetValidator calls for _, val := range vals { - getValCall := mockStakingKeeper.EXPECT().GetValidator(gomock.Any(), sdk.ValAddress(val.OperatorAddress)).Return(val, true) + getValCall := mockStakingKeeper.EXPECT().GetValidator(gomock.Any(), sdk.ValAddress(val.OperatorAddress)).Return(val, nil) if times == -1 { getValCall.AnyTimes() } else { diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index 783144eb49..7beb0c0bcd 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -10,19 +10,17 @@ import ( time "time" math "cosmossdk.io/math" - types "github.com/cometbft/cometbft/abci/types" - types0 "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/x/auth/types" - types2 "github.com/cosmos/cosmos-sdk/x/capability/types" - types3 "github.com/cosmos/cosmos-sdk/x/distribution/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - types4 "github.com/cosmos/cosmos-sdk/x/slashing/types" - types5 "github.com/cosmos/cosmos-sdk/x/staking/types" - types6 "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - types7 "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - types8 "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - types9 "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - exported "github.com/cosmos/ibc-go/v7/modules/core/exported" + types "cosmossdk.io/store/types" + types0 "github.com/cometbft/cometbft/abci/types" + types1 "github.com/cosmos/cosmos-sdk/types" + types2 "github.com/cosmos/cosmos-sdk/x/slashing/types" + types3 "github.com/cosmos/cosmos-sdk/x/staking/types" + types4 "github.com/cosmos/ibc-go/modules/capability/types" + types5 "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + types6 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + types7 "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + types8 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + exported "github.com/cosmos/ibc-go/v8/modules/core/exported" gomock "github.com/golang/mock/gomock" ) @@ -50,11 +48,12 @@ func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { } // BondDenom mocks base method. -func (m *MockStakingKeeper) BondDenom(ctx types0.Context) string { +func (m *MockStakingKeeper) BondDenom(ctx context.Context) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BondDenom", ctx) ret0, _ := ret[0].(string) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // BondDenom indicates an expected call of BondDenom. @@ -64,11 +63,12 @@ func (mr *MockStakingKeeperMockRecorder) BondDenom(ctx interface{}) *gomock.Call } // Delegation mocks base method. -func (m *MockStakingKeeper) Delegation(ctx types0.Context, addr types0.AccAddress, valAddr types0.ValAddress) types5.DelegationI { +func (m *MockStakingKeeper) Delegation(ctx context.Context, addr types1.AccAddress, valAddr types1.ValAddress) (types3.DelegationI, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Delegation", ctx, addr, valAddr) - ret0, _ := ret[0].(types5.DelegationI) - return ret0 + ret0, _ := ret[0].(types3.DelegationI) + ret1, _ := ret[1].(error) + return ret0, ret1 } // Delegation indicates an expected call of Delegation. @@ -78,11 +78,12 @@ func (mr *MockStakingKeeperMockRecorder) Delegation(ctx, addr, valAddr interface } // GetLastTotalPower mocks base method. -func (m *MockStakingKeeper) GetLastTotalPower(ctx types0.Context) math.Int { +func (m *MockStakingKeeper) GetLastTotalPower(ctx context.Context) (math.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLastTotalPower", ctx) ret0, _ := ret[0].(math.Int) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetLastTotalPower indicates an expected call of GetLastTotalPower. @@ -92,11 +93,12 @@ func (mr *MockStakingKeeperMockRecorder) GetLastTotalPower(ctx interface{}) *gom } // GetLastValidatorPower mocks base method. -func (m *MockStakingKeeper) GetLastValidatorPower(ctx types0.Context, operator types0.ValAddress) int64 { +func (m *MockStakingKeeper) GetLastValidatorPower(ctx context.Context, operator types1.ValAddress) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLastValidatorPower", ctx, operator) ret0, _ := ret[0].(int64) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetLastValidatorPower indicates an expected call of GetLastValidatorPower. @@ -106,11 +108,11 @@ func (mr *MockStakingKeeperMockRecorder) GetLastValidatorPower(ctx, operator int } // GetRedelegationByUnbondingID mocks base method. -func (m *MockStakingKeeper) GetRedelegationByUnbondingID(ctx types0.Context, id uint64) (types5.Redelegation, bool) { +func (m *MockStakingKeeper) GetRedelegationByUnbondingID(ctx context.Context, id uint64) (types3.Redelegation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetRedelegationByUnbondingID", ctx, id) - ret0, _ := ret[0].(types5.Redelegation) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.Redelegation) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -121,11 +123,12 @@ func (mr *MockStakingKeeperMockRecorder) GetRedelegationByUnbondingID(ctx, id in } // GetRedelegationsFromSrcValidator mocks base method. -func (m *MockStakingKeeper) GetRedelegationsFromSrcValidator(ctx types0.Context, valAddr types0.ValAddress) []types5.Redelegation { +func (m *MockStakingKeeper) GetRedelegationsFromSrcValidator(ctx context.Context, valAddr types1.ValAddress) ([]types3.Redelegation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetRedelegationsFromSrcValidator", ctx, valAddr) - ret0, _ := ret[0].([]types5.Redelegation) - return ret0 + ret0, _ := ret[0].([]types3.Redelegation) + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetRedelegationsFromSrcValidator indicates an expected call of GetRedelegationsFromSrcValidator. @@ -135,11 +138,11 @@ func (mr *MockStakingKeeperMockRecorder) GetRedelegationsFromSrcValidator(ctx, v } // GetUnbondingDelegationByUnbondingID mocks base method. -func (m *MockStakingKeeper) GetUnbondingDelegationByUnbondingID(ctx types0.Context, id uint64) (types5.UnbondingDelegation, bool) { +func (m *MockStakingKeeper) GetUnbondingDelegationByUnbondingID(ctx context.Context, id uint64) (types3.UnbondingDelegation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnbondingDelegationByUnbondingID", ctx, id) - ret0, _ := ret[0].(types5.UnbondingDelegation) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.UnbondingDelegation) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -150,11 +153,12 @@ func (mr *MockStakingKeeperMockRecorder) GetUnbondingDelegationByUnbondingID(ctx } // GetUnbondingDelegationsFromValidator mocks base method. -func (m *MockStakingKeeper) GetUnbondingDelegationsFromValidator(ctx types0.Context, valAddr types0.ValAddress) []types5.UnbondingDelegation { +func (m *MockStakingKeeper) GetUnbondingDelegationsFromValidator(ctx context.Context, valAddr types1.ValAddress) ([]types3.UnbondingDelegation, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnbondingDelegationsFromValidator", ctx, valAddr) - ret0, _ := ret[0].([]types5.UnbondingDelegation) - return ret0 + ret0, _ := ret[0].([]types3.UnbondingDelegation) + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetUnbondingDelegationsFromValidator indicates an expected call of GetUnbondingDelegationsFromValidator. @@ -164,11 +168,11 @@ func (mr *MockStakingKeeperMockRecorder) GetUnbondingDelegationsFromValidator(ct } // GetUnbondingType mocks base method. -func (m *MockStakingKeeper) GetUnbondingType(ctx types0.Context, id uint64) (types5.UnbondingType, bool) { +func (m *MockStakingKeeper) GetUnbondingType(ctx context.Context, id uint64) (types3.UnbondingType, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnbondingType", ctx, id) - ret0, _ := ret[0].(types5.UnbondingType) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.UnbondingType) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -179,11 +183,11 @@ func (mr *MockStakingKeeperMockRecorder) GetUnbondingType(ctx, id interface{}) * } // GetValidator mocks base method. -func (m *MockStakingKeeper) GetValidator(ctx types0.Context, addr types0.ValAddress) (types5.Validator, bool) { +func (m *MockStakingKeeper) GetValidator(ctx context.Context, addr types1.ValAddress) (types3.Validator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetValidator", ctx, addr) - ret0, _ := ret[0].(types5.Validator) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.Validator) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -194,11 +198,11 @@ func (mr *MockStakingKeeperMockRecorder) GetValidator(ctx, addr interface{}) *go } // GetValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) GetValidatorByConsAddr(ctx types0.Context, consAddr types0.ConsAddress) (types5.Validator, bool) { +func (m *MockStakingKeeper) GetValidatorByConsAddr(ctx context.Context, consAddr types1.ConsAddress) (types3.Validator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetValidatorByConsAddr", ctx, consAddr) - ret0, _ := ret[0].(types5.Validator) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.Validator) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -209,11 +213,11 @@ func (mr *MockStakingKeeperMockRecorder) GetValidatorByConsAddr(ctx, consAddr in } // GetValidatorByUnbondingID mocks base method. -func (m *MockStakingKeeper) GetValidatorByUnbondingID(ctx types0.Context, id uint64) (types5.Validator, bool) { +func (m *MockStakingKeeper) GetValidatorByUnbondingID(ctx context.Context, id uint64) (types3.Validator, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetValidatorByUnbondingID", ctx, id) - ret0, _ := ret[0].(types5.Validator) - ret1, _ := ret[1].(bool) + ret0, _ := ret[0].(types3.Validator) + ret1, _ := ret[1].(error) return ret0, ret1 } @@ -224,11 +228,12 @@ func (mr *MockStakingKeeperMockRecorder) GetValidatorByUnbondingID(ctx, id inter } // GetValidatorUpdates mocks base method. -func (m *MockStakingKeeper) GetValidatorUpdates(ctx types0.Context) []types.ValidatorUpdate { +func (m *MockStakingKeeper) GetValidatorUpdates(ctx context.Context) ([]types0.ValidatorUpdate, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetValidatorUpdates", ctx) - ret0, _ := ret[0].([]types.ValidatorUpdate) - return ret0 + ret0, _ := ret[0].([]types0.ValidatorUpdate) + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetValidatorUpdates indicates an expected call of GetValidatorUpdates. @@ -238,11 +243,12 @@ func (mr *MockStakingKeeperMockRecorder) GetValidatorUpdates(ctx interface{}) *g } // IsValidatorJailed mocks base method. -func (m *MockStakingKeeper) IsValidatorJailed(ctx types0.Context, addr types0.ConsAddress) bool { +func (m *MockStakingKeeper) IsValidatorJailed(ctx context.Context, addr types1.ConsAddress) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsValidatorJailed", ctx, addr) ret0, _ := ret[0].(bool) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // IsValidatorJailed indicates an expected call of IsValidatorJailed. @@ -252,9 +258,11 @@ func (mr *MockStakingKeeperMockRecorder) IsValidatorJailed(ctx, addr interface{} } // IterateLastValidatorPowers mocks base method. -func (m *MockStakingKeeper) IterateLastValidatorPowers(ctx types0.Context, cb func(types0.ValAddress, int64) bool) { +func (m *MockStakingKeeper) IterateLastValidatorPowers(ctx context.Context, cb func(types1.ValAddress, int64) bool) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateLastValidatorPowers", ctx, cb) + ret := m.ctrl.Call(m, "IterateLastValidatorPowers", ctx, cb) + ret0, _ := ret[0].(error) + return ret0 } // IterateLastValidatorPowers indicates an expected call of IterateLastValidatorPowers. @@ -264,9 +272,11 @@ func (mr *MockStakingKeeperMockRecorder) IterateLastValidatorPowers(ctx, cb inte } // IterateValidators mocks base method. -func (m *MockStakingKeeper) IterateValidators(ctx types0.Context, f func(int64, types5.ValidatorI) bool) { +func (m *MockStakingKeeper) IterateValidators(ctx context.Context, f func(int64, types3.ValidatorI) bool) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "IterateValidators", ctx, f) + ret := m.ctrl.Call(m, "IterateValidators", ctx, f) + ret0, _ := ret[0].(error) + return ret0 } // IterateValidators indicates an expected call of IterateValidators. @@ -276,9 +286,11 @@ func (mr *MockStakingKeeperMockRecorder) IterateValidators(ctx, f interface{}) * } // Jail mocks base method. -func (m *MockStakingKeeper) Jail(arg0 types0.Context, arg1 types0.ConsAddress) { +func (m *MockStakingKeeper) Jail(arg0 context.Context, arg1 types1.ConsAddress) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "Jail", arg0, arg1) + ret := m.ctrl.Call(m, "Jail", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 } // Jail indicates an expected call of Jail. @@ -288,11 +300,12 @@ func (mr *MockStakingKeeperMockRecorder) Jail(arg0, arg1 interface{}) *gomock.Ca } // MaxValidators mocks base method. -func (m *MockStakingKeeper) MaxValidators(ctx types0.Context) uint32 { +func (m *MockStakingKeeper) MaxValidators(ctx context.Context) (uint32, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MaxValidators", ctx) ret0, _ := ret[0].(uint32) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // MaxValidators indicates an expected call of MaxValidators. @@ -302,11 +315,12 @@ func (mr *MockStakingKeeperMockRecorder) MaxValidators(ctx interface{}) *gomock. } // MinCommissionRate mocks base method. -func (m *MockStakingKeeper) MinCommissionRate(ctx types0.Context) math.LegacyDec { +func (m *MockStakingKeeper) MinCommissionRate(ctx context.Context) (math.LegacyDec, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MinCommissionRate", ctx) ret0, _ := ret[0].(math.LegacyDec) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // MinCommissionRate indicates an expected call of MinCommissionRate. @@ -316,7 +330,7 @@ func (mr *MockStakingKeeperMockRecorder) MinCommissionRate(ctx interface{}) *gom } // PowerReduction mocks base method. -func (m *MockStakingKeeper) PowerReduction(ctx types0.Context) math.Int { +func (m *MockStakingKeeper) PowerReduction(ctx context.Context) math.Int { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PowerReduction", ctx) ret0, _ := ret[0].(math.Int) @@ -330,7 +344,7 @@ func (mr *MockStakingKeeperMockRecorder) PowerReduction(ctx interface{}) *gomock } // PutUnbondingOnHold mocks base method. -func (m *MockStakingKeeper) PutUnbondingOnHold(ctx types0.Context, id uint64) error { +func (m *MockStakingKeeper) PutUnbondingOnHold(ctx context.Context, id uint64) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "PutUnbondingOnHold", ctx, id) ret0, _ := ret[0].(error) @@ -344,63 +358,67 @@ func (mr *MockStakingKeeperMockRecorder) PutUnbondingOnHold(ctx, id interface{}) } // Slash mocks base method. -func (m *MockStakingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2, arg3 int64, arg4 types0.Dec) math.Int { +func (m *MockStakingKeeper) Slash(ctx context.Context, consAddr types1.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec) (math.Int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4) + ret := m.ctrl.Call(m, "Slash", ctx, consAddr, infractionHeight, power, slashFactor) ret0, _ := ret[0].(math.Int) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // Slash indicates an expected call of Slash. -func (mr *MockStakingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockStakingKeeperMockRecorder) Slash(ctx, consAddr, infractionHeight, power, slashFactor interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockStakingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockStakingKeeper)(nil).Slash), ctx, consAddr, infractionHeight, power, slashFactor) } // SlashRedelegation mocks base method. -func (m *MockStakingKeeper) SlashRedelegation(arg0 types0.Context, arg1 types5.Validator, arg2 types5.Redelegation, arg3 int64, arg4 types0.Dec) math.Int { +func (m *MockStakingKeeper) SlashRedelegation(ctx context.Context, srcValidator types3.Validator, redelegation types3.Redelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SlashRedelegation", arg0, arg1, arg2, arg3, arg4) + ret := m.ctrl.Call(m, "SlashRedelegation", ctx, srcValidator, redelegation, infractionHeight, slashFactor) ret0, _ := ret[0].(math.Int) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // SlashRedelegation indicates an expected call of SlashRedelegation. -func (mr *MockStakingKeeperMockRecorder) SlashRedelegation(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { +func (mr *MockStakingKeeperMockRecorder) SlashRedelegation(ctx, srcValidator, redelegation, infractionHeight, slashFactor interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashRedelegation", reflect.TypeOf((*MockStakingKeeper)(nil).SlashRedelegation), arg0, arg1, arg2, arg3, arg4) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashRedelegation", reflect.TypeOf((*MockStakingKeeper)(nil).SlashRedelegation), ctx, srcValidator, redelegation, infractionHeight, slashFactor) } // SlashUnbondingDelegation mocks base method. -func (m *MockStakingKeeper) SlashUnbondingDelegation(arg0 types0.Context, arg1 types5.UnbondingDelegation, arg2 int64, arg3 types0.Dec) math.Int { +func (m *MockStakingKeeper) SlashUnbondingDelegation(ctx context.Context, unbondingDelegation types3.UnbondingDelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SlashUnbondingDelegation", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "SlashUnbondingDelegation", ctx, unbondingDelegation, infractionHeight, slashFactor) ret0, _ := ret[0].(math.Int) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // SlashUnbondingDelegation indicates an expected call of SlashUnbondingDelegation. -func (mr *MockStakingKeeperMockRecorder) SlashUnbondingDelegation(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockStakingKeeperMockRecorder) SlashUnbondingDelegation(ctx, unbondingDelegation, infractionHeight, slashFactor interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashUnbondingDelegation", reflect.TypeOf((*MockStakingKeeper)(nil).SlashUnbondingDelegation), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashUnbondingDelegation", reflect.TypeOf((*MockStakingKeeper)(nil).SlashUnbondingDelegation), ctx, unbondingDelegation, infractionHeight, slashFactor) } // SlashWithInfractionReason mocks base method. -func (m *MockStakingKeeper) SlashWithInfractionReason(arg0 types0.Context, arg1 types0.ConsAddress, arg2, arg3 int64, arg4 types0.Dec, arg5 types5.Infraction) math.Int { +func (m *MockStakingKeeper) SlashWithInfractionReason(ctx context.Context, consAddr types1.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec, infraction types3.Infraction) (math.Int, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SlashWithInfractionReason", arg0, arg1, arg2, arg3, arg4, arg5) + ret := m.ctrl.Call(m, "SlashWithInfractionReason", ctx, consAddr, infractionHeight, power, slashFactor, infraction) ret0, _ := ret[0].(math.Int) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // SlashWithInfractionReason indicates an expected call of SlashWithInfractionReason. -func (mr *MockStakingKeeperMockRecorder) SlashWithInfractionReason(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +func (mr *MockStakingKeeperMockRecorder) SlashWithInfractionReason(ctx, consAddr, infractionHeight, power, slashFactor, infraction interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashWithInfractionReason", reflect.TypeOf((*MockStakingKeeper)(nil).SlashWithInfractionReason), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashWithInfractionReason", reflect.TypeOf((*MockStakingKeeper)(nil).SlashWithInfractionReason), ctx, consAddr, infractionHeight, power, slashFactor, infraction) } // UnbondingCanComplete mocks base method. -func (m *MockStakingKeeper) UnbondingCanComplete(ctx types0.Context, id uint64) error { +func (m *MockStakingKeeper) UnbondingCanComplete(ctx context.Context, id uint64) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnbondingCanComplete", ctx, id) ret0, _ := ret[0].(error) @@ -414,11 +432,12 @@ func (mr *MockStakingKeeperMockRecorder) UnbondingCanComplete(ctx, id interface{ } // UnbondingTime mocks base method. -func (m *MockStakingKeeper) UnbondingTime(ctx types0.Context) time.Duration { +func (m *MockStakingKeeper) UnbondingTime(ctx context.Context) (time.Duration, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnbondingTime", ctx) ret0, _ := ret[0].(time.Duration) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // UnbondingTime indicates an expected call of UnbondingTime. @@ -428,9 +447,11 @@ func (mr *MockStakingKeeperMockRecorder) UnbondingTime(ctx interface{}) *gomock. } // Unjail mocks base method. -func (m *MockStakingKeeper) Unjail(ctx types0.Context, addr types0.ConsAddress) { +func (m *MockStakingKeeper) Unjail(ctx context.Context, addr types1.ConsAddress) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "Unjail", ctx, addr) + ret := m.ctrl.Call(m, "Unjail", ctx, addr) + ret0, _ := ret[0].(error) + return ret0 } // Unjail indicates an expected call of Unjail. @@ -440,11 +461,12 @@ func (mr *MockStakingKeeperMockRecorder) Unjail(ctx, addr interface{}) *gomock.C } // Validator mocks base method. -func (m *MockStakingKeeper) Validator(ctx types0.Context, addr types0.ValAddress) types5.ValidatorI { +func (m *MockStakingKeeper) Validator(ctx context.Context, addr types1.ValAddress) (types3.ValidatorI, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Validator", ctx, addr) - ret0, _ := ret[0].(types5.ValidatorI) - return ret0 + ret0, _ := ret[0].(types3.ValidatorI) + ret1, _ := ret[1].(error) + return ret0, ret1 } // Validator indicates an expected call of Validator. @@ -454,11 +476,12 @@ func (mr *MockStakingKeeperMockRecorder) Validator(ctx, addr interface{}) *gomoc } // ValidatorByConsAddr mocks base method. -func (m *MockStakingKeeper) ValidatorByConsAddr(ctx types0.Context, consAddr types0.ConsAddress) types5.ValidatorI { +func (m *MockStakingKeeper) ValidatorByConsAddr(ctx context.Context, consAddr types1.ConsAddress) (types3.ValidatorI, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ValidatorByConsAddr", ctx, consAddr) - ret0, _ := ret[0].(types5.ValidatorI) - return ret0 + ret0, _ := ret[0].(types3.ValidatorI) + ret1, _ := ret[1].(error) + return ret0, ret1 } // ValidatorByConsAddr indicates an expected call of ValidatorByConsAddr. @@ -491,11 +514,12 @@ func (m *MockSlashingKeeper) EXPECT() *MockSlashingKeeperMockRecorder { } // DowntimeJailDuration mocks base method. -func (m *MockSlashingKeeper) DowntimeJailDuration(arg0 types0.Context) time.Duration { +func (m *MockSlashingKeeper) DowntimeJailDuration(arg0 context.Context) (time.Duration, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DowntimeJailDuration", arg0) ret0, _ := ret[0].(time.Duration) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // DowntimeJailDuration indicates an expected call of DowntimeJailDuration. @@ -505,22 +529,22 @@ func (mr *MockSlashingKeeperMockRecorder) DowntimeJailDuration(arg0 interface{}) } // GetValidatorSigningInfo mocks base method. -func (m *MockSlashingKeeper) GetValidatorSigningInfo(ctx types0.Context, address types0.ConsAddress) (types4.ValidatorSigningInfo, bool) { +func (m *MockSlashingKeeper) GetValidatorSigningInfo(arg0 context.Context, arg1 types1.ConsAddress) (types2.ValidatorSigningInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetValidatorSigningInfo", ctx, address) - ret0, _ := ret[0].(types4.ValidatorSigningInfo) - ret1, _ := ret[1].(bool) + ret := m.ctrl.Call(m, "GetValidatorSigningInfo", arg0, arg1) + ret0, _ := ret[0].(types2.ValidatorSigningInfo) + ret1, _ := ret[1].(error) return ret0, ret1 } // GetValidatorSigningInfo indicates an expected call of GetValidatorSigningInfo. -func (mr *MockSlashingKeeperMockRecorder) GetValidatorSigningInfo(ctx, address interface{}) *gomock.Call { +func (mr *MockSlashingKeeperMockRecorder) GetValidatorSigningInfo(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorSigningInfo", reflect.TypeOf((*MockSlashingKeeper)(nil).GetValidatorSigningInfo), ctx, address) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorSigningInfo", reflect.TypeOf((*MockSlashingKeeper)(nil).GetValidatorSigningInfo), arg0, arg1) } // IsTombstoned mocks base method. -func (m *MockSlashingKeeper) IsTombstoned(arg0 types0.Context, arg1 types0.ConsAddress) bool { +func (m *MockSlashingKeeper) IsTombstoned(arg0 context.Context, arg1 types1.ConsAddress) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IsTombstoned", arg0, arg1) ret0, _ := ret[0].(bool) @@ -534,9 +558,11 @@ func (mr *MockSlashingKeeperMockRecorder) IsTombstoned(arg0, arg1 interface{}) * } // JailUntil mocks base method. -func (m *MockSlashingKeeper) JailUntil(arg0 types0.Context, arg1 types0.ConsAddress, arg2 time.Time) { +func (m *MockSlashingKeeper) JailUntil(arg0 context.Context, arg1 types1.ConsAddress, arg2 time.Time) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "JailUntil", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "JailUntil", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 } // JailUntil indicates an expected call of JailUntil. @@ -546,37 +572,41 @@ func (mr *MockSlashingKeeperMockRecorder) JailUntil(arg0, arg1, arg2 interface{} } // SetValidatorSigningInfo mocks base method. -func (m *MockSlashingKeeper) SetValidatorSigningInfo(ctx types0.Context, address types0.ConsAddress, info types4.ValidatorSigningInfo) { +func (m *MockSlashingKeeper) SetValidatorSigningInfo(arg0 context.Context, arg1 types1.ConsAddress, arg2 types2.ValidatorSigningInfo) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetValidatorSigningInfo", ctx, address, info) + ret := m.ctrl.Call(m, "SetValidatorSigningInfo", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 } // SetValidatorSigningInfo indicates an expected call of SetValidatorSigningInfo. -func (mr *MockSlashingKeeperMockRecorder) SetValidatorSigningInfo(ctx, address, info interface{}) *gomock.Call { +func (mr *MockSlashingKeeperMockRecorder) SetValidatorSigningInfo(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetValidatorSigningInfo", reflect.TypeOf((*MockSlashingKeeper)(nil).SetValidatorSigningInfo), ctx, address, info) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetValidatorSigningInfo", reflect.TypeOf((*MockSlashingKeeper)(nil).SetValidatorSigningInfo), arg0, arg1, arg2) } // SlashFractionDoubleSign mocks base method. -func (m *MockSlashingKeeper) SlashFractionDoubleSign(ctx types0.Context) types0.Dec { +func (m *MockSlashingKeeper) SlashFractionDoubleSign(arg0 context.Context) (math.LegacyDec, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SlashFractionDoubleSign", ctx) - ret0, _ := ret[0].(types0.Dec) - return ret0 + ret := m.ctrl.Call(m, "SlashFractionDoubleSign", arg0) + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 } // SlashFractionDoubleSign indicates an expected call of SlashFractionDoubleSign. -func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(ctx interface{}) *gomock.Call { +func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashFractionDoubleSign", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashFractionDoubleSign), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashFractionDoubleSign", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashFractionDoubleSign), arg0) } // SlashFractionDowntime mocks base method. -func (m *MockSlashingKeeper) SlashFractionDowntime(arg0 types0.Context) types0.Dec { +func (m *MockSlashingKeeper) SlashFractionDowntime(arg0 context.Context) (math.LegacyDec, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SlashFractionDowntime", arg0) - ret0, _ := ret[0].(types0.Dec) - return ret0 + ret0, _ := ret[0].(math.LegacyDec) + ret1, _ := ret[1].(error) + return ret0, ret1 } // SlashFractionDowntime indicates an expected call of SlashFractionDowntime. @@ -586,9 +616,11 @@ func (mr *MockSlashingKeeperMockRecorder) SlashFractionDowntime(arg0 interface{} } // Tombstone mocks base method. -func (m *MockSlashingKeeper) Tombstone(arg0 types0.Context, arg1 types0.ConsAddress) { +func (m *MockSlashingKeeper) Tombstone(arg0 context.Context, arg1 types1.ConsAddress) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "Tombstone", arg0, arg1) + ret := m.ctrl.Call(m, "Tombstone", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 } // Tombstone indicates an expected call of Tombstone. @@ -621,7 +653,7 @@ func (m *MockChannelKeeper) EXPECT() *MockChannelKeeperMockRecorder { } // ChanCloseInit mocks base method. -func (m *MockChannelKeeper) ChanCloseInit(ctx types0.Context, portID, channelID string, chanCap *types2.Capability) error { +func (m *MockChannelKeeper) ChanCloseInit(ctx types1.Context, portID, channelID string, chanCap *types4.Capability) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ChanCloseInit", ctx, portID, channelID, chanCap) ret0, _ := ret[0].(error) @@ -635,10 +667,10 @@ func (mr *MockChannelKeeperMockRecorder) ChanCloseInit(ctx, portID, channelID, c } // GetChannel mocks base method. -func (m *MockChannelKeeper) GetChannel(ctx types0.Context, srcPort, srcChan string) (types9.Channel, bool) { +func (m *MockChannelKeeper) GetChannel(ctx types1.Context, srcPort, srcChan string) (types8.Channel, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetChannel", ctx, srcPort, srcChan) - ret0, _ := ret[0].(types9.Channel) + ret0, _ := ret[0].(types8.Channel) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -650,7 +682,7 @@ func (mr *MockChannelKeeperMockRecorder) GetChannel(ctx, srcPort, srcChan interf } // GetChannelConnection mocks base method. -func (m *MockChannelKeeper) GetChannelConnection(ctx types0.Context, portID, channelID string) (string, exported.ConnectionI, error) { +func (m *MockChannelKeeper) GetChannelConnection(ctx types1.Context, portID, channelID string) (string, exported.ConnectionI, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetChannelConnection", ctx, portID, channelID) ret0, _ := ret[0].(string) @@ -666,7 +698,7 @@ func (mr *MockChannelKeeperMockRecorder) GetChannelConnection(ctx, portID, chann } // GetNextSequenceSend mocks base method. -func (m *MockChannelKeeper) GetNextSequenceSend(ctx types0.Context, portID, channelID string) (uint64, bool) { +func (m *MockChannelKeeper) GetNextSequenceSend(ctx types1.Context, portID, channelID string) (uint64, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetNextSequenceSend", ctx, portID, channelID) ret0, _ := ret[0].(uint64) @@ -681,7 +713,7 @@ func (mr *MockChannelKeeperMockRecorder) GetNextSequenceSend(ctx, portID, channe } // SendPacket mocks base method. -func (m *MockChannelKeeper) SendPacket(ctx types0.Context, chanCap *types2.Capability, sourcePort, sourceChannel string, timeoutHeight types7.Height, timeoutTimestamp uint64, data []byte) (uint64, error) { +func (m *MockChannelKeeper) SendPacket(ctx types1.Context, chanCap *types4.Capability, sourcePort, sourceChannel string, timeoutHeight types6.Height, timeoutTimestamp uint64, data []byte) (uint64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendPacket", ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) ret0, _ := ret[0].(uint64) @@ -696,7 +728,7 @@ func (mr *MockChannelKeeperMockRecorder) SendPacket(ctx, chanCap, sourcePort, so } // WriteAcknowledgement mocks base method. -func (m *MockChannelKeeper) WriteAcknowledgement(ctx types0.Context, chanCap *types2.Capability, packet exported.PacketI, acknowledgement exported.Acknowledgement) error { +func (m *MockChannelKeeper) WriteAcknowledgement(ctx types1.Context, chanCap *types4.Capability, packet exported.PacketI, acknowledgement exported.Acknowledgement) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WriteAcknowledgement", ctx, chanCap, packet, acknowledgement) ret0, _ := ret[0].(error) @@ -733,10 +765,10 @@ func (m *MockPortKeeper) EXPECT() *MockPortKeeperMockRecorder { } // BindPort mocks base method. -func (m *MockPortKeeper) BindPort(ctx types0.Context, portID string) *types2.Capability { +func (m *MockPortKeeper) BindPort(ctx types1.Context, portID string) *types4.Capability { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "BindPort", ctx, portID) - ret0, _ := ret[0].(*types2.Capability) + ret0, _ := ret[0].(*types4.Capability) return ret0 } @@ -770,10 +802,10 @@ func (m *MockConnectionKeeper) EXPECT() *MockConnectionKeeperMockRecorder { } // GetConnection mocks base method. -func (m *MockConnectionKeeper) GetConnection(ctx types0.Context, connectionID string) (types8.ConnectionEnd, bool) { +func (m *MockConnectionKeeper) GetConnection(ctx types1.Context, connectionID string) (types7.ConnectionEnd, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetConnection", ctx, connectionID) - ret0, _ := ret[0].(types8.ConnectionEnd) + ret0, _ := ret[0].(types7.ConnectionEnd) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -808,10 +840,10 @@ func (m *MockClientKeeper) EXPECT() *MockClientKeeperMockRecorder { } // ClientStore mocks base method. -func (m *MockClientKeeper) ClientStore(ctx types0.Context, clientID string) types0.KVStore { +func (m *MockClientKeeper) ClientStore(ctx types1.Context, clientID string) types.KVStore { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClientStore", ctx, clientID) - ret0, _ := ret[0].(types0.KVStore) + ret0, _ := ret[0].(types.KVStore) return ret0 } @@ -822,7 +854,7 @@ func (mr *MockClientKeeperMockRecorder) ClientStore(ctx, clientID interface{}) * } // CreateClient mocks base method. -func (m *MockClientKeeper) CreateClient(ctx types0.Context, clientState exported.ClientState, consensusState exported.ConsensusState) (string, error) { +func (m *MockClientKeeper) CreateClient(ctx types1.Context, clientState exported.ClientState, consensusState exported.ConsensusState) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CreateClient", ctx, clientState, consensusState) ret0, _ := ret[0].(string) @@ -837,7 +869,7 @@ func (mr *MockClientKeeperMockRecorder) CreateClient(ctx, clientState, consensus } // GetClientConsensusState mocks base method. -func (m *MockClientKeeper) GetClientConsensusState(ctx types0.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) { +func (m *MockClientKeeper) GetClientConsensusState(ctx types1.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetClientConsensusState", ctx, clientID, height) ret0, _ := ret[0].(exported.ConsensusState) @@ -852,7 +884,7 @@ func (mr *MockClientKeeperMockRecorder) GetClientConsensusState(ctx, clientID, h } // GetClientState mocks base method. -func (m *MockClientKeeper) GetClientState(ctx types0.Context, clientID string) (exported.ClientState, bool) { +func (m *MockClientKeeper) GetClientState(ctx types1.Context, clientID string) (exported.ClientState, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetClientState", ctx, clientID) ret0, _ := ret[0].(exported.ClientState) @@ -867,7 +899,7 @@ func (mr *MockClientKeeperMockRecorder) GetClientState(ctx, clientID interface{} } // GetLatestClientConsensusState mocks base method. -func (m *MockClientKeeper) GetLatestClientConsensusState(ctx types0.Context, clientID string) (exported.ConsensusState, bool) { +func (m *MockClientKeeper) GetLatestClientConsensusState(ctx types1.Context, clientID string) (exported.ConsensusState, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetLatestClientConsensusState", ctx, clientID) ret0, _ := ret[0].(exported.ConsensusState) @@ -882,7 +914,7 @@ func (mr *MockClientKeeperMockRecorder) GetLatestClientConsensusState(ctx, clien } // GetSelfConsensusState mocks base method. -func (m *MockClientKeeper) GetSelfConsensusState(ctx types0.Context, height exported.Height) (exported.ConsensusState, error) { +func (m *MockClientKeeper) GetSelfConsensusState(ctx types1.Context, height exported.Height) (exported.ConsensusState, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetSelfConsensusState", ctx, height) ret0, _ := ret[0].(exported.ConsensusState) @@ -897,7 +929,7 @@ func (mr *MockClientKeeperMockRecorder) GetSelfConsensusState(ctx, height interf } // SetClientState mocks base method. -func (m *MockClientKeeper) SetClientState(ctx types0.Context, clientID string, clientState exported.ClientState) { +func (m *MockClientKeeper) SetClientState(ctx types1.Context, clientID string, clientState exported.ClientState) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetClientState", ctx, clientID, clientState) } @@ -932,9 +964,11 @@ func (m *MockDistributionKeeper) EXPECT() *MockDistributionKeeperMockRecorder { } // AllocateTokensToValidator mocks base method. -func (m *MockDistributionKeeper) AllocateTokensToValidator(ctx types0.Context, validator types5.ValidatorI, reward types0.DecCoins) { +func (m *MockDistributionKeeper) AllocateTokensToValidator(ctx context.Context, validator types3.ValidatorI, reward types1.DecCoins) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "AllocateTokensToValidator", ctx, validator, reward) + ret := m.ctrl.Call(m, "AllocateTokensToValidator", ctx, validator, reward) + ret0, _ := ret[0].(error) + return ret0 } // AllocateTokensToValidator indicates an expected call of AllocateTokensToValidator. @@ -944,7 +978,7 @@ func (mr *MockDistributionKeeperMockRecorder) AllocateTokensToValidator(ctx, val } // FundCommunityPool mocks base method. -func (m *MockDistributionKeeper) FundCommunityPool(ctx types0.Context, amount types0.Coins, sender types0.AccAddress) error { +func (m *MockDistributionKeeper) FundCommunityPool(ctx context.Context, amount types1.Coins, sender types1.AccAddress) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) ret0, _ := ret[0].(error) @@ -958,11 +992,12 @@ func (mr *MockDistributionKeeperMockRecorder) FundCommunityPool(ctx, amount, sen } // GetCommunityTax mocks base method. -func (m *MockDistributionKeeper) GetCommunityTax(ctx types0.Context) math.LegacyDec { +func (m *MockDistributionKeeper) GetCommunityTax(ctx context.Context) (math.LegacyDec, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCommunityTax", ctx) ret0, _ := ret[0].(math.LegacyDec) - return ret0 + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetCommunityTax indicates an expected call of GetCommunityTax. @@ -971,32 +1006,6 @@ func (mr *MockDistributionKeeperMockRecorder) GetCommunityTax(ctx interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommunityTax", reflect.TypeOf((*MockDistributionKeeper)(nil).GetCommunityTax), ctx) } -// GetFeePool mocks base method. -func (m *MockDistributionKeeper) GetFeePool(ctx types0.Context) types3.FeePool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetFeePool", ctx) - ret0, _ := ret[0].(types3.FeePool) - return ret0 -} - -// GetFeePool indicates an expected call of GetFeePool. -func (mr *MockDistributionKeeperMockRecorder) GetFeePool(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFeePool", reflect.TypeOf((*MockDistributionKeeper)(nil).GetFeePool), ctx) -} - -// SetFeePool mocks base method. -func (m *MockDistributionKeeper) SetFeePool(ctx types0.Context, feePool types3.FeePool) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetFeePool", ctx, feePool) -} - -// SetFeePool indicates an expected call of SetFeePool. -func (mr *MockDistributionKeeperMockRecorder) SetFeePool(ctx, feePool interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFeePool", reflect.TypeOf((*MockDistributionKeeper)(nil).SetFeePool), ctx, feePool) -} - // MockConsumerHooks is a mock of ConsumerHooks interface. type MockConsumerHooks struct { ctrl *gomock.Controller @@ -1021,7 +1030,7 @@ func (m *MockConsumerHooks) EXPECT() *MockConsumerHooksMockRecorder { } // AfterValidatorBonded mocks base method. -func (m *MockConsumerHooks) AfterValidatorBonded(ctx types0.Context, consAddr types0.ConsAddress, valAddresses types0.ValAddress) error { +func (m *MockConsumerHooks) AfterValidatorBonded(ctx context.Context, consAddr types1.ConsAddress, valAddresses types1.ValAddress) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AfterValidatorBonded", ctx, consAddr, valAddresses) ret0, _ := ret[0].(error) @@ -1058,10 +1067,10 @@ func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { } // GetAllBalances mocks base method. -func (m *MockBankKeeper) GetAllBalances(ctx types0.Context, addr types0.AccAddress) types0.Coins { +func (m *MockBankKeeper) GetAllBalances(ctx context.Context, addr types1.AccAddress) types1.Coins { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) - ret0, _ := ret[0].(types0.Coins) + ret0, _ := ret[0].(types1.Coins) return ret0 } @@ -1072,10 +1081,10 @@ func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gom } // GetBalance mocks base method. -func (m *MockBankKeeper) GetBalance(ctx types0.Context, addr types0.AccAddress, denom string) types0.Coin { +func (m *MockBankKeeper) GetBalance(ctx context.Context, addr types1.AccAddress, denom string) types1.Coin { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom) - ret0, _ := ret[0].(types0.Coin) + ret0, _ := ret[0].(types1.Coin) return ret0 } @@ -1086,7 +1095,7 @@ func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) * } // SendCoinsFromModuleToModule mocks base method. -func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx types0.Context, senderModule, recipientModule string, amt types0.Coins) error { +func (m *MockBankKeeper) SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt types1.Coins) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendCoinsFromModuleToModule", ctx, senderModule, recipientModule, amt) ret0, _ := ret[0].(error) @@ -1123,7 +1132,7 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { } // GetModuleAccount mocks base method. -func (m *MockAccountKeeper) GetModuleAccount(ctx types0.Context, name string) types1.ModuleAccountI { +func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types1.ModuleAccountI { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetModuleAccount", ctx, name) ret0, _ := ret[0].(types1.ModuleAccountI) @@ -1160,10 +1169,10 @@ func (m *MockIBCTransferKeeper) EXPECT() *MockIBCTransferKeeperMockRecorder { } // Transfer mocks base method. -func (m *MockIBCTransferKeeper) Transfer(arg0 context.Context, arg1 *types6.MsgTransfer) (*types6.MsgTransferResponse, error) { +func (m *MockIBCTransferKeeper) Transfer(arg0 context.Context, arg1 *types5.MsgTransfer) (*types5.MsgTransferResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Transfer", arg0, arg1) - ret0, _ := ret[0].(*types6.MsgTransferResponse) + ret0, _ := ret[0].(*types5.MsgTransferResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1198,10 +1207,10 @@ func (m *MockIBCCoreKeeper) EXPECT() *MockIBCCoreKeeperMockRecorder { } // ChannelOpenInit mocks base method. -func (m *MockIBCCoreKeeper) ChannelOpenInit(goCtx context.Context, msg *types9.MsgChannelOpenInit) (*types9.MsgChannelOpenInitResponse, error) { +func (m *MockIBCCoreKeeper) ChannelOpenInit(goCtx context.Context, msg *types8.MsgChannelOpenInit) (*types8.MsgChannelOpenInitResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ChannelOpenInit", goCtx, msg) - ret0, _ := ret[0].(*types9.MsgChannelOpenInitResponse) + ret0, _ := ret[0].(*types8.MsgChannelOpenInitResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1236,7 +1245,7 @@ func (m *MockScopedKeeper) EXPECT() *MockScopedKeeperMockRecorder { } // AuthenticateCapability mocks base method. -func (m *MockScopedKeeper) AuthenticateCapability(ctx types0.Context, cap *types2.Capability, name string) bool { +func (m *MockScopedKeeper) AuthenticateCapability(ctx types1.Context, cap *types4.Capability, name string) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AuthenticateCapability", ctx, cap, name) ret0, _ := ret[0].(bool) @@ -1250,7 +1259,7 @@ func (mr *MockScopedKeeperMockRecorder) AuthenticateCapability(ctx, cap, name in } // ClaimCapability mocks base method. -func (m *MockScopedKeeper) ClaimCapability(ctx types0.Context, cap *types2.Capability, name string) error { +func (m *MockScopedKeeper) ClaimCapability(ctx types1.Context, cap *types4.Capability, name string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ClaimCapability", ctx, cap, name) ret0, _ := ret[0].(error) @@ -1264,10 +1273,10 @@ func (mr *MockScopedKeeperMockRecorder) ClaimCapability(ctx, cap, name interface } // GetCapability mocks base method. -func (m *MockScopedKeeper) GetCapability(ctx types0.Context, name string) (*types2.Capability, bool) { +func (m *MockScopedKeeper) GetCapability(ctx types1.Context, name string) (*types4.Capability, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCapability", ctx, name) - ret0, _ := ret[0].(*types2.Capability) + ret0, _ := ret[0].(*types4.Capability) ret1, _ := ret[1].(bool) return ret0, ret1 } @@ -1277,41 +1286,3 @@ func (mr *MockScopedKeeperMockRecorder) GetCapability(ctx, name interface{}) *go mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCapability", reflect.TypeOf((*MockScopedKeeper)(nil).GetCapability), ctx, name) } - -// MockGovKeeper is a mock of GovKeeper interface. -type MockGovKeeper struct { - ctrl *gomock.Controller - recorder *MockGovKeeperMockRecorder -} - -// MockGovKeeperMockRecorder is the mock recorder for MockGovKeeper. -type MockGovKeeperMockRecorder struct { - mock *MockGovKeeper -} - -// NewMockGovKeeper creates a new mock instance. -func NewMockGovKeeper(ctrl *gomock.Controller) *MockGovKeeper { - mock := &MockGovKeeper{ctrl: ctrl} - mock.recorder = &MockGovKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockGovKeeper) EXPECT() *MockGovKeeperMockRecorder { - return m.recorder -} - -// GetProposal mocks base method. -func (m *MockGovKeeper) GetProposal(ctx types0.Context, proposalID uint64) (v1.Proposal, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetProposal", ctx, proposalID) - ret0, _ := ret[0].(v1.Proposal) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// GetProposal indicates an expected call of GetProposal. -func (mr *MockGovKeeperMockRecorder) GetProposal(ctx, proposalID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProposal", reflect.TypeOf((*MockGovKeeper)(nil).GetProposal), ctx, proposalID) -} diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 65cec0b784..a80138551a 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -6,32 +6,38 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/store" + "cosmossdk.io/store/metrics" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/address" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" 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" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - tmdb "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + + "github.com/cosmos/interchain-security/v5/x/ccv/types" + + dbm "github.com/cosmos/cosmos-db" ) // Parameters needed to instantiate an in-memory keeper @@ -45,11 +51,11 @@ type InMemKeeperParams struct { // NewInMemKeeperParams instantiates in-memory keeper params with default values func NewInMemKeeperParams(tb testing.TB) InMemKeeperParams { tb.Helper() - storeKey := sdk.NewKVStoreKey(types.StoreKey) + storeKey := storetypes.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) - db := tmdb.NewMemDB() - stateStore := store.NewCommitMultiStore(db) + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) require.NoError(tb, stateStore.LoadLatestVersion()) @@ -88,7 +94,7 @@ type MockedKeepers struct { *MockIBCTransferKeeper *MockIBCCoreKeeper *MockDistributionKeeper - *MockGovKeeper + // *MockGovKeeper } // NewMockedKeepers instantiates a struct with pointers to properly instantiated mocked keepers. @@ -106,7 +112,6 @@ func NewMockedKeepers(ctrl *gomock.Controller) MockedKeepers { MockIBCTransferKeeper: NewMockIBCTransferKeeper(ctrl), MockIBCCoreKeeper: NewMockIBCCoreKeeper(ctrl), MockDistributionKeeper: NewMockDistributionKeeper(ctrl), - MockGovKeeper: NewMockGovKeeper(ctrl), } } @@ -126,7 +131,11 @@ func NewInMemProviderKeeper(params InMemKeeperParams, mocks MockedKeepers) provi mocks.MockAccountKeeper, mocks.MockDistributionKeeper, mocks.MockBankKeeper, - mocks.MockGovKeeper, + // mocks.MockGovKeeper, + govkeeper.Keeper{}, // HACK: to make parts of the test work + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + address.NewBech32Codec("cosmosvaloper"), + address.NewBech32Codec("cosmosvalcons"), authtypes.FeeCollectorName, ) } @@ -148,6 +157,9 @@ func NewInMemConsumerKeeper(params InMemKeeperParams, mocks MockedKeepers) consu mocks.MockIBCTransferKeeper, mocks.MockIBCCoreKeeper, authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + address.NewBech32Codec("cosmosvaloper"), + address.NewBech32Codec("cosmosvalcons"), ) } diff --git a/testutil/simibc/chain_util.go b/testutil/simibc/chain_util.go index ffcc318ac0..3a304d6621 100644 --- a/testutil/simibc/chain_util.go +++ b/testutil/simibc/chain_util.go @@ -3,9 +3,10 @@ package simibc import ( "time" - 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" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,12 +14,32 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" ) -// BeginBlock updates the current header and calls the app.BeginBlock method. -// The new block height is the previous block height + 1. -// The new block time is the previous block time + dt. +// FinalizeBlock calls app.FinalizeBlock and app.Commit. +// It sets the next block time to currentBlockTime + dt. +// This function returns the TMHeader of the block that was just ended, // // NOTE: this method may be used independently of the rest of simibc. -func BeginBlock(c *ibctesting.TestChain, dt time.Duration) { +func FinalizeBlock(c *ibctesting.TestChain, dt time.Duration) (*ibctmtypes.Header, []channeltypes.Packet) { + res, err := c.App.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: c.CurrentHeader.Height, + Time: c.CurrentHeader.GetTime(), + NextValidatorsHash: c.NextVals.Hash(), + }) + require.NoError(c.TB, err) + + _, err = c.App.Commit() + require.NoError(c.TB, err) + + // set the last header to the current header + // use nil trusted fields + c.LastHeader = c.CurrentTMClientHeader() + + // val set changes returned from previous block get applied to the next validators + // of this block. See tendermint spec for details. + c.Vals = c.NextVals + c.NextVals = ibctesting.ApplyValSetChanges(c, c.Vals, res.ValidatorUpdates) + + // increment the current header c.CurrentHeader = tmproto.Header{ ChainID: c.ChainID, Height: c.App.LastBlockHeight() + 1, @@ -26,46 +47,16 @@ func BeginBlock(c *ibctesting.TestChain, dt time.Duration) { Time: c.CurrentHeader.Time.Add(dt), ValidatorsHash: c.Vals.Hash(), NextValidatorsHash: c.NextVals.Hash(), + ProposerAddress: c.CurrentHeader.ProposerAddress, } - _ = c.App.BeginBlock(abci.RequestBeginBlock{Header: c.CurrentHeader}) -} - -// EndBlock calls app.EndBlock and executes preCommitCallback BEFORE calling app.Commit -// The callback is useful for testing purposes to execute arbitrary code before the -// chain sdk context is cleared in .Commit(). -// For example, app.EndBlock may lead to a new state, which you would like to query -// to check that it is correct. However, the sdk context is cleared after .Commit(), -// so you can query the state inside the callback. -// -// NOTE: this method may be used independently of the rest of simibc. -func EndBlock( - c *ibctesting.TestChain, - preCommitCallback func(), -) (*ibctmtypes.Header, []channeltypes.Packet) { - ebRes := c.App.EndBlock(abci.RequestEndBlock{Height: c.CurrentHeader.Height}) - - /* - It is useful to call arbitrary code after ending the block but before - committing the block because the sdk.Context is cleared after committing. - */ - - c.App.Commit() - - c.Vals = c.NextVals - - c.NextVals = ibctesting.ApplyValSetChanges(c.T, c.Vals, ebRes.ValidatorUpdates) - - c.LastHeader = c.CurrentTMClientHeader() - - sdkEvts := ABCIToSDKEvents(ebRes.Events) - packets := ParsePacketsFromEvents(sdkEvts) - + // handle packets + packets := ParsePacketsFromEvents(res.Events) return c.LastHeader, packets } // ParsePacketsFromEvents returns all packets found in events. -func ParsePacketsFromEvents(events []sdk.Event) (packets []channeltypes.Packet) { +func ParsePacketsFromEvents(events []abci.Event) (packets []channeltypes.Packet) { for i, ev := range events { if ev.Type == channeltypes.EventTypeSendPacket { packet, err := ibctesting.ParsePacketFromEvents(events[i:]) diff --git a/testutil/simibc/ordered_outbox.go b/testutil/simibc/ordered_outbox.go index fdeb449962..9b0f008281 100644 --- a/testutil/simibc/ordered_outbox.go +++ b/testutil/simibc/ordered_outbox.go @@ -1,6 +1,6 @@ package simibc -import channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" +import channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" // The number of blocks to wait before a packet or ack is available for delivery // after it has been committed on the chain. diff --git a/testutil/simibc/relay_util.go b/testutil/simibc/relay_util.go index 1082b2d864..59341c355b 100644 --- a/testutil/simibc/relay_util.go +++ b/testutil/simibc/relay_util.go @@ -1,12 +1,12 @@ package simibc import ( - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - 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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + simapp "github.com/cosmos/ibc-go/v8/testing/simapp" errorsmod "cosmossdk.io/errors" @@ -36,16 +36,18 @@ func UpdateReceiverClient(sender, receiver *ibctesting.Endpoint, header *ibctmty return err } - _, _, err = simapp.SignAndDeliver( - receiver.Chain.T, + _, err = simapp.SignAndDeliver( + receiver.Chain.TB, receiver.Chain.TxConfig, receiver.Chain.App.GetBaseApp(), - receiver.Chain.GetContext().BlockHeader(), []sdk.Msg{msg}, receiver.Chain.ChainID, []uint64{receiver.Chain.SenderAccount.GetAccountNumber()}, []uint64{receiver.Chain.SenderAccount.GetSequence()}, - true, !expectExpiration, receiver.Chain.SenderPrivKey, + !expectExpiration, + receiver.Chain.GetContext().BlockHeader().Time, + receiver.Chain.GetContext().BlockHeader().NextValidatorsHash, + receiver.Chain.SenderPrivKey, ) setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) @@ -72,17 +74,20 @@ func TryRecvPacket(sender, receiver *ibctesting.Endpoint, packet channeltypes.Pa RPmsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, receiver.Chain.SenderAccount.GetAddress().String()) - _, resWithAck, err := simapp.SignAndDeliver( - receiver.Chain.T, + resWithAck, err := simapp.SignAndDeliver( + receiver.Chain.TB, receiver.Chain.TxConfig, receiver.Chain.App.GetBaseApp(), - receiver.Chain.GetContext().BlockHeader(), []sdk.Msg{RPmsg}, receiver.Chain.ChainID, []uint64{receiver.Chain.SenderAccount.GetAccountNumber()}, []uint64{receiver.Chain.SenderAccount.GetSequence()}, - true, !expectError, receiver.Chain.SenderPrivKey, + !expectError, + receiver.Chain.GetContext().BlockHeader().Time, + receiver.Chain.GetContext().BlockHeader().NextValidatorsHash, + receiver.Chain.SenderPrivKey, ) + // need to set the sequence even if there was an error in delivery setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) if err != nil { @@ -114,16 +119,18 @@ func TryRecvAck(sender, receiver *ibctesting.Endpoint, packet channeltypes.Packe ackMsg := channeltypes.NewMsgAcknowledgement(p, ack, proof, proofHeight, receiver.Chain.SenderAccount.GetAddress().String()) - _, _, err = simapp.SignAndDeliver( - receiver.Chain.T, + _, err = simapp.SignAndDeliver( + receiver.Chain.TB, receiver.Chain.TxConfig, receiver.Chain.App.GetBaseApp(), - receiver.Chain.GetContext().BlockHeader(), []sdk.Msg{ackMsg}, receiver.Chain.ChainID, []uint64{receiver.Chain.SenderAccount.GetAccountNumber()}, []uint64{receiver.Chain.SenderAccount.GetSequence()}, - true, true, receiver.Chain.SenderPrivKey, + true, + receiver.Chain.GetContext().BlockHeader().Time, + receiver.Chain.GetContext().BlockHeader().NextValidatorsHash, + receiver.Chain.SenderPrivKey, ) setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) diff --git a/testutil/simibc/relayed_path.go b/testutil/simibc/relayed_path.go index 4967c02f37..ca64987bcf 100644 --- a/testutil/simibc/relayed_path.go +++ b/testutil/simibc/relayed_path.go @@ -3,9 +3,9 @@ package simibc import ( "testing" - 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" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v8/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 806b91d2cf..c047ae775d 100644 --- a/x/ccv/consumer/client/cli/query.go +++ b/x/ccv/consumer/client/cli/query.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) // NewQueryCmd returns a root CLI command handler for all x/ccv/provider query commands. @@ -23,6 +23,7 @@ func NewQueryCmd() *cobra.Command { CmdNextFeeDistribution(), CmdProviderInfo(), CmdThrottleState(), + CmdParams(), ) return cmd @@ -108,3 +109,30 @@ func CmdThrottleState() *cobra.Command { return cmd } + +func CmdParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query consumer module parameters", + 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.QueryParamsRequest{} + res, err := queryClient.QueryParams(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 71caa4a082..d9cbcd6bde 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -5,21 +5,21 @@ import ( "strconv" "strings" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // OnChanOpenInit implements the IBCModule interface diff --git a/x/ccv/consumer/ibc_module_test.go b/x/ccv/consumer/ibc_module_test.go index 51fd910902..029a4accd5 100644 --- a/x/ccv/consumer/ibc_module_test.go +++ b/x/ccv/consumer/ibc_module_test.go @@ -3,20 +3,20 @@ package consumer_test import ( "testing" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestOnChanOpenInit validates the consumer's OnChanOpenInit implementation against the spec. diff --git a/x/ccv/consumer/keeper/changeover.go b/x/ccv/consumer/keeper/changeover.go index 74276d1253..7f7ba4ad5b 100644 --- a/x/ccv/consumer/keeper/changeover.go +++ b/x/ccv/consumer/keeper/changeover.go @@ -38,7 +38,12 @@ func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci. for _, val := range initialValUpdates { initialUpdatesFlag[val.PubKey.String()] = true } - for _, val := range k.GetLastStandaloneValidators(ctx) { + + standaloneValset, err := k.GetLastStandaloneValidators(ctx) + if err != nil { + panic(err) + } + for _, val := range standaloneValset { zeroPowerUpdate := val.ABCIValidatorUpdateZero() if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { initialValUpdates = append(initialValUpdates, zeroPowerUpdate) diff --git a/x/ccv/consumer/keeper/changeover_test.go b/x/ccv/consumer/keeper/changeover_test.go index ba70e56041..b9b160ffec 100644 --- a/x/ccv/consumer/keeper/changeover_test.go +++ b/x/ccv/consumer/keeper/changeover_test.go @@ -10,8 +10,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - uthelpers "github.com/cosmos/interchain-security/v4/testutil/keeper" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + uthelpers "github.com/cosmos/interchain-security/v5/testutil/keeper" ) func TestChangeoverToConsumer(t *testing.T) { @@ -128,7 +128,7 @@ func TestChangeoverToConsumer(t *testing.T) { for _, ccVal := range ccVals { ccvValPubKey, err := ccVal.ConsPubKey() require.NoError(t, err) - tmProtoPubKey, err := sdkcryptocodec.ToTmProtoPublicKey(ccvValPubKey) + tmProtoPubKey, err := sdkcryptocodec.ToCmtProtoPublicKey(ccvValPubKey) require.NoError(t, err) if tmProtoPubKey.Equal(valUpdate.PubKey) { found = true @@ -154,7 +154,7 @@ func TestChangeoverToConsumer(t *testing.T) { for _, val := range tc.lastSovVals { ccvValPubKey, err := val.ConsPubKey() require.NoError(t, err) - tmProtoPubKey, err := sdkcryptocodec.ToTmProtoPublicKey(ccvValPubKey) + tmProtoPubKey, err := sdkcryptocodec.ToCmtProtoPublicKey(ccvValPubKey) require.NoError(t, err) if returnedValUpdate.PubKey.Equal(tmProtoPubKey) { // If val was already matched to a val update for new set, it's power won't be 0 diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index 1b98638498..5c9bbe4a24 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -4,16 +4,17 @@ import ( "fmt" "strconv" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // EndBlockRD executes EndBlock logic for the Reward Distribution sub-protocol. @@ -56,7 +57,7 @@ func (k Keeper) DistributeRewardsInternally(ctx sdk.Context) { fpTokens := k.bankKeeper.GetAllBalances(ctx, consumerFeePoolAddr) // split the fee pool, send the consumer's fraction to the consumer redistribution address - frac, err := sdk.NewDecFromStr(k.GetConsumerRedistributionFrac(ctx)) + frac, err := math.LegacyNewDecFromStr(k.GetConsumerRedistributionFrac(ctx)) if err != nil { // ConsumerRedistributionFrac was already validated when set as a param panic(fmt.Errorf("ConsumerRedistributionFrac is invalid: %w", err)) @@ -253,7 +254,7 @@ func (k Keeper) GetEstimatedNextFeeDistribution(ctx sdk.Context) types.NextFeeDi total := k.bankKeeper.GetAllBalances(ctx, consumerFeePoolAddr) fracParam := k.GetConsumerRedistributionFrac(ctx) - frac, err := sdk.NewDecFromStr(fracParam) + frac, err := math.LegacyNewDecFromStr(fracParam) if err != nil { // ConsumerRedistributionFrac was already validated when set as a param panic(fmt.Errorf("ConsumerRedistributionFrac is invalid: %w", err)) diff --git a/x/ccv/consumer/keeper/distribution_test.go b/x/ccv/consumer/keeper/distribution_test.go index 189842a90e..5713361918 100644 --- a/x/ccv/consumer/keeper/distribution_test.go +++ b/x/ccv/consumer/keeper/distribution_test.go @@ -4,15 +4,16 @@ import ( "strings" "testing" + "cosmossdk.io/math" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" authTypes "github.com/cosmos/cosmos-sdk/x/auth/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestGetEstimatedNextFeeDistribution tests next fee distribution parameters. @@ -30,11 +31,11 @@ func TestGetEstimatedNextFeeDistribution(t *testing.T) { // Setup mock account balance fracParam := consumerKeeper.GetConsumerRedistributionFrac(ctx) - fracDec, err := sdk.NewDecFromStr(fracParam) + fracDec, err := math.LegacyNewDecFromStr(fracParam) require.NoError(t, err) feeAmount := sdk.Coin{ Denom: "MOCK", - Amount: sdk.NewInt(100), + Amount: math.NewInt(100), } feeAmountCoins := sdk.Coins([]sdk.Coin{feeAmount}) feeAmountDec := sdk.NewDecCoinsFromCoins(feeAmountCoins...) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index 1b9afb2a4e..bdb8e35418 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -7,8 +7,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // InitGenesis initializes the CCV consumer state and binds to PortID. diff --git a/x/ccv/consumer/keeper/genesis_test.go b/x/ccv/consumer/keeper/genesis_test.go index b9fc1b6f3a..780b2ba34a 100644 --- a/x/ccv/consumer/keeper/genesis_test.go +++ b/x/ccv/consumer/keeper/genesis_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -18,11 +18,11 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestInitGenesis tests that a consumer chain is correctly initialised from genesis. @@ -248,7 +248,7 @@ func TestExportGenesis(t *testing.T) { // mock a validator set pubKey := ed25519.GenPrivKey().PubKey() - tmPK, err := cryptocodec.ToTmPubKeyInterface(pubKey) + tmPK, err := cryptocodec.ToCmtPubKeyInterface(pubKey) require.NoError(t, err) validator := tmtypes.NewValidator(tmPK, 1) abciValidator := abci.Validator{Address: pubKey.Address(), Power: int64(1)} diff --git a/x/ccv/consumer/keeper/grpc_query.go b/x/ccv/consumer/keeper/grpc_query.go index 5ac5116a28..2f1543071b 100644 --- a/x/ccv/consumer/keeper/grpc_query.go +++ b/x/ccv/consumer/keeper/grpc_query.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) var _ types.QueryServer = Keeper{} //nolint:golint diff --git a/x/ccv/consumer/keeper/hooks.go b/x/ccv/consumer/keeper/hooks.go index c730bf266c..5e90129ed7 100644 --- a/x/ccv/consumer/keeper/hooks.go +++ b/x/ccv/consumer/keeper/hooks.go @@ -1,9 +1,11 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) var _ ccv.ConsumerHooks = Keeper{} @@ -18,7 +20,7 @@ func (k Keeper) Hooks() Hooks { return Hooks{k} } -func (k Keeper) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { +func (k Keeper) AfterValidatorBonded(ctx context.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { if k.hooks != nil { err := k.hooks.AfterValidatorBonded(ctx, consAddr, nil) return err diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 9dde578a4e..644cfc33a7 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -6,32 +6,38 @@ import ( "reflect" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + addresscodec "cosmossdk.io/core/address" + "cosmossdk.io/core/store" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + "cosmossdk.io/log" tmtypes "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Keeper defines the Cross-Chain Validation Consumer Keeper type Keeper struct { + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + storeKey storetypes.StoreKey + storeService store.KVStoreService cdc codec.BinaryCodec - paramStore paramtypes.Subspace scopedKeeper ccv.ScopedKeeper channelKeeper ccv.ChannelKeeper portKeeper ccv.PortKeeper @@ -48,6 +54,9 @@ type Keeper struct { ibcTransferKeeper ccv.IBCTransferKeeper ibcCoreKeeper ccv.IBCCoreKeeper feeCollectorName string + + validatorAddressCodec addresscodec.Codec + consensusAddressCodec addresscodec.Codec } // NewKeeper creates a new Consumer Keeper instance @@ -60,7 +69,8 @@ func NewKeeper( connectionKeeper ccv.ConnectionKeeper, clientKeeper ccv.ClientKeeper, slashingKeeper ccv.SlashingKeeper, bankKeeper ccv.BankKeeper, accountKeeper ccv.AccountKeeper, ibcTransferKeeper ccv.IBCTransferKeeper, ibcCoreKeeper ccv.IBCCoreKeeper, - feeCollectorName string, + feeCollectorName, authority string, validatorAddressCodec, + consensusAddressCodec addresscodec.Codec, ) Keeper { // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { @@ -68,9 +78,9 @@ func NewKeeper( } k := Keeper{ + authority: authority, storeKey: key, cdc: cdc, - paramStore: paramSpace, scopedKeeper: scopedKeeper, channelKeeper: channelKeeper, portKeeper: portKeeper, @@ -83,19 +93,25 @@ func NewKeeper( ibcCoreKeeper: ibcCoreKeeper, feeCollectorName: feeCollectorName, standaloneStakingKeeper: nil, + validatorAddressCodec: validatorAddressCodec, + consensusAddressCodec: consensusAddressCodec, } k.mustValidateFields() return k } +// GetAuthority returns the x/ccv/provider module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + // Returns a keeper with cdc, key and paramSpace set it does not raise any panics during registration (eg with IBCKeeper). // Used only in testing. func NewNonZeroKeeper(cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace) Keeper { return Keeper{ - storeKey: key, - cdc: cdc, - paramStore: paramSpace, + storeKey: key, + cdc: cdc, } } @@ -105,38 +121,44 @@ func (k *Keeper) SetStandaloneStakingKeeper(sk ccv.StakingKeeper) { k.standaloneStakingKeeper = sk } -// SetParamSpace sets the param space for the consumer keeper. -// Note: this is only used for testing! -func (k *Keeper) SetParamSpace(ctx sdk.Context, ps paramtypes.Subspace) { - k.paramStore = ps -} - // Validates that the consumer keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { // Ensures no fields are missed in this validation - if reflect.ValueOf(k).NumField() != 16 { + if reflect.ValueOf(k).NumField() != 19 { panic("number of fields in consumer keeper is not 16") } - // Note 14 / 16 fields will be validated, + // Note 116 / 16 fields will be validated, // hooks are explicitly set after the constructor, // stakingKeeper is optionally set after the constructor, - ccv.PanicIfZeroOrNil(k.storeKey, "storeKey") // 1 - ccv.PanicIfZeroOrNil(k.cdc, "cdc") // 2 - ccv.PanicIfZeroOrNil(k.paramStore, "paramStore") // 3 - ccv.PanicIfZeroOrNil(k.scopedKeeper, "scopedKeeper") // 4 - ccv.PanicIfZeroOrNil(k.channelKeeper, "channelKeeper") // 5 - ccv.PanicIfZeroOrNil(k.portKeeper, "portKeeper") // 6 - ccv.PanicIfZeroOrNil(k.connectionKeeper, "connectionKeeper") // 7 - ccv.PanicIfZeroOrNil(k.clientKeeper, "clientKeeper") // 8 - ccv.PanicIfZeroOrNil(k.slashingKeeper, "slashingKeeper") // 9 - ccv.PanicIfZeroOrNil(k.bankKeeper, "bankKeeper") // 10 - ccv.PanicIfZeroOrNil(k.authKeeper, "authKeeper") // 11 - ccv.PanicIfZeroOrNil(k.ibcTransferKeeper, "ibcTransferKeeper") // 12 - ccv.PanicIfZeroOrNil(k.ibcCoreKeeper, "ibcCoreKeeper") // 13 - ccv.PanicIfZeroOrNil(k.feeCollectorName, "feeCollectorName") // 14 + ccv.PanicIfZeroOrNil(k.storeKey, "storeKey") // 1 + ccv.PanicIfZeroOrNil(k.cdc, "cdc") // 2 + ccv.PanicIfZeroOrNil(k.scopedKeeper, "scopedKeeper") // 3 + ccv.PanicIfZeroOrNil(k.channelKeeper, "channelKeeper") // 4 + ccv.PanicIfZeroOrNil(k.portKeeper, "portKeeper") // 5 + ccv.PanicIfZeroOrNil(k.connectionKeeper, "connectionKeeper") // 6 + ccv.PanicIfZeroOrNil(k.clientKeeper, "clientKeeper") // 7 + ccv.PanicIfZeroOrNil(k.slashingKeeper, "slashingKeeper") // 8 + ccv.PanicIfZeroOrNil(k.bankKeeper, "bankKeeper") // 9 + ccv.PanicIfZeroOrNil(k.authKeeper, "authKeeper") // 10 + ccv.PanicIfZeroOrNil(k.ibcTransferKeeper, "ibcTransferKeeper") // 11 + ccv.PanicIfZeroOrNil(k.ibcCoreKeeper, "ibcCoreKeeper") // 12 + ccv.PanicIfZeroOrNil(k.feeCollectorName, "feeCollectorName") // 13 + ccv.PanicIfZeroOrNil(k.authority, "authority") // 14 + ccv.PanicIfZeroOrNil(k.validatorAddressCodec, "validatorAddressCodec") // 15 + ccv.PanicIfZeroOrNil(k.consensusAddressCodec, "consensusAddressCodec") // 16 +} + +// ValidatorAddressCodec returns the app validator address codec. +func (k Keeper) ValidatorAddressCodec() addresscodec.Codec { + return k.validatorAddressCodec +} + +// ConsensusAddressCodec returns the app consensus address codec. +func (k Keeper) ConsensusAddressCodec() addresscodec.Codec { + return k.consensusAddressCodec } // Logger returns a module-specific logger. @@ -327,7 +349,7 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { return []tmtypes.ValidatorUpdate{} } -func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) []stakingtypes.Validator { +func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) ([]stakingtypes.Validator, error) { if !k.IsPreCCV(ctx) || k.standaloneStakingKeeper == nil { panic("cannot get last standalone validators if not in pre-ccv state, or if standalone staking keeper is nil") } @@ -338,7 +360,7 @@ func (k Keeper) GetLastStandaloneValidators(ctx sdk.Context) []stakingtypes.Vali // i.e., the slice contains the IDs of the matured VSCPackets. func (k Keeper) GetElapsedPacketMaturityTimes(ctx sdk.Context) (maturingVSCPackets []types.MaturingVSCPacket) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) defer iterator.Close() @@ -370,7 +392,7 @@ func (k Keeper) GetElapsedPacketMaturityTimes(ctx sdk.Context) (maturingVSCPacke // If two entries have the same maturityTime, then they are ordered by vscID. func (k Keeper) GetAllPacketMaturityTimes(ctx sdk.Context) (maturingVSCPackets []types.MaturingVSCPacket) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PacketMaturityTimeBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -471,7 +493,7 @@ func (k Keeper) DeleteHeightValsetUpdateID(ctx sdk.Context, height uint64) { // Thus, the returned array is in ascending order of heights. func (k Keeper) GetAllHeightToValsetUpdateIDs(ctx sdk.Context) (heightToValsetUpdateIDs []types.HeightToValsetUpdateID) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.HeightValsetUpdateIDBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.HeightValsetUpdateIDBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -513,7 +535,7 @@ func (k Keeper) DeleteOutstandingDowntime(ctx sdk.Context, address sdk.ConsAddre // Thus, the returned array is in ascending order of consAddresses. func (k Keeper) GetAllOutstandingDowntimes(ctx sdk.Context) (downtimes []types.OutstandingDowntime) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.OutstandingDowntimeBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.OutstandingDowntimeBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -562,7 +584,7 @@ func (k Keeper) DeleteCCValidator(ctx sdk.Context, addr []byte) { // Thus, the returned array is in ascending order of addresses. func (k Keeper) GetAllCCValidator(ctx sdk.Context) (validators []types.CrossChainValidator) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.CrossChainValidatorBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.CrossChainValidatorBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -590,7 +612,7 @@ func (k Keeper) getAndIncrementPendingPacketsIdx(ctx sdk.Context) (toReturn uint // DeleteHeadOfPendingPackets deletes the head of the pending packets queue. func (k Keeper) DeleteHeadOfPendingPackets(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) defer iterator.Close() if !iterator.Valid() { return @@ -624,7 +646,7 @@ func (k Keeper) GetAllPendingPacketsWithIdx(ctx sdk.Context) []ConsumerPacketDat store := ctx.KVStore(k.storeKey) // Note: PendingDataPacketsBytePrefix is the correct prefix, NOT PendingDataPacketsByteKey. // See consistency with PendingDataPacketsKey(). - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { var packet ccv.ConsumerPacketData @@ -656,7 +678,7 @@ func (k Keeper) DeleteAllPendingDataPackets(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) // Note: PendingDataPacketsBytePrefix is the correct prefix, NOT PendingDataPacketsByteKey. // See consistency with PendingDataPacketsKey(). - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingDataPacketsBytePrefix}) keysToDel := [][]byte{} defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -693,6 +715,6 @@ func (k Keeper) IsPrevStandaloneChain(ctx sdk.Context) bool { // GetLastBondedValidators iterates the last validator powers in the staking module // and returns the first MaxValidators many validators with the largest powers. -func (k Keeper) GetLastBondedValidators(ctx sdk.Context) []stakingtypes.Validator { +func (k Keeper) GetLastBondedValidators(ctx sdk.Context) ([]stakingtypes.Validator, error) { return ccv.GetLastBondedValidatorsUtil(ctx, k.standaloneStakingKeeper, k.Logger(ctx)) } diff --git a/x/ccv/consumer/keeper/keeper_test.go b/x/ccv/consumer/keeper/keeper_test.go index 4b9a59fbba..ea90b2002f 100644 --- a/x/ccv/consumer/keeper/keeper_test.go +++ b/x/ccv/consumer/keeper/keeper_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -17,10 +17,10 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestProviderClientID tests getter and setter functionality for the client ID stored on consumer keeper @@ -51,9 +51,9 @@ func TestProviderChannel(t *testing.T) { // TestPendingChanges tests getter, setter, and delete functionality for pending VSCs on a consumer chain func TestPendingChanges(t *testing.T) { - pk1, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk1, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) - pk2, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk2, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) pd := ccv.NewValidatorSetChangePacketData( @@ -192,7 +192,8 @@ func TestGetLastSovereignValidators(t *testing.T) { 1, ) - lastSovVals := ck.GetLastStandaloneValidators(ctx) + lastSovVals, err := ck.GetLastStandaloneValidators(ctx) + require.NoError(t, err) require.Equal(t, []stakingtypes.Validator{val}, lastSovVals) require.Equal(t, "sanity check this is the correctly serialized val", lastSovVals[0].Description.Moniker) diff --git a/x/ccv/consumer/keeper/migrations.go b/x/ccv/consumer/keeper/migrations.go index a1e826e61e..145d595087 100644 --- a/x/ccv/consumer/keeper/migrations.go +++ b/x/ccv/consumer/keeper/migrations.go @@ -4,7 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - v2 "github.com/cosmos/interchain-security/v4/x/ccv/consumer/migrations/v2" + v2 "github.com/cosmos/interchain-security/v5/x/ccv/consumer/migrations/v2" + v3 "github.com/cosmos/interchain-security/v5/x/ccv/consumer/migrations/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -23,3 +24,11 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { store := ctx.KVStore(m.keeper.storeKey) return v2.MigrateConsumerPacketData(ctx, store) } + +// Migrate2to3 migrates x/ccvconsumer from consensus version 2 to 3. +// This migration is necessary to move the consumer module legacy params. +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + store := ctx.KVStore(m.keeper.storeKey) + cdc := m.keeper.cdc + return v3.MigrateLegacyParams(ctx, cdc, store, m.paramSpace) +} diff --git a/x/ccv/consumer/keeper/msg_server.go b/x/ccv/consumer/keeper/msg_server.go new file mode 100644 index 0000000000..ce3e67be5c --- /dev/null +++ b/x/ccv/consumer/keeper/msg_server.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" +) + +type msgServer struct { + *Keeper +} + +// NewMsgServerImpl returns an implementation of the bank MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper *Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// UpdateParams updates the params. +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + if err := msg.Params.Validate(); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.Keeper.SetParams(ctx, msg.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index 8d74205b8a..f72b627322 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -1,138 +1,136 @@ package keeper import ( + "context" "time" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/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) ccvtypes.ConsumerParams { - return ccvtypes.NewParams( - k.GetEnabled(ctx), - k.GetBlocksPerDistributionTransmission(ctx), - k.GetDistributionTransmissionChannel(ctx), - k.GetProviderFeePoolAddrStr(ctx), - k.GetCCVTimeoutPeriod(ctx), - k.GetTransferTimeoutPeriod(ctx), - k.GetConsumerRedistributionFrac(ctx), - k.GetHistoricalEntries(ctx), - k.GetUnbondingPeriod(ctx), - k.GetRewardDenoms(ctx), - k.GetProviderRewardDenoms(ctx), - k.GetRetryDelayPeriod(ctx), - ) + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParametersKey()) + var params ccvtypes.ConsumerParams + k.cdc.MustUnmarshal(bz, ¶ms) + return params } // SetParams sets the paramset for the consumer module func (k Keeper) SetParams(ctx sdk.Context, params ccvtypes.ConsumerParams) { - k.paramStore.SetParamSet(ctx, ¶ms) + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParametersKey(), bz) } // GetParams implements StakingKeeper GetParams interface method // it returns an a empty stakingtypes.Params struct // NOTE: this method must be implemented on the consumer keeper because the evidence module keeper -// in cosmos-sdk v0.47 requires this exact method with this exact signature to be available on the StakingKeepr -func (k Keeper) GetParams(ctx sdk.Context) stakingtypes.Params { - return stakingtypes.Params{} +// in cosmos-sdk v0.50 requires this exact method with this exact signature to be available on the StakingKeepr +func (k Keeper) GetParams(context.Context) (stakingtypes.Params, error) { + return stakingtypes.Params{}, nil } // GetEnabled returns the enabled flag for the consumer module func (k Keeper) GetEnabled(ctx sdk.Context) bool { - var enabled bool - k.paramStore.Get(ctx, ccvtypes.KeyEnabled, &enabled) - return enabled + params := k.GetConsumerParams(ctx) + return params.Enabled } func (k Keeper) GetBlocksPerDistributionTransmission(ctx sdk.Context) int64 { - var bpdt int64 - k.paramStore.Get(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, &bpdt) - return bpdt + params := k.GetConsumerParams(ctx) + return params.BlocksPerDistributionTransmission } func (k Keeper) SetBlocksPerDistributionTransmission(ctx sdk.Context, bpdt int64) { - k.paramStore.Set(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, bpdt) + params := k.GetConsumerParams(ctx) + params.BlocksPerDistributionTransmission = bpdt + k.SetParams(ctx, params) } func (k Keeper) GetDistributionTransmissionChannel(ctx sdk.Context) string { - var s string - k.paramStore.Get(ctx, ccvtypes.KeyDistributionTransmissionChannel, &s) - return s + params := k.GetConsumerParams(ctx) + return params.DistributionTransmissionChannel } func (k Keeper) SetDistributionTransmissionChannel(ctx sdk.Context, channel string) { - k.paramStore.Set(ctx, ccvtypes.KeyDistributionTransmissionChannel, channel) + params := k.GetConsumerParams(ctx) + params.DistributionTransmissionChannel = channel + k.SetParams(ctx, params) } func (k Keeper) GetProviderFeePoolAddrStr(ctx sdk.Context) string { - var s string - k.paramStore.Get(ctx, ccvtypes.KeyProviderFeePoolAddrStr, &s) - return s + params := k.GetConsumerParams(ctx) + return params.ProviderFeePoolAddrStr } func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string) { - k.paramStore.Set(ctx, ccvtypes.KeyProviderFeePoolAddrStr, addr) + params := k.GetConsumerParams(ctx) + params.ProviderFeePoolAddrStr = addr + k.SetParams(ctx, params) } // GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { - var p time.Duration - k.paramStore.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) - return p + params := k.GetConsumerParams(ctx) + return params.CcvTimeoutPeriod } // 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, ccvtypes.KeyTransferTimeoutPeriod, &p) - return p + params := k.GetConsumerParams(ctx) + return params.TransferTimeoutPeriod } // GetConsumerRedistributionFrac returns 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%. func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { - var str string - k.paramStore.Get(ctx, ccvtypes.KeyConsumerRedistributionFrac, &str) - return str + params := k.GetConsumerParams(ctx) + return params.ConsumerRedistributionFraction } // 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, ccvtypes.KeyHistoricalEntries, &n) - return n + params := k.GetConsumerParams(ctx) + return params.HistoricalEntries } // Only used to set an unbonding period in diff tests func (k Keeper) SetUnbondingPeriod(ctx sdk.Context, period time.Duration) { - k.paramStore.Set(ctx, ccvtypes.KeyConsumerUnbondingPeriod, period) + params := k.GetConsumerParams(ctx) + params.UnbondingPeriod = period + k.SetParams(ctx, params) } func (k Keeper) GetUnbondingPeriod(ctx sdk.Context) time.Duration { - var period time.Duration - k.paramStore.Get(ctx, ccvtypes.KeyConsumerUnbondingPeriod, &period) - return period + params := k.GetConsumerParams(ctx) + return params.UnbondingPeriod +} + +// GetSoftOptOutThreshold returns the percentage of validators at the bottom of the set +// that can opt out of running the consumer chain +func (k Keeper) GetSoftOptOutThreshold(ctx sdk.Context) string { + params := k.GetConsumerParams(ctx) + return params.SoftOptOutThreshold } func (k Keeper) GetRewardDenoms(ctx sdk.Context) []string { - var denoms []string - k.paramStore.Get(ctx, ccvtypes.KeyRewardDenoms, &denoms) - return denoms + params := k.GetConsumerParams(ctx) + return params.RewardDenoms } func (k Keeper) GetProviderRewardDenoms(ctx sdk.Context) []string { - var denoms []string - k.paramStore.Get(ctx, ccvtypes.KeyProviderRewardDenoms, &denoms) - return denoms + params := k.GetConsumerParams(ctx) + return params.ProviderRewardDenoms } func (k Keeper) GetRetryDelayPeriod(ctx sdk.Context) time.Duration { - var period time.Duration - k.paramStore.Get(ctx, ccvtypes.KeyRetryDelayPeriod, &period) - return period + params := k.GetConsumerParams(ctx) + return params.RetryDelayPeriod } diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 536ae98236..18d3f5a2b2 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestParams tests getters/setters for consumer params @@ -28,6 +28,7 @@ func TestParams(t *testing.T) { ccv.DefaultConsumerRedistributeFrac, ccv.DefaultHistoricalEntries, ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, ccv.DefaultRetryDelayPeriod, @@ -38,7 +39,7 @@ func TestParams(t *testing.T) { newParams := ccv.NewParams(false, 1000, "channel-2", "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm", - 7*24*time.Hour, 25*time.Hour, "0.5", 500, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour) + 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/provider_info.go b/x/ccv/consumer/keeper/provider_info.go index e5fbaf6540..8dc5c0448d 100644 --- a/x/ccv/consumer/keeper/provider_info.go +++ b/x/ccv/consumer/keeper/provider_info.go @@ -1,12 +1,12 @@ package keeper import ( - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" //nolint:golint + ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" //nolint:golint sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func (k Keeper) GetProviderInfo(ctx sdk.Context) (*types.QueryProviderInfoResponse, error) { //nolint:golint diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 2d4e16510a..e20a481cd6 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -1,11 +1,12 @@ package keeper import ( + "errors" "fmt" "strconv" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" @@ -14,8 +15,8 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // OnRecvVSCPacket sets the pending validator set changes that will be flushed to ABCI on Endblock @@ -217,7 +218,7 @@ func (k Keeper) SendPackets(ctx sdk.Context) { k.GetCCVTimeoutPeriod(ctx), ) if err != nil { - if clienttypes.ErrClientNotActive.Is(err) { + if errors.Is(err, clienttypes.ErrClientNotActive) { // IBC client is expired! // leave the packet data stored to be sent once the client is upgraded k.Logger(ctx).Info("IBC client is expired, cannot send IBC packet; leaving packet data stored:", "type", p.Type.String()) diff --git a/x/ccv/consumer/keeper/relay_test.go b/x/ccv/consumer/keeper/relay_test.go index 46a805a85a..d3ab3778e1 100644 --- a/x/ccv/consumer/keeper/relay_test.go +++ b/x/ccv/consumer/keeper/relay_test.go @@ -6,26 +6,26 @@ import ( "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" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/bytes" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + consumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestOnRecvVSCPacket tests the behavior of OnRecvVSCPacket over various packet scenarios @@ -33,11 +33,11 @@ func TestOnRecvVSCPacket(t *testing.T) { consumerCCVChannelID := "consumerCCVChannelID" providerCCVChannelID := "providerCCVChannelID" - pk1, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk1, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) - pk2, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk2, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) - pk3, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk3, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) changes1 := []abci.ValidatorUpdate{ diff --git a/x/ccv/consumer/keeper/soft_opt_out.go b/x/ccv/consumer/keeper/soft_opt_out.go new file mode 100644 index 0000000000..39b5bc22bc --- /dev/null +++ b/x/ccv/consumer/keeper/soft_opt_out.go @@ -0,0 +1,126 @@ +package keeper + +import ( + "encoding/binary" + "errors" + "fmt" + "sort" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" +) + +// BeginBlockSoftOptOut executes BeginBlock logic for the Soft Opt-Out sub-protocol +func (k Keeper) BeginBlockSoftOptOut(ctx sdk.Context) { + // Update smallest validator power that cannot opt out. + k.UpdateSmallestNonOptOutPower(ctx) + + // Update the SigningInfo structs of the Slashing module + k.UpdateSlashingSigningInfo(ctx) +} + +// SetSmallestNonOptOutPower sets the smallest validator power that cannot soft opt out. +func (k Keeper) SetSmallestNonOptOutPower(ctx sdk.Context, power uint64) { + store := ctx.KVStore(k.storeKey) + store.Set(types.SmallestNonOptOutPowerKey(), sdk.Uint64ToBigEndian(power)) +} + +// UpdateSmallestNonOptOutPower updates the smallest validator power that cannot soft opt out. +// This is the smallest validator power such that the sum of the power of all validators with a lower power +// is less than [SoftOptOutThreshold] of the total power of all validators. +func (k Keeper) UpdateSmallestNonOptOutPower(ctx sdk.Context) { + // get soft opt-out threshold + optOutThreshold := math.LegacyMustNewDecFromStr(k.GetSoftOptOutThreshold(ctx)) + if optOutThreshold.IsZero() { + // If the SoftOptOutThreshold is zero, then soft opt-out is disable. + // Setting the smallest non-opt-out power to zero, fixes the diff-testing + // when soft opt-out is disable. + k.SetSmallestNonOptOutPower(ctx, uint64(0)) + return + } + + // get all validators + valset := k.GetAllCCValidator(ctx) + + // Valset should only be empty for hacky tests. Log error in case this ever happens in prod. + if len(valset) == 0 { + k.Logger(ctx).Error("UpdateSoftOptOutThresholdPower called with empty validator set") + return + } + + // sort validators by power ascending + sort.SliceStable(valset, func(i, j int) bool { + return valset[i].Power < valset[j].Power + }) + + // get total power in set + totalPower := math.LegacyZeroDec() + for _, val := range valset { + totalPower = totalPower.Add(math.LegacyNewDec(val.Power)) + } + + // get power of the smallest validator that cannot soft opt out + powerSum := math.LegacyZeroDec() + for _, val := range valset { + powerSum = powerSum.Add(math.LegacyNewDec(val.Power)) + // if powerSum / totalPower > SoftOptOutThreshold + if powerSum.Quo(totalPower).GT(optOutThreshold) { + // set smallest non opt out power + k.SetSmallestNonOptOutPower(ctx, uint64(val.Power)) + k.Logger(ctx).Info("smallest non opt out power updated", "power", val.Power) + return + } + } + panic("UpdateSoftOptOutThresholdPower should not reach this point. Incorrect logic!") +} + +// GetSmallestNonOptOutPower returns the smallest validator power that cannot soft opt out. +func (k Keeper) GetSmallestNonOptOutPower(ctx sdk.Context) int64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.SmallestNonOptOutPowerKey()) + if bz == nil { + return 0 + } + return int64(binary.BigEndian.Uint64(bz)) +} + +func (k Keeper) UpdateSlashingSigningInfo(ctx sdk.Context) { + smallestNonOptOutPower := k.GetSmallestNonOptOutPower(ctx) + + // Update SigningInfo for opted out validators + valset := k.GetAllCCValidator(ctx) + // Note that we don't need to sort the valset as GetAllCCValidator + // uses KVStorePrefixIterator that iterates over all the keys with + // a certain prefix in ascending order + for _, val := range valset { + consAddr := sdk.ConsAddress(val.Address) + signingInfo, err := k.slashingKeeper.GetValidatorSigningInfo(ctx, consAddr) + if errors.Is(err, slashingtypes.ErrNoSigningInfoFound) { + continue + } else if err != nil { + panic(fmt.Errorf("failed to get validator signing info for validator %s", consAddr)) + } + if val.Power < smallestNonOptOutPower { + // validator CAN opt-out from validating on consumer chains + if !val.OptedOut { + // previously the validator couldn't opt-out + val.OptedOut = true + } + } else { + // validator CANNOT opt-out from validating on consumer chains + if val.OptedOut { + // previously the validator could opt-out + signingInfo.StartHeight = ctx.BlockHeight() + val.OptedOut = false + } + } + + if err := k.slashingKeeper.SetValidatorSigningInfo(ctx, consAddr, signingInfo); err != nil { + panic(fmt.Errorf("failed to update validator signing info for validator %s", consAddr)) + } + k.SetCCValidator(ctx, val) + } +} diff --git a/x/ccv/consumer/keeper/soft_opt_out_test.go b/x/ccv/consumer/keeper/soft_opt_out_test.go new file mode 100644 index 0000000000..5c21133832 --- /dev/null +++ b/x/ccv/consumer/keeper/soft_opt_out_test.go @@ -0,0 +1,120 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + tmtypes "github.com/cometbft/cometbft/types" + + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// Tests that UpdateSmallestNonOptOutPower updates the smallest validator power that cannot soft opt out. +// Soft opt out allows the bottom [SoftOptOutThreshold] portion of validators in the set to opt out. +// UpdateSmallestNonOptOutPower should update the smallest validator power that cannot opt out. +func TestUpdateSmallestNonOptOutPower(t *testing.T) { + cIds := crypto.GenMultipleCryptoIds(7, 682934679238) + + testCases := []struct { + name string + // soft opt out threshold set as param + optOutThresh string + // validators to set in store + validators []*tmtypes.Validator + // expected smallest power of validator which cannot opt out + expSmallestNonOptOutValPower int64 + }{ + { + name: "One", + optOutThresh: "0.05", + validators: []*tmtypes.Validator{ + tmtypes.NewValidator(cIds[0].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[1].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[2].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[3].TMCryptoPubKey(), 3), + tmtypes.NewValidator(cIds[4].TMCryptoPubKey(), 49), + tmtypes.NewValidator(cIds[5].TMCryptoPubKey(), 51), + }, + // 107 total power, validator with 3 power passes 0.05 threshold (6 / 107 = 0.056) and cannot opt out + expSmallestNonOptOutValPower: 3, + }, + { + name: "One in different order", + optOutThresh: "0.05", + validators: []*tmtypes.Validator{ + tmtypes.NewValidator(cIds[0].TMCryptoPubKey(), 3), + tmtypes.NewValidator(cIds[1].TMCryptoPubKey(), 51), + tmtypes.NewValidator(cIds[2].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[3].TMCryptoPubKey(), 49), + tmtypes.NewValidator(cIds[4].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[5].TMCryptoPubKey(), 1), + }, + // Same result as first test case, just confirms order of validators doesn't matter + expSmallestNonOptOutValPower: 3, + }, + { + name: "Two", + optOutThresh: "0.05", + validators: []*tmtypes.Validator{ + tmtypes.NewValidator(cIds[0].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[1].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[2].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[3].TMCryptoPubKey(), 3), + tmtypes.NewValidator(cIds[4].TMCryptoPubKey(), 500), + }, + // 506 total power, validator with 500 passes 0.05 threshold and cannot opt out + expSmallestNonOptOutValPower: 500, + }, + { + name: "Three", + optOutThresh: "0.199999", + validators: []*tmtypes.Validator{ + tmtypes.NewValidator(cIds[0].TMCryptoPubKey(), 54), + tmtypes.NewValidator(cIds[1].TMCryptoPubKey(), 53), + tmtypes.NewValidator(cIds[2].TMCryptoPubKey(), 52), + tmtypes.NewValidator(cIds[3].TMCryptoPubKey(), 51), + tmtypes.NewValidator(cIds[4].TMCryptoPubKey(), 50), + tmtypes.NewValidator(cIds[5].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[6].TMCryptoPubKey(), 1), + }, + // 262 total power, (50 + 1 + 1) / 262 ~= 0.19, validator with 51 passes 0.199999 threshold and cannot opt out + expSmallestNonOptOutValPower: 51, + }, + { + name: "soft opt-out disabled", + optOutThresh: "0", + validators: []*tmtypes.Validator{ + tmtypes.NewValidator(cIds[0].TMCryptoPubKey(), 54), + tmtypes.NewValidator(cIds[1].TMCryptoPubKey(), 53), + tmtypes.NewValidator(cIds[2].TMCryptoPubKey(), 52), + tmtypes.NewValidator(cIds[3].TMCryptoPubKey(), 51), + tmtypes.NewValidator(cIds[4].TMCryptoPubKey(), 50), + tmtypes.NewValidator(cIds[5].TMCryptoPubKey(), 1), + tmtypes.NewValidator(cIds[6].TMCryptoPubKey(), 1), + }, + expSmallestNonOptOutValPower: 0, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + moduleParams := ccvtypes.DefaultParams() + moduleParams.SoftOptOutThreshold = tc.optOutThresh + consumerKeeper.SetParams(ctx, moduleParams) + defer ctrl.Finish() + + // set validators in store + SetCCValidators(t, consumerKeeper, ctx, tc.validators) + + // update smallest power of validator which cannot opt out + consumerKeeper.UpdateSmallestNonOptOutPower(ctx) + + // expect smallest power of validator which cannot opt out to be updated + require.Equal(t, tc.expSmallestNonOptOutValPower, consumerKeeper.GetSmallestNonOptOutPower(ctx)) + }) + } +} diff --git a/x/ccv/consumer/keeper/throttle_retry.go b/x/ccv/consumer/keeper/throttle_retry.go index 22e48f9175..4b6df3cc04 100644 --- a/x/ccv/consumer/keeper/throttle_retry.go +++ b/x/ccv/consumer/keeper/throttle_retry.go @@ -5,7 +5,7 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) // diff --git a/x/ccv/consumer/keeper/throttle_retry_test.go b/x/ccv/consumer/keeper/throttle_retry_test.go index 4a222fde90..b979ebb51d 100644 --- a/x/ccv/consumer/keeper/throttle_retry_test.go +++ b/x/ccv/consumer/keeper/throttle_retry_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/require" - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func TestPacketSendingPermitted(t *testing.T) { diff --git a/x/ccv/consumer/keeper/validators.go b/x/ccv/consumer/keeper/validators.go index 27aefe4a44..2c4f0d79ab 100644 --- a/x/ccv/consumer/keeper/validators.go +++ b/x/ccv/consumer/keeper/validators.go @@ -1,6 +1,8 @@ package keeper import ( + "context" + "errors" "time" "cosmossdk.io/math" @@ -11,7 +13,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) // @@ -25,7 +27,7 @@ func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.Validato ret := []abci.ValidatorUpdate{} for _, change := range changes { // convert TM pubkey to SDK pubkey - pubkey, err := cryptocodec.FromTmProtoPublicKey(change.GetPubKey()) + pubkey, err := cryptocodec.FromCmtProtoPublicKey(change.GetPubKey()) if err != nil { // An error here would indicate that the validator updates // received from the provider are invalid. @@ -78,27 +80,30 @@ func (k Keeper) ApplyCCValidatorChanges(ctx sdk.Context, changes []abci.Validato // IterateValidators - unimplemented on CCV keeper but perform a no-op in order to pass the slashing module InitGenesis. // It is allowed since the condition verifying validator public keys in HandleValidatorSignature (x/slashing/keeper/infractions.go) is removed // therefore it isn't required to store any validator public keys to the slashing states during genesis. -func (k Keeper) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool)) { +func (k Keeper) IterateValidators(context.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error { + return nil } // Validator - unimplemented on CCV keeper -func (k Keeper) Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI { +func (k Keeper) Validator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.ValidatorI, error) { panic("unimplemented on CCV keeper") } // IsJailed returns the outstanding slashing flag for the given validator address -func (k Keeper) IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool { +func (k Keeper) IsValidatorJailed(goCtx context.Context, addr sdk.ConsAddress) (bool, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // if the changeover is not complete for prev standalone chain, // return the standalone staking keeper's jailed status if k.IsPrevStandaloneChain(ctx) && !k.ChangeoverIsComplete(ctx) { return k.standaloneStakingKeeper.IsValidatorJailed(ctx, addr) } // Otherwise, return the ccv consumer keeper's notion of a validator being jailed - return k.OutstandingDowntime(ctx, addr) + return k.OutstandingDowntime(ctx, addr), nil } // ValidatorByConsAddr returns an empty validator -func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI { +func (k Keeper) ValidatorByConsAddr(context.Context, sdk.ConsAddress) (stakingtypes.ValidatorI, error) { /* NOTE: @@ -109,22 +114,24 @@ func (k Keeper) ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.V Also, the slashing module will cal lthis function when it observes downtime. In that case the only requirement on the returned value is that it isn't null. */ - return stakingtypes.Validator{} + return stakingtypes.Validator{}, nil } // Calls SlashWithInfractionReason with Infraction_INFRACTION_UNSPECIFIED. // ConsumerKeeper must implement StakingKeeper interface. // This function should not be called anywhere -func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec) math.Int { +func (k Keeper) Slash(ctx context.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec) (math.Int, error) { return k.SlashWithInfractionReason(ctx, addr, infractionHeight, power, slashFactor, stakingtypes.Infraction_INFRACTION_UNSPECIFIED) } // Slash queues a slashing request for the provider chain // All queued slashing requests will be cleared in EndBlock // Called by Slashing keeper in SlashWithInfractionReason -func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infraction stakingtypes.Infraction) math.Int { +func (k Keeper) SlashWithInfractionReason(goCtx context.Context, addr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec, infraction stakingtypes.Infraction) (math.Int, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if infraction == stakingtypes.Infraction_INFRACTION_UNSPECIFIED { - return math.NewInt(0) + return math.ZeroInt(), nil } // If this is a previously standalone chain and infraction happened before the changeover was completed, @@ -136,6 +143,18 @@ func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, addr sdk.ConsAddress, // Otherwise infraction happened after the changeover was completed. + // if this is a downtime infraction and the validator is allowed to + // soft opt out, do not queue a slash packet + if infraction == stakingtypes.Infraction_INFRACTION_DOWNTIME { + if power < k.GetSmallestNonOptOutPower(ctx) { + // soft opt out + k.Logger(ctx).Debug("soft opt out", + "validator", addr, + "power", power, + ) + return math.ZeroInt(), nil + } + } // get VSC ID for infraction height vscID := k.GetHeightValsetUpdateID(ctx, uint64(infractionHeight)) @@ -158,7 +177,7 @@ func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, addr sdk.ConsAddress, ) // Only return to comply with the interface restriction - return math.ZeroInt() + return math.ZeroInt(), nil } // Jail - unimplemented on CCV keeper @@ -166,45 +185,50 @@ func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, addr sdk.ConsAddress, // This method should be a no-op even during a standalone to consumer changeover. // Once the upgrade has happened as a part of the changeover, // the provider validator set will soon be in effect, and jailing is n/a. -func (k Keeper) Jail(ctx sdk.Context, addr sdk.ConsAddress) {} +func (k Keeper) Jail(context.Context, sdk.ConsAddress) error { return nil } // Unjail - unimplemented on CCV keeper // // This method should be a no-op even during a standalone to consumer changeover. // Once the upgrade has happened as a part of the changeover, // the provider validator set will soon be in effect, and jailing is n/a. -func (k Keeper) Unjail(sdk.Context, sdk.ConsAddress) {} +func (k Keeper) Unjail(context.Context, sdk.ConsAddress) error { return nil } // Delegation - unimplemented on CCV keeper -func (k Keeper) Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI { +func (k Keeper) Delegation(ctx context.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.DelegationI, error) { panic("unimplemented on CCV keeper") } // MaxValidators - unimplemented on CCV keeper -func (k Keeper) MaxValidators(sdk.Context) uint32 { +func (k Keeper) MaxValidators(context.Context) (uint32, error) { panic("unimplemented on CCV keeper") } // UnbondingTime returns consumer unbonding period, satisfying the staking keeper interface -func (k Keeper) UnbondingTime(ctx sdk.Context) time.Duration { - return k.GetUnbondingPeriod(ctx) +func (k Keeper) UnbondingTime(goCtx context.Context) (time.Duration, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + return k.GetUnbondingPeriod(ctx), nil } // GetHistoricalInfo gets the historical info at a given height -func (k Keeper) GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) { +func (k Keeper) GetHistoricalInfo(goCtx context.Context, height int64) (stakingtypes.HistoricalInfo, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + store := ctx.KVStore(k.storeKey) key := types.HistoricalInfoKey(height) value := store.Get(key) if value == nil { - return stakingtypes.HistoricalInfo{}, false + return stakingtypes.HistoricalInfo{}, stakingtypes.ErrNoHistoricalInfo } - return stakingtypes.MustUnmarshalHistoricalInfo(k.cdc, value), true + return stakingtypes.UnmarshalHistoricalInfo(k.cdc, value) } // SetHistoricalInfo sets the historical info at a given height -func (k Keeper) SetHistoricalInfo(ctx sdk.Context, height int64, hi *stakingtypes.HistoricalInfo) { +func (k Keeper) SetHistoricalInfo(goCtx context.Context, height int64, hi *stakingtypes.HistoricalInfo) { + ctx := sdk.UnwrapSDKContext(goCtx) + store := ctx.KVStore(k.storeKey) key := types.HistoricalInfoKey(height) value := k.cdc.MustMarshal(hi) @@ -213,16 +237,21 @@ func (k Keeper) SetHistoricalInfo(ctx sdk.Context, height int64, hi *stakingtype } // DeleteHistoricalInfo deletes the historical info at a given height -func (k Keeper) DeleteHistoricalInfo(ctx sdk.Context, height int64) { +func (k Keeper) DeleteHistoricalInfo(goCtx context.Context, height int64) error { + ctx := sdk.UnwrapSDKContext(goCtx) + store := ctx.KVStore(k.storeKey) key := types.HistoricalInfoKey(height) store.Delete(key) + return nil } // TrackHistoricalInfo saves the latest historical-info and deletes the oldest // heights that are below pruning height -func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { +func (k Keeper) TrackHistoricalInfo(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) + numHistoricalEntries := k.GetHistoricalEntries(ctx) // Prune store to ensure we only have parameter-defined historical entries. @@ -233,17 +262,21 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { // over the historical entries starting from the most recent version to be pruned // and then return at the first empty entry. for i := ctx.BlockHeight() - numHistoricalEntries; i >= 0; i-- { - _, found := k.GetHistoricalInfo(ctx, i) - if found { - k.DeleteHistoricalInfo(ctx, i) - } else { - break + _, err := k.GetHistoricalInfo(ctx, i) + if err != nil { + if errors.Is(err, stakingtypes.ErrNoHistoricalInfo) { + break + } + return err + } + if err = k.DeleteHistoricalInfo(ctx, i); err != nil { + return err } } // if there is no need to persist historicalInfo, return if numHistoricalEntries == 0 { - return + return nil } // Create HistoricalInfo struct @@ -255,7 +288,8 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { // to be stored correctly in ApplyCCValidatorChanges. panic(err) } - val, err := stakingtypes.NewValidator(nil, pk, stakingtypes.Description{}) + + val, err := stakingtypes.NewValidator(sdk.ValAddress(pk.Address()).String(), pk, stakingtypes.Description{}) if err != nil { // This should never happen as the pubkey is assumed // to be stored correctly in ApplyCCValidatorChanges. @@ -270,10 +304,11 @@ func (k Keeper) TrackHistoricalInfo(ctx sdk.Context) { } // Create historical info entry which sorts the validator set by voting power - historicalEntry := stakingtypes.NewHistoricalInfo(ctx.BlockHeader(), lastVals, sdk.DefaultPowerReduction) + historicalEntry := stakingtypes.NewHistoricalInfo(ctx.BlockHeader(), stakingtypes.Validators{Validators: lastVals, ValidatorCodec: k.validatorAddressCodec}, sdk.DefaultPowerReduction) // Set latest HistoricalInfo at current height k.SetHistoricalInfo(ctx, ctx.BlockHeight(), &historicalEntry) + return nil } // MustGetCurrentValidatorsAsABCIUpdates gets all cross-chain validators converted @@ -288,7 +323,7 @@ func (k Keeper) MustGetCurrentValidatorsAsABCIUpdates(ctx sdk.Context) []abci.Va // to be stored correctly in ApplyCCValidatorChanges. panic(err) } - tmPK, err := cryptocodec.ToTmProtoPublicKey(pk) + tmPK, err := cryptocodec.ToCmtProtoPublicKey(pk) if err != nil { // This should never happen as the pubkey is assumed // to be stored correctly in ApplyCCValidatorChanges. @@ -301,12 +336,12 @@ func (k Keeper) MustGetCurrentValidatorsAsABCIUpdates(ctx sdk.Context) []abci.Va // implement interface method needed for x/genutil in sdk v47 // returns empty updates and err -func (k Keeper) ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate, err error) { +func (k Keeper) ApplyAndReturnValidatorSetUpdates(context.Context) (updates []abci.ValidatorUpdate, err error) { return } // GetAllValidators is needed to implement StakingKeeper as expected by the Slashing module since cosmos-sdk/v0.47.x. // Use GetAllCCValidator in places where access to all cross-chain validators is needed. -func (k Keeper) GetAllValidators(ctx sdk.Context) []stakingtypes.Validator { - return []stakingtypes.Validator{} +func (k Keeper) GetAllValidators(ctx context.Context) ([]stakingtypes.Validator, error) { + return []stakingtypes.Validator{}, nil } diff --git a/x/ccv/consumer/keeper/validators_test.go b/x/ccv/consumer/keeper/validators_test.go index 1d4dcb2c86..0ab47eb21f 100644 --- a/x/ccv/consumer/keeper/validators_test.go +++ b/x/ccv/consumer/keeper/validators_test.go @@ -15,10 +15,10 @@ import ( tmrand "github.com/cometbft/cometbft/libs/rand" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) // TestApplyCCValidatorChanges tests the ApplyCCValidatorChanges method for a consumer keeper @@ -120,13 +120,17 @@ func TestIsValidatorJailed(t *testing.T) { // IsValidatorJailed should return false for an arbitrary consensus address consAddr := []byte{0x01, 0x02, 0x03} - require.False(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) + isJailed1, err := consumerKeeper.IsValidatorJailed(ctx, consAddr) + require.NoError(t, err) + require.False(t, isJailed1) // Set outstanding downtime for that addr consumerKeeper.SetOutstandingDowntime(ctx, consAddr) // Now confirm IsValidatorJailed returns true - require.True(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) + isJailed2, err := consumerKeeper.IsValidatorJailed(ctx, consAddr) + require.NoError(t, err) + require.True(t, isJailed2) // Next, we set a value for the standalone staking keeper, // and mark the consumer keeper as being from a previous standalone chain @@ -141,10 +145,12 @@ func TestIsValidatorJailed(t *testing.T) { // At this point, the state of the consumer keeper is s.t. IsValidatorJailed() queries the standalone staking keeper // Now mock that a validator is jailed from the standalone staking keeper - mocks.MockStakingKeeper.EXPECT().IsValidatorJailed(ctx, consAddr).Return(true).Times(1) + mocks.MockStakingKeeper.EXPECT().IsValidatorJailed(ctx, consAddr).Return(true, nil).Times(1) // Confirm IsValidatorJailed returns true - require.True(t, consumerKeeper.IsValidatorJailed(ctx, consAddr)) + isJailed3, err := consumerKeeper.IsValidatorJailed(ctx, consAddr) + require.NoError(t, err) + require.True(t, isJailed3) } func TestSlash(t *testing.T) { @@ -152,7 +158,7 @@ func TestSlash(t *testing.T) { defer ctrl.Finish() // If we call slash with infraction type empty, no slash packet will be queued - consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.Infraction_INFRACTION_UNSPECIFIED) + consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, math.LegacyNewDec(9.0), stakingtypes.Infraction_INFRACTION_UNSPECIFIED) pendingPackets := consumerKeeper.GetPendingPackets(ctx) require.Len(t, pendingPackets, 0) @@ -163,7 +169,7 @@ func TestSlash(t *testing.T) { consumerKeeper.SetHeightValsetUpdateID(ctx, 5, 6) // Call slash with valid infraction type and confirm 1 slash packet is queued - consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.Infraction_INFRACTION_DOWNTIME) + consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, math.LegacyNewDec(9.0), stakingtypes.Infraction_INFRACTION_DOWNTIME) pendingPackets = consumerKeeper.GetPendingPackets(ctx) require.Len(t, pendingPackets, 1) @@ -178,21 +184,21 @@ func TestSlash(t *testing.T) { // If we call slash with infraction type empty, standalone staking keeper's slash will not be called // (if it was called, test would panic without mocking the call) - consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, sdk.NewDec(9.0), stakingtypes.Infraction_INFRACTION_UNSPECIFIED) + consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, 5, 6, math.LegacyNewDec(9.0), stakingtypes.Infraction_INFRACTION_UNSPECIFIED) // Now setup a mock for Slash, and confirm that it is called against // standalone staking keeper with valid infraction type infractionHeight := int64(5) mocks.MockStakingKeeper.EXPECT().SlashWithInfractionReason( ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, int64(6), - sdk.MustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_UNSPECIFIED).Times(1) // We pass empty infraction to standalone staking keeper since it's not used + math.LegacyMustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_UNSPECIFIED).Times(1) // We pass empty infraction to standalone staking keeper since it's not used // Also setup init genesis height s.t. infraction height is before first consumer height consumerKeeper.SetInitGenesisHeight(ctx, 4) require.Equal(t, consumerKeeper.FirstConsumerHeight(ctx), int64(6)) consumerKeeper.SlashWithInfractionReason(ctx, []byte{0x01, 0x02, 0x03}, infractionHeight, 6, - sdk.MustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_DOWNTIME) + math.LegacyMustNewDecFromStr("0.05"), stakingtypes.Infraction_INFRACTION_DOWNTIME) } // Tests the getter and setter behavior for historical info @@ -214,7 +220,7 @@ func TestHistoricalInfo(t *testing.T) { pk, err := v.ConsPubKey() require.NoError(t, err) - val, err := stakingtypes.NewValidator(nil, pk, stakingtypes.Description{}) + val, err := stakingtypes.NewValidator("", pk, stakingtypes.Description{}) require.NoError(t, err) // set voting power to random value @@ -224,13 +230,17 @@ func TestHistoricalInfo(t *testing.T) { currentHeight := ctx.BlockHeight() + validatorsWithCodec := stakingtypes.Validators{ + Validators: sVals, + ValidatorCodec: consumerKeeper.ValidatorAddressCodec(), + } // create and store historical info - hi := stakingtypes.NewHistoricalInfo(ctx.BlockHeader(), sVals, sdk.DefaultPowerReduction) + hi := stakingtypes.NewHistoricalInfo(ctx.BlockHeader(), validatorsWithCodec, sdk.DefaultPowerReduction) consumerKeeper.SetHistoricalInfo(ctx, currentHeight, &hi) // expect to get historical info - recv, found := consumerKeeper.GetHistoricalInfo(ctx, currentHeight) - require.True(t, found, "HistoricalInfo not found after set") + recv, err := consumerKeeper.GetHistoricalInfo(ctx, currentHeight) + require.NoError(t, err, "HistoricalInfo not found after set") require.Equal(t, hi, recv, "HistoricalInfo not equal") // verify that historical info valset has validators sorted in order diff --git a/x/ccv/consumer/migrations/v2/migration.go b/x/ccv/consumer/migrations/v2/migration.go index 80f06d4d71..a0b401188d 100644 --- a/x/ccv/consumer/migrations/v2/migration.go +++ b/x/ccv/consumer/migrations/v2/migration.go @@ -3,11 +3,11 @@ package v2 import ( "fmt" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // MigrateConsumerPacketData migrates consumer packet data according to diff --git a/x/ccv/consumer/migrations/v2/migration_test.go b/x/ccv/consumer/migrations/v2/migration_test.go index a99a2be0fb..0b3f24ec75 100644 --- a/x/ccv/consumer/migrations/v2/migration_test.go +++ b/x/ccv/consumer/migrations/v2/migration_test.go @@ -6,13 +6,12 @@ import ( "github.com/stretchr/testify/require" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" - v2 "github.com/cosmos/interchain-security/v4/x/ccv/consumer/migrations/v2" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + v2 "github.com/cosmos/interchain-security/v5/x/ccv/consumer/migrations/v2" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func TestMigrateConsumerPacketData(t *testing.T) { diff --git a/x/ccv/consumer/migrations/v3/legacy_params.go b/x/ccv/consumer/migrations/v3/legacy_params.go new file mode 100644 index 0000000000..0906455e21 --- /dev/null +++ b/x/ccv/consumer/migrations/v3/legacy_params.go @@ -0,0 +1,116 @@ +package v3 + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// Legacy: used for migration only! +// GetConsumerParamsLegacy returns the params for the consumer ccv module from legacy subspace +func GetConsumerParamsLegacy(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) ccvtypes.ConsumerParams { + return ccvtypes.NewParams( + getEnabled(ctx, paramSpace), + getBlocksPerDistributionTransmission(ctx, paramSpace), + getDistributionTransmissionChannel(ctx, paramSpace), + getProviderFeePoolAddrStr(ctx, paramSpace), + getCCVTimeoutPeriod(ctx, paramSpace), + getTransferTimeoutPeriod(ctx, paramSpace), + getConsumerRedistributionFrac(ctx, paramSpace), + getHistoricalEntries(ctx, paramSpace), + getUnbondingPeriod(ctx, paramSpace), + getSoftOptOutThreshold(ctx, paramSpace), + getRewardDenoms(ctx, paramSpace), + getProviderRewardDenoms(ctx, paramSpace), + getRetryDelayPeriod(ctx, paramSpace), + ) +} + +// getEnabled returns the enabled flag for the consumer module +func getEnabled(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) bool { + var enabled bool + paramStore.Get(ctx, ccvtypes.KeyEnabled, &enabled) + return enabled +} + +func getBlocksPerDistributionTransmission(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) int64 { + var bpdt int64 + paramStore.Get(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, &bpdt) + return bpdt +} + +func getDistributionTransmissionChannel(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) string { + var s string + paramStore.Get(ctx, ccvtypes.KeyDistributionTransmissionChannel, &s) + return s +} + +func getProviderFeePoolAddrStr(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) string { + var s string + paramStore.Get(ctx, ccvtypes.KeyProviderFeePoolAddrStr, &s) + return s +} + +// getCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets +func getCCVTimeoutPeriod(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramStore.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) + return p +} + +// getTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets +func getTransferTimeoutPeriod(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramStore.Get(ctx, ccvtypes.KeyTransferTimeoutPeriod, &p) + return p +} + +// getConsumerRedistributionFrac returns 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%. +func getConsumerRedistributionFrac(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) string { + var str string + paramStore.Get(ctx, ccvtypes.KeyConsumerRedistributionFrac, &str) + return str +} + +// getHistoricalEntries returns the number of historical info entries to persist in store +func getHistoricalEntries(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) int64 { + var n int64 + paramStore.Get(ctx, ccvtypes.KeyHistoricalEntries, &n) + return n +} + +func getUnbondingPeriod(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) time.Duration { + var period time.Duration + paramStore.Get(ctx, ccvtypes.KeyConsumerUnbondingPeriod, &period) + return period +} + +// getSoftOptOutThreshold returns the percentage of validators at the bottom of the set +// that can opt out of running the consumer chain +func getSoftOptOutThreshold(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) string { + var str string + paramStore.Get(ctx, ccvtypes.KeySoftOptOutThreshold, &str) + return str +} + +func getRewardDenoms(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) []string { + var denoms []string + paramStore.Get(ctx, ccvtypes.KeyRewardDenoms, &denoms) + return denoms +} + +func getProviderRewardDenoms(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) []string { + var denoms []string + paramStore.Get(ctx, ccvtypes.KeyProviderRewardDenoms, &denoms) + return denoms +} + +func getRetryDelayPeriod(ctx sdk.Context, paramStore ccvtypes.LegacyParamSubspace) time.Duration { + var period time.Duration + paramStore.Get(ctx, ccvtypes.KeyRetryDelayPeriod, &period) + return period +} diff --git a/x/ccv/consumer/migrations/v3/migration.go b/x/ccv/consumer/migrations/v3/migration.go new file mode 100644 index 0000000000..aadc94bc43 --- /dev/null +++ b/x/ccv/consumer/migrations/v3/migration.go @@ -0,0 +1,27 @@ +package v3 + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + storetypes "cosmossdk.io/store/types" + + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// MigrateLegacyParams migrates the consumers module's parameters from the x/params subspace to the +// consumer modules store. +func MigrateLegacyParams(ctx sdk.Context, cdc codec.BinaryCodec, store storetypes.KVStore, legacyParamspace ccvtypes.LegacyParamSubspace) error { + ctx.Logger().Info("starting consumer legacy params migration") + params := GetConsumerParamsLegacy(ctx, legacyParamspace) + err := params.Validate() + if err != nil { + return err + } + + bz := cdc.MustMarshal(¶ms) + store.Set(consumertypes.ParametersKey(), bz) + ctx.Logger().Info("successfully migrated consumer parameters") + return nil +} diff --git a/x/ccv/consumer/migrations/v3/migration_test.go b/x/ccv/consumer/migrations/v3/migration_test.go new file mode 100644 index 0000000000..bdc3f59f70 --- /dev/null +++ b/x/ccv/consumer/migrations/v3/migration_test.go @@ -0,0 +1,95 @@ +package v3 + +import ( + "fmt" + "testing" + "time" + + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/interchain-security/v5/app/encoding" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" + + "github.com/stretchr/testify/require" +) + +type testLegacyParamSubspace struct { + *ccvtypes.ConsumerParams +} + +func newTestLegacyParamsSubspace(p ccvtypes.ConsumerParams) testLegacyParamSubspace { + return testLegacyParamSubspace{ + &p, + } +} + +func (ps testLegacyParamSubspace) Get(ctx sdk.Context, key []byte, ptr interface{}) { + switch string(key) { + case string(ccvtypes.KeyEnabled): + *ptr.(*bool) = ps.Enabled + case string(ccvtypes.KeyBlocksPerDistributionTransmission): + *ptr.(*int64) = ps.BlocksPerDistributionTransmission + case string(ccvtypes.KeyDistributionTransmissionChannel): + *ptr.(*string) = ps.DistributionTransmissionChannel + case string(ccvtypes.KeyProviderFeePoolAddrStr): + *ptr.(*string) = ps.ProviderFeePoolAddrStr + case string(ccvtypes.KeyCCVTimeoutPeriod): + *ptr.(*time.Duration) = ps.CcvTimeoutPeriod + case string(ccvtypes.KeyTransferTimeoutPeriod): + *ptr.(*time.Duration) = ps.TransferTimeoutPeriod + case string(ccvtypes.KeyConsumerRedistributionFrac): + *ptr.(*string) = ps.ConsumerRedistributionFraction + case string(ccvtypes.KeyHistoricalEntries): + *ptr.(*int64) = ps.HistoricalEntries + case string(ccvtypes.KeyConsumerUnbondingPeriod): + *ptr.(*time.Duration) = ps.UnbondingPeriod + case string(ccvtypes.KeySoftOptOutThreshold): + *ptr.(*string) = ps.SoftOptOutThreshold + case string(ccvtypes.KeyRewardDenoms): + *ptr.(*[]string) = ps.RewardDenoms + case string(ccvtypes.KeyProviderRewardDenoms): + *ptr.(*[]string) = ps.ProviderRewardDenoms + case string(ccvtypes.KeyRetryDelayPeriod): + *ptr.(*time.Duration) = ps.RetryDelayPeriod + default: + panic(fmt.Sprintf("invalid paramspace key: %s", string(key))) + + } +} + +func TestMigrateParams(t *testing.T) { + cdc := encoding.MakeTestEncodingConfig().Codec + storeKey := storetypes.NewKVStoreKey("ccvconsumer") + ctx := testutil.DefaultContext(storeKey, storetypes.NewTransientStoreKey("transient_test")) + store := ctx.KVStore(storeKey) + + defaultParams := ccvtypes.DefaultParams() + legacyParamSubspace := newTestLegacyParamsSubspace(defaultParams) + // confirms that testLegacyParamSubspace works as expected + require.NotPanics(t, func() { + GetConsumerParamsLegacy(ctx, legacyParamSubspace) + }) + + emptyParams := ccvtypes.ConsumerParams{} + bz := store.Get(consumertypes.ParametersKey()) + require.NoError(t, cdc.Unmarshal(bz, &emptyParams)) + require.NotNil(t, emptyParams) + require.Empty(t, emptyParams) + require.NotEqual(t, defaultParams, emptyParams) + + err := MigrateLegacyParams(ctx, cdc, store, legacyParamSubspace) + require.NoError(t, err) + + // check that new params are available after migration and equal to defaults + // legacyParamSubspace was set to match defaultParams + migratedParams := ccvtypes.ConsumerParams{} + paramsBz := store.Get(consumertypes.ParametersKey()) + require.NotEqual(t, bz, paramsBz) + require.NoError(t, cdc.Unmarshal(paramsBz, &migratedParams)) + + require.Equal(t, defaultParams, migratedParams) + require.NotEqual(t, emptyParams, migratedParams) +} diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index 1896728085..49e19542be 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -19,16 +19,24 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/client/cli" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/client/cli" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) var ( - _ module.AppModule = AppModule{} - _ porttypes.IBCModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = (*AppModule)(nil) + _ module.AppModuleBasic = (*AppModuleBasic)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasABCIGenesis = (*AppModule)(nil) + _ module.HasABCIEndBlock = (*AppModule)(nil) + _ module.HasName = (*AppModule)(nil) + _ module.HasConsensusVersion = (*AppModule)(nil) + _ module.HasInvariants = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) ) // AppModuleBasic is the IBC Consumer AppModuleBasic @@ -46,9 +54,15 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces registers module concrete types into protobuf Any. func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - // ccv.RegisterInterfaces(registry) + consumertypes.RegisterInterfaces(registry) } +// IsAppModule implements the appmodule.AppModule interface. +func (AppModule) IsAppModule() {} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (AppModule) IsOnePerModuleType() {} + // DefaultGenesis returns default genesis state as raw bytes for the ibc // consumer module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { @@ -106,12 +120,16 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { + consumertypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) 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)) } + if err := cfg.RegisterMigration(consumertypes.ModuleName, 2, m.Migrate2to3); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s -- from 2 -> 3", consumertypes.ModuleName, err)) + } } // InitGenesis performs genesis initialization for the consumer module. It returns @@ -131,13 +149,18 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { - return 2 + return 3 } // BeginBlock implements the AppModule interface // Set the VSC ID for the subsequent block to the same value as the current block // Panic if the provider's channel was established and then closed -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { +func (am AppModule) BeginBlock(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Execute BeginBlock logic for the Soft Opt-Out sub-protocol + am.keeper.BeginBlockSoftOptOut(ctx) + channelID, found := am.keeper.GetProviderChannel(ctx) if found && am.keeper.IsChannelClosed(ctx, channelID) { // The CCV channel was established, but it was then closed; @@ -153,18 +176,21 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { am.keeper.Logger(ctx).Debug("block height was mapped to vscID", "height", blockHeight+1, "vscID", vID) am.keeper.TrackHistoricalInfo(ctx) + return nil } // EndBlock implements the AppModule interface // Flush PendingChanges to ABCI, send pending packets, write acknowledgements for packets that have finished unbonding. // // TODO: e2e tests confirming behavior with and without standalone -> consumer changeover -func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(goCtx context.Context) ([]abci.ValidatorUpdate, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // If PreCCV state is active, consumer is a previously standalone chain // that was just upgraded to include the consumer ccv module, execute changeover logic. if am.keeper.IsPreCCV(ctx) { initialValUpdates := am.keeper.ChangeoverToConsumer(ctx) - return initialValUpdates + return initialValUpdates, nil } // Execute EndBlock logic for the Reward Distribution sub-protocol @@ -179,7 +205,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V data, ok := am.keeper.GetPendingChanges(ctx) if !ok { - return []abci.ValidatorUpdate{} + return []abci.ValidatorUpdate{}, nil } // apply changes to cross-chain validator set tendermintUpdates := am.keeper.ApplyCCValidatorChanges(ctx, data.ValidatorUpdates) @@ -187,7 +213,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V am.keeper.Logger(ctx).Debug("sending validator updates to consensus engine", "len updates", len(tendermintUpdates)) - return tendermintUpdates + return tendermintUpdates, nil } // AppModuleSimulation functions @@ -199,7 +225,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // RegisterStoreDecoder registers a decoder for consumer module's types // TODO -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the consumer module operations with their respective weights. diff --git a/x/ccv/consumer/types/codec.go b/x/ccv/consumer/types/codec.go new file mode 100644 index 0000000000..243fc63f46 --- /dev/null +++ b/x/ccv/consumer/types/codec.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterInterfaces registers the consumer Tx message types to the interface registry +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgUpdateParams{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/ccv/consumer/types/consumer.pb.go b/x/ccv/consumer/types/consumer.pb.go index 621801a57e..5e0c9488ba 100644 --- a/x/ccv/consumer/types/consumer.pb.go +++ b/x/ccv/consumer/types/consumer.pb.go @@ -173,35 +173,35 @@ func init() { } var fileDescriptor_5b27a82b276e7f93 = []byte{ - // 435 bytes of a gzipped FileDescriptorProto + // 436 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xcd, 0x6e, 0xd3, 0x40, 0x10, 0xce, 0xb6, 0x50, 0xdc, 0x0d, 0x42, 0xc8, 0x44, 0xc2, 0xcd, 0xc1, 0x8e, 0xc2, 0xc5, 0x97, - 0xda, 0x6a, 0xca, 0x09, 0x89, 0x43, 0xd3, 0x23, 0x87, 0x22, 0x83, 0x40, 0xe2, 0x62, 0xad, 0xd7, - 0x8b, 0x63, 0x61, 0xef, 0xac, 0xf6, 0xc7, 0x65, 0x79, 0x8a, 0x3e, 0x0c, 0x0f, 0x51, 0x38, 0xf5, - 0xc8, 0xa9, 0xa0, 0xe4, 0x0d, 0x78, 0x02, 0xe4, 0x9f, 0x04, 0xf1, 0x73, 0x9b, 0xf9, 0x66, 0xbf, - 0x99, 0x6f, 0x66, 0x3f, 0xbc, 0x28, 0xb9, 0x66, 0x92, 0xae, 0x48, 0xc9, 0x53, 0xc5, 0xa8, 0x91, - 0xa5, 0xb6, 0x31, 0xa5, 0x4d, 0x4c, 0x81, 0x2b, 0x53, 0x33, 0x19, 0x37, 0x27, 0xbb, 0x38, 0x12, - 0x12, 0x34, 0xb8, 0x4f, 0xfe, 0xc3, 0x89, 0x28, 0x6d, 0xa2, 0xdd, 0xbb, 0xe6, 0x64, 0x7a, 0x54, - 0x00, 0x14, 0x15, 0x8b, 0x3b, 0x4a, 0x66, 0xde, 0xc7, 0x84, 0xdb, 0x9e, 0x3f, 0x9d, 0x14, 0x50, - 0x40, 0x17, 0xc6, 0x6d, 0x34, 0xa0, 0x47, 0x14, 0x54, 0x0d, 0x2a, 0xed, 0x0b, 0x7d, 0x32, 0x94, - 0x82, 0xbf, 0x7b, 0xe9, 0xb2, 0x66, 0x4a, 0x93, 0x5a, 0xf4, 0x0f, 0xe6, 0x5f, 0x10, 0x7e, 0x74, - 0x2e, 0x41, 0xa9, 0xf3, 0x56, 0xd4, 0x1b, 0x52, 0x95, 0x39, 0xd1, 0x20, 0x5d, 0x0f, 0xdf, 0x23, - 0x79, 0x2e, 0x99, 0x52, 0x1e, 0x9a, 0xa1, 0xf0, 0x7e, 0xb2, 0x4d, 0xdd, 0x09, 0xbe, 0x2b, 0xe0, - 0x92, 0x49, 0x6f, 0x6f, 0x86, 0xc2, 0xfd, 0xa4, 0x4f, 0x5c, 0x82, 0x0f, 0x84, 0xc9, 0x3e, 0x30, - 0xeb, 0xed, 0xcf, 0x50, 0x38, 0x5e, 0x4c, 0xa2, 0x7e, 0x72, 0xb4, 0x9d, 0x1c, 0x9d, 0x71, 0xbb, - 0x3c, 0xfd, 0x79, 0x1b, 0x3c, 0xb6, 0xa4, 0xae, 0x9e, 0xcd, 0xdb, 0x8d, 0x19, 0x57, 0x46, 0xa5, - 0x3d, 0x6f, 0xfe, 0xf5, 0xf3, 0xf1, 0x64, 0xd0, 0x4e, 0xa5, 0x15, 0x1a, 0xa2, 0x97, 0x26, 0x7b, - 0xc1, 0x6c, 0x32, 0x34, 0x76, 0x03, 0x7c, 0x08, 0x42, 0xb3, 0x3c, 0x05, 0xa3, 0xbd, 0x3b, 0x33, - 0x14, 0x3a, 0xcb, 0x3d, 0x0f, 0x25, 0x4e, 0x07, 0x5e, 0x18, 0x3d, 0xff, 0x84, 0xc7, 0xaf, 0x2a, - 0xa2, 0x56, 0x09, 0xa3, 0x20, 0x73, 0x37, 0xc4, 0x0f, 0x2f, 0x49, 0xa9, 0x4b, 0x5e, 0xa4, 0xc0, - 0x53, 0xc9, 0x44, 0x65, 0xbb, 0x5d, 0x9c, 0xe4, 0xc1, 0x80, 0x5f, 0xf0, 0xa4, 0x45, 0xdd, 0x33, - 0x7c, 0xa8, 0x18, 0xcf, 0xd3, 0xf6, 0x38, 0xdd, 0x5a, 0xe3, 0xc5, 0xf4, 0x1f, 0xfd, 0xaf, 0xb7, - 0x97, 0x5b, 0x3a, 0xd7, 0xb7, 0xc1, 0xe8, 0xea, 0x7b, 0x80, 0x12, 0xa7, 0xa5, 0xb5, 0x85, 0xe5, - 0xdb, 0xeb, 0xb5, 0x8f, 0x6e, 0xd6, 0x3e, 0xfa, 0xb1, 0xf6, 0xd1, 0xd5, 0xc6, 0x1f, 0xdd, 0x6c, - 0xfc, 0xd1, 0xb7, 0x8d, 0x3f, 0x7a, 0xf7, 0xbc, 0x28, 0xf5, 0xca, 0x64, 0x11, 0x85, 0x7a, 0xf8, - 0x9b, 0xf8, 0xb7, 0x0b, 0x8e, 0x77, 0xce, 0x69, 0x9e, 0xc6, 0x1f, 0xff, 0xb4, 0x8f, 0xb6, 0x82, - 0xa9, 0xec, 0xa0, 0x13, 0x70, 0xfa, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x7c, 0x38, 0x7e, 0x6f, - 0x02, 0x00, 0x00, + 0xda, 0x6a, 0x2a, 0x2e, 0x48, 0x1c, 0x9a, 0x1e, 0x39, 0x14, 0x19, 0x04, 0x12, 0x17, 0x6b, 0xbd, + 0x5e, 0x1c, 0x0b, 0x7b, 0x67, 0xb5, 0x3f, 0x2e, 0xcb, 0x53, 0xf4, 0x61, 0x78, 0x88, 0xc2, 0xa9, + 0x47, 0x4e, 0x05, 0x25, 0x6f, 0xc0, 0x13, 0x20, 0xff, 0x24, 0x88, 0x9f, 0xdb, 0xcc, 0x37, 0xfb, + 0xcd, 0x7c, 0x33, 0xfb, 0xe1, 0x45, 0xc9, 0x35, 0x93, 0x74, 0x45, 0x4a, 0x9e, 0x2a, 0x46, 0x8d, + 0x2c, 0xb5, 0x8d, 0x29, 0x6d, 0x62, 0x0a, 0x5c, 0x99, 0x9a, 0xc9, 0xb8, 0x39, 0xd9, 0xc5, 0x91, + 0x90, 0xa0, 0xc1, 0x7d, 0xf2, 0x1f, 0x4e, 0x44, 0x69, 0x13, 0xed, 0xde, 0x35, 0x27, 0xd3, 0xa3, + 0x02, 0xa0, 0xa8, 0x58, 0xdc, 0x51, 0x32, 0xf3, 0x3e, 0x26, 0xdc, 0xf6, 0xfc, 0xe9, 0xa4, 0x80, + 0x02, 0xba, 0x30, 0x6e, 0xa3, 0x01, 0x3d, 0xa2, 0xa0, 0x6a, 0x50, 0x69, 0x5f, 0xe8, 0x93, 0xa1, + 0x14, 0xfc, 0xdd, 0x4b, 0x97, 0x35, 0x53, 0x9a, 0xd4, 0xa2, 0x7f, 0x30, 0xff, 0x82, 0xf0, 0xa3, + 0x73, 0x09, 0x4a, 0x9d, 0xb7, 0xa2, 0xde, 0x90, 0xaa, 0xcc, 0x89, 0x06, 0xe9, 0x7a, 0xf8, 0x1e, + 0xc9, 0x73, 0xc9, 0x94, 0xf2, 0xd0, 0x0c, 0x85, 0xf7, 0x93, 0x6d, 0xea, 0x4e, 0xf0, 0x5d, 0x01, + 0x97, 0x4c, 0x7a, 0x7b, 0x33, 0x14, 0xee, 0x27, 0x7d, 0xe2, 0x12, 0x7c, 0x20, 0x4c, 0xf6, 0x81, + 0x59, 0x6f, 0x7f, 0x86, 0xc2, 0xf1, 0x62, 0x12, 0xf5, 0x93, 0xa3, 0xed, 0xe4, 0xe8, 0x8c, 0xdb, + 0xe5, 0xe9, 0xcf, 0xdb, 0xe0, 0xb1, 0x25, 0x75, 0xf5, 0x6c, 0xde, 0x6e, 0xcc, 0xb8, 0x32, 0x2a, + 0xed, 0x79, 0xf3, 0xaf, 0x9f, 0x8f, 0x27, 0x83, 0x76, 0x2a, 0xad, 0xd0, 0x10, 0xbd, 0x34, 0xd9, + 0x0b, 0x66, 0x93, 0xa1, 0xb1, 0x1b, 0xe0, 0x43, 0x10, 0x9a, 0xe5, 0x29, 0x18, 0xed, 0xdd, 0x99, + 0xa1, 0xd0, 0x59, 0xee, 0x79, 0x28, 0x71, 0x3a, 0xf0, 0xc2, 0xe8, 0xf9, 0x27, 0x3c, 0x7e, 0x55, + 0x11, 0xb5, 0x4a, 0x18, 0x05, 0x99, 0xbb, 0x21, 0x7e, 0x78, 0x49, 0x4a, 0x5d, 0xf2, 0x22, 0x05, + 0x9e, 0x4a, 0x26, 0x2a, 0xdb, 0xed, 0xe2, 0x24, 0x0f, 0x06, 0xfc, 0x82, 0x27, 0x2d, 0xea, 0x9e, + 0xe1, 0x43, 0xc5, 0x78, 0x9e, 0xb6, 0xc7, 0xe9, 0xd6, 0x1a, 0x2f, 0xa6, 0xff, 0xe8, 0x7f, 0xbd, + 0xbd, 0xdc, 0xd2, 0xb9, 0xbe, 0x0d, 0x46, 0x57, 0xdf, 0x03, 0x94, 0x38, 0x2d, 0xad, 0x2d, 0x2c, + 0xdf, 0x5e, 0xaf, 0x7d, 0x74, 0xb3, 0xf6, 0xd1, 0x8f, 0xb5, 0x8f, 0xae, 0x36, 0xfe, 0xe8, 0x66, + 0xe3, 0x8f, 0xbe, 0x6d, 0xfc, 0xd1, 0xbb, 0xe7, 0x45, 0xa9, 0x57, 0x26, 0x8b, 0x28, 0xd4, 0xc3, + 0xdf, 0xc4, 0xbf, 0x5d, 0x70, 0xbc, 0x73, 0x4e, 0xf3, 0x34, 0xfe, 0xf8, 0xa7, 0x7d, 0xb4, 0x15, + 0x4c, 0x65, 0x07, 0x9d, 0x80, 0xd3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x83, 0x9f, 0x58, 0x42, + 0x6f, 0x02, 0x00, 0x00, } func (m *CrossChainValidator) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/consumer/types/genesis.go b/x/ccv/consumer/types/genesis.go index cb9cb61f40..b75de5d46d 100644 --- a/x/ccv/consumer/types/genesis.go +++ b/x/ccv/consumer/types/genesis.go @@ -1,13 +1,13 @@ package types import ( - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" abci "github.com/cometbft/cometbft/abci/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // NewRestartGenesisState returns a consumer GenesisState that has already been established. diff --git a/x/ccv/consumer/types/genesis.pb.go b/x/ccv/consumer/types/genesis.pb.go index dbb7c51981..8b86b0b34c 100644 --- a/x/ccv/consumer/types/genesis.pb.go +++ b/x/ccv/consumer/types/genesis.pb.go @@ -9,8 +9,8 @@ import ( _ "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" - types "github.com/cosmos/interchain-security/v4/x/ccv/types" + _07_tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + types "github.com/cosmos/interchain-security/v5/x/ccv/types" _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" @@ -466,61 +466,61 @@ var fileDescriptor_2db73a6057a27482 = []byte{ // 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, 0xca, 0x0f, 0x21, 0x21, 0x10, 0x24, 0x95, 0x68, 0x50, 0x11, 0x55, 0xda, + 0x14, 0xf1, 0xc3, 0x43, 0x8a, 0x16, 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, 0xef, 0xad, 0x08, 0x41, 0x84, 0x64, 0xa8, 0x08, 0x41, 0x59, 0xf7, 0xf0, 0x93, + 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, - 0xf7, 0xef, 0x21, 0x9e, 0xb1, 0x94, 0x5a, 0xb7, 0xa3, 0x50, 0x88, 0x30, 0xa2, 0x9e, 0x39, 0x8d, - 0xa7, 0xcf, 0x3d, 0xc5, 0x62, 0x2a, 0x15, 0x8e, 0x13, 0xeb, 0xd0, 0x58, 0x60, 0xc7, 0x63, 0xc2, + 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, 0x00, - 0xdd, 0x25, 0x52, 0xd6, 0x45, 0x7d, 0x5b, 0xf8, 0xb9, 0x89, 0xe8, 0x6d, 0xbf, 0xfa, 0xfb, 0x68, - 0x63, 0x68, 0xe3, 0xe1, 0x47, 0x00, 0x26, 0xa9, 0xc8, 0x58, 0x40, 0x53, 0x3f, 0x17, 0xc2, 0x67, + 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, 0xed, 0xff, 0x53, 0x4b, 0x5d, 0x9d, 0xfb, 0xc0, 0xd4, 0xf4, - 0x21, 0x62, 0x63, 0x82, 0x16, 0x3b, 0x84, 0x16, 0x7a, 0xa2, 0xeb, 0x32, 0x5f, 0x8d, 0x20, 0xbd, + 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, 0x46, 0x9e, 0x22, 0x6c, 0x4e, 0x55, 0x2f, 0xa9, 0x96, - 0x6c, 0x30, 0x04, 0xfb, 0x31, 0x56, 0xd3, 0x94, 0xf1, 0xd0, 0x4f, 0x30, 0x79, 0x41, 0x95, 0x74, - 0xdf, 0x6a, 0x6d, 0x75, 0x76, 0x8e, 0xbf, 0x40, 0x6b, 0x8c, 0x31, 0xfa, 0xd1, 0x06, 0x8f, 0x2e, + 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, 0xd3, 0x24, 0xd0, 0xf9, 0x57, 0x34, 0xa2, 0xeb, + 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, 0x15, 0x53, 0x25, 0x15, 0xe6, 0x81, 0x56, 0x2f, 0x10, 0x33, 0xae, + 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, - 0xc2, 0xcf, 0x45, 0x73, 0x77, 0x4d, 0x0e, 0xdf, 0xae, 0x95, 0xc3, 0x19, 0x96, 0xea, 0x72, 0x01, + 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, 0x73, 0x61, 0x69, 0xcb, 0xf8, 0xf6, 0x33, + 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, 0xa7, 0xe0, 0x60, 0xc5, 0x10, + 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, 0x3b, 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, 0xf9, 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, 0xd5, 0x75, 0xd3, 0x79, 0x7d, 0xdd, 0x74, 0xfe, - 0xbd, 0x6e, 0x3a, 0x2f, 0x6f, 0x9a, 0x1b, 0xaf, 0x6f, 0x9a, 0x1b, 0x7f, 0xdd, 0x34, 0x37, 0x9e, - 0x7d, 0x1d, 0x32, 0x35, 0x99, 0x8e, 0x11, 0x11, 0xb1, 0x47, 0x84, 0x8c, 0x85, 0xf4, 0xe6, 0x34, - 0x1f, 0x97, 0x6f, 0x65, 0xf6, 0x99, 0xf7, 0xcb, 0xf2, 0x3f, 0x00, 0xf3, 0xf2, 0x8d, 0x2b, 0xa6, - 0xd0, 0x4f, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xa1, 0x41, 0x38, 0x32, 0x08, 0x00, 0x00, + 0xb5, 0xe1, 0x7b, 0xa5, 0x4b, 0xb9, 0xde, 0xdf, 0xe5, 0x0e, 0xed, 0xa7, 0xa0, 0x71, 0x76, 0xbf, + 0x6a, 0x0b, 0x79, 0x6f, 0x15, 0x79, 0xb7, 0x15, 0x78, 0x7c, 0x6b, 0xb5, 0xe1, 0x13, 0xf0, 0x20, + 0x93, 0x64, 0x10, 0xd8, 0x1a, 0xf3, 0x03, 0x1c, 0x80, 0xbd, 0x7c, 0xd9, 0xd5, 0x95, 0xaf, 0x53, + 0x36, 0xf5, 0xed, 0x1c, 0x1f, 0xa2, 0xfc, 0x05, 0x41, 0xc5, 0x0b, 0x82, 0x2e, 0x8b, 0x17, 0xa4, + 0x57, 0xd5, 0xba, 0xbe, 0xfa, 0xe7, 0xc8, 0x19, 0xee, 0x16, 0xa1, 0xda, 0xd8, 0x1e, 0x83, 0xfa, + 0xea, 0x49, 0x84, 0xa7, 0x60, 0x3b, 0x62, 0x52, 0x67, 0xb9, 0x95, 0xdf, 0x80, 0xeb, 0xbc, 0x1e, + 0x05, 0x82, 0xed, 0xa3, 0x41, 0xe8, 0xfd, 0xfc, 0xfa, 0xba, 0xe9, 0xbc, 0xb9, 0x6e, 0x3a, 0xff, + 0x5e, 0x37, 0x9d, 0x57, 0x37, 0xcd, 0x8d, 0x37, 0x37, 0xcd, 0x8d, 0xbf, 0x6e, 0x9a, 0x1b, 0xcf, + 0xbf, 0x0e, 0x99, 0x9a, 0x4c, 0xc7, 0x88, 0x88, 0xd8, 0x23, 0x42, 0xc6, 0x42, 0x7a, 0x73, 0x9a, + 0x4f, 0xcb, 0xb7, 0x32, 0x7b, 0xea, 0xfd, 0xb2, 0xfc, 0x0f, 0xc0, 0xbc, 0x7c, 0xe3, 0x8a, 0x29, + 0xf4, 0xf3, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x42, 0x21, 0x04, 0x32, 0x08, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index c8c61776ec..1efa8339c7 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,9 +15,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -230,6 +230,7 @@ func TestValidateInitialGenesisState(t *testing.T) { ccv.DefaultConsumerRedistributeFrac, ccv.DefaultHistoricalEntries, ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, ccv.DefaultRetryDelayPeriod, @@ -249,6 +250,7 @@ func TestValidateInitialGenesisState(t *testing.T) { ccv.DefaultConsumerRedistributeFrac, ccv.DefaultHistoricalEntries, ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, ccv.DefaultRetryDelayPeriod, @@ -454,6 +456,7 @@ func TestValidateRestartConsumerGenesisState(t *testing.T) { ccv.DefaultConsumerRedistributeFrac, ccv.DefaultHistoricalEntries, ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, ccv.DefaultRetryDelayPeriod, diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index 5fcd26a1ca..184524ccb9 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -65,9 +65,8 @@ const ( // [DEPRECATED] LastStandaloneHeightByteKey - // NOTE: This key is deprecated, but left in place to avoid consumer state migrations - // [DEPRECATED] - DeprecatedSmallestNonOptOutPowerByteKey + // SmallestNonOptOutPowerByteKey is the byte that will store the smallest val power that cannot opt out + SmallestNonOptOutPowerByteKey // HistoricalInfoKey is the byte prefix that will store the historical info for a given height HistoricalInfoBytePrefix @@ -107,6 +106,9 @@ const ( // SlashRecordByteKey is the single byte key storing the consumer's slash record. SlashRecordByteKey + // ParametersKey is the single byte key for storing consumer's parameters. + ParametersByteKey + // NOTE: DO NOT ADD NEW BYTE PREFIXES HERE WITHOUT ADDING THEM TO getAllKeyPrefixes() IN keys_test.go ) @@ -114,6 +116,11 @@ const ( // Fully defined key func section // +// ParametersKey returns the key for the consumer parameters in the store +func ParametersKey() []byte { + return []byte{ParametersByteKey} +} + // PortKey returns the key to the port ID in the store func PortKey() []byte { return []byte{PortByteKey} @@ -202,6 +209,10 @@ func InitGenesisHeightKey() []byte { return []byte{InitGenesisHeightByteKey} } +func SmallestNonOptOutPowerKey() []byte { + return []byte{SmallestNonOptOutPowerByteKey} +} + // StandaloneTransferChannelIDKey returns the key to the transfer channelID that existed from a standalone chain // changing over to a consumer func StandaloneTransferChannelIDKey() []byte { diff --git a/x/ccv/consumer/types/keys_test.go b/x/ccv/consumer/types/keys_test.go index 66880b2ae9..7ca5ce2a10 100644 --- a/x/ccv/consumer/types/keys_test.go +++ b/x/ccv/consumer/types/keys_test.go @@ -31,7 +31,7 @@ func getAllKeyPrefixes() []byte { PreCCVByteKey, InitialValSetByteKey, LastStandaloneHeightByteKey, - DeprecatedSmallestNonOptOutPowerByteKey, + SmallestNonOptOutPowerByteKey, HistoricalInfoBytePrefix, PacketMaturityTimeBytePrefix, HeightValsetUpdateIDBytePrefix, @@ -43,6 +43,7 @@ func getAllKeyPrefixes() []byte { PrevStandaloneChainByteKey, PendingPacketsIndexByteKey, SlashRecordByteKey, + ParametersByteKey, } } diff --git a/x/ccv/consumer/types/params_test.go b/x/ccv/consumer/types/params_test.go index 8e81e2301c..ee4d45a80d 100644 --- a/x/ccv/consumer/types/params_test.go +++ b/x/ccv/consumer/types/params_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Tests the validation of consumer params that happens at genesis @@ -19,59 +19,59 @@ func TestValidateParams(t *testing.T) { {"default params", ccvtypes.DefaultParams(), true}, { "custom valid params", - ccvtypes.NewParams(true, 5, "", "", 1004, 1005, "0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, -5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "badchannel/", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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 ", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "notFrac", 1000, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", -100, 24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, -24*21*time.Hour, []string{"untrn"}, []string{"uatom"}, 2*time.Hour), 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 reward denom", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, []string{"u"}, []string{}, 2*time.Hour), 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", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, []string{}, []string{"a"}, 2*time.Hour), 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, []string{}, []string{}, -2*time.Hour), false, + 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, []string{}, []string{}, 0), false, + 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 fe62a4217f..3276f98197 100644 --- a/x/ccv/consumer/types/query.pb.go +++ b/x/ccv/consumer/types/query.pb.go @@ -9,7 +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/v4/x/ccv/types" + types "github.com/cosmos/interchain-security/v5/x/ccv/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -561,7 +561,7 @@ var fileDescriptor_f627751d3cc10225 = []byte{ // 826 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, 0x2c, 0x52, 0x97, 0xc3, 0xb2, 0xa8, 0x0d, 0x55, 0x23, 0x01, 0x6a, 0xdd, + 0xc2, 0x4a, 0xb1, 0x93, 0xac, 0x50, 0x97, 0xc3, 0xb2, 0xa8, 0x0d, 0x55, 0x23, 0x01, 0x6a, 0xdd, 0x4a, 0x08, 0x2e, 0x66, 0x3a, 0x99, 0x26, 0x16, 0x89, 0xc7, 0x9d, 0x19, 0x9b, 0xf6, 0x86, 0xe0, 0x8e, 0x90, 0xf8, 0x26, 0x7c, 0x01, 0xae, 0x95, 0x38, 0x50, 0x89, 0x03, 0x70, 0x41, 0xa8, 0xe5, 0x43, 0x70, 0x44, 0x33, 0x1e, 0xa7, 0x4e, 0x9b, 0x26, 0x6e, 0xe1, 0xe6, 0x79, 0x7f, 0x7e, 0xef, @@ -610,7 +610,7 @@ var fileDescriptor_f627751d3cc10225 = []byte{ 0x7a, 0xe9, 0xec, 0xa2, 0x5e, 0xfa, 0xfd, 0xa2, 0x5e, 0xfa, 0xfc, 0xf9, 0x20, 0x10, 0xc3, 0xf8, 0xc0, 0xc1, 0x74, 0xec, 0x62, 0xca, 0xc7, 0x94, 0xe7, 0xc0, 0x9b, 0x13, 0xf0, 0xe4, 0x5d, 0xf7, 0xf8, 0x4a, 0x85, 0x93, 0x88, 0xf0, 0x83, 0x8a, 0xfa, 0x33, 0xf1, 0xf4, 0xdf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x36, 0xbd, 0x78, 0x1c, 0x65, 0x09, 0x00, 0x00, + 0xff, 0xff, 0x3e, 0x5e, 0x18, 0x20, 0x65, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ccv/consumer/types/tx.pb.go b/x/ccv/consumer/types/tx.pb.go new file mode 100644 index 0000000000..4fde6e583d --- /dev/null +++ b/x/ccv/consumer/types/tx.pb.go @@ -0,0 +1,598 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: interchain_security/ccv/consumer/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/interchain-security/v5/x/ccv/types" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUpdateParams is the Msg/UpdateParams request type +type MsgUpdateParams struct { + // signer is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/provider parameters to update. + Params types.ConsumerParams `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_9d7049279494b73f, []int{0} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() types.ConsumerParams { + if m != nil { + return m.Params + } + return types.ConsumerParams{} +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9d7049279494b73f, []int{1} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateParams)(nil), "interchain_security.ccv.consumer.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "interchain_security.ccv.consumer.v1.MsgUpdateParamsResponse") +} + +func init() { + proto.RegisterFile("interchain_security/ccv/consumer/v1/tx.proto", fileDescriptor_9d7049279494b73f) +} + +var fileDescriptor_9d7049279494b73f = []byte{ + // 402 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, 0x4f, 0xce, 0xcf, 0x2b, 0x2e, 0xcd, 0x4d, 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, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, + 0x42, 0xf4, 0x49, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, + 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x65, 0x45, 0xd2, 0xf3, 0xd3, + 0xf3, 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x2a, 0x2a, 0x99, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0x1c, 0x0f, + 0x91, 0x80, 0x70, 0xa0, 0x52, 0xe2, 0x10, 0x9e, 0x7e, 0x6e, 0x71, 0x3a, 0xc8, 0x79, 0xb9, 0xc5, + 0xe9, 0x50, 0x09, 0x03, 0x5c, 0xbe, 0x29, 0x33, 0xd4, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0x89, + 0x87, 0xbb, 0x14, 0xac, 0x43, 0x69, 0x31, 0x23, 0x17, 0xbf, 0x6f, 0x71, 0x7a, 0x68, 0x41, 0x4a, + 0x62, 0x49, 0x6a, 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x90, 0x19, 0x17, 0x67, 0x62, 0x69, 0x49, + 0x46, 0x3e, 0x48, 0xb7, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, + 0x50, 0x37, 0x38, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, + 0x21, 0x94, 0x0a, 0x79, 0x70, 0xb1, 0x15, 0x80, 0x4d, 0x90, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x36, + 0xd2, 0xd2, 0xc3, 0x15, 0x5c, 0x65, 0x86, 0x7a, 0xce, 0x50, 0x77, 0x40, 0xec, 0x74, 0x62, 0x39, + 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0xdf, 0x8a, 0xaf, 0xe9, 0xf9, 0x06, 0x2d, 0x84, 0xc9, 0x4a, + 0x92, 0x5c, 0xe2, 0x68, 0x8e, 0x0c, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, 0x9a, 0xc8, + 0xc8, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0xd4, 0xc4, 0xc8, 0xc5, 0x83, 0xe2, 0x0b, 0x13, 0x3d, 0x22, + 0x22, 0x4b, 0x0f, 0xcd, 0x58, 0x29, 0x1b, 0x72, 0x74, 0xc1, 0x1c, 0x23, 0xc5, 0xda, 0xf0, 0x7c, + 0x83, 0x16, 0xa3, 0x53, 0xf8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, + 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, + 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0x42, 0xa3, 0x54, 0x1f, 0x61, 0x9f, + 0x2e, 0x3c, 0xca, 0xca, 0x4c, 0xf5, 0x2b, 0x50, 0x53, 0x61, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0x38, 0xd2, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc4, 0xb3, 0xd4, 0x91, 0xb6, 0x02, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// 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 { + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.consumer.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.consumer.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "interchain_security.ccv.consumer.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "interchain_security/ccv/consumer/v1/tx.proto", +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ccv/democracy/distribution/module.go b/x/ccv/democracy/distribution/module.go index af35c86846..310e542b6a 100644 --- a/x/ccv/democracy/distribution/module.go +++ b/x/ccv/democracy/distribution/module.go @@ -1,8 +1,11 @@ package distribution import ( + "context" "time" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,15 +17,16 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - abci "github.com/cometbft/cometbft/abci/types" - - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" ) var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModule embeds the Cosmos SDK's x/distribution AppModuleBasic. @@ -60,22 +64,27 @@ func NewAppModule( } } -// BeginBlocker mirror functionality of cosmos-sdk/distribution BeginBlocker -// however it allocates no proposer reward -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { +// BeginBlock implements HasBeginBlocker interface +// The cosmos-sdk/distribution BeginBlocker functionality is replicated here, +// however no proposer awards are allocated. +func (am AppModule) BeginBlock(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) defer telemetry.ModuleMeasureSince(distrtypes.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) // TODO this is Tendermint-dependent // ref https://github.com/cosmos/cosmos-sdk/issues/3095 if ctx.BlockHeight() > 1 { - am.AllocateTokens(ctx) + return am.AllocateTokens(ctx) } + + return nil } // AllocateTokens handles distribution of the collected fees +// NOTE: refactored to use collections (FeePool.Get instead of GetFeePool) for v47 -> v50 migration func (am AppModule) AllocateTokens( ctx sdk.Context, -) { +) error { // fetch and clear the collected fees for distribution, since this is // called in BeginBlock, collected fees will be from the previous block // (and distributed to the current representatives) @@ -86,31 +95,41 @@ func (am AppModule) AllocateTokens( // transfer collected fees to the distribution module account err := am.bankKeeper.SendCoinsFromModuleToModule(ctx, consumertypes.ConsumerRedistributeName, distrtypes.ModuleName, feesCollectedInt) if err != nil { - // same behavior as in the original x/distribution module of cosmos-sdk - panic(err) + return err } // temporary workaround to keep CanWithdrawInvariant happy // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 - feePool := am.keeper.GetFeePool(ctx) + feePool, err := am.keeper.FeePool.Get(ctx) + if err != nil { + return err + } vs := am.stakingKeeper.GetValidatorSet() - totalBondedTokens := vs.TotalBondedTokens(ctx) + totalBondedTokens, err := vs.TotalBondedTokens(ctx) + if err != nil { + return err + } if totalBondedTokens.IsZero() { feePool.CommunityPool = feePool.CommunityPool.Add(feesCollected...) - am.keeper.SetFeePool(ctx, feePool) - return + if err := am.keeper.FeePool.Set(ctx, feePool); err != nil { + return err + } + return nil } // calculate the fraction allocated to representatives by subtracting the community tax. // e.g. if community tax is 0.02, representatives fraction will be 0.98 (2% goes to the community pool and the rest to the representatives) remaining := feesCollected - communityTax := am.keeper.GetCommunityTax(ctx) - representativesFraction := sdk.OneDec().Sub(communityTax) + communityTax, err := am.keeper.GetCommunityTax(ctx) + if err != nil { + return err + } + representativesFraction := math.LegacyOneDec().Sub(communityTax) // allocate tokens proportionally to representatives voting power vs.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool { // we get this validator's percentage of the total power by dividing their tokens by the total bonded tokens - powerFraction := sdk.NewDecFromInt(validator.GetTokens()).QuoTruncate(sdk.NewDecFromInt(totalBondedTokens)) + powerFraction := math.LegacyNewDecFromInt(validator.GetTokens()).QuoTruncate(math.LegacyNewDecFromInt(totalBondedTokens)) // we truncate here again, which means that the reward will be slightly lower than it should be reward := feesCollected.MulDecTruncate(representativesFraction).MulDecTruncate(powerFraction) am.keeper.AllocateTokensToValidator(ctx, validator, reward) @@ -122,5 +141,9 @@ func (am AppModule) AllocateTokens( // allocate community funding // due to the 3 truncations above, remaining sent to the community pool will be slightly more than it should be. This is OK feePool.CommunityPool = feePool.CommunityPool.Add(remaining...) - am.keeper.SetFeePool(ctx, feePool) + if err := am.keeper.FeePool.Set(ctx, feePool); err != nil { + return err + } + + return nil } diff --git a/x/ccv/democracy/governance/module.go b/x/ccv/democracy/governance/module.go index 3922607766..c4bf930066 100644 --- a/x/ccv/democracy/governance/module.go +++ b/x/ccv/democracy/governance/module.go @@ -1,8 +1,12 @@ package governance import ( + "context" "fmt" + "time" + "cosmossdk.io/collections" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -11,8 +15,6 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - abci "github.com/cometbft/cometbft/abci/types" ) const ( @@ -22,6 +24,8 @@ const ( var ( _ module.AppModule = AppModule{} _ module.AppModuleSimulation = AppModule{} + + _ appmodule.HasEndBlocker = AppModule{} ) // AppModule embeds the Cosmos SDK's x/governance AppModule @@ -56,15 +60,25 @@ func NewAppModule(cdc codec.Codec, } } -func (am AppModule) EndBlock(ctx sdk.Context, request abci.RequestEndBlock) []abci.ValidatorUpdate { - am.keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal govv1.Proposal) bool { - // if there are forbidden proposals in active proposals queue, refund deposit, delete votes for that proposal - // and delete proposal from all storages +func (am AppModule) EndBlock(c context.Context) error { + ctx := sdk.UnwrapSDKContext(c) + rng := collections.NewPrefixUntilPairRange[time.Time, uint64](ctx.BlockTime()) + keeper := am.keeper + // if there are forbidden proposals in active proposals queue, refund deposit, delete votes for that proposal + // and delete proposal from all storages + err := am.keeper.ActiveProposalsQueue.Walk(ctx, rng, func(key collections.Pair[time.Time, uint64], _ uint64) (bool, error) { + proposal, err := keeper.Proposals.Get(ctx, key.K2()) + if err != nil { + return false, err + } deleteForbiddenProposal(ctx, am, proposal) - return false + return false, nil }) - return am.AppModule.EndBlock(ctx, request) + if err != nil { + return err + } + return am.AppModule.EndBlock(ctx) } // isProposalWhitelisted checks whether a proposal is whitelisted diff --git a/x/ccv/democracy/staking/module.go b/x/ccv/democracy/staking/module.go index 3e176aaa2c..324320923b 100644 --- a/x/ccv/democracy/staking/module.go +++ b/x/ccv/democracy/staking/module.go @@ -1,6 +1,7 @@ package staking import ( + "context" "encoding/json" "github.com/cosmos/cosmos-sdk/codec" @@ -21,6 +22,9 @@ var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} _ module.AppModuleSimulation = AppModule{} + + _ module.HasABCIGenesis = AppModule{} + _ module.HasABCIEndBlock = AppModule{} ) // AppModule embeds the Cosmos SDK's x/staking AppModuleBasic. @@ -41,11 +45,11 @@ type AppModule struct { // NewAppModule creates a new AppModule object using the native x/staking module // AppModule constructor. -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, subspace exported.Subspace) AppModule { - stakingAppMod := staking.NewAppModule(cdc, &keeper, ak, bk, subspace) +func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper, subspace exported.Subspace) AppModule { + stakingAppMod := staking.NewAppModule(cdc, keeper, ak, bk, subspace) return AppModule{ AppModule: stakingAppMod, - keeper: keeper, + keeper: *keeper, accKeeper: ak, bankKeeper: bk, } @@ -78,7 +82,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. // The ccv consumer Endblocker is ordered to run before the staking Endblocker, // so if PreCCV is true during one block, the ccv consumer Enblocker will return the proper validator updates, // the PreCCV flag will be toggled to false, and no validator updates should be returned by this method. -func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - _ = am.keeper.BlockValidatorUpdates(ctx) - return []abci.ValidatorUpdate{} +func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) { + _, _ = am.keeper.BlockValidatorUpdates(ctx) + return []abci.ValidatorUpdate{}, nil } diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 21d840f01f..697fccbb76 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // NewQueryCmd returns a root CLI command handler for all x/ccv/provider query commands. diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 876aaa9b8b..eadb3a7e57 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -6,7 +6,9 @@ import ( "os" "strings" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "cosmossdk.io/math" + + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -18,7 +20,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // GetTxCmd returns the transaction commands for this module @@ -52,6 +54,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { return err } + signer := clientCtx.GetFromAddress().String() txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) if err != nil { return err @@ -60,7 +63,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1]) + msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], signer) if err != nil { return err } @@ -233,7 +236,9 @@ func NewOptInCmd() *cobra.Command { } else { consumerPubKey = "" } - msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey) + + signer := clientCtx.GetFromAddress().String() + msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey, signer) if err != nil { return err } @@ -271,7 +276,8 @@ func NewOptOutCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr)) + signer := clientCtx.GetFromAddress().String() + msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr), signer) if err != nil { return err } @@ -315,7 +321,7 @@ func NewSetConsumerCommissionRateCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - commission, err := sdk.NewDecFromStr(args[1]) + commission, err := math.LegacyNewDecFromStr(args[1]) if err != nil { return err } diff --git a/x/ccv/provider/client/proposal_handler.go b/x/ccv/provider/client/legacy_proposal_handler.go similarity index 51% rename from x/ccv/provider/client/proposal_handler.go rename to x/ccv/provider/client/legacy_proposal_handler.go index 2de87504ad..f837e7bab2 100644 --- a/x/ccv/provider/client/proposal_handler.go +++ b/x/ccv/provider/client/legacy_proposal_handler.go @@ -1,14 +1,6 @@ package client import ( - "context" - "encoding/json" - "fmt" - "os" - "path/filepath" - "time" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -18,16 +10,15 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) var ( ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd) ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd) - ConsumerModificationProposalHandler = govclient.NewProposalHandler(SubmitConsumerModificationProposalTxCmd) ChangeRewardDenomsProposalHandler = govclient.NewProposalHandler(SubmitChangeRewardDenomsProposalTxCmd) + ConsumerModificationProposalHandler = govclient.NewProposalHandler(SubmitConsumerModificationProposalTxCmd) ) // SubmitConsumerAdditionPropTxCmd returns a CLI command handler for submitting @@ -107,7 +98,7 @@ Where proposal.json contains: return err } - msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary) + msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false) if err != nil { return err } @@ -163,71 +154,7 @@ Where proposal.json contains: 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) - }, - } -} - -// SubmitConsumerModificationProposalTxCmd returns a CLI command handler for submitting -// a consumer modification proposal via a transaction. -func SubmitConsumerModificationProposalTxCmd() *cobra.Command { - return &cobra.Command{ - Use: "consumer-modification [proposal-file]", - Args: cobra.ExactArgs(1), - Short: "Submit a consumer modification proposal", - Long: ` -Submit a consumer modification proposal along with an initial deposit. -The proposal details must be supplied via a JSON file. - -Example: -$ tx gov submit-legacy-proposal consumer-modification --from= - -Where proposal.json contains: - -{ - "title": "Modify FooChain", - "summary": "Make it an Opt In chain", - "chain_id": "foochain", - "top_n": 0, - "validators_power_cap": 32, - "validator_set_cap": 50, - "allowlist": [], - "denylist": ["validatorAConsensusAddress", "validatorBConsensusAddress"] -} - `, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - proposal, err := ParseConsumerModificationProposalJSON(args[0]) - if err != nil { - return err - } - - content := types.NewConsumerModificationProposal( - proposal.Title, proposal.Summary, proposal.ChainId, proposal.TopN, - proposal.ValidatorsPowerCap, proposal.ValidatorSetCap, proposal.Allowlist, proposal.Denylist) - - from := clientCtx.GetFromAddress() - - deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) - if err != nil { - return err - } - - msgContent, err := govv1.NewLegacyContent(content, authtypes.NewModuleAddress(govtypes.ModuleName).String()) - if err != nil { - return err - } - - msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary) + msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false) if err != nil { return err } @@ -284,7 +211,7 @@ func SubmitChangeRewardDenomsProposalTxCmd() *cobra.Command { return err } - msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary) + msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false) if err != nil { return err } @@ -294,256 +221,66 @@ func SubmitChangeRewardDenomsProposalTxCmd() *cobra.Command { } } -type ConsumerAdditionProposalJSON struct { - Title string `json:"title"` - Summary string `json:"summary"` - ChainId string `json:"chain_id"` - InitialHeight clienttypes.Height `json:"initial_height"` - GenesisHash []byte `json:"genesis_hash"` - BinaryHash []byte `json:"binary_hash"` - SpawnTime time.Time `json:"spawn_time"` - - ConsumerRedistributionFraction string `json:"consumer_redistribution_fraction"` - BlocksPerDistributionTransmission int64 `json:"blocks_per_distribution_transmission"` - DistributionTransmissionChannel string `json:"distribution_transmission_channel"` - HistoricalEntries int64 `json:"historical_entries"` - CcvTimeoutPeriod time.Duration `json:"ccv_timeout_period"` - TransferTimeoutPeriod time.Duration `json:"transfer_timeout_period"` - UnbondingPeriod time.Duration `json:"unbonding_period"` - - Deposit string `json:"deposit"` - - TopN uint32 `json:"top_N"` - ValidatorsPowerCap uint32 `json:"validators_power_cap"` - ValidatorSetCap uint32 `json:"validator_set_cap"` - Allowlist []string `json:"allowlist"` - Denylist []string `json:"denylist"` -} - -type ConsumerAdditionProposalReq struct { - Proposer sdk.AccAddress `json:"proposer"` - - Title string `json:"title"` - Description string `json:"description"` - ChainId string `json:"chainId"` - InitialHeight clienttypes.Height `json:"initialHeight"` - GenesisHash []byte `json:"genesisHash"` - BinaryHash []byte `json:"binaryHash"` - SpawnTime time.Time `json:"spawnTime"` - - ConsumerRedistributionFraction string `json:"consumer_redistribution_fraction"` - BlocksPerDistributionTransmission int64 `json:"blocks_per_distribution_transmission"` - DistributionTransmissionChannel string `json:"distribution_transmission_channel"` - HistoricalEntries int64 `json:"historical_entries"` - CcvTimeoutPeriod time.Duration `json:"ccv_timeout_period"` - TransferTimeoutPeriod time.Duration `json:"transfer_timeout_period"` - UnbondingPeriod time.Duration `json:"unbonding_period"` - - Deposit sdk.Coins `json:"deposit"` -} - -func ParseConsumerAdditionProposalJSON(proposalFile string) (ConsumerAdditionProposalJSON, error) { - proposal := ConsumerAdditionProposalJSON{} - - 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 ConsumerRemovalProposalJSON struct { - Title string `json:"title"` - Summary string `json:"summary"` - ChainId string `json:"chain_id"` - StopTime time.Time `json:"stop_time"` - Deposit string `json:"deposit"` -} - -type ConsumerRemovalProposalReq struct { - Proposer sdk.AccAddress `json:"proposer"` - - Title string `json:"title"` - Description string `json:"description"` - ChainId string `json:"chainId"` - - StopTime time.Time `json:"stopTime"` - 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 ConsumerModificationProposalJSON struct { - Title string `json:"title"` - Summary string `json:"summary"` - ChainId string `json:"chain_id"` - - TopN uint32 `json:"top_N"` - ValidatorsPowerCap uint32 `json:"validators_power_cap"` - ValidatorSetCap uint32 `json:"validator_set_cap"` - Allowlist []string `json:"allowlist"` - Denylist []string `json:"denylist"` - - Deposit string `json:"deposit"` -} - -func ParseConsumerModificationProposalJSON(proposalFile string) (ConsumerModificationProposalJSON, error) { - proposal := ConsumerModificationProposalJSON{} - - 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 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 -} - -func CheckPropUnbondingPeriod(clientCtx client.Context, propUnbondingPeriod time.Duration) { - queryClient := stakingtypes.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &stakingtypes.QueryParamsRequest{}) - if err != nil { - fmt.Println(err.Error()) - return - } - - providerUnbondingTime := res.Params.UnbondingTime - - if providerUnbondingTime < propUnbondingPeriod { - fmt.Fprintf( - os.Stderr, - `consumer unbonding period is advised to be smaller than provider unbonding period, but is longer. -This is not a security risk, but will effectively lengthen the unbonding period on the provider. -consumer unbonding: %s -provider unbonding: %s`, - propUnbondingPeriod, - providerUnbondingTime) - } -} +// SubmitConsumerModificationProposalTxCmd returns a CLI command handler for submitting +// a consumer modification proposal via a transaction. +func SubmitConsumerModificationProposalTxCmd() *cobra.Command { + return &cobra.Command{ + Use: "consumer-modification [proposal-file]", + Args: cobra.ExactArgs(1), + Short: "Submit a consumer modification proposal", + Long: ` +Submit a consumer modification proposal along with an initial deposit. +The proposal details must be supplied via a JSON file. -/* Proposal REST handlers: NOT NEEDED POST 47, BUT PLEASE CHECK THAT ALL FUNCTIONALITY EXISTS IN THE 47 VERSION. +Example: +$ tx gov submit-legacy-proposal consumer-modification --from= -// ConsumerAdditionProposalRESTHandler returns a ProposalRESTHandler that exposes the consumer addition rest handler. -func ConsumerAdditionProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { - return govrest.ProposalRESTHandler{ - SubRoute: "consumer_addition", - Handler: postConsumerAdditionProposalHandlerFn(clientCtx), - } -} +Where proposal.json contains: -// ConsumerRemovalProposalRESTHandler returns a ProposalRESTHandler that exposes the consumer removal rest handler. -func ConsumerRemovalProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { - return govrest.ProposalRESTHandler{ - SubRoute: "consumer_removal", - Handler: postConsumerRemovalProposalHandlerFn(clientCtx), - } +{ + "title": "Modify FooChain", + "summary": "Make it an Opt In chain", + "chain_id": "foochain", + "top_n": 0, + "validators_power_cap": 32, + "validator_set_cap": 50, + "allowlist": [], + "denylist": ["validatorAConsensusAddress", "validatorBConsensusAddress"] } + `, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } -func postConsumerAdditionProposalHandlerFn(clientCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req ConsumerAdditionProposalReq - if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - content := types.NewConsumerAdditionProposal( - req.Title, req.Description, req.ChainId, req.InitialHeight, - req.GenesisHash, req.BinaryHash, req.SpawnTime, - req.ConsumerRedistributionFraction, req.BlocksPerDistributionTransmission, - req.DistributionTransmissionChannel, req.HistoricalEntries, - req.CcvTimeoutPeriod, req.TransferTimeoutPeriod, req.UnbondingPeriod) - - msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer) - if rest.CheckBadRequestError(w, err) { - return - } - - if rest.CheckBadRequestError(w, msg.ValidateBasic()) { - return - } - - tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) - } -} + proposal, err := ParseConsumerModificationProposalJSON(args[0]) + if err != nil { + return err + } -func postConsumerRemovalProposalHandlerFn(clientCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req ConsumerRemovalProposalReq - if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { - return - } + content := types.NewConsumerModificationProposal( + proposal.Title, proposal.Summary, proposal.ChainId, proposal.TopN, + proposal.ValidatorsPowerCap, proposal.ValidatorSetCap, proposal.Allowlist, proposal.Denylist) - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } + from := clientCtx.GetFromAddress() - content := types.NewConsumerRemovalProposal( - req.Title, req.Description, req.ChainId, req.StopTime, - ) + deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) + if err != nil { + return err + } - msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, req.Proposer) - if rest.CheckBadRequestError(w, err) { - return - } + msgContent, err := govv1.NewLegacyContent(content, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + if err != nil { + return err + } - if rest.CheckBadRequestError(w, msg.ValidateBasic()) { - return - } + msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary, false) + if err != nil { + return err + } - tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, } } -*/ diff --git a/x/ccv/provider/client/legacy_proposals.go b/x/ccv/provider/client/legacy_proposals.go new file mode 100644 index 0000000000..b19528b1b7 --- /dev/null +++ b/x/ccv/provider/client/legacy_proposals.go @@ -0,0 +1,192 @@ +package client + +import ( + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + + "github.com/cosmos/cosmos-sdk/client" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" +) + +type ConsumerAdditionProposalJSON struct { + Title string `json:"title"` + Summary string `json:"summary"` + ChainId string `json:"chain_id"` + InitialHeight clienttypes.Height `json:"initial_height"` + GenesisHash []byte `json:"genesis_hash"` + BinaryHash []byte `json:"binary_hash"` + SpawnTime time.Time `json:"spawn_time"` + + ConsumerRedistributionFraction string `json:"consumer_redistribution_fraction"` + BlocksPerDistributionTransmission int64 `json:"blocks_per_distribution_transmission"` + DistributionTransmissionChannel string `json:"distribution_transmission_channel"` + HistoricalEntries int64 `json:"historical_entries"` + CcvTimeoutPeriod time.Duration `json:"ccv_timeout_period"` + TransferTimeoutPeriod time.Duration `json:"transfer_timeout_period"` + UnbondingPeriod time.Duration `json:"unbonding_period"` + + Deposit string `json:"deposit"` + + TopN uint32 `json:"top_N"` + ValidatorsPowerCap uint32 `json:"validators_power_cap"` + ValidatorSetCap uint32 `json:"validator_set_cap"` + Allowlist []string `json:"allowlist"` + Denylist []string `json:"denylist"` +} + +type ConsumerAdditionProposalReq struct { + Proposer sdk.AccAddress `json:"proposer"` + + Title string `json:"title"` + Description string `json:"description"` + ChainId string `json:"chainId"` + InitialHeight clienttypes.Height `json:"initialHeight"` + GenesisHash []byte `json:"genesisHash"` + BinaryHash []byte `json:"binaryHash"` + SpawnTime time.Time `json:"spawnTime"` + + ConsumerRedistributionFraction string `json:"consumer_redistribution_fraction"` + BlocksPerDistributionTransmission int64 `json:"blocks_per_distribution_transmission"` + DistributionTransmissionChannel string `json:"distribution_transmission_channel"` + HistoricalEntries int64 `json:"historical_entries"` + CcvTimeoutPeriod time.Duration `json:"ccv_timeout_period"` + TransferTimeoutPeriod time.Duration `json:"transfer_timeout_period"` + UnbondingPeriod time.Duration `json:"unbonding_period"` + + Deposit sdk.Coins `json:"deposit"` +} + +func ParseConsumerAdditionProposalJSON(proposalFile string) (ConsumerAdditionProposalJSON, error) { + proposal := ConsumerAdditionProposalJSON{} + + 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 ConsumerRemovalProposalJSON struct { + Title string `json:"title"` + Summary string `json:"summary"` + ChainId string `json:"chain_id"` + StopTime time.Time `json:"stop_time"` + Deposit string `json:"deposit"` +} + +type ConsumerRemovalProposalReq struct { + Proposer sdk.AccAddress `json:"proposer"` + + Title string `json:"title"` + Description string `json:"description"` + ChainId string `json:"chainId"` + + StopTime time.Time `json:"stopTime"` + 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 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 +} + +func CheckPropUnbondingPeriod(clientCtx client.Context, propUnbondingPeriod time.Duration) { + queryClient := stakingtypes.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &stakingtypes.QueryParamsRequest{}) + if err != nil { + fmt.Println(err.Error()) + return + } + + providerUnbondingTime := res.Params.UnbondingTime + + if providerUnbondingTime < propUnbondingPeriod { + fmt.Fprintf( + os.Stderr, + `consumer unbonding period is advised to be smaller than provider unbonding period, but is longer. +This is not a security risk, but will effectively lengthen the unbonding period on the provider. +consumer unbonding: %s +provider unbonding: %s`, + propUnbondingPeriod, + providerUnbondingTime) + } +} + +type ConsumerModificationProposalJSON struct { + Title string `json:"title"` + Summary string `json:"summary"` + ChainId string `json:"chain_id"` + + TopN uint32 `json:"top_N"` + ValidatorsPowerCap uint32 `json:"validators_power_cap"` + ValidatorSetCap uint32 `json:"validator_set_cap"` + Allowlist []string `json:"allowlist"` + Denylist []string `json:"denylist"` + + Deposit string `json:"deposit"` +} + +func ParseConsumerModificationProposalJSON(proposalFile string) (ConsumerModificationProposalJSON, error) { + proposal := ConsumerModificationProposalJSON{} + + 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 8232ef3b6c..78e17257de 100644 --- a/x/ccv/provider/handler.go +++ b/x/ccv/provider/handler.go @@ -3,14 +3,15 @@ package provider import ( errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) -func NewHandler(k *keeper.Keeper) sdk.Handler { +func NewHandler(k *keeper.Keeper) baseapp.MsgServiceHandler { msgServer := keeper.NewMsgServerImpl(k) return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { @@ -18,22 +19,22 @@ func NewHandler(k *keeper.Keeper) sdk.Handler { switch msg := msg.(type) { case *types.MsgAssignConsumerKey: - res, err := msgServer.AssignConsumerKey(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.AssignConsumerKey(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgSubmitConsumerMisbehaviour: - res, err := msgServer.SubmitConsumerMisbehaviour(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.SubmitConsumerMisbehaviour(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgSubmitConsumerDoubleVoting: - res, err := msgServer.SubmitConsumerDoubleVoting(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.SubmitConsumerDoubleVoting(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgOptIn: - res, err := msgServer.OptIn(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.OptIn(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgOptOut: - res, err := msgServer.OptOut(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.OptOut(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) case *types.MsgSetConsumerCommissionRate: - res, err := msgServer.SetConsumerCommissionRate(sdk.WrapSDKContext(ctx), msg) + res, err := msgServer.SetConsumerCommissionRate(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/handler_test.go b/x/ccv/provider/handler_test.go index 6e13511e3b..ffb3614e17 100644 --- a/x/ccv/provider/handler_test.go +++ b/x/ccv/provider/handler_test.go @@ -14,11 +14,11 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - testcrypto "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - keeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testcrypto "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" + keeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestInvalidMsg(t *testing.T) { @@ -30,7 +30,7 @@ func TestInvalidMsg(t *testing.T) { require.True(t, strings.Contains(err.Error(), "unrecognized provider message type")) } -func TestAssignConsensusKeyForConsumerChain(t *testing.T) { +func TestAssignConsensusKeyMsgHandling(t *testing.T) { providerCryptoId := testcrypto.NewCryptoIdentityFromIntSeed(0) providerConsAddr := providerCryptoId.ProviderConsAddress() @@ -61,11 +61,10 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), - // Return a valid validator, found! - ).Return(providerCryptoId.SDKStakingValidator(), true).Times(1), + ).Return(providerCryptoId.SDKStakingValidator(), nil).Times(1), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerConsAddr.ToSdkConsAddr(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, expError: false, @@ -80,7 +79,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), // Return a valid validator, found! - ).Return(providerCryptoId.SDKStakingValidator(), true).Times(1), + ).Return(providerCryptoId.SDKStakingValidator(), nil).Times(1), ) }, expError: true, @@ -97,8 +96,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), - // return false: not found! - ).Return(stakingtypes.Validator{}, false).Times(1), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound).Times(1), ) }, expError: true, @@ -119,11 +117,11 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), // validator should not be missing - ).Return(providerCryptoId.SDKStakingValidator(), true).Times(1), + ).Return(providerCryptoId.SDKStakingValidator(), nil).Times(1), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerConsAddr.ToSdkConsAddr(), // return false - no other validator uses the consumer key to validate *on the provider* - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, nil), ) }, expError: true, @@ -143,11 +141,10 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), - // Return a valid validator, found! - ).Return(providerCryptoId.SDKStakingValidator(), true).Times(1), + ).Return(providerCryptoId.SDKStakingValidator(), nil).Times(1), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerConsAddr.ToSdkConsAddr(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, expError: false, @@ -163,6 +160,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { msg, err := providertypes.NewMsgAssignConsumerKey(tc.chainID, providerCryptoId.SDKValOpAddress(), consumerKey, + providerCryptoId.SDKStakingValidator().OperatorAddress, ) require.NoError(t, err) diff --git a/x/ccv/provider/ibc_middleware.go b/x/ccv/provider/ibc_middleware.go index ef0837ae5b..d9d816ab93 100644 --- a/x/ccv/provider/ibc_middleware.go +++ b/x/ccv/provider/ibc_middleware.go @@ -1,19 +1,19 @@ package provider import ( - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + "github.com/cosmos/ibc-go/v8/modules/core/exported" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) var _ porttypes.Middleware = &IBCMiddleware{} diff --git a/x/ccv/provider/ibc_middleware_test.go b/x/ccv/provider/ibc_middleware_test.go index 347cdc66cb..3148069bf2 100644 --- a/x/ccv/provider/ibc_middleware_test.go +++ b/x/ccv/provider/ibc_middleware_test.go @@ -3,11 +3,11 @@ package provider_test import ( "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/stretchr/testify/require" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" ) func TestGetProviderDenom(t *testing.T) { diff --git a/x/ccv/provider/ibc_module.go b/x/ccv/provider/ibc_module.go index f6ad43d60b..f91f69e618 100644 --- a/x/ccv/provider/ibc_module.go +++ b/x/ccv/provider/ibc_module.go @@ -4,20 +4,20 @@ import ( "fmt" "strconv" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // OnChanOpenInit implements the IBCModule interface diff --git a/x/ccv/provider/ibc_module_test.go b/x/ccv/provider/ibc_module_test.go index df12ed4cb8..fdae2a03ba 100644 --- a/x/ccv/provider/ibc_module_test.go +++ b/x/ccv/provider/ibc_module_test.go @@ -3,23 +3,23 @@ package provider_test import ( "testing" - "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - 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" + "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestOnChanOpenInit tests the provider's OnChanOpenInit method against spec. diff --git a/x/ccv/provider/keeper/consumer_equivocation.go b/x/ccv/provider/keeper/consumer_equivocation.go index e6fc74072f..b7aebf5c9c 100644 --- a/x/ccv/provider/keeper/consumer_equivocation.go +++ b/x/ccv/provider/keeper/consumer_equivocation.go @@ -3,25 +3,25 @@ package keeper import ( "bytes" "encoding/binary" + "errors" "fmt" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" + evidencetypes "cosmossdk.io/x/evidence/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // @@ -244,7 +244,7 @@ func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes. // create a map with the validators' address that signed header1 header1Signers := map[string]int{} for idx, sign := range lightBlock1.Commit.Signatures { - if sign.Absent() { + if sign.BlockIDFlag == tmtypes.BlockIDFlagAbsent { continue } header1Signers[sign.ValidatorAddress.String()] = idx @@ -252,7 +252,7 @@ func (k Keeper) GetByzantineValidators(ctx sdk.Context, misbehaviour ibctmtypes. // iterate over the header2 signers and check if they signed header1 for sigIdxHeader2, sign := range lightBlock2.Commit.Signatures { - if sign.Absent() { + if sign.BlockIDFlag == tmtypes.BlockIDFlagAbsent { continue } if sigIdxHeader1, ok := header1Signers[sign.ValidatorAddress.String()]; ok { @@ -311,7 +311,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe // the misbehaviour is for a light client attack and not a time violation, // see ibc-go/modules/light-clients/07-tendermint/types/misbehaviour_handle.go if !misbehaviour.Header1.GetHeight().EQ(misbehaviour.Header2.GetHeight()) { - return sdkerrors.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height") + return errorsmod.Wrap(ibcclienttypes.ErrInvalidMisbehaviour, "headers are not at same height") } // Check that the evidence is not too old @@ -393,9 +393,11 @@ func verifyLightBlockCommitSig(lightBlock tmtypes.LightBlock, sigIdx int) error // JailAndTombstoneValidator jails and tombstones the validator with the given provider consensus address func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress) error { - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) - if !found { + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) + if err != nil && errors.Is(err, stakingtypes.ErrNoValidatorFound) { return errorsmod.Wrapf(slashingtypes.ErrNoValidatorForAddress, "provider consensus address: %s", providerAddr.String()) + } else if err != nil { + return errorsmod.Wrapf(slashingtypes.ErrBadValidatorAddr, "unkown error looking for provider consensus address: %s", providerAddr.String()) } if validator.IsUnbonded() { @@ -403,23 +405,27 @@ func (k Keeper) JailAndTombstoneValidator(ctx sdk.Context, providerAddr types.Pr } if k.slashingKeeper.IsTombstoned(ctx, providerAddr.ToSdkConsAddr()) { - return fmt.Errorf("validator is tombstoned. provider consensus address: %s", providerAddr.String()) + return errorsmod.Wrapf(slashingtypes.ErrValidatorTombstoned, providerAddr.String()) } // jail validator if not already if !validator.IsJailed() { - k.stakingKeeper.Jail(ctx, providerAddr.ToSdkConsAddr()) + err := k.stakingKeeper.Jail(ctx, providerAddr.ToSdkConsAddr()) + if err != nil { + return err + } } - k.slashingKeeper.JailUntil(ctx, providerAddr.ToSdkConsAddr(), evidencetypes.DoubleSignJailEndTime) + err = k.slashingKeeper.JailUntil(ctx, providerAddr.ToSdkConsAddr(), evidencetypes.DoubleSignJailEndTime) + if err != nil { + return fmt.Errorf("fail to set jail duration for validator: %s: %s", providerAddr.String(), err) + } // Tombstone the validator so that we cannot slash the validator more than once // Note that we cannot simply use the fact that a validator is jailed to avoid slashing more than once // because then a validator could i) perform an equivocation, ii) get jailed (e.g., through downtime) // and in such a case the validator would not get slashed when we call `SlashValidator`. - k.slashingKeeper.Tombstone(ctx, providerAddr.ToSdkConsAddr()) - - return nil + return k.slashingKeeper.Tombstone(ctx, providerAddr.ToSdkConsAddr()) } // ComputePowerToSlash computes the power to be slashed based on the tokens in non-matured `undelegations` and @@ -429,19 +435,21 @@ func (k Keeper) ComputePowerToSlash(ctx sdk.Context, validator stakingtypes.Vali redelegations []stakingtypes.Redelegation, power int64, powerReduction math.Int, ) int64 { // compute the total numbers of tokens currently being undelegated - undelegationsInTokens := sdk.NewInt(0) + undelegationsInTokens := math.NewInt(0) // Note that we use a **cached** context to avoid any actual slashing of undelegations or redelegations. cachedCtx, _ := ctx.CacheContext() for _, u := range undelegations { - amountSlashed := k.stakingKeeper.SlashUnbondingDelegation(cachedCtx, u, 0, sdk.NewDec(1)) + // v50: errors are ignored + amountSlashed, _ := k.stakingKeeper.SlashUnbondingDelegation(cachedCtx, u, 0, math.LegacyNewDec(1)) undelegationsInTokens = undelegationsInTokens.Add(amountSlashed) } // compute the total numbers of tokens currently being redelegated - redelegationsInTokens := sdk.NewInt(0) + redelegationsInTokens := math.NewInt(0) for _, r := range redelegations { - amountSlashed := k.stakingKeeper.SlashRedelegation(cachedCtx, validator, r, 0, sdk.NewDec(1)) + // v50 errors are ignored + amountSlashed, _ := k.stakingKeeper.SlashRedelegation(cachedCtx, validator, r, 0, math.LegacyNewDec(1)) redelegationsInTokens = redelegationsInTokens.Add(amountSlashed) } @@ -455,9 +463,11 @@ func (k Keeper) ComputePowerToSlash(ctx sdk.Context, validator stakingtypes.Vali // SlashValidator slashes validator with given provider Address func (k Keeper) SlashValidator(ctx sdk.Context, providerAddr types.ProviderConsAddress) error { - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) - if !found { + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) + if err != nil && errors.Is(err, stakingtypes.ErrNoValidatorFound) { return errorsmod.Wrapf(slashingtypes.ErrNoValidatorForAddress, "provider consensus address: %s", providerAddr.String()) + } else if err != nil { + return errorsmod.Wrapf(slashingtypes.ErrBadValidatorAddr, "unkown error looking for provider consensus address: %s", providerAddr.String()) } if validator.IsUnbonded() { @@ -468,21 +478,38 @@ func (k Keeper) SlashValidator(ctx sdk.Context, providerAddr types.ProviderConsA return fmt.Errorf("validator is tombstoned. provider consensus address: %s", providerAddr.String()) } - undelegations := k.stakingKeeper.GetUnbondingDelegationsFromValidator(ctx, validator.GetOperator()) - redelegations := k.stakingKeeper.GetRedelegationsFromSrcValidator(ctx, validator.GetOperator()) - lastPower := k.stakingKeeper.GetLastValidatorPower(ctx, validator.GetOperator()) + valAddr, err := k.ValidatorAddressCodec().StringToBytes(validator.GetOperator()) + if err != nil { + return err + } + + undelegations, err := k.stakingKeeper.GetUnbondingDelegationsFromValidator(ctx, valAddr) + if err != nil { + return err + } + redelegations, err := k.stakingKeeper.GetRedelegationsFromSrcValidator(ctx, valAddr) + if err != nil { + return err + } + lastPower, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + return err + } + powerReduction := k.stakingKeeper.PowerReduction(ctx) totalPower := k.ComputePowerToSlash(ctx, validator, undelegations, redelegations, lastPower, powerReduction) - slashFraction := k.slashingKeeper.SlashFractionDoubleSign(ctx) + slashFraction, err := k.slashingKeeper.SlashFractionDoubleSign(ctx) + if err != nil { + return err + } consAdrr, err := validator.GetConsAddr() if err != nil { - panic(err) + return err } - k.stakingKeeper.SlashWithInfractionReason(ctx, consAdrr, 0, totalPower, slashFraction, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN) - - return nil + _, err = k.stakingKeeper.SlashWithInfractionReason(ctx, consAdrr, 0, totalPower, slashFraction, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN) + return err } // diff --git a/x/ccv/provider/keeper/consumer_equivocation_test.go b/x/ccv/provider/keeper/consumer_equivocation_test.go index d92caf69a3..cd0aba4f13 100644 --- a/x/ccv/provider/keeper/consumer_equivocation_test.go +++ b/x/ccv/provider/keeper/consumer_equivocation_test.go @@ -9,18 +9,18 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/math" + evidencetypes "cosmossdk.io/x/evidence/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmtypes "github.com/cometbft/cometbft/types" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestVerifyDoubleVotingEvidence(t *testing.T) { @@ -339,7 +339,7 @@ func TestJailAndTombstoneValidator(t *testing.T) { // Method will return once validator is not found. mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{}, false, // false = Not found. + stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound, ).Times(1), } }, @@ -354,7 +354,7 @@ func TestJailAndTombstoneValidator(t *testing.T) { // We only expect a single call to GetValidatorByConsAddr. mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{Status: stakingtypes.Unbonded}, true, + stakingtypes.Validator{Status: stakingtypes.Unbonded}, nil, ).Times(1), } }, @@ -368,7 +368,7 @@ func TestJailAndTombstoneValidator(t *testing.T) { return []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{}, true, + stakingtypes.Validator{}, nil, ).Times(1), mocks.MockSlashingKeeper.EXPECT().IsTombstoned( ctx, providerConsAddr.ToSdkConsAddr()).Return( @@ -386,7 +386,7 @@ func TestJailAndTombstoneValidator(t *testing.T) { return []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{Jailed: true}, true, + stakingtypes.Validator{Jailed: true}, nil, ).Times(1), mocks.MockSlashingKeeper.EXPECT().IsTombstoned( ctx, providerConsAddr.ToSdkConsAddr()).Return( @@ -410,7 +410,7 @@ func TestJailAndTombstoneValidator(t *testing.T) { return []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{Status: stakingtypes.Bonded}, true, + stakingtypes.Validator{Status: stakingtypes.Bonded}, nil, ).Times(1), mocks.MockSlashingKeeper.EXPECT().IsTombstoned( ctx, providerConsAddr.ToSdkConsAddr()).Return( @@ -449,7 +449,7 @@ func createUndelegation(initialBalances []int64, completionTimes []time.Time) st var entries []stakingtypes.UnbondingDelegationEntry for i, balance := range initialBalances { entry := stakingtypes.UnbondingDelegationEntry{ - InitialBalance: sdk.NewInt(balance), + InitialBalance: math.NewInt(balance), CompletionTime: completionTimes[i], } entries = append(entries, entry) @@ -463,7 +463,7 @@ func createRedelegation(initialBalances []int64, completionTimes []time.Time) st var entries []stakingtypes.RedelegationEntry for i, balance := range initialBalances { entry := stakingtypes.RedelegationEntry{ - InitialBalance: sdk.NewInt(balance), + InitialBalance: math.NewInt(balance), CompletionTime: completionTimes[i], } entries = append(entries, entry) @@ -504,7 +504,7 @@ func TestComputePowerToSlash(t *testing.T) { createRedelegation([]int64{250, 250}, []time.Time{nowPlus1Hour, nowPlus1Hour}), }, int64(1000), - sdk.NewInt(1), + math.NewInt(1), int64(2000/1 + 1000), }, { @@ -527,7 +527,7 @@ func TestComputePowerToSlash(t *testing.T) { createRedelegation([]int64{400}, []time.Time{nowPlus1Hour}), }, int64(8391), - sdk.NewInt(2), + math.NewInt(2), int64((2000+3500)/2 + 8391), }, { @@ -535,7 +535,7 @@ func TestComputePowerToSlash(t *testing.T) { []stakingtypes.UnbondingDelegation{}, []stakingtypes.Redelegation{}, int64(3000), - sdk.NewInt(5), + math.NewInt(5), int64(3000), // expectedPower is 0/5 + 3000 }, { @@ -551,7 +551,7 @@ func TestComputePowerToSlash(t *testing.T) { createRedelegation([]int64{100}, []time.Time{nowPlus1Hour}), }, int64(17), - sdk.NewInt(3), + math.NewInt(3), int64(2000/3 + 17), }, { @@ -566,7 +566,7 @@ func TestComputePowerToSlash(t *testing.T) { }, []stakingtypes.Redelegation{}, int64(1), - sdk.NewInt(3), + math.NewInt(3), int64(2000/3 + 1), }, { @@ -591,40 +591,40 @@ func TestComputePowerToSlash(t *testing.T) { createRedelegation([]int64{400}, []time.Time{now}), }, int64(8391), - sdk.NewInt(2), + math.NewInt(2), int64((1150+2550)/2 + 8391), }, } pubKey, _ := cryptocodec.FromTmPubKeyInterface(tmtypes.NewMockPV().PrivKey.PubKey()) - validator, _ := stakingtypes.NewValidator(pubKey.Address().Bytes(), pubKey, stakingtypes.Description{}) + validator, _ := stakingtypes.NewValidator(pubKey.Address().String(), pubKey, stakingtypes.Description{}) for _, tc := range testCases { gomock.InOrder(mocks.MockStakingKeeper.EXPECT(). - SlashUnbondingDelegation(gomock.Any(), gomock.Any(), int64(0), sdk.NewDec(1)). + SlashUnbondingDelegation(gomock.Any(), gomock.Any(), int64(0), math.LegacyNewDec(1)). DoAndReturn( - func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ math.LegacyDec) (math.Int, error) { + sum := math.NewInt(0) for _, r := range undelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } - return sum + return sum, nil }).AnyTimes(), mocks.MockStakingKeeper.EXPECT(). - SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), int64(0), sdk.NewDec(1)). + SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), int64(0), math.LegacyNewDec(1)). DoAndReturn( - func(ctx sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(ctx sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ math.LegacyDec) (math.Int, error) { + sum := math.NewInt(0) for _, r := range redelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } - return sum + return sum, nil }).AnyTimes(), ) @@ -649,13 +649,10 @@ func TestSlashValidator(t *testing.T) { // undelegation or redelegation entries with completion time one hour in the future have not yet matured nowPlus1Hour := now.Add(time.Hour) - keeperParams := testkeeper.NewInMemKeeperParams(t) - testkeeper.NewInMemProviderKeeper(keeperParams, mocks) - pubKey, _ := cryptocodec.FromTmPubKeyInterface(tmtypes.NewMockPV().PrivKey.PubKey()) validator, err := stakingtypes.NewValidator( - sdk.ValAddress(pubKey.Address().Bytes()), + sdk.ValAddress(pubKey.Address()).String(), pubKey, stakingtypes.NewDescription("", "", "", "", ""), ) @@ -679,64 +676,67 @@ func TestSlashValidator(t *testing.T) { // validator's current power currentPower := int64(3000) - powerReduction := sdk.NewInt(2) - slashFraction, _ := sdk.NewDecFromStr("0.5") + powerReduction := math.NewInt(2) + slashFraction, _ := math.LegacyNewDecFromStr("0.5") // the call to `Slash` should provide an `infractionHeight` of 0 and an expected power of // (750 (undelegations) + 750 (redelegations)) / 2 (= powerReduction) + 3000 (currentPower) = 3750 expectedInfractionHeight := int64(0) expectedSlashPower := int64(3750) + expectedValoperAddr, err := keeper.ValidatorAddressCodec().StringToBytes(validator.GetOperator()) + require.NoError(t, err) + expectedCalls := []*gomock.Call{ mocks.MockStakingKeeper.EXPECT(). GetValidatorByConsAddr(ctx, gomock.Any()). - Return(validator, true), + Return(validator, nil), mocks.MockSlashingKeeper.EXPECT(). IsTombstoned(ctx, consAddr). Return(false), mocks.MockStakingKeeper.EXPECT(). - GetUnbondingDelegationsFromValidator(ctx, validator.GetOperator()). - Return(undelegations), + GetUnbondingDelegationsFromValidator(ctx, expectedValoperAddr). + Return(undelegations, nil), mocks.MockStakingKeeper.EXPECT(). - GetRedelegationsFromSrcValidator(ctx, validator.GetOperator()). - Return(redelegations), + GetRedelegationsFromSrcValidator(ctx, expectedValoperAddr). + Return(redelegations, nil), mocks.MockStakingKeeper.EXPECT(). - GetLastValidatorPower(ctx, validator.GetOperator()). - Return(currentPower), + GetLastValidatorPower(ctx, expectedValoperAddr). + Return(currentPower, nil), mocks.MockStakingKeeper.EXPECT(). PowerReduction(ctx). Return(powerReduction), mocks.MockStakingKeeper.EXPECT(). SlashUnbondingDelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn( - func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(_ sdk.Context, undelegation stakingtypes.UnbondingDelegation, _ int64, _ math.LegacyDec) (math.Int, error) { + sum := math.NewInt(0) for _, r := range undelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } - return sum + return sum, nil }).AnyTimes(), mocks.MockStakingKeeper.EXPECT(). SlashRedelegation(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). DoAndReturn( - func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ sdk.Dec) math.Int { - sum := sdk.NewInt(0) + func(_ sdk.Context, _ stakingtypes.Validator, redelegation stakingtypes.Redelegation, _ int64, _ math.LegacyDec) (math.Int, error) { + sum := math.NewInt(0) for _, r := range redelegation.Entries { if r.IsMature(ctx.BlockTime()) { continue } - sum = sum.Add(sdk.NewInt(r.InitialBalance.Int64())) + sum = sum.Add(math.NewInt(r.InitialBalance.Int64())) } - return sum + return sum, nil }).AnyTimes(), mocks.MockSlashingKeeper.EXPECT(). SlashFractionDoubleSign(ctx). - Return(slashFraction), + Return(slashFraction, nil), mocks.MockStakingKeeper.EXPECT(). - SlashWithInfractionReason(ctx, consAddr, expectedInfractionHeight, expectedSlashPower, slashFraction, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN). + SlashWithInfractionReason(ctx, consAddr, expectedInfractionHeight, expectedSlashPower, slashFraction, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN).Return(math.NewInt(expectedSlashPower), nil). Times(1), } @@ -756,7 +756,7 @@ func TestSlashValidatorDoesNotSlashIfValidatorIsUnbonded(t *testing.T) { pubKey, _ := cryptocodec.FromTmPubKeyInterface(tmtypes.NewMockPV().PrivKey.PubKey()) // validator is initially unbonded - validator, _ := stakingtypes.NewValidator(pubKey.Address().Bytes(), pubKey, stakingtypes.Description{}) + validator, _ := stakingtypes.NewValidator(pubKey.Address().String(), pubKey, stakingtypes.Description{}) consAddr, _ := validator.GetConsAddr() providerAddr := types.NewProviderConsAddress(consAddr) @@ -764,7 +764,7 @@ func TestSlashValidatorDoesNotSlashIfValidatorIsUnbonded(t *testing.T) { expectedCalls := []*gomock.Call{ mocks.MockStakingKeeper.EXPECT(). GetValidatorByConsAddr(ctx, gomock.Any()). - Return(validator, true), + Return(validator, nil), } gomock.InOrder(expectedCalls...) diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 2259e472d1..ca16831ee8 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -1,22 +1,22 @@ package keeper import ( - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + storetypes "cosmossdk.io/store/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + + "context" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - abci "github.com/cometbft/cometbft/abci/types" - - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // BeginBlockRD executes BeginBlock logic for the Reward Distribution sub-protocol. -func (k Keeper) BeginBlockRD(ctx sdk.Context, req abci.RequestBeginBlock) { +func (k Keeper) BeginBlockRD(ctx sdk.Context) { // TODO this is Tendermint-dependent // ref https://github.com/cosmos/cosmos-sdk/issues/3095 if ctx.BlockHeight() > 1 { @@ -56,8 +56,7 @@ func (k Keeper) DeleteConsumerRewardDenom( func (k Keeper) GetAllConsumerRewardDenoms(ctx sdk.Context) (consumerRewardDenoms []string) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.ConsumerRewardDenomsBytePrefix}) - + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ConsumerRewardDenomsBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { key := iterator.Key()[1:] @@ -77,53 +76,90 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { // Iterate over all registered consumer chains for _, consumerChainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { - // transfer the consumer rewards to the distribution module account - // note that the rewards transferred are only consumer whitelisted denoms - rewardsCollected, err := k.TransferConsumerRewardsToDistributionModule(ctx, consumerChainID) - if err != nil { - k.Logger(ctx).Error( - "fail to transfer rewards to distribution module for chain %s: %s", - consumerChainID, - err, - ) - continue - } // note that it's possible that no rewards are collected even though the // reward pool isn't empty. This can happen if the reward pool holds some tokens // of non-whitelisted denominations. - if rewardsCollected.IsZero() { + alloc := k.GetConsumerRewardsAllocation(ctx, consumerChainID) + if alloc.Rewards.IsZero() { continue } - rewardsCollectedDec := sdk.NewDecCoinsFromCoins(rewardsCollected...) - // temporary workaround to keep CanWithdrawInvariant happy // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 - feePool := k.distributionKeeper.GetFeePool(ctx) if k.ComputeConsumerTotalVotingPower(ctx, consumerChainID) == 0 { - feePool.CommunityPool = feePool.CommunityPool.Add(rewardsCollectedDec...) - k.distributionKeeper.SetFeePool(ctx, feePool) + rewardsToSend, rewardsChange := alloc.Rewards.TruncateDecimal() + err := k.distributionKeeper.FundCommunityPool(context.Context(ctx), rewardsToSend, k.accountKeeper.GetModuleAccount(ctx, types.ConsumerRewardsPool).GetAddress()) + if err != nil { + k.Logger(ctx).Error( + "fail to allocate rewards from consumer chain %s to community pool: %s", + consumerChainID, + err, + ) + } + + // set the consumer allocation to the remaining reward decimals + alloc.Rewards = rewardsChange + k.SetConsumerRewardsAllocation(ctx, consumerChainID, alloc) + return } - // calculate the reward allocations - remaining := rewardsCollectedDec - communityTax := k.distributionKeeper.GetCommunityTax(ctx) + // Consumer rewards are distributed between the validators and the community pool. + // The decimals resulting from the distribution are expected to remain in the consumer reward allocations. + + communityTax, err := k.distributionKeeper.GetCommunityTax(ctx) + if err != nil { + k.Logger(ctx).Error( + "cannot get community tax while allocating rewards from consumer chain %s: %s", + consumerChainID, + err, + ) + continue + } + + // compute rewards for validators + consumerRewards := alloc.Rewards voteMultiplier := math.LegacyOneDec().Sub(communityTax) - feeMultiplier := rewardsCollectedDec.MulDecTruncate(voteMultiplier) + validatorsRewards := consumerRewards.MulDecTruncate(voteMultiplier) + + // compute remaining rewards for the community pool + remaining := consumerRewards.Sub(validatorsRewards) + + // transfer validators rewards to distribution module account + validatorsRewardsTrunc, validatorsRewardsChange := validatorsRewards.TruncateDecimal() + err = k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ConsumerRewardsPool, distrtypes.ModuleName, validatorsRewardsTrunc) + if err != nil { + k.Logger(ctx).Error( + "cannot send rewards to distribution module account %s: %s", + consumerChainID, + err, + ) + continue + } // allocate tokens to consumer validators - feeAllocated := k.AllocateTokensToConsumerValidators( + k.AllocateTokensToConsumerValidators( ctx, consumerChainID, - feeMultiplier, + sdk.NewDecCoinsFromCoins(validatorsRewardsTrunc...), ) - remaining = remaining.Sub(feeAllocated) - // allocate community funding - feePool.CommunityPool = feePool.CommunityPool.Add(remaining...) - k.distributionKeeper.SetFeePool(ctx, feePool) + // allocate remaining rewards to the community pool + remainingRewards, remainingChanges := remaining.TruncateDecimal() + err = k.distributionKeeper.FundCommunityPool(context.Context(ctx), remainingRewards, k.accountKeeper.GetModuleAccount(ctx, types.ConsumerRewardsPool).GetAddress()) + if err != nil { + k.Logger(ctx).Error( + "fail to allocate rewards from consumer chain %s to community pool: %s", + consumerChainID, + err, + ) + continue + } + + // set consumer allocations to the remaining rewards decimals + alloc.Rewards = validatorsRewardsChange.Add(remainingChanges...) + k.SetConsumerRewardsAllocation(ctx, consumerChainID, alloc) } } @@ -168,7 +204,18 @@ func (k Keeper) AllocateTokensToConsumerValidators( tokensFraction := tokens.MulDecTruncate(powerFraction) // get the validator type struct for the consensus address - val := k.stakingKeeper.ValidatorByConsAddr(ctx, consAddr).(stakingtypes.Validator) + val, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) + if err != nil { + k.Logger(ctx).Error( + "cannot find validator by consensus address", + consAddr, + "while allocating rewards from consumer chain", + chainID, + "error", + err, + ) + continue + } // check if the validator set a custom commission rate for the consumer chain if cr, found := k.GetConsumerCommissionRate(ctx, chainID, types.NewProviderConsAddress(consAddr)); found { @@ -177,11 +224,16 @@ func (k Keeper) AllocateTokensToConsumerValidators( } // allocate the consumer reward tokens to the validator - k.distributionKeeper.AllocateTokensToValidator( + err = k.distributionKeeper.AllocateTokensToValidator( ctx, val, tokensFraction, ) + if err != nil { + k.Logger(ctx).Error("fail to allocate tokens to validator :%s while allocating rewards from consumer chain: %s", + consAddr, chainID) + continue + } // sum the tokens allocated allocated = allocated.Add(tokensFraction...) @@ -190,39 +242,6 @@ func (k Keeper) AllocateTokensToConsumerValidators( return allocated } -// TransferConsumerRewardsToDistributionModule transfers the rewards allocation of the given consumer chain -// from the consumer rewards pool to a the distribution module -func (k Keeper) TransferConsumerRewardsToDistributionModule( - ctx sdk.Context, - chainID string, -) (sdk.Coins, error) { - // Get coins of the consumer rewards allocation - allocation := k.GetConsumerRewardsAllocation(ctx, chainID) - - if allocation.Rewards.IsZero() { - return sdk.Coins{}, nil - } - - // Truncate coin rewards - rewardsToSend, remRewards := allocation.Rewards.TruncateDecimal() - - // NOTE the consumer rewards allocation isn't a module account, however its coins - // are held in the consumer reward pool module account. Thus the consumer - // rewards allocation must be reduced separately from the SendCoinsFromModuleToAccount call. - - // Update consumer rewards allocation with the remaining decimal coins - allocation.Rewards = remRewards - - // Send coins to distribution module account - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ConsumerRewardsPool, distrtypes.ModuleName, rewardsToSend) - if err != nil { - return sdk.Coins{}, err - } - - k.SetConsumerRewardsAllocation(ctx, chainID, allocation) - return rewardsToSend, nil -} - // consumer reward pools getter and setter // GetConsumerRewardsAllocation returns the consumer rewards allocation for the given chain ID @@ -292,7 +311,7 @@ func (k Keeper) IdentifyConsumerChainIDFromIBCPacket(ctx sdk.Context, packet cha // HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address // on the condition that the given consumer chain exists. -func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate sdk.Dec) error { +func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec) error { // check that the consumer chain exists if !k.IsConsumerProposedOrRegistered(ctx, chainID) { return errorsmod.Wrapf( @@ -301,7 +320,10 @@ func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, } // validate against the minimum commission rate - minRate := k.stakingKeeper.MinCommissionRate(ctx) + minRate, err := k.stakingKeeper.MinCommissionRate(ctx) + if err != nil { + return err + } if commissionRate.LT(minRate) { return errorsmod.Wrapf( stakingtypes.ErrCommissionLTMinRate, diff --git a/x/ccv/provider/keeper/distribution_test.go b/x/ccv/provider/keeper/distribution_test.go index 2c80b418b0..ba79458e00 100644 --- a/x/ccv/provider/keeper/distribution_test.go +++ b/x/ccv/provider/keeper/distribution_test.go @@ -3,10 +3,11 @@ package keeper_test import ( "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -14,9 +15,9 @@ import ( tmtypes "github.com/cometbft/cometbft/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestComputeConsumerTotalVotingPower(t *testing.T) { @@ -253,7 +254,7 @@ func TestSetConsumerRewardsAllocation(t *testing.T) { providerKeeper := testkeeper.NewInMemProviderKeeper(keeperParams, mocks) rewardAllocation := providertypes.ConsumerRewardsAllocation{ - Rewards: sdk.NewDecCoins(sdk.NewDecCoin("uatom", sdk.NewInt(1000))), + Rewards: sdk.NewDecCoins(sdk.NewDecCoin("uatom", math.NewInt(1000))), } providerKeeper.SetConsumerRewardsAllocation(ctx, "consumer-1", rewardAllocation) diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index cc8bdc41cd..b965e3ed57 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // InitGenesis initializes the CCV provider state and binds to PortID. @@ -21,7 +21,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { err := k.BindPort(ctx, ccv.ProviderPortID) if err != nil { // If the binding fails, the chain MUST NOT start - panic(fmt.Errorf("could not claim port capability: %v", err)) + panic(fmt.Errorf("could not claim port capability: %w", err)) } } diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index 81b0a90bd8..8fd22824ef 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -5,17 +5,18 @@ import ( "testing" "time" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "cosmossdk.io/math" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestInitAndExportGenesis tests the export and the initialisation of a provider chain genesis @@ -137,7 +138,7 @@ func TestInitAndExportGenesis(t *testing.T) { ctx, host.PortPath(ccv.ProviderPortID), ).Return(nil, true).Times(1), mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - ctx).Return(sdk.NewInt(100)).Times(1), // Return total voting power as 100 + ctx).Return(math.NewInt(100), nil).Times(1), // Return total voting power as 100 ) // init provider chain @@ -146,9 +147,9 @@ func TestInitAndExportGenesis(t *testing.T) { // Expect slash meter to be initialized to it's allowance value // (replenish fraction * mocked value defined above) slashMeter := pk.GetSlashMeter(ctx) - replenishFraction, err := sdk.NewDecFromStr(pk.GetParams(ctx).SlashMeterReplenishFraction) + replenishFraction, err := math.LegacyNewDecFromStr(pk.GetParams(ctx).SlashMeterReplenishFraction) require.NoError(t, err) - expectedSlashMeterValue := sdk.NewInt(replenishFraction.MulInt(sdk.NewInt(100)).RoundInt64()) + expectedSlashMeterValue := math.NewInt(replenishFraction.MulInt(math.NewInt(100)).RoundInt64()) require.Equal(t, expectedSlashMeterValue, slashMeter) // Expect slash meter replenishment time candidate to be set to the current block time + replenish period diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index b1a5b36dcd..d2a36c686d 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -11,8 +11,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) var _ types.QueryServer = Keeper{} @@ -268,8 +268,12 @@ func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, } // QueryParams returns all parameters and current values of provider -func (k Keeper) QueryParams(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +func (k Keeper) QueryParams(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) params := k.GetParams(ctx) return &types.QueryParamsResponse{Params: params}, nil @@ -380,7 +384,10 @@ func (k Keeper) hasToValidate( } // if the validator was not part of the last epoch, check if the validator is going to be part of te next epoch - bondedValidators := k.GetLastBondedValidators(ctx) + bondedValidators, err := k.GetLastBondedValidators(ctx) + if err != nil { + return false, nil + } if topN, found := k.GetTopN(ctx, chainID); found && topN > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N minPower, found := k.GetMinimumPowerInTopN(ctx, chainID) @@ -394,7 +401,11 @@ func (k Keeper) hasToValidate( // if the validator is opted in and belongs to the validators of the next epoch, then if nothing changes // the validator would have to validate in the next epoch if k.IsOptedIn(ctx, chainID, provAddr) { - nextValidators := k.ComputeNextValidators(ctx, chainID, bondedValidators) + lastVals, err := k.GetLastBondedValidators(ctx) + if err != nil { + return false, err + } + nextValidators := k.ComputeNextValidators(ctx, chainID, lastVals) for _, v := range nextValidators { consAddr := sdk.ConsAddress(v.ProviderConsAddr) if provAddr.ToSdkConsAddr().Equals(consAddr) { @@ -437,8 +448,8 @@ func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req if found { res.Rate = consumerRate } else { - v, ok := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) - if !ok { + v, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) + if err != nil { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown validator: %s", consAddr.String())) } res.Rate = v.Commission.Rate diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index c5b22ecc5f..3d9f9ee86d 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -5,18 +5,18 @@ import ( "testing" "time" + "cosmossdk.io/math" + "github.com/cometbft/cometbft/proto/tendermint/crypto" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" + sdk "github.com/cosmos/cosmos-sdk/types" sdktypes "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/cometbft/cometbft/proto/tendermint/crypto" - - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" + "github.com/stretchr/testify/require" ) func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { @@ -180,10 +180,10 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - val := createStakingValidator(ctx, mocks, 1, 1) + val := createStakingValidator(ctx, mocks, 1, 1, 1) valConsAddr, _ := val.GetConsAddr() providerAddr := types.NewProviderConsAddress(valConsAddr) - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr).Return(val, true).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr).Return(val, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{val}, []int64{1}, -1) // -1 to allow the calls "AnyTimes" req := types.QueryConsumerChainsValidatorHasToValidateRequest{ @@ -237,19 +237,19 @@ func TestQueryValidatorConsumerCommissionRate(t *testing.T) { pk.SetProposedConsumerChain(ctx, chainID, 1) // validator with set consumer commission rate - expectedCommissionRate, _ := sdktypes.NewDecFromStr("0.123") + expectedCommissionRate := math.LegacyMustNewDecFromStr("0.123") pk.SetConsumerCommissionRate(ctx, chainID, providerAddr, expectedCommissionRate) res, _ := pk.QueryValidatorConsumerCommissionRate(ctx, &req) require.Equal(t, expectedCommissionRate, res.Rate) // validator with no set consumer commission rate pk.DeleteConsumerCommissionRate(ctx, chainID, providerAddr) - expectedCommissionRate, _ = sdktypes.NewDecFromStr("0.456") + expectedCommissionRate = math.LegacyMustNewDecFromStr("0.456") // because no consumer commission rate is set, the validator's set commission rate on the provider is used val := stakingtypes.Validator{Commission: stakingtypes.Commission{CommissionRates: stakingtypes.CommissionRates{Rate: expectedCommissionRate}}} mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( - ctx, providerAddr.ToSdkConsAddr()).Return(val, true).Times(1) + ctx, providerAddr.ToSdkConsAddr()).Return(val, nil).Times(1) res, _ = pk.QueryValidatorConsumerCommissionRate(ctx, &req) require.Equal(t, expectedCommissionRate, res.Rate) } @@ -273,7 +273,9 @@ func TestGetConsumerChain(t *testing.T) { testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, maxValidators, vals, powers, -1) // -1 to allow the calls "AnyTimes" for i, val := range vals { - mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), val.GetOperator()).Return(powers[i]).AnyTimes() + valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) + require.NoError(t, err) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr).Return(powers[i], nil).AnyTimes() } // set Top N parameters, client ids and expected result diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 5aef4a16ef..81226a2bdf 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -1,16 +1,18 @@ package keeper import ( + "context" "fmt" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Wrapper struct @@ -33,36 +35,38 @@ func (k *Keeper) Hooks() Hooks { // // This stores a record of each unbonding op from staking, allowing us to track which consumer chains have unbonded -func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { +func (h Hooks) AfterUnbondingInitiated(goCtx context.Context, id uint64) error { var consumerChainIDS []string + ctx := sdk.UnwrapSDKContext(goCtx) + // get validator address from unbonding operation - unbondingType, found := h.k.stakingKeeper.GetUnbondingType(ctx, id) + unbondingType, err := h.k.stakingKeeper.GetUnbondingType(ctx, id) vadAddrBech32 := "" - if !found { - ctx.Logger().Error("undefined type for unbonding operation id: %d", id) + if err != nil { + ctx.Logger().Error("undefined type for unbonding operation: id: %d: %s", id, err) return nil } switch unbondingType { case stakingtypes.UnbondingType_UnbondingDelegation: - ubd, found := h.k.stakingKeeper.GetUnbondingDelegationByUnbondingID(ctx, id) - if !found { - ctx.Logger().Error("unfound ubonding delegation for unbonding id: %d", id) + ubd, err := h.k.stakingKeeper.GetUnbondingDelegationByUnbondingID(ctx, id) + if err != nil { + ctx.Logger().Error("unfound ubonding delegation for unbonding id: %d: %s", id, err) return nil } vadAddrBech32 = ubd.ValidatorAddress case stakingtypes.UnbondingType_Redelegation: - red, found := h.k.stakingKeeper.GetRedelegationByUnbondingID(ctx, id) - if !found { - ctx.Logger().Error("unfound relegation for unbonding operation id: %d", id) + red, err := h.k.stakingKeeper.GetRedelegationByUnbondingID(ctx, id) + if err != nil { + ctx.Logger().Error("unfound relegation for unbonding operation id: %d: %s", id, err) return nil } vadAddrBech32 = red.ValidatorSrcAddress case stakingtypes.UnbondingType_ValidatorUnbonding: - val, found := h.k.stakingKeeper.GetValidatorByUnbondingID(ctx, id) - if !found { - ctx.Logger().Error("unfound validator for unbonding operation id: %d", id) + val, err := h.k.stakingKeeper.GetValidatorByUnbondingID(ctx, id) + if err != nil { + ctx.Logger().Error("unfound validator for unbonding operation id: %d: %s", id, err) return nil } vadAddrBech32 = val.OperatorAddress @@ -77,9 +81,9 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { return nil } - validator, found := h.k.stakingKeeper.GetValidator(ctx, valAddr) - if !found { - ctx.Logger().Error("unfound validator for validator address %s", vadAddrBech32) + validator, err := h.k.stakingKeeper.GetValidator(ctx, valAddr) + if err != nil { + ctx.Logger().Error("unfound validator for validator address: %s: %s", vadAddrBech32, err) return nil } @@ -100,19 +104,6 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { // Do not put the unbonding op on hold if there are no consumer chains return nil } - // Call back into staking to tell it to stop this op from unbonding when the unbonding period is complete - if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { - // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called - // from staking.EndBlock. - - // In this case PutUnbondingOnHold fails if either the unbonding operation was - // not found or the UnbondingOnHoldRefCount is negative. - - // This change should be updated for SDK v0.48 because it will include changes in handling - // check: https://github.com/cosmos/cosmos-sdk/pull/16043 - ctx.Logger().Error("unbonding could not be put on hold: %w", err) - return nil - } valsetUpdateID := h.k.GetValidatorSetUpdateId(ctx) unbondingOp := providertypes.UnbondingOp{ @@ -129,26 +120,25 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { h.k.SetUnbondingOp(ctx, unbondingOp) - // NOTE: This is a temporary fix for v0.47 -> we should not panic in this edge case - // since the AfterUnbondInitiatedHook can be called with a non-existing UnbondingEntry.id - // check: https://github.com/cosmos/cosmos-sdk/pull/16043 - // // Call back into staking to tell it to stop this op from unbonding when the unbonding period is complete - // if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { - // // If there was an error putting the unbonding on hold, panic to end execution for - // // the current tx and prevent committal of this invalid state. - // // - // // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called - // // from staking.EndBlock, thus the following panic would halt the chain. - // // In this case PutUnbondingOnHold fails if either the unbonding operation was - // // not found or the UnbondingOnHoldRefCount is negative. In either cases, - // // the state of the x/staking module of cosmos-sdk is invalid. - // panic(fmt.Errorf("unbonding could not be put on hold: %w", err)) - // } + if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { + // If there was an error putting the unbonding on hold, panic to end execution for + // the current tx and prevent committal of this invalid state. + // + // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called + // from staking.EndBlock, thus the following panic would halt the chain. + + // In this case PutUnbondingOnHold fails if either the unbonding operation was + // not found or the UnbondingOnHoldRefCount is negative. In either cases, + // the state of the x/staking module of cosmos-sdk is invalid. + panic(fmt.Errorf("unbonding could not be put on hold: %w", err)) + } return nil } -func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) error { +func (h Hooks) AfterValidatorCreated(goCtx context.Context, valAddr sdk.ValAddress) error { + ctx := sdk.UnwrapSDKContext(goCtx) + if h.k.ValidatorConsensusKeyInUse(ctx, valAddr) { // Abort TX, do NOT allow validator to be created panic("cannot create a validator with a consensus key that is already in use or was recently in use as an assigned consumer chain key") @@ -156,7 +146,9 @@ func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) er return nil } -func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, valConsAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { +func (h Hooks) AfterValidatorRemoved(goCtx context.Context, valConsAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { + ctx := sdk.UnwrapSDKContext(goCtx) + for _, validatorConsumerPubKey := range h.k.GetAllValidatorConsumerPubKeys(ctx, nil) { if sdk.ConsAddress(validatorConsumerPubKey.ProviderAddr).Equals(valConsAddr) { consumerAddrTmp, err := ccvtypes.TMCryptoPublicKeyToConsAddr(*validatorConsumerPubKey.ConsumerKey) @@ -174,35 +166,39 @@ func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, valConsAddr sdk.ConsAddres return nil } -func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { +func (h Hooks) BeforeDelegationCreated(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) BeforeDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { +func (h Hooks) BeforeDelegationSharesModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) AfterDelegationModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { +func (h Hooks) AfterDelegationModified(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec) error { +func (h Hooks) BeforeValidatorSlashed(_ context.Context, _ sdk.ValAddress, _ math.LegacyDec) error { return nil } -func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error { +func (h Hooks) BeforeValidatorModified(_ context.Context, _ sdk.ValAddress) error { return nil } -func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { +func (h Hooks) AfterValidatorBonded(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { +func (h Hooks) AfterValidatorBeginUnbonding(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { +func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { + return nil +} + +func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) error { return nil } @@ -213,29 +209,38 @@ func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.Va // AfterProposalSubmission - call hook if registered // After a consumerAddition proposal submission, a record is created // that maps the proposal ID to the consumer chain ID. -func (h Hooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) { +func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalID uint64) error { + ctx := sdk.UnwrapSDKContext(goCtx) + if p, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok { h.k.SetProposedConsumerChain(ctx, p.ChainId, proposalID) } + return nil } // AfterProposalVotingPeriodEnded - call hook if registered // After proposal voting ends, the consumer chainID in store is deleted. // When a consumerAddition proposal passes, the consumer chainID is available in providerKeeper.GetAllPendingConsumerAdditionProps // or providerKeeper.GetAllConsumerChains(ctx). -func (h Hooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) { +func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalID uint64) error { + ctx := sdk.UnwrapSDKContext(goCtx) + if _, ok := h.GetConsumerAdditionLegacyPropFromProp(ctx, proposalID); ok { h.k.DeleteProposedConsumerChainInStore(ctx, proposalID) } + return nil } -func (h Hooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) { +func (h Hooks) AfterProposalDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress) error { + return nil } -func (h Hooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) { +func (h Hooks) AfterProposalVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress) error { + return nil } -func (h Hooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) { +func (h Hooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error { + return nil } // GetConsumerAdditionLegacyPropFromProp extracts a consumer addition legacy proposal from @@ -244,9 +249,9 @@ func (h Hooks) GetConsumerAdditionLegacyPropFromProp( ctx sdk.Context, proposalID uint64, ) (providertypes.ConsumerAdditionProposal, bool) { - p, ok := h.k.govKeeper.GetProposal(ctx, proposalID) - if !ok { - panic(fmt.Errorf("failed to get proposal %d from store", proposalID)) + p, err := h.k.govKeeper.Proposals.Get(ctx, proposalID) + if err != nil { + return providertypes.ConsumerAdditionProposal{}, false } // Iterate over the messages in the proposal @@ -270,7 +275,3 @@ func (h Hooks) GetConsumerAdditionLegacyPropFromProp( } return providertypes.ConsumerAdditionProposal{}, false } - -func (h Hooks) BeforeTokenizeShareRecordRemoved(_ sdk.Context, _ uint64) error { - return nil -} diff --git a/x/ccv/provider/keeper/hooks_test.go b/x/ccv/provider/keeper/hooks_test.go index 931667fac4..2447b5edf3 100644 --- a/x/ccv/provider/keeper/hooks_test.go +++ b/x/ccv/provider/keeper/hooks_test.go @@ -2,22 +2,12 @@ package keeper_test import ( "testing" - "time" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" 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" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/golang/mock/gomock" ) func TestValidatorConsensusKeyInUse(t *testing.T) { @@ -77,151 +67,15 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator(ctx, newValidator.SDKValOpAddress(), - ).Return(newValidator.SDKStakingValidator(), true), + ).Return(newValidator.SDKStakingValidator(), nil), ) tt.setup(ctx, k) t.Run(tt.name, func(t *testing.T) { - if actual := k.ValidatorConsensusKeyInUse(ctx, newValidator.SDKStakingValidator().GetOperator()); actual != tt.expect { + if actual := k.ValidatorConsensusKeyInUse(ctx, newValidator.SDKValOpAddress()); actual != tt.expect { t.Errorf("validatorConsensusKeyInUse() = %v, want %v", actual, tt.expect) } }) } } - -func TestAfterPropSubmissionAndVotingPeriodEnded(t *testing.T) { - acct := cryptotestutil.NewCryptoIdentityFromIntSeed(0) - - propMsg, err := v1.NewLegacyContent( - testkeeper.GetTestConsumerAdditionProp(), - authtypes.NewModuleAddress("gov").String(), - ) - require.NoError(t, err) - - prop, err := v1.NewProposal( - []sdk.Msg{propMsg}, - 0, - time.Now(), - time.Now(), - "", - "", - "", - sdk.AccAddress(acct.SDKValOpAddress()), - ) - require.NoError(t, err) - - k, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // pass the prop to the mocked gov keeper, - // which is called by both the AfterProposalVotingPeriodEnded and - // AfterProposalSubmission gov hooks - gomock.InOrder( - mocks.MockGovKeeper.EXPECT().GetProposal(ctx, prop.Id).Return(prop, true).Times(2), - ) - - k.Hooks().AfterProposalSubmission(ctx, prop.Id) - // verify that the proposal ID is created - _, found := k.GetProposedConsumerChain(ctx, prop.Id) - require.True(t, found) - - k.Hooks().AfterProposalVotingPeriodEnded(ctx, prop.Id) - // verify that the proposal ID is deleted - _, found = k.GetProposedConsumerChain(ctx, prop.Id) - require.False(t, found) -} - -func TestGetConsumerAdditionLegacyPropFromProp(t *testing.T) { - acct := cryptotestutil.NewCryptoIdentityFromIntSeed(0) - anotherAcct := cryptotestutil.NewCryptoIdentityFromIntSeed(1) - - // create a dummy bank send message - dummyMsg := &banktypes.MsgSend{ - FromAddress: sdk.AccAddress(acct.SDKValOpAddress()).String(), - ToAddress: sdk.AccAddress(anotherAcct.SDKValOpAddress()).String(), - Amount: sdk.NewCoins(sdk.NewCoin("stake", math.OneInt())), - } - - textProp, err := v1.NewLegacyContent( - v1beta1.NewTextProposal("a title", "a legacy text prop"), - authtypes.NewModuleAddress("gov").String(), - ) - require.NoError(t, err) - - consuProp, err := v1.NewLegacyContent( - testkeeper.GetTestConsumerAdditionProp(), - authtypes.NewModuleAddress("gov").String(), - ) - require.NoError(t, err) - - testCases := map[string]struct { - propMsg sdk.Msg - // setup func(sdk.Context, k providerkeeper, proposalID uint64) - expPanic bool - expConsuAddProp bool - }{ - "prop not found": { - propMsg: nil, - expPanic: true, - }, - "msgs in prop contain no legacy props": { - propMsg: dummyMsg, - }, - "msgs contain a legacy prop but not of ConsumerAdditionProposal type": { - propMsg: textProp, - }, - "msgs contain an invalid legacy prop": { - propMsg: &v1.MsgExecLegacyContent{}, - expPanic: true, - }, - "msg contains a prop of ConsumerAdditionProposal type - hook should create a new proposed chain": { - propMsg: consuProp, - expConsuAddProp: true, - }, - } - - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - k, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - var ( - prop v1.Proposal - propFound bool - ) - - if tc.propMsg != nil { - propFound = true - prop, err = v1.NewProposal( - []sdk.Msg{tc.propMsg}, - 0, - time.Now(), - time.Now(), - "", - "", - "", - sdk.AccAddress(acct.SDKValOpAddress()), - ) - require.NoError(t, err) - } - - gomock.InOrder( - mocks.MockGovKeeper.EXPECT().GetProposal(ctx, prop.Id).Return(prop, propFound), - ) - - if tc.expPanic { - defer func() { - // fail test if not panic was recovered - if r := recover(); r == nil { - require.Fail(t, r.(string)) - } - }() - } - - // retrieve consumer addition proposal - _, ok := k.Hooks().GetConsumerAdditionLegacyPropFromProp(ctx, prop.Id) - require.Equal(t, tc.expConsuAddProp, ok) - }) - } -} diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 5829ebaf61..22f5f33626 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -1,38 +1,46 @@ package keeper import ( + "context" "encoding/binary" "fmt" "reflect" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + addresscodec "cosmossdk.io/core/address" + "cosmossdk.io/math" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" + ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Keeper defines the Cross-Chain Validation Provider Keeper type Keeper struct { - storeKey storetypes.StoreKey + // address capable of executing gov messages (gov module account) + authority string + + storeKey storetypes.StoreKey + cdc codec.BinaryCodec - paramSpace paramtypes.Subspace scopedKeeper ccv.ScopedKeeper channelKeeper ccv.ChannelKeeper portKeeper ccv.PortKeeper @@ -43,8 +51,11 @@ type Keeper struct { slashingKeeper ccv.SlashingKeeper distributionKeeper ccv.DistributionKeeper bankKeeper ccv.BankKeeper - govKeeper ccv.GovKeeper + govKeeper govkeeper.Keeper feeCollectorName string + + validatorAddressCodec addresscodec.Codec + consensusAddressCodec addresscodec.Codec } // NewKeeper creates a new provider Keeper instance @@ -55,69 +66,87 @@ func NewKeeper( stakingKeeper ccv.StakingKeeper, slashingKeeper ccv.SlashingKeeper, accountKeeper ccv.AccountKeeper, distributionKeeper ccv.DistributionKeeper, bankKeeper ccv.BankKeeper, - govKeeper ccv.GovKeeper, feeCollectorName string, + govKeeper govkeeper.Keeper, + authority string, + validatorAddressCodec, consensusAddressCodec addresscodec.Codec, + feeCollectorName string, ) Keeper { - // set KeyTable if it has not already been set - if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) - } - k := Keeper{ - cdc: cdc, - storeKey: key, - paramSpace: paramSpace, - scopedKeeper: scopedKeeper, - channelKeeper: channelKeeper, - portKeeper: portKeeper, - connectionKeeper: connectionKeeper, - clientKeeper: clientKeeper, - stakingKeeper: stakingKeeper, - slashingKeeper: slashingKeeper, - accountKeeper: accountKeeper, - distributionKeeper: distributionKeeper, - bankKeeper: bankKeeper, - govKeeper: govKeeper, - feeCollectorName: feeCollectorName, + cdc: cdc, + storeKey: key, + authority: authority, + scopedKeeper: scopedKeeper, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + connectionKeeper: connectionKeeper, + clientKeeper: clientKeeper, + stakingKeeper: stakingKeeper, + slashingKeeper: slashingKeeper, + accountKeeper: accountKeeper, + distributionKeeper: distributionKeeper, + bankKeeper: bankKeeper, + feeCollectorName: feeCollectorName, + validatorAddressCodec: validatorAddressCodec, + consensusAddressCodec: consensusAddressCodec, + govKeeper: govKeeper, } k.mustValidateFields() return k } -// SetParamSpace sets the param space for the provider keeper. -// Note: this is only used for testing! -func (k *Keeper) SetParamSpace(ctx sdk.Context, ps paramtypes.Subspace) { - k.paramSpace = ps +// GetAuthority returns the x/ccv/provider module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// ValidatorAddressCodec returns the app validator address codec. +func (k Keeper) ValidatorAddressCodec() addresscodec.Codec { + return k.validatorAddressCodec +} + +// ConsensusAddressCodec returns the app consensus address codec. +func (k Keeper) ConsensusAddressCodec() addresscodec.Codec { + return k.consensusAddressCodec } // Validates that the provider keeper is initialized with non-zero and // non-nil values for all its fields. Otherwise this method will panic. func (k Keeper) mustValidateFields() { // Ensures no fields are missed in this validation - if reflect.ValueOf(k).NumField() != 15 { - panic("number of fields in provider keeper is not 15") - } - - ccv.PanicIfZeroOrNil(k.cdc, "cdc") // 1 - ccv.PanicIfZeroOrNil(k.storeKey, "storeKey") // 2 - ccv.PanicIfZeroOrNil(k.paramSpace, "paramSpace") // 3 - ccv.PanicIfZeroOrNil(k.scopedKeeper, "scopedKeeper") // 4 - ccv.PanicIfZeroOrNil(k.channelKeeper, "channelKeeper") // 5 - ccv.PanicIfZeroOrNil(k.portKeeper, "portKeeper") // 6 - ccv.PanicIfZeroOrNil(k.connectionKeeper, "connectionKeeper") // 7 - ccv.PanicIfZeroOrNil(k.accountKeeper, "accountKeeper") // 8 - ccv.PanicIfZeroOrNil(k.clientKeeper, "clientKeeper") // 9 - ccv.PanicIfZeroOrNil(k.stakingKeeper, "stakingKeeper") // 10 - ccv.PanicIfZeroOrNil(k.slashingKeeper, "slashingKeeper") // 11 - ccv.PanicIfZeroOrNil(k.distributionKeeper, "distributionKeeper") // 12 - ccv.PanicIfZeroOrNil(k.bankKeeper, "bankKeeper") // 13 - ccv.PanicIfZeroOrNil(k.govKeeper, "govKeeper") // 14 - ccv.PanicIfZeroOrNil(k.feeCollectorName, "feeCollectorName") // 15 + if reflect.ValueOf(k).NumField() != 17 { + panic(fmt.Sprintf("number of fields in provider keeper is not 18 - have %d", reflect.ValueOf(k).NumField())) + } + + if k.validatorAddressCodec == nil || k.consensusAddressCodec == nil { + panic("validator and/or consensus address codec are nil") + } + + ccv.PanicIfZeroOrNil(k.cdc, "cdc") // 1 + ccv.PanicIfZeroOrNil(k.storeKey, "storeKey") // 2 + ccv.PanicIfZeroOrNil(k.scopedKeeper, "scopedKeeper") // 3 + ccv.PanicIfZeroOrNil(k.channelKeeper, "channelKeeper") // 4 + ccv.PanicIfZeroOrNil(k.portKeeper, "portKeeper") // 5 + ccv.PanicIfZeroOrNil(k.connectionKeeper, "connectionKeeper") // 6 + ccv.PanicIfZeroOrNil(k.accountKeeper, "accountKeeper") // 7 + ccv.PanicIfZeroOrNil(k.clientKeeper, "clientKeeper") // 8 + ccv.PanicIfZeroOrNil(k.stakingKeeper, "stakingKeeper") // 9 + ccv.PanicIfZeroOrNil(k.slashingKeeper, "slashingKeeper") // 10 + ccv.PanicIfZeroOrNil(k.distributionKeeper, "distributionKeeper") // 11 + ccv.PanicIfZeroOrNil(k.bankKeeper, "bankKeeper") // 12 + ccv.PanicIfZeroOrNil(k.feeCollectorName, "feeCollectorName") // 13 + ccv.PanicIfZeroOrNil(k.authority, "authority") // 14 + ccv.PanicIfZeroOrNil(k.validatorAddressCodec, "validatorAddressCodec") // 15 + ccv.PanicIfZeroOrNil(k.consensusAddressCodec, "consensusAddressCodec") // 16 + + // this can be nil in tests + // ccv.PanicIfZeroOrNil(k.govKeeper, "govKeeper") // 17 } // Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+ibchost.ModuleName+"-"+types.ModuleName) +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", "x/"+ibchost.ModuleName+"-"+types.ModuleName) } // IsBound checks if the CCV module is already bound to the desired port @@ -206,7 +235,7 @@ func (k Keeper) DeleteProposedConsumerChainInStore(ctx sdk.Context, proposalID u // GetAllProposedConsumerChainIDs returns the proposed chainID of all gov consumerAddition proposals that are still in the voting period. func (k Keeper) GetAllProposedConsumerChainIDs(ctx sdk.Context) []types.ProposedChain { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.ProposedConsumerChainByteKey}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ProposedConsumerChainByteKey}) defer iterator.Close() proposedChains := []types.ProposedChain{} @@ -247,7 +276,7 @@ func (k Keeper) GetAllRegisteredConsumerChainIDs(ctx sdk.Context) []string { chainIDs := []string{} store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.ChainToClientBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ChainToClientBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -290,7 +319,7 @@ func (k Keeper) DeleteChannelToChain(ctx sdk.Context, channelID string) { // Thus, the returned array is in ascending order of channelIDs. func (k Keeper) GetAllChannelToChains(ctx sdk.Context) (channels []types.ChannelToChain) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.ChannelToChainBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ChannelToChainBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -461,7 +490,7 @@ func (k Keeper) DeleteUnbondingOp(ctx sdk.Context, id uint64) { // Thus, the iteration is in ascending order of IDs. func (k Keeper) GetAllUnbondingOps(ctx sdk.Context) (ops []types.UnbondingOp) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.UnbondingOpBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.UnbondingOpBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -552,7 +581,7 @@ func (k Keeper) SetUnbondingOpIndex(ctx sdk.Context, chainID string, vscID uint6 // Thus, the returned array is in ascending order of vscIDs. func (k Keeper) GetAllUnbondingOpIndexes(ctx sdk.Context, chainID string) (indexes []types.VscUnbondingOps) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.UnbondingOpIndexBytePrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.UnbondingOpIndexBytePrefix, chainID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -751,7 +780,7 @@ func (k Keeper) GetValsetUpdateBlockHeight(ctx sdk.Context, valsetUpdateId uint6 // Thus, the returned array is in ascending order of vscIDs. func (k Keeper) GetAllValsetUpdateBlockHeights(ctx sdk.Context) (valsetUpdateBlockHeights []types.ValsetUpdateIdToHeight) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.ValsetUpdateBlockHeightBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.ValsetUpdateBlockHeightBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -957,7 +986,7 @@ func (k Keeper) DeleteInitTimeoutTimestamp(ctx sdk.Context, chainID string) { // Thus, the returned array is in ascending order of chainIDs (NOT in timestamp order). func (k Keeper) GetAllInitTimeoutTimestamps(ctx sdk.Context) (initTimeoutTimestamps []types.InitTimeoutTimestamp) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.InitTimeoutTimestampBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.InitTimeoutTimestampBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1021,7 +1050,7 @@ func (k Keeper) DeleteVscSendTimestamp(ctx sdk.Context, chainID string, vscID ui // Thus, the iteration is in ascending order of vscIDs, and as a result in send timestamp order. func (k Keeper) GetAllVscSendTimestamps(ctx sdk.Context, chainID string) (vscSendTimestamps []types.VscSendTimestamp) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, chainID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1050,7 +1079,8 @@ func (k Keeper) GetAllVscSendTimestamps(ctx sdk.Context, chainID string) (vscSen // DeleteVscSendTimestampsForConsumer deletes all VSC send timestamps for a given consumer chain func (k Keeper) DeleteVscSendTimestampsForConsumer(ctx sdk.Context, consumerChainID string) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, consumerChainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, consumerChainID)) + defer iterator.Close() keysToDel := [][]byte{} @@ -1067,7 +1097,7 @@ func (k Keeper) DeleteVscSendTimestampsForConsumer(ctx sdk.Context, consumerChai // GetFirstVscSendTimestamp gets the vsc send timestamp with the lowest vscID for the given chainID. func (k Keeper) GetFirstVscSendTimestamp(ctx sdk.Context, chainID string) (vscSendTimestamp types.VscSendTimestamp, found bool) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.VscSendTimestampBytePrefix, chainID)) defer iterator.Close() if iterator.Valid() { @@ -1115,7 +1145,7 @@ func (k Keeper) GetSlashLog( return bz != nil } -func (k Keeper) BondDenom(ctx sdk.Context) string { +func (k Keeper) BondDenom(ctx sdk.Context) (string, error) { return k.stakingKeeper.BondDenom(ctx) } @@ -1214,7 +1244,7 @@ func (k Keeper) GetAllOptedIn( ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.OptedInBytePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1231,7 +1261,7 @@ func (k Keeper) DeleteAllOptedIn( ) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.OptedInBytePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) var keysToDel [][]byte defer iterator.Close() @@ -1249,7 +1279,7 @@ func (k Keeper) SetConsumerCommissionRate( ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, - commissionRate sdk.Dec, + commissionRate math.LegacyDec, ) error { store := ctx.KVStore(k.storeKey) bz, err := commissionRate.Marshal() @@ -1269,18 +1299,18 @@ func (k Keeper) GetConsumerCommissionRate( ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, -) (sdk.Dec, bool) { +) (math.LegacyDec, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ConsumerCommissionRateKey(chainID, providerAddr)) if bz == nil { - return sdk.ZeroDec(), false + return math.LegacyZeroDec(), false } - cr := sdk.Dec{} + cr := math.LegacyZeroDec() // handle error gracefully since it's called in BeginBlockRD if err := cr.Unmarshal(bz); err != nil { k.Logger(ctx).Error("consumer commission rate unmarshalling failed: %s", err) - return sdk.ZeroDec(), false + return cr, false } return cr, true @@ -1294,7 +1324,7 @@ func (k Keeper) GetAllCommissionRateValidators( ) (addresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.ConsumerCommissionRatePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1405,7 +1435,7 @@ func (k Keeper) GetAllowList( ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.AllowlistPrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1429,7 +1459,7 @@ func (k Keeper) IsAllowlisted( // DeleteAllowlist deletes all allowlisted validators func (k Keeper) DeleteAllowlist(ctx sdk.Context, chainID string) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistPrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistPrefix, chainID)) defer iterator.Close() keysToDel := [][]byte{} @@ -1445,7 +1475,7 @@ func (k Keeper) DeleteAllowlist(ctx sdk.Context, chainID string) { // IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `chainID` func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, chainID string) bool { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistPrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistPrefix, chainID)) defer iterator.Close() return !iterator.Valid() @@ -1468,7 +1498,7 @@ func (k Keeper) GetDenyList( ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.DenylistPrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -1492,7 +1522,7 @@ func (k Keeper) IsDenylisted( // DeleteDenylist deletes all denylisted validators func (k Keeper) DeleteDenylist(ctx sdk.Context, chainID string) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistPrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistPrefix, chainID)) defer iterator.Close() keysToDel := [][]byte{} @@ -1508,7 +1538,7 @@ func (k Keeper) DeleteDenylist(ctx sdk.Context, chainID string) { // IsDenylistEmpty returns `true` if no validator is denylisted on chain `chainID` func (k Keeper) IsDenylistEmpty(ctx sdk.Context, chainID string) bool { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistPrefix, chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistPrefix, chainID)) defer iterator.Close() return !iterator.Valid() diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 9a064a0389..e61a93cda1 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -7,19 +7,19 @@ import ( "testing" "time" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + "cosmossdk.io/math" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const consumer = "consumer" @@ -161,7 +161,7 @@ func TestPendingVSCs(t *testing.T) { _, pks, _ := ibctesting.GenerateKeys(t, 4) var ppks [4]tmprotocrypto.PublicKey for i, pk := range pks { - ppks[i], _ = cryptocodec.ToTmProtoPublicKey(pk) + ppks[i], _ = cryptocodec.ToCmtProtoPublicKey(pk) } packetList := []ccv.ValidatorSetChangePacketData{ @@ -718,17 +718,17 @@ func TestConsumerCommissionRate(t *testing.T) { cr, found := providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) require.False(t, found) - require.Equal(t, sdk.ZeroDec(), cr) + require.Equal(t, math.LegacyZeroDec(), cr) - providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr1, sdk.OneDec()) + providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr1, math.LegacyOneDec()) cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) require.True(t, found) - require.Equal(t, sdk.OneDec(), cr) + require.Equal(t, math.LegacyOneDec(), cr) - providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr2, sdk.ZeroDec()) + providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr2, math.LegacyZeroDec()) cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr2) require.True(t, found) - require.Equal(t, sdk.ZeroDec(), cr) + require.Equal(t, math.LegacyZeroDec(), cr) provAddrs := providerKeeper.GetAllCommissionRateValidators(ctx, "chainID") require.Len(t, provAddrs, 2) diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index 67f4d89fdd..596c3be606 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -5,14 +5,15 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // ParseConsumerKey parses the ED25519 PubKey`consumerKey` from a JSON string @@ -117,7 +118,7 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, chainID *string) // iterate over the validators public keys assigned for chainID prefix = types.ChainIdWithLenKey(types.ConsumerValidatorsBytePrefix, *chainID) } - iterator := sdk.KVStorePrefixIterator(store, prefix) + iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // TODO: store chainID and provider cons address in value bytes, marshaled as protobuf type @@ -201,7 +202,7 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, chainID *string) // iterate over the mappings from consensus addresses on chainID prefix = types.ChainIdWithLenKey(types.ValidatorsByConsumerAddrBytePrefix, *chainID) } - iterator := sdk.KVStorePrefixIterator(store, prefix) + iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // TODO: store chainID and consumer cons address in value bytes, marshaled as protobuf type @@ -290,7 +291,7 @@ func (k Keeper) GetConsumerAddrsToPrune( func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, chainID string) (consumerAddrsToPrune []types.ConsumerAddrsToPrune) { store := ctx.KVStore(k.storeKey) iteratorPrefix := types.ChainIdWithLenKey(types.ConsumerAddrsToPruneBytePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, iteratorPrefix) + iterator := storetypes.KVStorePrefixIterator(store, iteratorPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { _, vscID, err := types.ParseChainIdAndUintIdKey(types.ConsumerAddrsToPruneBytePrefix, iterator.Key()) @@ -352,7 +353,7 @@ func (k Keeper) AssignConsumerKey( } providerAddr := types.NewProviderConsAddress(consAddrTmp) - if existingVal, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, consumerAddr.ToSdkConsAddr()); found { + if existingVal, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consumerAddr.ToSdkConsAddr()); err == nil { // If there is already a different validator using the consumer key to validate on the provider // we prevent assigning the consumer key. if existingVal.OperatorAddress != validator.OperatorAddress { @@ -502,10 +503,10 @@ func (k Keeper) IsConsumerProposedOrRegistered(ctx sdk.Context, chainID string) // In case it panics, the TX aborts and thus, the validator is not created. See AfterValidatorCreated hook. func (k Keeper) ValidatorConsensusKeyInUse(ctx sdk.Context, valAddr sdk.ValAddress) bool { // Get the validator being added in the staking module. - val, found := k.stakingKeeper.GetValidator(ctx, valAddr) - if !found { + val, err := k.stakingKeeper.GetValidator(ctx, valAddr) + if err != nil { // Abort TX, do NOT allow validator to be created - panic("did not find newly created validator in staking module") + panic(fmt.Errorf("error finding newly created validator in staking module: %w", err)) } // Get the consensus address of the validator being added diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index abf7858d40..2f67890b00 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -17,11 +17,11 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ChainID = "chainID" @@ -357,11 +357,11 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { }, { name: "1", - mockSetup: func(ctx sdk.Context, k providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { + mockSetup: func(sdkCtx sdk.Context, k providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { gomock.InOrder( - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(sdkCtx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -379,29 +379,30 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { }, { name: "2", - mockSetup: func(ctx sdk.Context, k providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { + mockSetup: func(sdkCtx sdk.Context, k providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { + ctx := sdk.WrapSDKContext(sdkCtx) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[1].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, - doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerClientId(ctx, chainID, "") - err := k.AssignConsumerKey(ctx, chainID, + doActions: func(sdkCtx sdk.Context, k providerkeeper.Keeper) { + k.SetConsumerClientId(sdkCtx, chainID, "") + err := k.AssignConsumerKey(sdkCtx, chainID, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - err = k.AssignConsumerKey(ctx, chainID, + err = k.AssignConsumerKey(sdkCtx, chainID, providerIdentities[0].SDKStakingValidator(), consumerIdentities[1].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(sdkCtx, chainID, consumerIdentities[1].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -413,10 +414,10 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -443,7 +444,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, providerIdentities[0].SDKValConsAddress(), - ).Return(providerIdentities[0].SDKStakingValidator(), true), + ).Return(providerIdentities[0].SDKStakingValidator(), nil), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -461,7 +462,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -483,10 +484,10 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[1].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -513,10 +514,10 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, consumerIdentities[0].SDKValConsAddress(), - ).Return(stakingtypes.Validator{}, false), + ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -543,7 +544,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, providerIdentities[0].SDKValConsAddress(), - ).Return(providerIdentities[0].SDKStakingValidator(), true), + ).Return(providerIdentities[0].SDKStakingValidator(), nil), ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { @@ -591,7 +592,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, cId.SDKValConsAddress(), - ).Return(cId.SDKStakingValidator(), true), // found = true + ).Return(cId.SDKStakingValidator(), nil), // nil == no error ) // AssignConsumerKey should return an error if we try to re-assign the already existing default key assignment @@ -726,12 +727,12 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower( gomock.Any(), gomock.Any(), - ).DoAndReturn(func(_ interface{}, valAddr sdk.ValAddress) int64 { + ).DoAndReturn(func(_ interface{}, valAddr sdk.ValAddress) (int64, error) { // When the mocked method is called, locate the appropriate validator // in the provider valset and return its power. for i, id := range providerIDS { - if id.SDKStakingValidator().GetOperator().Equals(valAddr) { - return providerValset.power[i] + if id.SDKStakingValidator().GetOperator() == valAddr.String() { + return providerValset.power[i], nil } } panic("must find validator") @@ -784,7 +785,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { applyAssignments := func(assignments []Assignment) { for _, a := range assignments { // ignore err return, it can be possible for an error to occur - _ = k.AssignConsumerKey(ctx, CHAINID, a.val, a.ck) + _ = k.AssignConsumerKey(ctx, ChainID, a.val, a.ck) } } @@ -799,7 +800,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { applyUpdatesAndIncrementVSCID(stakingUpdates) // Register the consumer chain - k.SetConsumerClientId(ctx, CHAINID, "") + k.SetConsumerClientId(ctx, ChainID, "") // Analogous to the last vscid received from the consumer in a maturity // Used to check the correct pruning property @@ -822,7 +823,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { prunedVscid := greatestPrunedVSCID + // +1 and -1 because id was incremented (-1), (+1) to make upper bound inclusive rng.Intn(int(k.GetValidatorSetUpdateId(ctx))+1-1-greatestPrunedVSCID) - k.PruneKeyAssignments(ctx, CHAINID, uint64(prunedVscid)) + k.PruneKeyAssignments(ctx, ChainID, uint64(prunedVscid)) greatestPrunedVSCID = prunedVscid /* @@ -842,7 +843,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { // For each active validator on the provider chain if 0 < providerValset.power[i] { // Get the assigned key - ck, found := k.GetValidatorConsumerPubKey(ctx, CHAINID, idP.ProviderConsAddress()) + ck, found := k.GetValidatorConsumerPubKey(ctx, ChainID, idP.ProviderConsAddress()) if !found { // Use default if unassigned ck = idP.TMProtoCryptoPublicKey() @@ -864,7 +865,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { consC := consumerValset.identities[i].ConsumerConsAddress() if 0 < consumerValset.power[i] { // Get the provider who assigned the key - consP := k.GetProviderAddrFromConsumerAddr(ctx, CHAINID, consC) + consP := k.GetProviderAddrFromConsumerAddr(ctx, ChainID, consC) // Find the corresponding provider validator (must always be found) for j, idP := range providerValset.identities { if idP.SDKValConsAddress().Equals(consP.ToSdkConsAddr()) { @@ -880,7 +881,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { Check that all keys have been or will eventually be pruned. */ - require.True(t, checkCorrectPruningProperty(ctx, k, CHAINID)) + require.True(t, checkCorrectPruningProperty(ctx, k, ChainID)) /* Property: Correct Consumer Initiated Slash Lookup @@ -898,7 +899,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { consC := consumerValset.identities[i].ConsumerConsAddress() if 0 < consumerValset.power[i] { // Get the provider who assigned the key - consP := k.GetProviderAddrFromConsumerAddr(ctx, CHAINID, consC) + consP := k.GetProviderAddrFromConsumerAddr(ctx, ChainID, consC) if _, found := historicSlashQueries[consC.String()]; !found { historicSlashQueries[consC.String()] = map[uint64]string{} diff --git a/x/ccv/provider/keeper/legacy_proposal.go b/x/ccv/provider/keeper/legacy_proposal.go new file mode 100644 index 0000000000..19ad553038 --- /dev/null +++ b/x/ccv/provider/keeper/legacy_proposal.go @@ -0,0 +1,142 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" +) + +func (k Keeper) HandleLegacyConsumerRewardDenomProposal(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 +} + +// HandleConsumerAdditionProposal will receive the consumer chain's client state from the proposal. +// If the client can be successfully created in a cached context, it stores the proposal as a pending proposal. +// +// Note: This method implements SpawnConsumerChainProposalHandler in spec. +// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 +// Spec tag: [CCV-PCF-HCAPROP.1] +func (k Keeper) HandleLegacyConsumerAdditionProposal(ctx sdk.Context, p *types.ConsumerAdditionProposal) error { + // verify the consumer addition proposal execution + // in cached context and discard the cached writes + if _, _, err := k.CreateConsumerClientInCachedCtx(ctx, *p); err != nil { + return err + } + + k.SetPendingConsumerAdditionProp(ctx, p) + + k.Logger(ctx).Info("consumer addition proposal enqueued", + "chainID", p.ChainId, + "title", p.Title, + "spawn time", p.SpawnTime.UTC(), + ) + + return nil +} + +// HandleConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. +// If the consumer can be successfully stopped in a cached context, it stores the proposal as a pending proposal. +// +// This method implements StopConsumerChainProposalHandler from spec. +// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 +// Spec tag: [CCV-PCF-HCRPROP.1] +func (k Keeper) HandleLegacyConsumerRemovalProposal(ctx sdk.Context, p *types.ConsumerRemovalProposal) error { + // verify the consumer removal proposal execution + // in cached context and discard the cached writes + if _, _, err := k.StopConsumerChainInCachedCtx(ctx, *p); err != nil { + return err + } + + k.SetPendingConsumerRemovalProp(ctx, p) + + k.Logger(ctx).Info("consumer removal proposal enqueued", + "chainID", p.ChainId, + "title", p.Title, + "stop time", p.StopTime.UTC(), + ) + + return nil +} + +// HandleConsumerModificationProposal modifies a running consumer chain +func (k Keeper) HandleLegacyConsumerModificationProposal(ctx sdk.Context, p *types.ConsumerModificationProposal) error { + if _, found := k.GetConsumerClientId(ctx, p.ChainId); !found { + return errorsmod.Wrapf(types.ErrInvalidConsumerChainID, "consumer %s chain is not running", p.ChainId) + } + + k.SetTopN(ctx, p.ChainId, p.Top_N) + k.SetValidatorsPowerCap(ctx, p.ChainId, p.ValidatorsPowerCap) + k.SetValidatorSetCap(ctx, p.ChainId, p.ValidatorSetCap) + + k.DeleteAllowlist(ctx, p.ChainId) + for _, address := range p.Allowlist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetAllowlist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) + } + + k.DeleteDenylist(ctx, p.ChainId) + for _, address := range p.Denylist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetDenylist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) + } + + oldTopN, found := k.GetTopN(ctx, p.ChainId) + if !found { + oldTopN = 0 + k.Logger(ctx).Info("consumer chain top N not found, treating as 0", "chainID", p.ChainId) + } + + // if the top N changes, we need to update the new minimum power in top N + if p.Top_N != oldTopN { + if p.Top_N > 0 { + // if the chain receives a non-zero top N value, store the minimum power in the top N + bondedValidators, err := k.GetLastBondedValidators(ctx) + if err != nil { + return err + } + minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, p.Top_N) + if err != nil { + return err + } + k.SetMinimumPowerInTopN(ctx, p.ChainId, minPower) + } else { + // if the chain receives a zero top N value, we delete the min power + k.DeleteMinimumPowerInTopN(ctx, p.ChainId) + } + } + + return nil +} diff --git a/x/ccv/provider/keeper/legacy_proposal_test.go b/x/ccv/provider/keeper/legacy_proposal_test.go new file mode 100644 index 0000000000..06533a2503 --- /dev/null +++ b/x/ccv/provider/keeper/legacy_proposal_test.go @@ -0,0 +1,318 @@ +package keeper_test + +import ( + "testing" + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" +) + +// +// Initialization sub-protocol related tests of proposal.go +// + +// Tests the HandleConsumerAdditionProposal method against the SpawnConsumerChainProposalHandler spec. +// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 +// Spec tag: [CCV-PCF-HCAPROP.1] +func TestHandleLegacyConsumerAdditionProposal(t *testing.T) { + type testCase struct { + description string + malleate func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) + prop *providertypes.ConsumerAdditionProposal + // Time when prop is handled + blockTime time.Time + // Whether it's expected that the proposal is successfully verified + // and appended to the pending proposals + expAppendProp bool + } + + // Snapshot times asserted in tests + now := time.Now().UTC() + + tests := []testCase{ + { + description: "expect to append valid proposal", + malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, + prop: providertypes.NewConsumerAdditionProposal( + "title", + "description", + "chainID", + clienttypes.NewHeight(2, 3), + []byte("gen_hash"), + []byte("bin_hash"), + now, // Spawn time + "0.75", + 10, + "", + 10000, + 100000000000, + 100000000000, + 100000000000, + 0, + 0, + 0, + nil, + nil, + ).(*providertypes.ConsumerAdditionProposal), + blockTime: now, + expAppendProp: true, + }, + { + description: "expect to not append invalid proposal using an already existing chain id", + malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { + k.SetConsumerClientId(ctx, chainID, "anyClientId") + }, + + prop: providertypes.NewConsumerAdditionProposal( + "title", + "description", + "chainID", + clienttypes.NewHeight(2, 3), + []byte("gen_hash"), + []byte("bin_hash"), + now, + "0.75", + 10, + "", + 10000, + 100000000000, + 100000000000, + 100000000000, + 0, + 0, + 0, + nil, + nil, + ).(*providertypes.ConsumerAdditionProposal), + blockTime: now, + expAppendProp: false, + }, + } + + for _, tc := range tests { + // Common setup + keeperParams := testkeeper.NewInMemKeeperParams(t) + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + ctx = ctx.WithBlockTime(tc.blockTime) + + if tc.expAppendProp { + // Mock calls are only asserted if we expect a client to be created. + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{}, []int64{}, 1) + gomock.InOrder( + testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, tc.prop.ChainId, clienttypes.NewHeight(2, 3))..., + ) + } + + tc.malleate(ctx, providerKeeper, tc.prop.ChainId) + + err := providerKeeper.HandleLegacyConsumerAdditionProposal(ctx, tc.prop) + + if tc.expAppendProp { + require.NoError(t, err) + // check that prop was added to the stored pending props + gotProposal, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) + require.True(t, found) + require.Equal(t, *tc.prop, gotProposal) + } else { + require.Error(t, err) + // check that prop wasn't added to the stored pending props + _, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) + require.False(t, found) + } + + ctrl.Finish() + } +} + +// TestHandleConsumerRemovalProposal tests HandleConsumerRemovalProposal against its corresponding spec method. +// +// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 +// Spec tag: [CCV-PCF-HCRPROP.1] +func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { + type testCase struct { + description string + setupMocks func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) + + // Consumer removal proposal to handle + prop *providertypes.ConsumerRemovalProposal + // Time when prop is handled + blockTime time.Time + // Whether it's expected that the proposal is successfully verified + // and appended to the pending proposals + expAppendProp bool + + // chainID of the consumer chain + // tests need to check that the CCV channel is not closed prematurely + chainId string + } + + // Snapshot times asserted in tests + now := time.Now().UTC() + hourAfterNow := now.Add(time.Hour).UTC() + hourBeforeNow := now.Add(-time.Hour).UTC() + + tests := []testCase{ + { + description: "valid proposal", + setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { + k.SetConsumerClientId(ctx, chainID, "ClientID") + }, + prop: providertypes.NewConsumerRemovalProposal( + "title", + "description", + "chainID", + now, + ).(*providertypes.ConsumerRemovalProposal), + blockTime: hourAfterNow, // After stop time. + expAppendProp: true, + chainId: "chainID", + }, + { + description: "valid proposal - stop_time in the past", + setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { + k.SetConsumerClientId(ctx, chainID, "ClientID") + }, + prop: providertypes.NewConsumerRemovalProposal( + "title", + "description", + "chainID", + hourBeforeNow, + ).(*providertypes.ConsumerRemovalProposal), + blockTime: hourAfterNow, // After stop time. + expAppendProp: true, + chainId: "chainID", + }, + { + description: "valid proposal - before stop_time in the future", + setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { + k.SetConsumerClientId(ctx, chainID, "ClientID") + }, + prop: providertypes.NewConsumerRemovalProposal( + "title", + "description", + "chainID", + hourAfterNow, + ).(*providertypes.ConsumerRemovalProposal), + blockTime: now, + expAppendProp: true, + chainId: "chainID", + }, + { + description: "rejected valid proposal - consumer chain does not exist", + setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, + prop: providertypes.NewConsumerRemovalProposal( + "title", + "description", + "chainID-2", + hourAfterNow, + ).(*providertypes.ConsumerRemovalProposal), + blockTime: hourAfterNow, // After stop time. + expAppendProp: false, + chainId: "chainID-2", + }, + } + + for _, tc := range tests { + + // Common setup + keeperParams := testkeeper.NewInMemKeeperParams(t) + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + ctx = ctx.WithBlockTime(tc.blockTime) + + // Mock expectations and setup for stopping the consumer chain, if applicable + // Note: when expAppendProp is false, no mocks are setup, + // meaning no external keeper methods are allowed to be called. + if tc.expAppendProp { + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + // Valid client creation is asserted with mock expectations here + gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + } + + tc.setupMocks(ctx, providerKeeper, tc.prop.ChainId) + + err := providerKeeper.HandleLegacyConsumerRemovalProposal(ctx, tc.prop) + + if tc.expAppendProp { + require.NoError(t, err) + + // Proposal should be stored as pending + found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) + require.True(t, found) + + // confirm that the channel was not closed + _, found = providerKeeper.GetChainToChannel(ctx, tc.chainId) + require.True(t, found) + } else { + require.Error(t, err) + + // Expect no pending proposal to exist + found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) + require.False(t, found) + } + + // Assert mock calls from setup function + ctrl.Finish() + } +} + +func TestHandleConsumerModificationProposal(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + chainID := "chainID" + + // set up a consumer client, so it seems that "chainID" is running + providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + + // set PSS-related fields to update them later on + providerKeeper.SetTopN(ctx, chainID, 50) + providerKeeper.SetValidatorSetCap(ctx, chainID, 10) + providerKeeper.SetValidatorsPowerCap(ctx, chainID, 34) + providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr1"))) + providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr2"))) + providerKeeper.SetDenylist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("denylistedAddr1"))) + + expectedTopN := uint32(75) + expectedValidatorsPowerCap := uint32(67) + expectedValidatorSetCap := uint32(20) + expectedAllowlistedValidator := "cosmosvalcons1wpex7anfv3jhystyv3eq20r35a" + expectedDenylistedValidator := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + proposal := providertypes.NewConsumerModificationProposal("title", "description", chainID, + expectedTopN, + expectedValidatorsPowerCap, + expectedValidatorSetCap, + []string{expectedAllowlistedValidator}, + []string{expectedDenylistedValidator}, + ).(*providertypes.ConsumerModificationProposal) + + err := providerKeeper.HandleLegacyConsumerModificationProposal(ctx, proposal) + require.NoError(t, err) + + actualTopN, _ := providerKeeper.GetTopN(ctx, chainID) + require.Equal(t, expectedTopN, actualTopN) + actualValidatorsPowerCap, _ := providerKeeper.GetValidatorsPowerCap(ctx, chainID) + require.Equal(t, expectedValidatorsPowerCap, actualValidatorsPowerCap) + actualValidatorSetCap, _ := providerKeeper.GetValidatorSetCap(ctx, chainID) + require.Equal(t, expectedValidatorSetCap, actualValidatorSetCap) + + allowlistedValidator, err := sdk.ConsAddressFromBech32(expectedAllowlistedValidator) + require.NoError(t, err) + require.Equal(t, 1, len(providerKeeper.GetAllowList(ctx, chainID))) + require.Equal(t, providertypes.NewProviderConsAddress(allowlistedValidator), providerKeeper.GetAllowList(ctx, chainID)[0]) + + denylistedValidator, err := sdk.ConsAddressFromBech32(expectedDenylistedValidator) + require.NoError(t, err) + require.Equal(t, 1, len(providerKeeper.GetDenyList(ctx, chainID))) + require.Equal(t, providertypes.NewProviderConsAddress(denylistedValidator), providerKeeper.GetDenyList(ctx, chainID)[0]) +} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index c4c7a04085..08429c55a8 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -7,12 +7,13 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) type msgServer struct { @@ -27,6 +28,22 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { var _ types.MsgServer = msgServer{} +// UpdateParams updates the params. +func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + } + + if err := msg.Params.Validate(); err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.Keeper.SetParams(ctx, msg.Params) + + return &types.MsgUpdateParamsResponse{}, nil +} + // AssignConsumerKey defines a method to assign a consensus key on a consumer chain // for a given validator on the provider func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssignConsumerKey) (*types.MsgAssignConsumerKeyResponse, error) { @@ -38,9 +55,11 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign } // validator must already be registered - validator, found := k.stakingKeeper.GetValidator(ctx, providerValidatorAddr) - if !found { + validator, err := k.stakingKeeper.GetValidator(ctx, providerValidatorAddr) + if err != nil && err == stakingtypes.ErrNoValidatorFound { return nil, stakingtypes.ErrNoValidatorFound + } else if err != nil { + return nil, err } consumerTMPublicKey, err := k.ParseConsumerKey(msg.ConsumerKey) @@ -68,6 +87,52 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign return &types.MsgAssignConsumerKeyResponse{}, nil } +// ConsumerAddition defines an RPC handler method for MsgConsumerAddition +func (k msgServer) ConsumerAddition(goCtx context.Context, msg *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + err := k.Keeper.HandleConsumerAdditionProposal(ctx, msg) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") + } + return &types.MsgConsumerAdditionResponse{}, nil +} + +// ConsumerRemoval defines an RPC handler method for MsgConsumerRemoval +func (k msgServer) ConsumerRemoval( + goCtx context.Context, + msg *types.MsgConsumerRemoval) (*types.MsgConsumerRemovalResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + err := k.Keeper.HandleConsumerRemovalProposal(ctx, msg) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") + } + + return &types.MsgConsumerRemovalResponse{}, nil +} + +// ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms +func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChangeRewardDenoms) (*types.MsgChangeRewardDenomsResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + sdkCtx := sdk.UnwrapSDKContext(goCtx) + err := k.Keeper.HandleConsumerRewardDenomProposal(sdkCtx, msg) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed handling Change Reward Denoms proposal") + } + + return &types.MsgChangeRewardDenomsResponse{}, nil +} + func (k msgServer) SubmitConsumerMisbehaviour(goCtx context.Context, msg *types.MsgSubmitConsumerMisbehaviour) (*types.MsgSubmitConsumerMisbehaviourResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := k.Keeper.HandleConsumerMisbehaviour(ctx, *msg.Misbehaviour); err != nil { @@ -146,9 +211,9 @@ func (k msgServer) OptIn(goCtx context.Context, msg *types.MsgOptIn) (*types.Msg } // validator must already be registered - validator, found := k.stakingKeeper.GetValidator(ctx, valAddress) - if !found { - return nil, stakingtypes.ErrNoValidatorFound + validator, err := k.stakingKeeper.GetValidator(ctx, valAddress) + if err != nil { + return nil, err } consAddrTmp, err := validator.GetConsAddr() @@ -182,9 +247,9 @@ func (k msgServer) OptOut(goCtx context.Context, msg *types.MsgOptOut) (*types.M } // validator must already be registered - validator, found := k.stakingKeeper.GetValidator(ctx, valAddress) - if !found { - return nil, stakingtypes.ErrNoValidatorFound + validator, err := k.stakingKeeper.GetValidator(ctx, valAddress) + if err != nil { + return nil, err } consAddrTmp, err := validator.GetConsAddr() @@ -217,8 +282,8 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M } // validator must already be registered - validator, found := k.stakingKeeper.GetValidator(ctx, providerValidatorAddr) - if !found { + validator, err := k.stakingKeeper.GetValidator(ctx, providerValidatorAddr) + if err != nil { return nil, stakingtypes.ErrNoValidatorFound } @@ -242,3 +307,17 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M return &types.MsgSetConsumerCommissionRateResponse{}, nil } + +func (k msgServer) ConsumerModification(goCtx context.Context, msg *types.MsgConsumerModification) (*types.MsgConsumerModificationResponse, error) { + if k.GetAuthority() != msg.Authority { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + err := k.Keeper.HandleConsumerModificationProposal(ctx, msg) + if err != nil { + return nil, errorsmod.Wrapf(err, "failed handling ConsumerModification proposal") + } + + return &types.MsgConsumerModificationResponse{}, nil +} diff --git a/x/ccv/provider/keeper/params.go b/x/ccv/provider/keeper/params.go index b5854e5b59..da3dda92b7 100644 --- a/x/ccv/provider/keeper/params.go +++ b/x/ccv/provider/keeper/params.go @@ -1,115 +1,105 @@ package keeper import ( + "fmt" "time" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // GetTemplateClient returns the template client for provider proposals func (k Keeper) GetTemplateClient(ctx sdk.Context) *ibctmtypes.ClientState { - var cs ibctmtypes.ClientState - k.paramSpace.Get(ctx, types.KeyTemplateClient, &cs) - return &cs + params := k.GetParams(ctx) + return params.TemplateClient } // GetTrustingPeriodFraction returns a TrustingPeriodFraction // used to compute the provider IBC client's TrustingPeriod as UnbondingPeriod / TrustingPeriodFraction func (k Keeper) GetTrustingPeriodFraction(ctx sdk.Context) string { - var f string - k.paramSpace.Get(ctx, types.KeyTrustingPeriodFraction, &f) - return f + params := k.GetParams(ctx) + return params.TrustingPeriodFraction } // GetCCVTimeoutPeriod returns the timeout period for sent ibc packets func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { - var p time.Duration - k.paramSpace.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) - return p + params := k.GetParams(ctx) + return params.CcvTimeoutPeriod } // GetInitTimeoutPeriod returns the init timeout period func (k Keeper) GetInitTimeoutPeriod(ctx sdk.Context) time.Duration { - var p time.Duration - k.paramSpace.Get(ctx, types.KeyInitTimeoutPeriod, &p) - return p + params := k.GetParams(ctx) + return params.InitTimeoutPeriod } // GetVscTimeoutPeriod returns the vsc timeout period func (k Keeper) GetVscTimeoutPeriod(ctx sdk.Context) time.Duration { - var p time.Duration - k.paramSpace.Get(ctx, types.KeyVscTimeoutPeriod, &p) - return p + params := k.GetParams(ctx) + return params.VscTimeoutPeriod } // SetVscTimeoutPeriod sets the vsc timeout period func (k Keeper) SetVscTimeoutPeriod(ctx sdk.Context, period time.Duration) { - k.paramSpace.Set(ctx, types.KeyVscTimeoutPeriod, period) + params := k.GetParams(ctx) + params.VscTimeoutPeriod = period + k.SetParams(ctx, params) } // GetSlashMeterReplenishPeriod returns the period in which: // Once the slash meter becomes not-full, the slash meter is replenished after this period. func (k Keeper) GetSlashMeterReplenishPeriod(ctx sdk.Context) time.Duration { - var p time.Duration - k.paramSpace.Get(ctx, types.KeySlashMeterReplenishPeriod, &p) - return p + params := k.GetParams(ctx) + return params.SlashMeterReplenishPeriod } // GetSlashMeterReplenishFraction returns the string fraction of total voting power 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. func (k Keeper) GetSlashMeterReplenishFraction(ctx sdk.Context) string { - var f string - k.paramSpace.Get(ctx, types.KeySlashMeterReplenishFraction, &f) - return f + params := k.GetParams(ctx) + return params.SlashMeterReplenishFraction } 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 // need to run migrations to add the param. This will allow us to change the fee by governance. - var c sdk.Coin - k.paramSpace.Get(ctx, types.KeyConsumerRewardDenomRegistrationFee, &c) - return c + params := k.GetParams(ctx) + return params.ConsumerRewardDenomRegistrationFee } // GetBlocksPerEpoch returns the number of blocks that constitute an epoch func (k Keeper) GetBlocksPerEpoch(ctx sdk.Context) int64 { - var b int64 - k.paramSpace.Get(ctx, types.KeyBlocksPerEpoch, &b) - return b + params := k.GetParams(ctx) + return params.BlocksPerEpoch } // GetNumberOfEpochsToStartReceivingRewards returns the number of epochs needed by a validator to continuously validate // to start receiving rewards func (k Keeper) GetNumberOfEpochsToStartReceivingRewards(ctx sdk.Context) int64 { - var b int64 - k.paramSpace.Get(ctx, types.KeyNumberOfEpochsToStartReceivingRewards, &b) - return b + params := k.GetParams(ctx) + return params.NumberOfEpochsToStartReceivingRewards } // GetParams returns the paramset for the provider module func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams( - k.GetTemplateClient(ctx), - k.GetTrustingPeriodFraction(ctx), - k.GetCCVTimeoutPeriod(ctx), - k.GetInitTimeoutPeriod(ctx), - k.GetVscTimeoutPeriod(ctx), - k.GetSlashMeterReplenishPeriod(ctx), - k.GetSlashMeterReplenishFraction(ctx), - k.GetConsumerRewardDenomRegistrationFee(ctx), - k.GetBlocksPerEpoch(ctx), - k.GetNumberOfEpochsToStartReceivingRewards(ctx), - ) + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParametersKey()) + var params types.Params + err := k.cdc.Unmarshal(bz, ¶ms) + if err != nil { + panic(fmt.Sprintf("error unmarshalling module parameters: %v:", err)) + } + return params } // SetParams sets the params for the provider module func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramSpace.SetParamSet(ctx, ¶ms) + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParametersKey(), bz) } diff --git a/x/ccv/provider/keeper/params_test.go b/x/ccv/provider/keeper/params_test.go index 9dd10076a6..cb1dc3cfe0 100644 --- a/x/ccv/provider/keeper/params_test.go +++ b/x/ccv/provider/keeper/params_test.go @@ -4,15 +4,16 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestParams tests the getting/setting of provider ccv module params. @@ -46,7 +47,7 @@ func TestParams(t *testing.T) { "0.4", sdk.Coin{ Denom: "stake", - Amount: sdk.NewInt(10000000), + Amount: math.NewInt(10000000), }, 600, 24, diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index fe7a18714b..069eb219dc 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -5,11 +5,12 @@ import ( "sort" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // HandleOptIn prepares validator `providerAddr` to opt in to `chainID` with an optional `consumerKey` consumer public key. @@ -29,9 +30,9 @@ func (k Keeper) HandleOptIn(ctx sdk.Context, chainID string, providerAddr types. return err } - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.Address) - if !found { - return stakingtypes.ErrNoValidatorFound + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.Address) + if err != nil { + return err } err = k.AssignConsumerKey(ctx, chainID, validator, consumerTMPublicKey) @@ -56,13 +57,18 @@ func (k Keeper) HandleOptOut(ctx sdk.Context, chainID string, providerAddr types if topN, found := k.GetTopN(ctx, chainID); found && topN > 0 { // a validator cannot opt out from a Top N chain if the validator is in the Top N validators - validator, validatorFound := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) - if !validatorFound { - return errorsmod.Wrapf( - stakingtypes.ErrNoValidatorFound, - "validator with consensus address %s could not be found", providerAddr.ToSdkConsAddr()) + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) + if err != nil { + return err + } + valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) + if err != nil { + return err + } + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + return err } - power := k.stakingKeeper.GetLastValidatorPower(ctx, validator.GetOperator()) minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, chainID) if !found { return errorsmod.Wrapf( @@ -85,13 +91,23 @@ func (k Keeper) HandleOptOut(ctx sdk.Context, chainID string, providerAddr types // OptInTopNValidators opts in to `chainID` all the `bondedValidators` that have at least `minPowerToOptIn` power func (k Keeper) OptInTopNValidators(ctx sdk.Context, chainID string, bondedValidators []stakingtypes.Validator, minPowerToOptIn int64) { for _, val := range bondedValidators { - power := k.stakingKeeper.GetLastValidatorPower(ctx, val.GetOperator()) + valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) + if err != nil { + k.Logger(ctx).Error("could not retrieve validator address: %s: %s", + val.GetOperator(), err) + continue + } + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + k.Logger(ctx).Error("could not retrieve last power of validator address: %s: %s", + val.GetOperator(), err) + continue + } if power >= minPowerToOptIn { consAddr, err := val.GetConsAddr() if err != nil { - k.Logger(ctx).Error("could not retrieve validators consensus address", - "validator", val, - "error", err) + k.Logger(ctx).Error("could not retrieve validators consensus address: %s: %s", + val, err) continue } @@ -112,13 +128,20 @@ func (k Keeper) ComputeMinPowerInTopN(ctx sdk.Context, bondedValidators []stakin " topN value (%d). topN has to be in (0, 100]", topN) } - totalPower := sdk.ZeroDec() + totalPower := math.LegacyZeroDec() var powers []int64 for _, val := range bondedValidators { - power := k.stakingKeeper.GetLastValidatorPower(ctx, val.GetOperator()) + valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) + if err != nil { + return 0, err + } + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + return 0, err + } powers = append(powers, power) - totalPower = totalPower.Add(sdk.NewDec(power)) + totalPower = totalPower.Add(math.LegacyNewDec(power)) } // sort by powers descending @@ -126,10 +149,10 @@ func (k Keeper) ComputeMinPowerInTopN(ctx sdk.Context, bondedValidators []stakin return powers[i] > powers[j] }) - topNThreshold := sdk.NewDec(int64(topN)).QuoInt64(int64(100)) - powerSum := sdk.ZeroDec() + topNThreshold := math.LegacyNewDec(int64(topN)).QuoInt64(int64(100)) + powerSum := math.LegacyZeroDec() for _, power := range powers { - powerSum = powerSum.Add(sdk.NewDec(power)) + powerSum = powerSum.Add(math.LegacyNewDec(power)) if powerSum.Quo(totalPower).GTE(topNThreshold) { return power, nil } @@ -212,7 +235,7 @@ func NoMoreThanPercentOfTheSum(validators []types.ConsumerValidator, percent uin // ---------------- // Computes `floor((sum(validators) * percent) / 100)` - maxPower := sdk.NewDec(sum(validators)).Mul(sdk.NewDec(int64(percent))).QuoInt64(100).TruncateInt64() + maxPower := math.LegacyNewDec(sum(validators)).Mul(math.LegacyNewDec(int64(percent))).QuoInt64(100).TruncateInt64() if maxPower == 0 { // edge case: set `maxPower` to 1 to avoid setting the power of a validator to 0 diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index bc0396d428..2dfbfd3b82 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -2,10 +2,13 @@ package keeper_test import ( "bytes" - "math" "sort" "testing" + gomath "math" + + "cosmossdk.io/math" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "pgregory.net/rapid" @@ -17,10 +20,10 @@ import ( "github.com/cometbft/cometbft/proto/tendermint/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func TestHandleOptIn(t *testing.T) { @@ -50,15 +53,15 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { calls := []*gomock.Call{ mocks.MockStakingKeeper.EXPECT(). GetValidatorByConsAddr(gomock.Any(), gomock.Any()). - DoAndReturn(func(ctx sdk.Context, addr sdk.ConsAddress) (stakingtypes.Validator, bool) { + DoAndReturn(func(ctx sdk.Context, addr sdk.ConsAddress) (stakingtypes.Validator, error) { if addr.Equals(providerAddr.Address) { // Given `providerAddr`, `GetValidatorByConsAddr` returns a validator with the // exact same `ConsensusPubkey` pkAny, _ := codectypes.NewAnyWithValue(providerConsPubKey) - return stakingtypes.Validator{ConsensusPubkey: pkAny}, true + return stakingtypes.Validator{ConsensusPubkey: pkAny}, nil } else { // for any other consensus address, we cannot find a validator - return stakingtypes.Validator{}, false + return stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound } }).Times(2), } @@ -69,9 +72,10 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { // create a sample consumer key to assign to the `providerAddr` validator // on the consumer chain with id `chainID` consumerKey := "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}" - expectedConsumerPubKey, _ := providerKeeper.ParseConsumerKey(consumerKey) + expectedConsumerPubKey, err := providerKeeper.ParseConsumerKey(consumerKey) + require.NoError(t, err) - err := providerKeeper.HandleOptIn(ctx, "chainID", providerAddr, consumerKey) + err = providerKeeper.HandleOptIn(ctx, "chainID", providerAddr, consumerKey) require.NoError(t, err) // assert that the consumeKey was assigned to `providerAddr` validator on chain with id `chainID` @@ -116,18 +120,18 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { // set the chain as Top 50 and create 4 validators with 10%, 20%, 30%, and 40% of the total voting power // respectively providerKeeper.SetTopN(ctx, "chainID", 50) - valA := createStakingValidator(ctx, mocks, 1, 1) // 10% of the total voting power (can opt out) + valA := createStakingValidator(ctx, mocks, 1, 1, 1) // 10% of the total voting power (can opt out) valAConsAddr, _ := valA.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, true).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 2) // 20% of the total voting power (can opt out) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() + valB := createStakingValidator(ctx, mocks, 2, 2, 2) // 20% of the total voting power (can opt out) valBConsAddr, _ := valB.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, true).AnyTimes() - valC := createStakingValidator(ctx, mocks, 3, 3) // 30% of the total voting power (cannot opt out) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() + valC := createStakingValidator(ctx, mocks, 3, 3, 3) // 30% of the total voting power (cannot opt out) valCConsAddr, _ := valC.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, true).AnyTimes() - valD := createStakingValidator(ctx, mocks, 4, 4) // 40% of the total voting power (cannot opt out) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, nil).AnyTimes() + valD := createStakingValidator(ctx, mocks, 4, 4, 4) // 40% of the total voting power (cannot opt out) valDConsAddr, _ := valD.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, true).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 4, []stakingtypes.Validator{valA, valB, valC, valD}, []int64{1, 2, 3, 4}, -1) // -1 to allow mocks AnyTimes @@ -152,10 +156,10 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { require.Error(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(valDConsAddr))) // opting out a validator that cannot be found from a Top N chain should also return an error - notFoundValidator := createStakingValidator(ctx, mocks, 5, 5) + notFoundValidator := createStakingValidator(ctx, mocks, 5, 5, 5) notFoundValidatorConsAddr, _ := notFoundValidator.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, notFoundValidatorConsAddr). - Return(stakingtypes.Validator{}, false) + Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound) require.Error(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(notFoundValidatorConsAddr))) } @@ -166,7 +170,7 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) // trying to set a commission rate to a unknown consumer chain - require.Error(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, "unknownChainID", providerAddr, sdk.ZeroDec())) + require.Error(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, "unknownChainID", providerAddr, math.LegacyZeroDec())) // setup a pending consumer chain chainID := "pendingChainID" @@ -176,24 +180,24 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { _, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) require.False(t, found) - mocks.MockStakingKeeper.EXPECT().MinCommissionRate(ctx).Return(sdk.ZeroDec()).Times(1) - require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, sdk.OneDec())) + mocks.MockStakingKeeper.EXPECT().MinCommissionRate(ctx).Return(math.LegacyZeroDec(), nil).Times(1) + require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, math.LegacyOneDec())) // check that the commission rate is now set cr, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) - require.Equal(t, sdk.OneDec(), cr) + require.Equal(t, math.LegacyOneDec(), cr) require.True(t, found) // set minimum rate of 1/2 - commissionRate := sdk.NewDec(1).Quo(sdk.NewDec(2)) - mocks.MockStakingKeeper.EXPECT().MinCommissionRate(ctx).Return(commissionRate).AnyTimes() + commissionRate := math.LegacyNewDec(1).Quo(math.LegacyNewDec(2)) + mocks.MockStakingKeeper.EXPECT().MinCommissionRate(ctx).Return(commissionRate, nil).AnyTimes() // try to set a rate slightly below the minimum require.Error(t, providerKeeper.HandleSetConsumerCommissionRate( ctx, chainID, providerAddr, - commissionRate.Sub(sdk.NewDec(1).Quo(sdk.NewDec(100)))), // 0.5 - 0.01 + commissionRate.Sub(math.LegacyNewDec(1).Quo(math.LegacyNewDec(100)))), // 0.5 - 0.01 "commission rate should be rejected (below min), but is not", ) @@ -210,13 +214,13 @@ func TestOptInTopNValidators(t *testing.T) { defer ctrl.Finish() // create 4 validators with powers 1, 2, 3, and 1 respectively - valA := createStakingValidator(ctx, mocks, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1, 1) valAConsAddr, _ := valA.GetConsAddr() - valB := createStakingValidator(ctx, mocks, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2, 2) valBConsAddr, _ := valB.GetConsAddr() - valC := createStakingValidator(ctx, mocks, 3, 3) + valC := createStakingValidator(ctx, mocks, 3, 3, 3) valCConsAddr, _ := valC.GetConsAddr() - valD := createStakingValidator(ctx, mocks, 4, 1) + valD := createStakingValidator(ctx, mocks, 4, 1, 4) valDConsAddr, _ := valD.GetConsAddr() // Start Test 1: opt in all validators with power >= 0 @@ -297,11 +301,11 @@ func TestComputeMinPowerInTopN(t *testing.T) { // 1 => 100% bondedValidators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, 1, 5), - createStakingValidator(ctx, mocks, 2, 10), - createStakingValidator(ctx, mocks, 3, 3), - createStakingValidator(ctx, mocks, 4, 1), - createStakingValidator(ctx, mocks, 5, 6), + createStakingValidator(ctx, mocks, 1, 5, 1), + createStakingValidator(ctx, mocks, 2, 10, 2), + createStakingValidator(ctx, mocks, 3, 3, 3), + createStakingValidator(ctx, mocks, 4, 1, 4), + createStakingValidator(ctx, mocks, 5, 6, 5), } m, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, 100) @@ -356,7 +360,7 @@ func TestCanValidateChain(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - validator := createStakingValidator(ctx, mocks, 0, 1) + validator := createStakingValidator(ctx, mocks, 0, 1, 1) consAddr, _ := validator.GetConsAddr() providerAddr := types.NewProviderConsAddress(consAddr) @@ -366,7 +370,7 @@ func TestCanValidateChain(t *testing.T) { require.True(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) // create an allow list but do not add the validator `providerAddr` to it - validatorA := createStakingValidator(ctx, mocks, 1, 1) + validatorA := createStakingValidator(ctx, mocks, 1, 1, 2) consAddrA, _ := validatorA.GetConsAddr() providerKeeper.SetAllowlist(ctx, "chainID", types.NewProviderConsAddress(consAddrA)) require.False(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) @@ -629,7 +633,7 @@ func TestNoMoreThanPercentOfTheSumProps(t *testing.T) { // (except for small changes by rounding errors) equalSumIfCapSatisfiable := func(valsBefore, valsAfter []types.ConsumerValidator, percent uint32) bool { if CapSatisfiable(valsBefore, percent) { - difference := math.Abs(float64(sumPowers(valsBefore) - sumPowers(valsAfter))) + difference := gomath.Abs(float64(sumPowers(valsBefore) - sumPowers(valsAfter))) if difference > 1 { // if the difference is more than a rounding error, they are not equal return false diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index dc769b152e..8d471f086b 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -5,44 +5,87 @@ import ( "strconv" "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" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// HandleConsumerAdditionProposal will receive the consumer chain's client state from the proposal. -// If the client can be successfully created in a cached context, it stores the proposal as a pending proposal. -// -// Note: This method implements SpawnConsumerChainProposalHandler in spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 -// Spec tag: [CCV-PCF-HCAPROP.1] -func (k Keeper) HandleConsumerAdditionProposal(ctx sdk.Context, p *types.ConsumerAdditionProposal) error { - // verify the consumer addition proposal execution - // in cached context and discard the cached writes - if _, _, err := k.CreateConsumerClientInCachedCtx(ctx, *p); err != nil { - return err +// Wrapper for the new proposal message MsgConsumerAddition +// Will replace legacy handler HandleLegacyConsumerAdditionProposal +func (k Keeper) HandleConsumerAdditionProposal(ctx sdk.Context, proposal *types.MsgConsumerAddition) error { + p := types.ConsumerAdditionProposal{ + ChainId: proposal.ChainId, + InitialHeight: proposal.InitialHeight, + GenesisHash: proposal.GenesisHash, + BinaryHash: proposal.BinaryHash, + SpawnTime: proposal.SpawnTime, + UnbondingPeriod: proposal.UnbondingPeriod, + CcvTimeoutPeriod: proposal.CcvTimeoutPeriod, + TransferTimeoutPeriod: proposal.TransferTimeoutPeriod, + ConsumerRedistributionFraction: proposal.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: proposal.BlocksPerDistributionTransmission, + HistoricalEntries: proposal.HistoricalEntries, + DistributionTransmissionChannel: proposal.DistributionTransmissionChannel, + Top_N: proposal.Top_N, + ValidatorsPowerCap: proposal.ValidatorsPowerCap, + ValidatorSetCap: proposal.ValidatorSetCap, + Allowlist: proposal.Allowlist, + Denylist: proposal.Denylist, + } + + return k.HandleLegacyConsumerAdditionProposal(ctx, &p) +} + +// Wrapper for the new proposal message MsgConsumerRemoval +// Will replace legacy handler HandleLegacyConsumerRemovalProposal +func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, proposal *types.MsgConsumerRemoval) error { + p := types.ConsumerRemovalProposal{ + ChainId: proposal.ChainId, + StopTime: proposal.StopTime, } - k.SetPendingConsumerAdditionProp(ctx, p) + return k.HandleLegacyConsumerRemovalProposal(ctx, &p) +} - k.Logger(ctx).Info("consumer addition proposal enqueued", - "chainID", p.ChainId, - "title", p.Title, - "spawn time", p.SpawnTime.UTC(), - ) +// Wrapper for the new proposal message MsgChangeRewardDenoms +// Will replace legacy handler HandleLegacyConsumerRewardDenomProposal +func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, proposal *types.MsgChangeRewardDenoms) error { + p := types.ChangeRewardDenomsProposal{ + DenomsToAdd: proposal.DenomsToAdd, + DenomsToRemove: proposal.DenomsToRemove, + } - return nil + return k.HandleLegacyConsumerRewardDenomProposal(ctx, &p) +} + +// HandleConsumerModificationProposal modifies a running consumer chain +func (k Keeper) HandleConsumerModificationProposal(ctx sdk.Context, proposal *types.MsgConsumerModification) error { + p := types.ConsumerModificationProposal{ + Title: proposal.Title, + Description: proposal.Description, + ChainId: proposal.ChainId, + Top_N: proposal.Top_N, + ValidatorsPowerCap: proposal.ValidatorsPowerCap, + ValidatorSetCap: proposal.ValidatorSetCap, + Allowlist: proposal.Allowlist, + Denylist: proposal.Denylist, + } + + return k.HandleLegacyConsumerModificationProposal(ctx, &p) } // CreateConsumerClient will create the CCV client for the given consumer chain. The CCV channel must be built @@ -123,85 +166,6 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi return nil } -// HandleConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. -// If the consumer can be successfully stopped in a cached context, it stores the proposal as a pending proposal. -// -// This method implements StopConsumerChainProposalHandler from spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 -// Spec tag: [CCV-PCF-HCRPROP.1] -func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, p *types.ConsumerRemovalProposal) error { - // verify the consumer removal proposal execution - // in cached context and discard the cached writes - if _, _, err := k.StopConsumerChainInCachedCtx(ctx, *p); err != nil { - return err - } - - k.SetPendingConsumerRemovalProp(ctx, p) - - k.Logger(ctx).Info("consumer removal proposal enqueued", - "chainID", p.ChainId, - "title", p.Title, - "stop time", p.StopTime.UTC(), - ) - - return nil -} - -// HandleConsumerModificationProposal modifies a running consumer chain -func (k Keeper) HandleConsumerModificationProposal(ctx sdk.Context, p *types.ConsumerModificationProposal) error { - if _, found := k.GetConsumerClientId(ctx, p.ChainId); !found { - return fmt.Errorf("consumer chain (%s) is not running", p.ChainId) - } - - k.SetTopN(ctx, p.ChainId, p.Top_N) - k.SetValidatorsPowerCap(ctx, p.ChainId, p.ValidatorsPowerCap) - k.SetValidatorSetCap(ctx, p.ChainId, p.ValidatorSetCap) - - k.DeleteAllowlist(ctx, p.ChainId) - for _, address := range p.Allowlist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetAllowlist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) - } - - k.DeleteDenylist(ctx, p.ChainId) - for _, address := range p.Denylist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetDenylist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) - } - - oldTopN, found := k.GetTopN(ctx, p.ChainId) - if !found { - oldTopN = 0 - k.Logger(ctx).Info("consumer chain top N not found, treating as 0", "chainID", p.ChainId) - } - - // if the top N changes, we need to update the new minimum power in top N - if p.Top_N != oldTopN { - if p.Top_N > 0 { - // if the chain receives a non-zero top N value, store the minimum power in the top N - bondedValidators := k.GetLastBondedValidators(ctx) - minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, p.Top_N) - if err != nil { - return err - } - k.SetMinimumPowerInTopN(ctx, p.ChainId, minPower) - } else { - // if the chain receives a zero top N value, we delete the min power - k.DeleteMinimumPowerInTopN(ctx, p.ChainId) - } - } - - return nil -} - // StopConsumerChain cleans up the states for the given consumer chain ID and // completes the outstanding unbonding operations on the consumer chain. // @@ -222,7 +186,6 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo // Note: this call panics if the key assignment state is invalid k.DeleteKeyAssignments(ctx, chainID) k.DeleteMinimumPowerInTopN(ctx, chainID) - k.DeleteEquivocationEvidenceMinHeight(ctx, chainID) // close channel and delete the mappings between chain ID and channel ID if channelID, found := k.GetChainToChannel(ctx, chainID); found { @@ -298,7 +261,10 @@ func (k Keeper) MakeConsumerGenesis( prop *types.ConsumerAdditionProposal, ) (gen ccv.ConsumerGenesisState, nextValidatorsHash []byte, err error) { chainID := prop.ChainId - providerUnbondingPeriod := k.stakingKeeper.UnbondingTime(ctx) + providerUnbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) + if err != nil { + return gen, nil, errorsmod.Wrapf(types.ErrNoUnbondingTime, "unbonding time not found: %s", err) + } height := clienttypes.GetSelfHeight(ctx) clientState := k.GetTemplateClient(ctx) @@ -320,7 +286,10 @@ func (k Keeper) MakeConsumerGenesis( } // get the bonded validators from the staking module - bondedValidators := k.GetLastBondedValidators(ctx) + bondedValidators, err := k.GetLastBondedValidators(ctx) + if err != nil { + return gen, nil, errorsmod.Wrapf(stakingtypes.ErrNoValidatorFound, "error getting last bonded validators: %s", err) + } if prop.Top_N > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N @@ -355,6 +324,7 @@ func (k Keeper) MakeConsumerGenesis( prop.ConsumerRedistributionFraction, prop.HistoricalEntries, prop.UnbondingPeriod, + "0.05", []string{}, []string{}, ccv.DefaultRetryDelayPeriod, @@ -484,7 +454,8 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { // Note: this method is split out from BeginBlockInit to be easily unit tested. func (k Keeper) GetConsumerAdditionPropsToExecute(ctx sdk.Context) (propsToExecute []types.ConsumerAdditionProposal) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingCAPBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingCAPBytePrefix}) + defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -514,7 +485,8 @@ func (k Keeper) GetConsumerAdditionPropsToExecute(ctx sdk.Context) (propsToExecu // then they are ordered by chainID. func (k Keeper) GetAllPendingConsumerAdditionProps(ctx sdk.Context) (props []types.ConsumerAdditionProposal) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingCAPBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingCAPBytePrefix}) + defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -622,7 +594,7 @@ func (k Keeper) GetConsumerRemovalPropsToExecute(ctx sdk.Context) []types.Consum propsToExecute := []types.ConsumerRemovalProposal{} store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingCRPBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingCRPBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -653,7 +625,7 @@ func (k Keeper) GetConsumerRemovalPropsToExecute(ctx sdk.Context) []types.Consum // Thus, the returned array is in stopTime order. func (k Keeper) GetAllPendingConsumerRemovalProps(ctx sdk.Context) (props []types.ConsumerRemovalProposal) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte{types.PendingCRPBytePrefix}) + iterator := storetypes.KVStorePrefixIterator(store, []byte{types.PendingCRPBytePrefix}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -686,31 +658,3 @@ func (k Keeper) StopConsumerChainInCachedCtx(ctx sdk.Context, p types.ConsumerRe err = k.StopConsumerChain(cc, p.ChainId, true) return } - -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 18257a508a..3cd957f61a 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -7,22 +7,24 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" _go "github.com/cosmos/ics23/go" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // @@ -124,7 +126,7 @@ func TestHandleConsumerAdditionProposal(t *testing.T) { tc.malleate(ctx, providerKeeper, tc.prop.ChainId) - err := providerKeeper.HandleConsumerAdditionProposal(ctx, tc.prop) + err := providerKeeper.HandleLegacyConsumerAdditionProposal(ctx, tc.prop) if tc.expAppendProp { require.NoError(t, err) @@ -380,194 +382,8 @@ func TestGetAllConsumerAdditionProps(t *testing.T) { require.Equal(t, expectedGetAllOrder, result) } -// -// Consumer Chain Removal sub-protocol related tests of proposal.go -// - -// TestHandleConsumerRemovalProposal tests HandleConsumerRemovalProposal against its corresponding spec method. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 -// Spec tag: [CCV-PCF-HCRPROP.1] -func TestHandleConsumerRemovalProposal(t *testing.T) { - type testCase struct { - description string - setupMocks func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) - - // Consumer removal proposal to handle - prop *providertypes.ConsumerRemovalProposal - // Time when prop is handled - blockTime time.Time - // Whether it's expected that the proposal is successfully verified - // and appended to the pending proposals - expAppendProp bool - - // chainID of the consumer chain - // tests need to check that the CCV channel is not closed prematurely - chainId string - } - - // Snapshot times asserted in tests - now := time.Now().UTC() - hourAfterNow := now.Add(time.Hour).UTC() - hourBeforeNow := now.Add(-time.Hour).UTC() - - tests := []testCase{ - { - description: "valid proposal", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "chainID", - now, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: true, - chainId: "chainID", - }, - { - description: "valid proposal - stop_time in the past", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "chainID", - hourBeforeNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: true, - chainId: "chainID", - }, - { - description: "valid proposal - before stop_time in the future", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "chainID", - hourAfterNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: now, - expAppendProp: true, - chainId: "chainID", - }, - { - description: "rejected valid proposal - consumer chain does not exist", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "chainID-2", - hourAfterNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: false, - chainId: "chainID-2", - }, - } - - for _, tc := range tests { - - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - ctx = ctx.WithBlockTime(tc.blockTime) - - // Mock expectations and setup for stopping the consumer chain, if applicable - // Note: when expAppendProp is false, no mocks are setup, - // 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) - - err := providerKeeper.HandleConsumerRemovalProposal(ctx, tc.prop) - - if tc.expAppendProp { - require.NoError(t, err) - - // Proposal should be stored as pending - found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) - require.True(t, found) - - // confirm that the channel was not closed - _, found = providerKeeper.GetChainToChannel(ctx, tc.chainId) - require.True(t, found) - } else { - require.Error(t, err) - - // Expect no pending proposal to exist - found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) - require.False(t, found) - } - - // Assert mock calls from setup function - ctrl.Finish() - } -} - -func TestHandleConsumerModificationProposal(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - chainID := "chainID" - - // set up a consumer client, so it seems that "chainID" is running - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") - - // set PSS-related fields to update them later on - providerKeeper.SetTopN(ctx, chainID, 50) - providerKeeper.SetValidatorSetCap(ctx, chainID, 10) - providerKeeper.SetValidatorsPowerCap(ctx, chainID, 34) - providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr1"))) - providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr2"))) - providerKeeper.SetDenylist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("denylistedAddr1"))) - - expectedTopN := uint32(75) - expectedValidatorsPowerCap := uint32(67) - expectedValidatorSetCap := uint32(20) - expectedAllowlistedValidator := "cosmosvalcons1wpex7anfv3jhystyv3eq20r35a" - expectedDenylistedValidator := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - proposal := providertypes.NewConsumerModificationProposal("title", "description", chainID, - expectedTopN, - expectedValidatorsPowerCap, - expectedValidatorSetCap, - []string{expectedAllowlistedValidator}, - []string{expectedDenylistedValidator}, - ).(*providertypes.ConsumerModificationProposal) - - err := providerKeeper.HandleConsumerModificationProposal(ctx, proposal) - require.NoError(t, err) - - actualTopN, _ := providerKeeper.GetTopN(ctx, chainID) - require.Equal(t, expectedTopN, actualTopN) - actualValidatorsPowerCap, _ := providerKeeper.GetValidatorsPowerCap(ctx, chainID) - require.Equal(t, expectedValidatorsPowerCap, actualValidatorsPowerCap) - actualValidatorSetCap, _ := providerKeeper.GetValidatorSetCap(ctx, chainID) - require.Equal(t, expectedValidatorSetCap, actualValidatorSetCap) - - allowlistedValidator, err := sdk.ConsAddressFromBech32(expectedAllowlistedValidator) - require.Equal(t, 1, len(providerKeeper.GetAllowList(ctx, chainID))) - require.Equal(t, providertypes.NewProviderConsAddress(allowlistedValidator), providerKeeper.GetAllowList(ctx, chainID)[0]) - - denylistedValidator, err := sdk.ConsAddressFromBech32(expectedDenylistedValidator) - require.Equal(t, 1, len(providerKeeper.GetDenyList(ctx, chainID))) - require.Equal(t, providertypes.NewProviderConsAddress(denylistedValidator), providerKeeper.GetDenyList(ctx, chainID)[0]) -} - // Tests the StopConsumerChain method against the spec, -// with more granularity than what's covered in TestHandleConsumerRemovalProposal, or integration tests. +// with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 // Spec tag: [CCV-PCF-STCC.1] func TestStopConsumerChain(t *testing.T) { @@ -836,7 +652,7 @@ func TestMakeConsumerGenesis(t *testing.T) { SlashMeterReplenishFraction: providertypes.DefaultSlashMeterReplenishFraction, ConsumerRewardDenomRegistrationFee: sdk.Coin{ Denom: "stake", - Amount: sdk.NewInt(1000000), + Amount: math.NewInt(1000000), }, BlocksPerEpoch: 600, NumberOfEpochsToStartReceivingRewards: 24, @@ -877,7 +693,7 @@ func TestMakeConsumerGenesis(t *testing.T) { "consumer_redistribution_fraction": "0.75", "historical_entries": 10000, "unbonding_period": 1728000000000000, - "soft_opt_out_threshold": "0", + "soft_opt_out_threshold": "0.05", "reward_denoms": [], "provider_reward_denoms": [], "retry_delay_period": 3600000000000 @@ -1097,7 +913,8 @@ func TestBeginBlockInit(t *testing.T) { consAddr, _ := validator.GetConsAddr() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{validator}, []int64{0}, -1) // -1 to allow any number of calls - mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), validator.GetOperator()).Return(int64(1)).AnyTimes() + valAddr, _ := sdk.ValAddressFromBech32(validator.GetOperator()) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr).Return(int64(1), nil).AnyTimes() providerKeeper.SetOptedIn(ctx, pendingProps[4].ChainId, providertypes.NewProviderConsAddress(consAddr)) providerKeeper.BeginBlockInit(ctx) @@ -1165,6 +982,7 @@ func TestBeginBlockInit(t *testing.T) { // test that Top N is set correctly require.True(t, providerKeeper.IsTopN(ctx, "chain1")) topN, found := providerKeeper.GetTopN(ctx, "chain1") + require.True(t, found) require.Equal(t, uint32(50), topN) require.True(t, providerKeeper.IsOptIn(ctx, "chain4")) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 4749a21a23..4d8f862c1b 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -1,19 +1,20 @@ package keeper import ( + "errors" "fmt" "strconv" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // OnRecvVSCMaturedPacket handles a VSCMatured packet and returns a no-op result ack. @@ -88,10 +89,10 @@ func (k Keeper) completeMaturedUnbondingOps(ctx sdk.Context) { // Attempt to complete unbonding in staking module err := k.stakingKeeper.UnbondingCanComplete(ctx, id) if err != nil { - if stakingtypes.ErrUnbondingNotFound.Is(err) { + if errors.Is(err, stakingtypes.ErrNoUnbondingDelegation) { // The unbonding was not found. - unbondingType, found := k.stakingKeeper.GetUnbondingType(ctx, id) - if found && unbondingType == stakingtypes.UnbondingType_UnbondingDelegation { + unbondingType, errGet := k.stakingKeeper.GetUnbondingType(ctx, id) + if errGet == nil && unbondingType == stakingtypes.UnbondingType_UnbondingDelegation { // If this is an unbonding delegation, it may have been removed // after through a CancelUnbondingDelegation message k.Logger(ctx).Debug("unbonding delegation was already removed:", "unbondingID", id) @@ -189,7 +190,7 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string k.GetCCVTimeoutPeriod(ctx), ) if err != nil { - if clienttypes.ErrClientNotActive.Is(err) { + if errors.Is(err, clienttypes.ErrClientNotActive) { // IBC client is expired! // leave the packet data stored to be sent once the client is upgraded // the client cannot expire during iteration (in the middle of a block) @@ -214,11 +215,17 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string } // QueueVSCPackets queues latest validator updates for every registered consumer chain +// failing to GetLastBondedValidators will cause a panic in EndBlock + +// TODO: decide if this func shouldn't return an error to be propagated to BeginBlocker func (k Keeper) QueueVSCPackets(ctx sdk.Context) { valUpdateID := k.GetValidatorSetUpdateId(ctx) // current valset update ID // get the bonded validators from the staking module - bondedValidators := k.GetLastBondedValidators(ctx) + bondedValidators, err := k.GetLastBondedValidators(ctx) + if err != nil { + panic(fmt.Errorf("failed to get last validators: %w", err)) + } for _, chainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { currentValidators := k.GetConsumerValSet(ctx, chainID) @@ -419,16 +426,20 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas ) // Obtain validator from staking keeper - validator, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerConsAddr.ToSdkConsAddr()) + validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerConsAddr.ToSdkConsAddr()) + if err != nil { + k.Logger(ctx).Error("validator not found", "validator", providerConsAddr.String(), "error", err) + return + } // make sure the validator is not yet unbonded; // stakingKeeper.Slash() panics otherwise - if !found || validator.IsUnbonded() { + if validator.IsUnbonded() { // if validator is not found or is unbonded, drop slash packet and log error. // Note that it is impossible for the validator to be not found or unbonded if both the provider // and the consumer are following the protocol. Thus if this branch is taken then one or both // chains is incorrect, but it is impossible to tell which. - k.Logger(ctx).Error("validator not found or is unbonded", "validator", providerConsAddr.String()) + k.Logger(ctx).Error("validator already unbonded", "validator", providerConsAddr.String()) return } @@ -458,10 +469,23 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas // jail validator if !validator.IsJailed() { - k.stakingKeeper.Jail(ctx, providerConsAddr.ToSdkConsAddr()) + err := k.stakingKeeper.Jail(ctx, providerConsAddr.ToSdkConsAddr()) + if err != nil { + k.Logger(ctx).Error("failed to jail vaidator", providerConsAddr.ToSdkConsAddr().String(), "err", err.Error()) + return + } k.Logger(ctx).Info("validator jailed", "provider cons addr", providerConsAddr.String()) - jailTime := ctx.BlockTime().Add(k.slashingKeeper.DowntimeJailDuration(ctx)) - k.slashingKeeper.JailUntil(ctx, providerConsAddr.ToSdkConsAddr(), jailTime) + jailDuration, err := k.slashingKeeper.DowntimeJailDuration(ctx) + if err != nil { + k.Logger(ctx).Error("failed to get jail duration", "err", err.Error()) + return + } + jailEndTime := ctx.BlockTime().Add(jailDuration) + err = k.slashingKeeper.JailUntil(ctx, providerConsAddr.ToSdkConsAddr(), jailEndTime) + if err != nil { + k.Logger(ctx).Error("failed to set jail duration", "err", err.Error()) + return + } } ctx.EventManager().EmitEvent( @@ -492,7 +516,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) { "chainID", initTimeoutTimestamp.ChainId) err := k.StopConsumerChain(ctx, initTimeoutTimestamp.ChainId, false) if err != nil { - if providertypes.ErrConsumerChainNotFound.Is(err) { + if errors.Is(err, providertypes.ErrConsumerChainNotFound) { // consumer chain not found continue } @@ -519,7 +543,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) { ) err := k.StopConsumerChain(ctx, channelToChain.ChainId, true) if err != nil { - if providertypes.ErrConsumerChainNotFound.Is(err) { + if errors.Is(err, providertypes.ErrConsumerChainNotFound) { // consumer chain not found continue } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index c71a53d13d..b6487e8ec1 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -4,14 +4,13 @@ import ( "strings" "testing" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "cosmossdk.io/math" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -20,19 +19,19 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // TestQueueVSCPackets tests queueing validator set updates. func TestQueueVSCPackets(t *testing.T) { _, _, key := ibctesting.GenerateKeys(t, 1) - tmPubKey, _ := cryptocodec.ToTmProtoPublicKey(key) + tmPubKey, _ := cryptocodec.ToCmtProtoPublicKey(key) testCases := []struct { name string @@ -98,13 +97,13 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { providerKeeper.SetParams(ctx, providertypes.DefaultParams()) // mock 2 bonded validators - valA := createStakingValidator(ctx, mocks, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1, 1) valAConsAddr, _ := valA.GetConsAddr() valAPubKey, _ := valA.TmConsPublicKey() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, true).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 2) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() + valB := createStakingValidator(ctx, mocks, 2, 2, 2) valBConsAddr, _ := valB.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, true).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{valA, valB}, []int64{1, 2}, -1) // set a consumer client, so we have a consumer chain (i.e., `k.GetAllConsumerChains(ctx)` is non empty) @@ -199,15 +198,19 @@ func TestOnRecvDowntimeSlashPacket(t *testing.T) { providerKeeper.SetSlashMeter(ctx, math.NewInt(5)) // Set the consumer validator - providerKeeper.SetConsumerValidator(ctx, "chain-1", types.ConsumerValidator{ProviderConsAddr: packetData.Validator.Address}) + providerKeeper.SetConsumerValidator(ctx, "chain-1", providertypes.ConsumerValidator{ProviderConsAddr: packetData.Validator.Address}) // 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), + Return(stakingtypes.Validator{ + // provided address must be valid so it can be processed correctly + // by k.ValidatorAddressCodec().StringToBytes(val.GetOperator()) call in GetEffectiveValPower() + OperatorAddress: sdk.ValAddress(packetData.Validator.Address).String(), + }, nil).Times(1), mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(ctx, gomock.Any()). - Return(int64(2)).Times(1), + Return(int64(2), nil).Times(1), } // Add mocks for slash packet handling @@ -364,7 +367,7 @@ func TestHandleSlashPacket(t *testing.T) { // The mocks that we expect to be called for the specified packet data. expectedCalls func(sdk.Context, testkeeper.MockedKeepers, ccv.SlashPacketData) []*gomock.Call expectedSlashAcksLen int - expectedSlashAckConsumerConsAddress types.ConsumerConsAddress + expectedSlashAckConsumerConsAddress providertypes.ConsumerConsAddress }{ { "unfound validator", @@ -381,7 +384,7 @@ func TestHandleSlashPacket(t *testing.T) { // Method will return once validator is not found. mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{}, false, // false = Not found. + stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound, // false = Not found. ).Times(1), } }, @@ -401,7 +404,7 @@ func TestHandleSlashPacket(t *testing.T) { return []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{}, true, // true = Found. + stakingtypes.Validator{}, nil, // nil = no error. ).Times(1), // Execution will stop after this call as validator is tombstoned. mocks.MockSlashingKeeper.EXPECT().IsTombstoned(ctx, @@ -425,7 +428,7 @@ func TestHandleSlashPacket(t *testing.T) { return []*gomock.Call{ mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( ctx, providerConsAddr.ToSdkConsAddr()).Return( - stakingtypes.Validator{}, true, + stakingtypes.Validator{}, nil, ).Times(1), mocks.MockSlashingKeeper.EXPECT().IsTombstoned(ctx, @@ -489,7 +492,7 @@ func TestHandleSlashPacket(t *testing.T) { // Setup consumer address to provider address mapping. require.NotEmpty(t, tc.packetData.Validator.Address) providerKeeper.SetValidatorByConsumerAddr(ctx, chainId, consumerConsAddr, providerConsAddr) - providerKeeper.SetConsumerValidator(ctx, chainId, types.ConsumerValidator{ProviderConsAddr: providerConsAddr.Address.Bytes()}) + providerKeeper.SetConsumerValidator(ctx, chainId, providertypes.ConsumerValidator{ProviderConsAddr: providerConsAddr.Address.Bytes()}) // Execute method and assert expected mock calls. providerKeeper.HandleSlashPacket(ctx, chainId, tc.packetData) @@ -520,7 +523,7 @@ func TestHandleVSCMaturedPacket(t *testing.T) { // Start first unbonding without any consumers registered var unbondingOpId uint64 = 1 gomock.InOrder( - mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_Undefined, false), + mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_Undefined, stakingtypes.ErrNoUnbondingType), ) err := pk.Hooks().AfterUnbondingInitiated(ctx, unbondingOpId) @@ -549,18 +552,18 @@ func TestHandleVSCMaturedPacket(t *testing.T) { } // Opt-in one validator to consumer - pk.SetConsumerValidator(ctx, "chain-1", types.ConsumerValidator{ProviderConsAddr: valsPk[0].Address()}) + pk.SetConsumerValidator(ctx, "chain-1", providertypes.ConsumerValidator{ProviderConsAddr: valsPk[0].Address()}) // Start second unbonding unbondingOpId = 2 gomock.InOrder( - mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_UnbondingDelegation, true), + mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_UnbondingDelegation, nil), mocks.MockStakingKeeper.EXPECT().GetUnbondingDelegationByUnbondingID(ctx, unbondingOpId).Return( stakingtypes.UnbondingDelegation{ ValidatorAddress: sdk.ValAddress([]byte{1}).String(), - }, true), + }, nil), mocks.MockStakingKeeper.EXPECT().GetValidator(ctx, sdk.ValAddress([]byte{1})). - Return(vals[0], true), + Return(vals[0], nil), mocks.MockStakingKeeper.EXPECT().PutUnbondingOnHold(ctx, unbondingOpId).Return(nil), ) err = pk.Hooks().AfterUnbondingInitiated(ctx, unbondingOpId) @@ -585,20 +588,20 @@ func TestHandleVSCMaturedPacket(t *testing.T) { pk.SetConsumerClientId(ctx, "chain-2", "client-2") // Opt-in both validators to second consumer - pk.SetConsumerValidator(ctx, "chain-2", types.ConsumerValidator{ProviderConsAddr: valsPk[0].Address()}) - pk.SetConsumerValidator(ctx, "chain-2", types.ConsumerValidator{ProviderConsAddr: valsPk[1].Address()}) + pk.SetConsumerValidator(ctx, "chain-2", providertypes.ConsumerValidator{ProviderConsAddr: valsPk[0].Address()}) + pk.SetConsumerValidator(ctx, "chain-2", providertypes.ConsumerValidator{ProviderConsAddr: valsPk[1].Address()}) // Start third and fourth unbonding unbondingOpIds := []uint64{3, 4} for _, id := range unbondingOpIds { gomock.InOrder( - mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, id).Return(stakingtypes.UnbondingType_Redelegation, true), + mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, id).Return(stakingtypes.UnbondingType_Redelegation, nil), mocks.MockStakingKeeper.EXPECT().GetRedelegationByUnbondingID(ctx, id).Return( stakingtypes.Redelegation{ ValidatorSrcAddress: sdk.ValAddress([]byte{1}).String(), - }, true), + }, nil), mocks.MockStakingKeeper.EXPECT().GetValidator(ctx, sdk.ValAddress([]byte{1})). - Return(vals[0], true), + Return(vals[0], nil), mocks.MockStakingKeeper.EXPECT().PutUnbondingOnHold(ctx, id).Return(nil), ) err = pk.Hooks().AfterUnbondingInitiated(ctx, id) @@ -626,13 +629,13 @@ func TestHandleVSCMaturedPacket(t *testing.T) { // Start fith unbonding unbondingOpId = 5 gomock.InOrder( - mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_ValidatorUnbonding, true), + mocks.MockStakingKeeper.EXPECT().GetUnbondingType(ctx, unbondingOpId).Return(stakingtypes.UnbondingType_ValidatorUnbonding, nil), mocks.MockStakingKeeper.EXPECT().GetValidatorByUnbondingID(ctx, unbondingOpId).Return( stakingtypes.Validator{ OperatorAddress: sdk.ValAddress([]byte{1}).String(), - }, true), + }, nil), mocks.MockStakingKeeper.EXPECT().GetValidator(ctx, sdk.ValAddress([]byte{1})). - Return(vals[1], true), + Return(vals[1], nil), mocks.MockStakingKeeper.EXPECT().PutUnbondingOnHold(ctx, unbondingOpId).Return(nil), ) err = pk.Hooks().AfterUnbondingInitiated(ctx, unbondingOpId) @@ -808,13 +811,13 @@ func TestEndBlockVSU(t *testing.T) { // create 4 sample lastValidators var lastValidators []stakingtypes.Validator - var valAddresses []sdk.ValAddress var powers []int64 for i := 0; i < 4; i++ { validator := crypto.NewCryptoIdentityFromIntSeed(i).SDKStakingValidator() lastValidators = append(lastValidators, validator) - valAddresses = append(valAddresses, validator.GetOperator()) - mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), validator.GetOperator()).Return(int64(i + 1)).AnyTimes() + valAdrr, err := sdk.ValAddressFromBech32(validator.GetOperator()) + require.NoError(t, err) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAdrr).Return(int64(i+1), nil).AnyTimes() powers = append(powers, int64(i+1)) } @@ -853,25 +856,25 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { providerKeeper.SetValidatorSetUpdateId(ctx, 1) - valA := createStakingValidator(ctx, mocks, 1, 1) // 3.125% of the total voting power + valA := createStakingValidator(ctx, mocks, 1, 1, 1) // 3.125% of the total voting power valAConsAddr, _ := valA.GetConsAddr() valAPubKey, _ := valA.TmConsPublicKey() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, true).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 3) // 9.375% of the total voting power + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() + valB := createStakingValidator(ctx, mocks, 2, 3, 2) // 9.375% of the total voting power valBConsAddr, _ := valB.GetConsAddr() valBPubKey, _ := valB.TmConsPublicKey() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, true).AnyTimes() - valC := createStakingValidator(ctx, mocks, 3, 4) // 12.5% of the total voting power + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() + valC := createStakingValidator(ctx, mocks, 3, 4, 3) // 12.5% of the total voting power valCConsAddr, _ := valC.GetConsAddr() valCPubKey, _ := valC.TmConsPublicKey() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, true).AnyTimes() - valD := createStakingValidator(ctx, mocks, 4, 8) // 25% of the total voting power + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, nil).AnyTimes() + valD := createStakingValidator(ctx, mocks, 4, 8, 4) // 25% of the total voting power valDConsAddr, _ := valD.GetConsAddr() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, true).AnyTimes() - valE := createStakingValidator(ctx, mocks, 5, 16) // 50% of the total voting power + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, nil).AnyTimes() + valE := createStakingValidator(ctx, mocks, 5, 16, 5) // 50% of the total voting power valEConsAddr, _ := valE.GetConsAddr() valEPubKey, _ := valE.TmConsPublicKey() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valEConsAddr).Return(valE, true).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valEConsAddr).Return(valE, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 5, []stakingtypes.Validator{valA, valB, valC, valD, valE}, []int64{1, 3, 4, 8, 16}, -1) diff --git a/x/ccv/provider/keeper/throttle.go b/x/ccv/provider/keeper/throttle.go index b7e7fd5941..7be82d4eaa 100644 --- a/x/ccv/provider/keeper/throttle.go +++ b/x/ccv/provider/keeper/throttle.go @@ -10,7 +10,7 @@ import ( tmtypes "github.com/cometbft/cometbft/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // Obtains the effective validator power relevant to a validator consensus address. @@ -19,15 +19,24 @@ func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context, ) math.Int { // Obtain staking module val object from the provider's consensus address. // Note: if validator is not found or unbonded, this will be handled appropriately in HandleSlashPacket - val, found := k.stakingKeeper.GetValidatorByConsAddr(ctx, valConsAddr.ToSdkConsAddr()) + val, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, valConsAddr.ToSdkConsAddr()) - if !found || val.IsJailed() { + if err != nil || val.IsJailed() { // If validator is not found, or found but jailed, it's power is 0. This path is explicitly defined since the // staking keeper's LastValidatorPower values are not updated till the staking keeper's endblocker. - return sdktypes.ZeroInt() + return math.ZeroInt() } else { // Otherwise, return the staking keeper's LastValidatorPower value. - return sdktypes.NewInt(k.stakingKeeper.GetLastValidatorPower(ctx, val.GetOperator())) + valAddr, err := k.ValidatorAddressCodec().StringToBytes(val.GetOperator()) + if err != nil { + return math.ZeroInt() + } + + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + return math.ZeroInt() + } + return math.NewInt(power) } } @@ -98,19 +107,21 @@ func (k Keeper) GetSlashMeterAllowance(ctx sdktypes.Context) math.Int { strFrac := k.GetSlashMeterReplenishFraction(ctx) // MustNewDecFromStr should not panic, since the (string representation) of the slash meter replenish fraction // is validated in ValidateGenesis and anytime the param is mutated. - decFrac := sdktypes.MustNewDecFromStr(strFrac) + decFrac := math.LegacyMustNewDecFromStr(strFrac) // Compute allowance in units of tendermint voting power (integer), // noting that total power changes over time - totalPower := k.stakingKeeper.GetLastTotalPower(ctx) + // NOTE: ignoring err seems safe here, since the func returns a default math.ZeroInt() + // and there are no concrete actions we can take if the err is not nil. + totalPower, _ := k.stakingKeeper.GetLastTotalPower(ctx) - roundedInt := sdktypes.NewInt(decFrac.MulInt(totalPower).RoundInt64()) + roundedInt := math.NewInt(decFrac.MulInt(totalPower).RoundInt64()) if roundedInt.IsZero() { k.Logger(ctx).Info("slash meter replenish fraction is too small " + "to add any allowance to the meter, considering bankers rounding") // Return non-zero allowance to guarantee some slash packets are eventually handled - return sdktypes.NewInt(1) + return math.NewInt(1) } return roundedInt } @@ -127,7 +138,7 @@ func (k Keeper) GetSlashMeter(ctx sdktypes.Context) math.Int { // there is no deletion method exposed, so nil bytes would indicate something is very wrong. panic("slash meter not set") } - value := sdktypes.ZeroInt() + value := math.ZeroInt() err := value.Unmarshal(bz) if err != nil { // We should have obtained value bytes that were serialized in SetSlashMeter, @@ -147,12 +158,12 @@ func (k Keeper) SetSlashMeter(ctx sdktypes.Context, value math.Int) { // // Explanation: slash meter replenish fraction is validated to be in range of [0, 1], // and MaxMeterValue = MaxAllowance = MaxReplenishFrac * MaxTotalVotingPower = 1 * MaxTotalVotingPower. - if value.GT(sdktypes.NewInt(tmtypes.MaxTotalVotingPower)) { + if value.GT(math.NewInt(tmtypes.MaxTotalVotingPower)) { panic("slash meter value cannot be greater than tendermint's MaxTotalVotingPower") } // Further, HandleThrottleQueues should never subtract more than MaxTotalVotingPower from the meter, // since we cannot slash more than an entire validator set. So MinMeterValue = -1 * MaxTotalVotingPower. - if value.LT(sdktypes.NewInt(-tmtypes.MaxTotalVotingPower)) { + if value.LT(math.NewInt(-tmtypes.MaxTotalVotingPower)) { panic("slash meter value cannot be less than negative tendermint's MaxTotalVotingPower") } store := ctx.KVStore(k.storeKey) diff --git a/x/ccv/provider/keeper/throttle_legacy.go b/x/ccv/provider/keeper/throttle_legacy.go index 6f347b8f60..53c6f39c72 100644 --- a/x/ccv/provider/keeper/throttle_legacy.go +++ b/x/ccv/provider/keeper/throttle_legacy.go @@ -3,10 +3,11 @@ package keeper import ( "fmt" + storetypes "cosmossdk.io/store/types" sdktypes "github.com/cosmos/cosmos-sdk/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Pending packet data type enum, used to encode the type of packet data stored at each entry in the mutual queue. @@ -26,7 +27,7 @@ func (k Keeper) LegacyGetAllThrottledPacketData(ctx sdktypes.Context, consumerCh store := ctx.KVStore(k.storeKey) iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + iterator := storetypes.KVStorePrefixIterator(store, iteratorPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -60,7 +61,7 @@ func (k Keeper) LegacyGetAllThrottledPacketData(ctx sdktypes.Context, consumerCh func (k Keeper) LegacyDeleteThrottledPacketDataForConsumer(ctx sdktypes.Context, consumerChainID string) { store := ctx.KVStore(k.storeKey) iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + iterator := storetypes.KVStorePrefixIterator(store, iteratorPrefix) defer iterator.Close() keysToDel := [][]byte{} diff --git a/x/ccv/provider/keeper/throttle_test.go b/x/ccv/provider/keeper/throttle_test.go index 478ec0f235..cb8e8804c4 100644 --- a/x/ccv/provider/keeper/throttle_test.go +++ b/x/ccv/provider/keeper/throttle_test.go @@ -9,12 +9,10 @@ import ( "cosmossdk.io/math" - sdktypes "github.com/cosmos/cosmos-sdk/types" - tmtypes "github.com/cometbft/cometbft/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestSlashMeterReplenishment tests the CheckForSlashMeterReplenishment, ReplenishSlashMeter, @@ -30,20 +28,20 @@ func TestSlashMeterReplenishment(t *testing.T) { { replenishPeriod: time.Minute, replenishFraction: "0.01", - totalPower: sdktypes.NewInt(1000), - expectedAllowance: sdktypes.NewInt(10), + totalPower: math.NewInt(1000), + expectedAllowance: math.NewInt(10), }, { replenishPeriod: time.Hour, replenishFraction: "0.1", - totalPower: sdktypes.NewInt(100000), - expectedAllowance: sdktypes.NewInt(10000), + totalPower: math.NewInt(100000), + expectedAllowance: math.NewInt(10000), }, { replenishPeriod: 30 * time.Minute, replenishFraction: "0.5", - totalPower: sdktypes.NewInt(1000000000000000), - expectedAllowance: sdktypes.NewInt(500000000000000), + totalPower: math.NewInt(1000000000000000), + expectedAllowance: math.NewInt(500000000000000), }, } for _, tc := range testCases { @@ -65,7 +63,7 @@ func TestSlashMeterReplenishment(t *testing.T) { // Any ctx is accepted, and the method will be called multiple times during the tests gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - gomock.Any()).Return(tc.totalPower).AnyTimes(), + gomock.Any()).Return(tc.totalPower, nil).AnyTimes(), ) // Now we can initialize the slash meter (this would happen in InitGenesis) @@ -79,8 +77,8 @@ func TestSlashMeterReplenishment(t *testing.T) { require.Equal(t, now.Add(tc.replenishPeriod), initialReplenishCandidate) // Decrement slash meter - providerKeeper.SetSlashMeter(ctx, providerKeeper.GetSlashMeter(ctx).Sub(sdktypes.NewInt(3))) - require.Equal(t, tc.expectedAllowance.Sub(sdktypes.NewInt(3)), providerKeeper.GetSlashMeter(ctx)) + providerKeeper.SetSlashMeter(ctx, providerKeeper.GetSlashMeter(ctx).Sub(math.NewInt(3))) + require.Equal(t, tc.expectedAllowance.Sub(math.NewInt(3)), providerKeeper.GetSlashMeter(ctx)) // Check for replenishment, confirm meter is not replenished (since no time has passed since init) meterBefore := providerKeeper.GetSlashMeter(ctx) @@ -146,7 +144,7 @@ func TestConsecutiveReplenishments(t *testing.T) { // Any ctx is accepted, and the method will be called multiple times during the tests gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - gomock.Any()).Return(sdktypes.NewInt(1000)).AnyTimes(), + gomock.Any()).Return(math.NewInt(1000), nil).AnyTimes(), ) // Now we can initialize the slash meter (this would happen in InitGenesis) @@ -159,45 +157,45 @@ func TestConsecutiveReplenishments(t *testing.T) { require.Equal(t, now.Add(time.Hour), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) // Decrement slash meter to negative value that would take 4 replenishments to recover from - providerKeeper.SetSlashMeter(ctx, sdktypes.NewInt(-150)) + providerKeeper.SetSlashMeter(ctx, math.NewInt(-150)) // Confirm no replenishment occurs when no time has passed, replenish candidate is not updated providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(-150), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(-150), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(time.Hour), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) // Now increment block time past replenishment period and confirm that meter is replenished ONCE, // and replenish candidate is updated to block time + replenish period ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * time.Hour)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(-100), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(-100), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(3*time.Hour), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) // Note 3 hours, not 2 // Simulate next block and check that no consecutive replenishments occur (replenish period has not passed) // and replenish candidate is not updated ctx = ctx.WithBlockTime(ctx.BlockTime().Add(5 * time.Second)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(-100), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(-100), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(3*time.Hour), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) // Increment block time past replenishment period and confirm that meter is replenished ONCE more // and replenish candidate is updated to block time + replenish period ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Hour * 1)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(-50), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(-50), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(4*time.Hour).Add(5*time.Second), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) // Replenishments should happen if we increment block times past replenishment period ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Hour * 1)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(0), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(0), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(5*time.Hour).Add(5*time.Second), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(0), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(0), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(5*time.Hour).Add(5*time.Second), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Hour * 1)) providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(50), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(50), providerKeeper.GetSlashMeter(ctx)) require.Equal(t, now.Add(6*time.Hour).Add(5*time.Second), providerKeeper.GetSlashMeterReplenishTimeCandidate(ctx)) } @@ -219,28 +217,28 @@ func TestTotalVotingPowerChanges(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( // Expect two calls, once for initialization, once for allowance check - ctx).Return(sdktypes.NewInt(1000)).Times(2), + ctx).Return(math.NewInt(1000), nil).Times(2), ) // Initialize the slash meter (this would happen in InitGenesis) providerKeeper.InitializeSlashMeter(ctx) // Confirm slash meter is full, and allowance is expected value via params - require.Equal(t, sdktypes.NewInt(100), providerKeeper.GetSlashMeterAllowance(ctx)) - require.Equal(t, sdktypes.NewInt(100), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(100), providerKeeper.GetSlashMeterAllowance(ctx)) + require.Equal(t, math.NewInt(100), providerKeeper.GetSlashMeter(ctx)) // Mutate context so mocked total power is less than before ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Microsecond)) // Don't add enough time for replenishment gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( // Expect two calls, once for replenish check, once for allowance check - ctx).Return(sdktypes.NewInt(500)).Times(2), + ctx).Return(math.NewInt(500), nil).Times(2), ) // Replenishment should not happen here, but slash meter should be decremented to new allowance providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(50), providerKeeper.GetSlashMeterAllowance(ctx)) - require.Equal(t, sdktypes.NewInt(50), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(50), providerKeeper.GetSlashMeterAllowance(ctx)) + require.Equal(t, math.NewInt(50), providerKeeper.GetSlashMeter(ctx)) // Mutate context so mocked total power is again less than before, // with ctx time set to a time that will replenish meter @@ -249,20 +247,20 @@ func TestTotalVotingPowerChanges(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( // Expect three calls, once for replenish check, // once for replenishment, once for allowance check - ctx).Return(sdktypes.NewInt(100)).Times(3), + ctx).Return(math.NewInt(100), nil).Times(3), ) // Replenishment should happen here, slash meter should be decremented to new allowance regardless providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(10), providerKeeper.GetSlashMeterAllowance(ctx)) - require.Equal(t, sdktypes.NewInt(10), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(10), providerKeeper.GetSlashMeterAllowance(ctx)) + require.Equal(t, math.NewInt(10), providerKeeper.GetSlashMeter(ctx)) // Mutate context so mocked total power is now more than before ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Microsecond)) // Don't add enough time for replenishment gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( // Expect two calls, once for replenish check, once for allowance check - ctx).Return(sdktypes.NewInt(5000)).Times(2), + ctx).Return(math.NewInt(5000), nil).Times(2), ) // @@ -271,8 +269,8 @@ func TestTotalVotingPowerChanges(t *testing.T) { // Replenishment should not happen here, slash meter should remain at previous value providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(500), providerKeeper.GetSlashMeterAllowance(ctx)) - require.Equal(t, sdktypes.NewInt(10), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(500), providerKeeper.GetSlashMeterAllowance(ctx)) + require.Equal(t, math.NewInt(10), providerKeeper.GetSlashMeter(ctx)) // Mutate context so mocked total power is again more than before, // with ctx time set to a time that will replenish meter @@ -281,13 +279,13 @@ func TestTotalVotingPowerChanges(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( // Expect three calls, once for replenish check, // once for replenishment, once for allowance check - ctx).Return(sdktypes.NewInt(10000)).Times(3), + ctx).Return(math.NewInt(10000), nil).Times(3), ) // Replenishment should happen here, slash meter should be set to new allowance providerKeeper.CheckForSlashMeterReplenishment(ctx) - require.Equal(t, sdktypes.NewInt(1000), providerKeeper.GetSlashMeterAllowance(ctx)) - require.Equal(t, sdktypes.NewInt(1000), providerKeeper.GetSlashMeter(ctx)) + require.Equal(t, math.NewInt(1000), providerKeeper.GetSlashMeterAllowance(ctx)) + require.Equal(t, math.NewInt(1000), providerKeeper.GetSlashMeter(ctx)) } // TestNegativeSlashMeter tests behavior of the slash meter when it goes negative, @@ -306,33 +304,33 @@ func TestNegativeSlashMeter(t *testing.T) { // Slashing 100 of voting power makes total voting power = 900, and meter = -90. // Expected replenish allowance is then 9, meaning it'd take 10 replenishes // for meter to reach 0 in value, and 11 replenishes for meter to reach a value of 9. - slashedPower: sdktypes.NewInt(100), - totalPower: sdktypes.NewInt(1000), + slashedPower: math.NewInt(100), + totalPower: math.NewInt(1000), replenishFraction: "0.01", numReplenishesTillFull: 11, - finalMeterValue: sdktypes.NewInt(9), + finalMeterValue: math.NewInt(9), }, { // Meter is initialized to a value of: 0.1*100 = 10. // Slashing 30 of voting power makes total voting power = 70, and meter = -20. // Expected replenish allowance is then 7, meaning it'd take 3 replenishes // for meter to reach 1 in value, and 4 replenishes for meter to reach a value of 7. - slashedPower: sdktypes.NewInt(30), - totalPower: sdktypes.NewInt(100), + slashedPower: math.NewInt(30), + totalPower: math.NewInt(100), replenishFraction: "0.1", numReplenishesTillFull: 4, - finalMeterValue: sdktypes.NewInt(7), + finalMeterValue: math.NewInt(7), }, { // Meter is initialized to a value of 1, since replenish fraction is too low, and min allowance is 1. // Slashing 5 of voting power makes total voting power = 995, and meter = -4. // Expected replenish allowance is then 1 (still minimum amount), meaning it'd take 4 replenishes // for meter to reach 0 in value, and 5 replenishes for meter to reach a value of 1. - slashedPower: sdktypes.NewInt(5), - totalPower: sdktypes.NewInt(1000), + slashedPower: math.NewInt(5), + totalPower: math.NewInt(1000), replenishFraction: "0.0000001", numReplenishesTillFull: 5, - finalMeterValue: sdktypes.NewInt(1), + finalMeterValue: math.NewInt(1), }, } @@ -349,9 +347,9 @@ func TestNegativeSlashMeter(t *testing.T) { // then total power minus slashed power any amount of times gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - gomock.Any()).Return(tc.totalPower).Times(1), + gomock.Any()).Return(tc.totalPower, nil).Times(1), mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - gomock.Any()).Return(tc.totalPower.Sub(tc.slashedPower)).AnyTimes(), + gomock.Any()).Return(tc.totalPower.Sub(tc.slashedPower), nil).AnyTimes(), ) // Initialize the slash meter (using first mocked value) @@ -360,11 +358,11 @@ func TestNegativeSlashMeter(t *testing.T) { // remaining calls to GetLastTotalPower should return the second mocked value. // Confirm that meter is initialized to expected initial allowance - decFrac, err := sdktypes.NewDecFromStr(tc.replenishFraction) + decFrac, err := math.LegacyNewDecFromStr(tc.replenishFraction) require.NoError(t, err) - expectedInitAllowance := sdktypes.NewInt(decFrac.MulInt(tc.totalPower).RoundInt64()) + expectedInitAllowance := math.NewInt(decFrac.MulInt(tc.totalPower).RoundInt64()) if expectedInitAllowance.IsZero() { // Allowances have a minimum of 1. - expectedInitAllowance = sdktypes.NewInt(1) + expectedInitAllowance = math.NewInt(1) } require.Equal(t, expectedInitAllowance, providerKeeper.GetSlashMeter(ctx)) @@ -374,9 +372,9 @@ func TestNegativeSlashMeter(t *testing.T) { require.True(t, providerKeeper.GetSlashMeter(ctx).LT(before)) // New expected allowance is replenish fraction * (total power - slashed power) - expectedNewAllowance := sdktypes.NewInt(decFrac.MulInt(tc.totalPower.Sub(tc.slashedPower)).RoundInt64()) + expectedNewAllowance := math.NewInt(decFrac.MulInt(tc.totalPower.Sub(tc.slashedPower)).RoundInt64()) if expectedNewAllowance.IsZero() { - expectedNewAllowance = sdktypes.NewInt(1) + expectedNewAllowance = math.NewInt(1) } require.Equal(t, expectedNewAllowance, providerKeeper.GetSlashMeterAllowance(ctx)) @@ -416,33 +414,33 @@ func TestGetSlashMeterAllowance(t *testing.T) { }{ { replenishFraction: "0.00", - totalPower: sdktypes.NewInt(100), - expectedAllowance: sdktypes.NewInt(1), // 0.0 * 100 = 0, 1 is returned + totalPower: math.NewInt(100), + expectedAllowance: math.NewInt(1), // 0.0 * 100 = 0, 1 is returned }, { replenishFraction: "0.00000000001", - totalPower: sdktypes.NewInt(100), - expectedAllowance: sdktypes.NewInt(1), // 0.00000000001 * 100 = 0 (bankers rounding), 1 is returned + totalPower: math.NewInt(100), + expectedAllowance: math.NewInt(1), // 0.00000000001 * 100 = 0 (bankers rounding), 1 is returned }, { replenishFraction: "0.01", - totalPower: sdktypes.NewInt(100), - expectedAllowance: sdktypes.NewInt(1), // 0.00000000001 * 100 = 0 (bankers rounding), 1 is returned + totalPower: math.NewInt(100), + expectedAllowance: math.NewInt(1), // 0.00000000001 * 100 = 0 (bankers rounding), 1 is returned }, { replenishFraction: "0.015", - totalPower: sdktypes.NewInt(100), - expectedAllowance: sdktypes.NewInt(2), // 0.015 * 10 = 2 (bankers rounding) + totalPower: math.NewInt(100), + expectedAllowance: math.NewInt(2), // 0.015 * 10 = 2 (bankers rounding) }, { replenishFraction: "0.27", - totalPower: sdktypes.NewInt(100), - expectedAllowance: sdktypes.NewInt(27), + totalPower: math.NewInt(100), + expectedAllowance: math.NewInt(27), }, { replenishFraction: "0.34", - totalPower: sdktypes.NewInt(10000000), - expectedAllowance: sdktypes.NewInt(3400000), + totalPower: math.NewInt(10000000), + expectedAllowance: math.NewInt(3400000), }, } for _, tc := range testCases { @@ -453,7 +451,7 @@ func TestGetSlashMeterAllowance(t *testing.T) { gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - gomock.Any()).Return(tc.totalPower).Times(1), + gomock.Any()).Return(tc.totalPower, nil).Times(1), ) // Set desired params @@ -473,18 +471,18 @@ func TestSlashMeter(t *testing.T) { meterValue math.Int shouldPanic bool }{ - {meterValue: sdktypes.NewInt(-7999999999999999999), shouldPanic: true}, - {meterValue: sdktypes.NewInt(-tmtypes.MaxTotalVotingPower - 1), shouldPanic: true}, - {meterValue: sdktypes.NewInt(-tmtypes.MaxTotalVotingPower), shouldPanic: false}, - {meterValue: sdktypes.NewInt(-50000000078987), shouldPanic: false}, - {meterValue: sdktypes.NewInt(-4237), shouldPanic: false}, - {meterValue: sdktypes.NewInt(0), shouldPanic: false}, - {meterValue: sdktypes.NewInt(1), shouldPanic: false}, - {meterValue: sdktypes.NewInt(4237897), shouldPanic: false}, - {meterValue: sdktypes.NewInt(500078078987), shouldPanic: false}, - {meterValue: sdktypes.NewInt(tmtypes.MaxTotalVotingPower), shouldPanic: false}, - {meterValue: sdktypes.NewInt(tmtypes.MaxTotalVotingPower + 1), shouldPanic: true}, - {meterValue: sdktypes.NewInt(7999974823991111199), shouldPanic: true}, + {meterValue: math.NewInt(-7999999999999999999), shouldPanic: true}, + {meterValue: math.NewInt(-tmtypes.MaxTotalVotingPower - 1), shouldPanic: true}, + {meterValue: math.NewInt(-tmtypes.MaxTotalVotingPower), shouldPanic: false}, + {meterValue: math.NewInt(-50000000078987), shouldPanic: false}, + {meterValue: math.NewInt(-4237), shouldPanic: false}, + {meterValue: math.NewInt(0), shouldPanic: false}, + {meterValue: math.NewInt(1), shouldPanic: false}, + {meterValue: math.NewInt(4237897), shouldPanic: false}, + {meterValue: math.NewInt(500078078987), shouldPanic: false}, + {meterValue: math.NewInt(tmtypes.MaxTotalVotingPower), shouldPanic: false}, + {meterValue: math.NewInt(tmtypes.MaxTotalVotingPower + 1), shouldPanic: true}, + {meterValue: math.NewInt(7999974823991111199), shouldPanic: true}, } for _, tc := range testCases { diff --git a/x/ccv/provider/keeper/validator_set_update.go b/x/ccv/provider/keeper/validator_set_update.go index de46e880ab..d7f764171e 100644 --- a/x/ccv/provider/keeper/validator_set_update.go +++ b/x/ccv/provider/keeper/validator_set_update.go @@ -3,13 +3,14 @@ package keeper import ( "fmt" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // SetConsumerValidator sets provided consumer `validator` on the consumer chain with `chainID` @@ -53,7 +54,7 @@ func (k Keeper) DeleteConsumerValSet( ) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.ConsumerValidatorBytePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) var keysToDel [][]byte defer iterator.Close() @@ -96,7 +97,7 @@ func (k Keeper) GetConsumerValSet( ) (validators []types.ConsumerValidator) { store := ctx.KVStore(k.storeKey) key := types.ChainIdWithLenKey(types.ConsumerValidatorBytePrefix, chainID) - iterator := sdk.KVStorePrefixIterator(store, key) + iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { @@ -154,7 +155,11 @@ func DiffValidators( // CreateConsumerValidator creates a consumer validator for `chainID` from the given staking `validator` func (k Keeper) CreateConsumerValidator(ctx sdk.Context, chainID string, validator stakingtypes.Validator) (types.ConsumerValidator, error) { - power := k.stakingKeeper.GetLastValidatorPower(ctx, validator.GetOperator()) + valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) + if err != nil { + return types.ConsumerValidator{}, err + } + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) consAddr, err := validator.GetConsAddr() if err != nil { return types.ConsumerValidator{}, fmt.Errorf("could not retrieve validator's (%+v) consensus address: %w", @@ -204,7 +209,7 @@ func (k Keeper) FilterValidators( if err != nil { // this should never happen but is recoverable if we exclude this validator from the next validator set k.Logger(ctx).Error("could not create consumer validator", - "validator", val.GetOperator().String(), + "validator", val.GetOperator(), "error", err) continue } @@ -218,6 +223,6 @@ func (k Keeper) FilterValidators( // GetLastBondedValidators iterates the last validator powers in the staking module // and returns the first MaxValidators many validators with the largest powers. -func (k Keeper) GetLastBondedValidators(ctx sdk.Context) []stakingtypes.Validator { +func (k Keeper) GetLastBondedValidators(ctx sdk.Context) ([]stakingtypes.Validator, error) { return ccv.GetLastBondedValidatorsUtil(ctx, k.stakingKeeper, k.Logger(ctx)) } diff --git a/x/ccv/provider/keeper/validator_set_update_test.go b/x/ccv/provider/keeper/validator_set_update_test.go index 3ce6b34e90..43bc5a0370 100644 --- a/x/ccv/provider/keeper/validator_set_update_test.go +++ b/x/ccv/provider/keeper/validator_set_update_test.go @@ -13,13 +13,12 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/proto/tendermint/crypto" - cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestConsumerValidator tests the `SetConsumerValidator`, `IsConsumerValidator`, and `DeleteConsumerValidator` methods @@ -111,16 +110,17 @@ func createConsumerValidator(index int, power int64, seed int) (types.ConsumerVa } // createStakingValidator helper function to generate a validator with the given power and with a provider address based on index -func createStakingValidator(ctx sdk.Context, mocks testkeeper.MockedKeepers, index int, power int64) stakingtypes.Validator { - providerConsPubKey := ed25519.GenPrivKeyFromSecret([]byte{byte(index)}).PubKey() - consAddr := sdk.ConsAddress(providerConsPubKey.Address()) - providerAddr := types.NewProviderConsAddress(consAddr) - pk, _ := cryptocodec.FromTmPubKeyInterface(providerConsPubKey) +func createStakingValidator(ctx sdk.Context, mocks testkeeper.MockedKeepers, index int, power int64, seed int) stakingtypes.Validator { + providerConsPubKey := cryptotestutil.NewCryptoIdentityFromIntSeed(seed).TMProtoCryptoPublicKey() + + pk, _ := cryptocodec.FromCmtProtoPublicKey(providerConsPubKey) pkAny, _ := codectypes.NewAnyWithValue(pk) + consAddr := sdk.ConsAddress(pk.Address()) + providerAddr := types.NewProviderConsAddress(consAddr) providerValidatorAddr := sdk.ValAddress(providerAddr.Address.Bytes()) mocks.MockStakingKeeper.EXPECT(). - GetLastValidatorPower(ctx, providerValidatorAddr).Return(power).AnyTimes() + GetLastValidatorPower(ctx, providerValidatorAddr).Return(power, nil).AnyTimes() return stakingtypes.Validator{ OperatorAddress: providerValidatorAddr.String(), @@ -340,7 +340,7 @@ func TestFilterValidatorsConsiderAll(t *testing.T) { var expectedValidators []types.ConsumerValidator // create a staking validator A that has not set a consumer public key - valA := createStakingValidator(ctx, mocks, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1, 1) // because validator A has no consumer key set, the `ConsumerPublicKey` we expect is the key on the provider chain valAConsAddr, _ := valA.GetConsAddr() valAPublicKey, _ := valA.TmConsPublicKey() @@ -351,7 +351,7 @@ func TestFilterValidatorsConsiderAll(t *testing.T) { }) // create a staking validator B that has set a consumer public key - valB := createStakingValidator(ctx, mocks, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2, 2) // validator B has set a consumer key, the `ConsumerPublicKey` we expect is the key set by `SetValidatorConsumerPubKey` valBConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valBConsAddr, _ := valB.GetConsAddr() @@ -382,7 +382,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { var expectedValidators []types.ConsumerValidator // create a staking validator A that has not set a consumer public key - valA := createStakingValidator(ctx, mocks, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1, 1) // because validator A has no consumer key set, the `ConsumerPublicKey` we expect is the key on the provider chain valAConsAddr, _ := valA.GetConsAddr() valAPublicKey, _ := valA.TmConsPublicKey() @@ -394,7 +394,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { expectedValidators = append(expectedValidators, expectedValAConsumerValidator) // create a staking validator B that has set a consumer public key - valB := createStakingValidator(ctx, mocks, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2, 2) // validator B has set a consumer key, the `ConsumerPublicKey` we expect is the key set by `SetValidatorConsumerPubKey` valBConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valBConsAddr, _ := valB.GetConsAddr() @@ -429,7 +429,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { require.Equal(t, expectedValidators, actualValidators) // create a staking validator C that is not opted in, hence `expectedValidators` remains the same - valC := createStakingValidator(ctx, mocks, 3, 3) + valC := createStakingValidator(ctx, mocks, 3, 3, 3) bondedValidators = []stakingtypes.Validator{valA, valB, valC} actualValidators = providerKeeper.FilterValidators(ctx, "chainID", bondedValidators, func(providerAddr types.ProviderConsAddress) bool { @@ -448,7 +448,7 @@ func TestCreateConsumerValidator(t *testing.T) { chainID := "chainID" // create a validator which has set a consumer public key - valA := createStakingValidator(ctx, mocks, 0, 1) + valA := createStakingValidator(ctx, mocks, 0, 1, 1) valAConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valAConsAddr, _ := valA.GetConsAddr() valAProviderConsAddr := types.NewProviderConsAddress(valAConsAddr) @@ -463,7 +463,7 @@ func TestCreateConsumerValidator(t *testing.T) { require.NoError(t, err) // create a validator which has not set a consumer public key - valB := createStakingValidator(ctx, mocks, 1, 2) + valB := createStakingValidator(ctx, mocks, 1, 2, 2) valBConsAddr, _ := valB.GetConsAddr() valBProviderConsAddr := types.NewProviderConsAddress(valBConsAddr) valBPublicKey, _ := valB.TmConsPublicKey() diff --git a/x/ccv/provider/migrations/migrator.go b/x/ccv/provider/migrations/migrator.go index 3ed41da6dd..b031f9705b 100644 --- a/x/ccv/provider/migrations/migrator.go +++ b/x/ccv/provider/migrations/migrator.go @@ -1,20 +1,25 @@ package migrations import ( + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" sdktypes "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - v3 "github.com/cosmos/interchain-security/v4/x/ccv/provider/migrations/v3" - v4 "github.com/cosmos/interchain-security/v4/x/ccv/provider/migrations/v4" - v5 "github.com/cosmos/interchain-security/v4/x/ccv/provider/migrations/v5" - v6 "github.com/cosmos/interchain-security/v4/x/ccv/provider/migrations/v6" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + v3 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v3" + v4 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v4" + v5 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v5" + v6 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v6" + v7 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v7" ) // Migrator is a struct for handling in-place store migrations. type Migrator struct { providerKeeper providerkeeper.Keeper paramSpace paramtypes.Subspace + cdc codec.BinaryCodec + storeKey storetypes.StoreKey } // NewMigrator returns a new Migrator. @@ -49,11 +54,16 @@ func (m Migrator) Migrate4to5(ctx sdktypes.Context) error { return nil } -// Migrate5to6 migrates x/ccvprovider state from consensus version 5 to 6. -// The migration consists of setting the `NumberOfEpochsToStartReceivingRewards` param, as well as +// Migrate5to6 consists of setting the `NumberOfEpochsToStartReceivingRewards` param, as well as // computing and storing the minimal power in the top N for all registered consumer chains. func (m Migrator) Migrate5to6(ctx sdktypes.Context) error { v6.MigrateParams(ctx, m.paramSpace) v6.MigrateMinPowerInTopN(ctx, m.providerKeeper) return nil } + +// Migrate6to7 migrates x/ccvprovider state from consensus version 6 to 7. +// The migration consists of initializing new provider chain params using params from the legacy store. +func (m Migrator) Migrate6to7(ctx sdktypes.Context) error { + return v7.MigrateLegacyParams(ctx, m.providerKeeper, m.paramSpace) +} diff --git a/x/ccv/provider/migrations/v3/migration_test.go b/x/ccv/provider/migrations/v3/migration_test.go index 630b8fd7dd..56d6b617d9 100644 --- a/x/ccv/provider/migrations/v3/migration_test.go +++ b/x/ccv/provider/migrations/v3/migration_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" ) func TestMigrate2To3(t *testing.T) { diff --git a/x/ccv/provider/migrations/v3/migrations.go b/x/ccv/provider/migrations/v3/migrations.go index 0a3ae68f12..8c17000b0b 100644 --- a/x/ccv/provider/migrations/v3/migrations.go +++ b/x/ccv/provider/migrations/v3/migrations.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" ) // MigrateQueuedPackets processes all queued packet data for all consumer chains that were stored diff --git a/x/ccv/provider/migrations/v4/migration_test.go b/x/ccv/provider/migrations/v4/migration_test.go index 5ab5faf87a..4423842149 100644 --- a/x/ccv/provider/migrations/v4/migration_test.go +++ b/x/ccv/provider/migrations/v4/migration_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestMigrateParams(t *testing.T) { diff --git a/x/ccv/provider/migrations/v4/migrations.go b/x/ccv/provider/migrations/v4/migrations.go index 825d01e25d..e60c98700e 100644 --- a/x/ccv/provider/migrations/v4/migrations.go +++ b/x/ccv/provider/migrations/v4/migrations.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // MigrateParams adds missing provider chain params to the param store. diff --git a/x/ccv/provider/migrations/v5/migration_test.go b/x/ccv/provider/migrations/v5/migration_test.go index 1adf57baeb..907aa1b019 100644 --- a/x/ccv/provider/migrations/v5/migration_test.go +++ b/x/ccv/provider/migrations/v5/migration_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" ) func TestMigrateParams(t *testing.T) { diff --git a/x/ccv/provider/migrations/v5/migrations.go b/x/ccv/provider/migrations/v5/migrations.go index 7ed8bd8efc..411efd49e1 100644 --- a/x/ccv/provider/migrations/v5/migrations.go +++ b/x/ccv/provider/migrations/v5/migrations.go @@ -3,7 +3,7 @@ package v5 import ( sdk "github.com/cosmos/cosmos-sdk/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" ) // This migration only takes already registered chains into account. diff --git a/x/ccv/provider/migrations/v6/migration_test.go b/x/ccv/provider/migrations/v6/migration_test.go index a5ae1b0d0c..9396a3e05d 100644 --- a/x/ccv/provider/migrations/v6/migration_test.go +++ b/x/ccv/provider/migrations/v6/migration_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestMigrateParams(t *testing.T) { @@ -19,7 +19,7 @@ func TestMigrateParams(t *testing.T) { MigrateParams(ctx, *inMemParams.ParamsSubspace) - // after migration, number of epochs epoch param should exist and be equal to default + // after migration, number of epochs to start receiving rewards param should exist and be equal to default require.True(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards)) var numberOfEpochsParam int64 inMemParams.ParamsSubspace.Get(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, &numberOfEpochsParam) diff --git a/x/ccv/provider/migrations/v6/migrations.go b/x/ccv/provider/migrations/v6/migrations.go index 9395d625e3..5829f29222 100644 --- a/x/ccv/provider/migrations/v6/migrations.go +++ b/x/ccv/provider/migrations/v6/migrations.go @@ -3,11 +3,19 @@ package v6 import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - providerkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) +// MigrateParams adds missing provider chain params to the param store. +func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { + if !paramsSubspace.HasKeyTable() { + paramsSubspace.WithKeyTable(providertypes.ParamKeyTable()) + } + paramsSubspace.Set(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, providertypes.DefaultNumberOfEpochsToStartReceivingRewards) +} + func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { // we only get the registered consumer chains and not also the proposed consumer chains because // the minimal power is first set when the consumer chain addition proposal passes @@ -23,7 +31,11 @@ func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper providerKeeper.Logger(ctx).Info("top N is 0, not setting minimal power", "chain", chain) } else { // set the minimal power in the top N - bondedValidators := providerKeeper.GetLastBondedValidators(ctx) + bondedValidators, err := providerKeeper.GetLastBondedValidators(ctx) + if err != nil { + providerKeeper.Logger(ctx).Error("failed to get last bonded validators", "chain", chain, "error", err) + continue + } minPower, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, topN) if err != nil { providerKeeper.Logger(ctx).Error("failed to compute min power in top N", "chain", chain, "topN", topN, "error", err) @@ -33,11 +45,3 @@ func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper } } } - -// MigrateParams adds missing provider chain params to the param store. -func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { - if !paramsSubspace.HasKeyTable() { - paramsSubspace.WithKeyTable(providertypes.ParamKeyTable()) - } - paramsSubspace.Set(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, providertypes.DefaultNumberOfEpochsToStartReceivingRewards) -} diff --git a/x/ccv/provider/migrations/v7/legacy_params.go b/x/ccv/provider/migrations/v7/legacy_params.go new file mode 100644 index 0000000000..a8c6d5218d --- /dev/null +++ b/x/ccv/provider/migrations/v7/legacy_params.go @@ -0,0 +1,99 @@ +package v7 + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// getTemplateClient returns the template client for provider proposals +func getTemplateClient(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) *ibctmtypes.ClientState { + var cs ibctmtypes.ClientState + paramSpace.Get(ctx, types.KeyTemplateClient, &cs) + return &cs +} + +// getTrustingPeriodFraction returns a TrustingPeriodFraction +// used to compute the provider IBC client's TrustingPeriod as UnbondingPeriod / TrustingPeriodFraction +func getTrustingPeriodFraction(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) string { + var f string + paramSpace.Get(ctx, types.KeyTrustingPeriodFraction, &f) + return f +} + +// getCCVTimeoutPeriod returns the timeout period for sent ibc packets +func getCCVTimeoutPeriod(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramSpace.Get(ctx, ccvtypes.KeyCCVTimeoutPeriod, &p) + return p +} + +// getInitTimeoutPeriod returns the init timeout period +func getInitTimeoutPeriod(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramSpace.Get(ctx, types.KeyInitTimeoutPeriod, &p) + return p +} + +// getVscTimeoutPeriod returns the vsc timeout period +func getVscTimeoutPeriod(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramSpace.Get(ctx, types.KeyVscTimeoutPeriod, &p) + return p +} + +// getSlashMeterReplenishPeriod returns the period in which: +// Once the slash meter becomes not-full, the slash meter is replenished after this period. +func getSlashMeterReplenishPeriod(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) time.Duration { + var p time.Duration + paramSpace.Get(ctx, types.KeySlashMeterReplenishPeriod, &p) + return p +} + +// getSlashMeterReplenishFraction returns the string fraction of total voting power 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. +func getSlashMeterReplenishFraction(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) string { + var f string + paramSpace.Get(ctx, types.KeySlashMeterReplenishFraction, &f) + return f +} + +func getConsumerRewardDenomRegistrationFee(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) sdk.Coin { + var c sdk.Coin + paramSpace.Get(ctx, types.KeyConsumerRewardDenomRegistrationFee, &c) + return c +} + +func getBlocksPerEpoch(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) int64 { + var b int64 + paramSpace.Get(ctx, types.KeyBlocksPerEpoch, &b) + return b +} + +func getNumberOfEpochsToStartReceivingRewards(ctx sdk.Context, paramSpace ccvtypes.LegacyParamSubspace) int64 { + var b int64 + paramSpace.Get(ctx, types.KeyNumberOfEpochsToStartReceivingRewards, &b) + return b +} + +// Legacy: Only for migration purposes. GetParamsLegacy returns the paramset for the provider +// module from a given param subspace +func GetParamsLegacy(ctx sdk.Context, paramspace ccvtypes.LegacyParamSubspace) types.Params { + return types.NewParams( + getTemplateClient(ctx, paramspace), + getTrustingPeriodFraction(ctx, paramspace), + getCCVTimeoutPeriod(ctx, paramspace), + getInitTimeoutPeriod(ctx, paramspace), + getVscTimeoutPeriod(ctx, paramspace), + getSlashMeterReplenishPeriod(ctx, paramspace), + getSlashMeterReplenishFraction(ctx, paramspace), + getConsumerRewardDenomRegistrationFee(ctx, paramspace), + getBlocksPerEpoch(ctx, paramspace), + getNumberOfEpochsToStartReceivingRewards(ctx, paramspace), + ) +} diff --git a/x/ccv/provider/migrations/v7/migrations.go b/x/ccv/provider/migrations/v7/migrations.go new file mode 100644 index 0000000000..3c2f171dac --- /dev/null +++ b/x/ccv/provider/migrations/v7/migrations.go @@ -0,0 +1,21 @@ +package v7 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// MigrateParams migrates the provider module's parameters from the x/params to self store. +func MigrateLegacyParams(ctx sdk.Context, keeper providerkeeper.Keeper, legacyParamspace ccvtypes.LegacyParamSubspace) error { + ctx.Logger().Info("starting provider legacy params migration") + params := GetParamsLegacy(ctx, legacyParamspace) + err := params.Validate() + if err != nil { + return err + } + + keeper.SetParams(ctx, params) + keeper.Logger(ctx).Info("successfully migrated legacy provider parameters") + return nil +} diff --git a/x/ccv/provider/migrations/v7/migrations_test.go b/x/ccv/provider/migrations/v7/migrations_test.go new file mode 100644 index 0000000000..f4ee763263 --- /dev/null +++ b/x/ccv/provider/migrations/v7/migrations_test.go @@ -0,0 +1,56 @@ +package v7 + +import ( + "testing" + + testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" + "github.com/stretchr/testify/require" +) + +func TestMigrateParams(t *testing.T) { + t.Helper() + inMemParams := testutil.NewInMemKeeperParams(t) + k, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) + defer ctrl.Finish() + + if !inMemParams.ParamsSubspace.HasKeyTable() { + inMemParams.ParamsSubspace.WithKeyTable(providertypes.ParamKeyTable()) + } + + defaultParams := providertypes.DefaultParams() + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyTemplateClient, defaultParams.TemplateClient) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyTrustingPeriodFraction, defaultParams.TrustingPeriodFraction) + inMemParams.ParamsSubspace.Set(ctx, ccvtypes.KeyCCVTimeoutPeriod, defaultParams.CcvTimeoutPeriod) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyInitTimeoutPeriod, defaultParams.InitTimeoutPeriod) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyVscTimeoutPeriod, defaultParams.VscTimeoutPeriod) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeySlashMeterReplenishPeriod, defaultParams.SlashMeterReplenishPeriod) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeySlashMeterReplenishFraction, defaultParams.SlashMeterReplenishFraction) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyConsumerRewardDenomRegistrationFee, defaultParams.ConsumerRewardDenomRegistrationFee) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyBlocksPerEpoch, defaultParams.BlocksPerEpoch) + inMemParams.ParamsSubspace.Set(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, defaultParams.NumberOfEpochsToStartReceivingRewards) + + // confirms that inMemParams.ParamsSubspace works as expected + require.NotPanics(t, func() { + GetParamsLegacy(ctx, inMemParams.ParamsSubspace) + }) + + // no "new" params should be available before migration + // "new" params are stored under providertypes.ParametersKey() + emptyParams := k.GetParams(ctx) + require.Empty(t, emptyParams) + + // make sure that the legacy params are equal to the default params (they were set using inMemParams.ParamsSubspace.Set()) + legacyParams := GetParamsLegacy(ctx, inMemParams.ParamsSubspace) + require.NotNil(t, legacyParams) + require.Equal(t, defaultParams, legacyParams) + + err := MigrateLegacyParams(ctx, k, inMemParams.ParamsSubspace) + require.NoError(t, err) + + // check that "new" params are available after migration and equal to defaults + migratedParams := k.GetParams(ctx) + require.NotEmpty(t, migratedParams) + require.Equal(t, defaultParams, migratedParams) +} diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index e78a1e051e..8c87262640 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -17,18 +17,24 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - abci "github.com/cometbft/cometbft/abci/types" - - "github.com/cosmos/interchain-security/v4/x/ccv/provider/client/cli" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/migrations" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/client/cli" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) var ( - _ module.AppModule = AppModule{} - _ porttypes.IBCModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = (*AppModule)(nil) + _ module.AppModuleBasic = (*AppModuleBasic)(nil) + _ module.AppModuleSimulation = (*AppModule)(nil) + _ module.HasGenesis = (*AppModule)(nil) + _ module.HasName = (*AppModule)(nil) + _ module.HasConsensusVersion = (*AppModule)(nil) + _ module.HasInvariants = (*AppModule)(nil) + _ module.HasServices = (*AppModule)(nil) + _ appmodule.AppModule = (*AppModule)(nil) + _ appmodule.HasBeginBlocker = (*AppModule)(nil) + _ appmodule.HasEndBlocker = (*AppModule)(nil) ) // AppModuleBasic is the IBC Provider AppModuleBasic @@ -39,6 +45,12 @@ func (AppModuleBasic) Name() string { return providertypes.ModuleName } +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + // RegisterLegacyAminoCodec implements AppModuleBasic interface func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { providertypes.RegisterLegacyAminoCodec(cdc) @@ -108,32 +120,33 @@ 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 := migrations.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)) + + migrator := migrations.NewMigrator(*am.keeper, am.paramSpace) + if err := cfg.RegisterMigration(providertypes.ModuleName, 2, migrator.Migrate2to3); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s -- from 2 -> 3", providertypes.ModuleName, err)) } - if err := cfg.RegisterMigration(providertypes.ModuleName, 3, m.Migrate3to4); err != nil { - panic(fmt.Sprintf("failed to register migrator for %s: %s", providertypes.ModuleName, err)) + if err := cfg.RegisterMigration(providertypes.ModuleName, 3, migrator.Migrate3to4); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s -- from 3 -> 4", providertypes.ModuleName, err)) + } + if err := cfg.RegisterMigration(providertypes.ModuleName, 4, migrator.Migrate4to5); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s -- from 4 -> 5", providertypes.ModuleName, err)) } - if err := cfg.RegisterMigration(providertypes.ModuleName, 4, m.Migrate4to5); err != nil { + if err := cfg.RegisterMigration(providertypes.ModuleName, 5, migrator.Migrate5to6); err != nil { panic(fmt.Sprintf("failed to register migrator for %s: %s", providertypes.ModuleName, err)) } - if err := cfg.RegisterMigration(providertypes.ModuleName, 5, m.Migrate5to6); err != nil { + if err := cfg.RegisterMigration(providertypes.ModuleName, 6, migrator.Migrate6to7); 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. // Note: This method along with ValidateGenesis satisfies the CCV spec: // https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-initg1 -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) { var genesisState providertypes.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) am.keeper.InitGenesis(ctx, &genesisState) - - return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the provider @@ -144,31 +157,36 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 6 } +func (AppModule) ConsensusVersion() uint64 { return 7 } // BeginBlock implements the AppModule interface -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - // Create clients to consumer chains that are due to be spawned via pending consumer addition proposals - am.keeper.BeginBlockInit(ctx) +func (am AppModule) BeginBlock(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) // Create clients to consumer chains that are due to be spawned via pending consumer addition proposals + + am.keeper.BeginBlockInit(sdkCtx) // Stop and remove state for any consumer chains that are due to be stopped via pending consumer removal proposals - am.keeper.BeginBlockCCR(ctx) + am.keeper.BeginBlockCCR(sdkCtx) // Check for replenishing slash meter before any slash packets are processed for this block - am.keeper.BeginBlockCIS(ctx) - // BeginBlock logic need for the Reward Distribution sub-protocol - am.keeper.BeginBlockRD(ctx, req) + am.keeper.BeginBlockCIS(sdkCtx) + // BeginBlock logic needed for the Reward Distribution sub-protocol + am.keeper.BeginBlockRD(sdkCtx) + + return nil } // EndBlock implements the AppModule interface -func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { +func (am AppModule) EndBlock(ctx context.Context) error { + sdkCtx := sdk.UnwrapSDKContext(ctx) + // EndBlock logic needed for the Consumer Initiated Slashing sub-protocol. // Important: EndBlockCIS must be called before EndBlockVSU - am.keeper.EndBlockCIS(ctx) + am.keeper.EndBlockCIS(sdkCtx) // EndBlock logic needed for the Consumer Chain Removal sub-protocol - am.keeper.EndBlockCCR(ctx) + am.keeper.EndBlockCCR(sdkCtx) // EndBlock logic needed for the Validator Set Update sub-protocol - am.keeper.EndBlockVSU(ctx) + am.keeper.EndBlockVSU(sdkCtx) - return []abci.ValidatorUpdate{} + return nil } // AppModuleSimulation functions @@ -178,7 +196,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // RegisterStoreDecoder registers a decoder for provider module's types -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { } // WeightedOperations returns the all the provider module operations with their respective weights. diff --git a/x/ccv/provider/module_test.go b/x/ccv/provider/module_test.go index 869c24253f..b37c34d1da 100644 --- a/x/ccv/provider/module_test.go +++ b/x/ccv/provider/module_test.go @@ -3,18 +3,18 @@ package provider_test import ( "testing" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "cosmossdk.io/math" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Tests the provider's InitGenesis implementation against the spec. @@ -143,7 +143,7 @@ func TestInitGenesis(t *testing.T) { if !tc.expPanic { orderedCalls = append(orderedCalls, mocks.MockStakingKeeper.EXPECT().GetLastTotalPower( - ctx).Return(sdk.NewInt(100)).Times(1), // Return total voting power as 100 + ctx).Return(math.NewInt(100), nil).Times(1), // Return total voting power as 100 ) } @@ -159,7 +159,7 @@ func TestInitGenesis(t *testing.T) { continue // Nothing else to verify } - valUpdates := appModule.InitGenesis(ctx, cdc, jsonBytes) + appModule.InitGenesis(ctx, cdc, jsonBytes) numStatesCounted := 0 for _, state := range tc.consumerStates { @@ -174,14 +174,12 @@ func TestInitGenesis(t *testing.T) { } require.Equal(t, len(tc.consumerStates), numStatesCounted) - require.Empty(t, valUpdates, "InitGenesis should return no validator updates") - // Expect slash meter to be initialized to it's allowance value // (replenish fraction * mocked value defined above) slashMeter := providerKeeper.GetSlashMeter(ctx) - replenishFraction, err := sdk.NewDecFromStr(providerKeeper.GetParams(ctx).SlashMeterReplenishFraction) + replenishFraction, err := math.LegacyNewDecFromStr(providerKeeper.GetParams(ctx).SlashMeterReplenishFraction) require.NoError(t, err) - expectedSlashMeterValue := sdk.NewInt(replenishFraction.MulInt(sdk.NewInt(100)).RoundInt64()) + expectedSlashMeterValue := math.NewInt(replenishFraction.MulInt(math.NewInt(100)).RoundInt64()) require.Equal(t, expectedSlashMeterValue, slashMeter) // Expect slash meter replenishment time candidate to be set to the current block time + replenish period diff --git a/x/ccv/provider/proposal_handler.go b/x/ccv/provider/proposal_handler.go index 98e349652f..40a551d185 100644 --- a/x/ccv/provider/proposal_handler.go +++ b/x/ccv/provider/proposal_handler.go @@ -7,8 +7,8 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // NewProviderProposalHandler defines the handler for consumer addition, @@ -18,13 +18,13 @@ func NewProviderProposalHandler(k keeper.Keeper) govv1beta1.Handler { return func(ctx sdk.Context, content govv1beta1.Content) error { switch c := content.(type) { case *types.ConsumerAdditionProposal: - return k.HandleConsumerAdditionProposal(ctx, c) + return k.HandleLegacyConsumerAdditionProposal(ctx, c) case *types.ConsumerRemovalProposal: - return k.HandleConsumerRemovalProposal(ctx, c) + return k.HandleLegacyConsumerRemovalProposal(ctx, c) case *types.ConsumerModificationProposal: - return k.HandleConsumerModificationProposal(ctx, c) + return k.HandleLegacyConsumerModificationProposal(ctx, c) case *types.ChangeRewardDenomsProposal: - return k.HandleConsumerRewardDenomProposal(ctx, c) + return k.HandleLegacyConsumerRewardDenomProposal(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 d4e6195b8a..2494da8c60 100644 --- a/x/ccv/provider/proposal_handler_test.go +++ b/x/ccv/provider/proposal_handler_test.go @@ -4,18 +4,19 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" - "github.com/cosmos/interchain-security/v4/x/ccv/provider" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // TestProviderProposalHandler tests the highest level handler for proposals @@ -81,7 +82,7 @@ func TestProviderProposalHandler(t *testing.T) { Title: "title", Description: "desc", Recipient: "", - Amount: sdk.NewCoins(sdk.NewCoin("communityfunds", sdk.NewInt(10))), + Amount: sdk.NewCoins(sdk.NewCoin("communityfunds", math.NewInt(10))), }, }, } diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index d817de9302..1d75778bb1 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -1,18 +1,15 @@ package types import ( - "github.com/cosmos/ibc-go/v7/modules/core/exported" - tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/ibc-go/v8/modules/core/exported" + tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ) -// 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) { } @@ -33,7 +30,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgAssignConsumerKey{}, + &MsgConsumerAddition{}, + &MsgConsumerRemoval{}, + &MsgChangeRewardDenoms{}, + &MsgUpdateParams{}, ) + // keep so existing proposals can be correctly deserialized registry.RegisterImplementations( (*govv1beta1.Content)(nil), &EquivocationProposal{}, diff --git a/x/ccv/provider/types/consumer.go b/x/ccv/provider/types/consumer.go index 4c43bd58e7..02651ac03e 100644 --- a/x/ccv/provider/types/consumer.go +++ b/x/ccv/provider/types/consumer.go @@ -1,7 +1,7 @@ package types import ( - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func NewConsumerStates( diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 93e88397c4..5109489d76 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -28,4 +28,8 @@ var ( ErrCannotOptOutFromTopN = errorsmod.Register(ModuleName, 20, "cannot opt out from a Top N chain") ErrNoUnconfirmedVSCPacket = errorsmod.Register(ModuleName, 21, "no unconfirmed vsc packet for this chain id") ErrInvalidConsumerModificationProposal = errorsmod.Register(ModuleName, 22, "invalid consumer modification proposal") + ErrNoUnbondingTime = errorsmod.Register(ModuleName, 23, "provider unbonding time not found") + ErrInvalidAddress = errorsmod.Register(ModuleName, 24, "invalid address") + ErrUnauthorized = errorsmod.Register(ModuleName, 25, "unauthorized") + ErrBlankConsumerChainID = errorsmod.Register(ModuleName, 26, "consumer chain id must not be blank") ) diff --git a/x/ccv/provider/types/genesis.go b/x/ccv/provider/types/genesis.go index ae929ba541..7ef643970b 100644 --- a/x/ccv/provider/types/genesis.go +++ b/x/ccv/provider/types/genesis.go @@ -3,13 +3,13 @@ package types import ( "fmt" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func NewGenesisState( diff --git a/x/ccv/provider/types/genesis.pb.go b/x/ccv/provider/types/genesis.pb.go index d5041f1b10..d885dbc667 100644 --- a/x/ccv/provider/types/genesis.pb.go +++ b/x/ccv/provider/types/genesis.pb.go @@ -7,7 +7,7 @@ import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - types "github.com/cosmos/interchain-security/v4/x/ccv/types" + types "github.com/cosmos/interchain-security/v5/x/ccv/types" io "io" math "math" math_bits "math/bits" @@ -353,63 +353,63 @@ func init() { var fileDescriptor_48411d9c7900d48e = []byte{ // 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, 0xbb, 0x39, 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, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xce, 0x26, 0x69, 0x1a, 0x4f, 0x7e, 0x08, 0x43, 0x70, 0x37, 0x09, 0xb8, 0x91, 0x51, 0xa5, + 0x48, 0x80, 0xdd, 0x04, 0x90, 0xca, 0x4f, 0x2f, 0x9a, 0x16, 0x81, 0x85, 0x10, 0x96, 0x93, 0x06, + 0xa9, 0x5c, 0x8c, 0xc6, 0x33, 0x23, 0x7b, 0x1a, 0x7b, 0x66, 0x35, 0x67, 0x76, 0x13, 0x0b, 0x21, + 0x15, 0xc1, 0x03, 0xf0, 0x58, 0xbd, 0xcc, 0x25, 0x57, 0x15, 0x4a, 0xde, 0x80, 0x27, 0x40, 0x3b, + 0x3b, 0xbb, 0x5d, 0x07, 0xa7, 0xb2, 0x7b, 0x95, 0x78, 0xbe, 0x39, 0xdf, 0xf7, 0x9d, 0x39, 0x33, + 0xe7, 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, + 0xa1, 0x11, 0x19, 0x6d, 0x35, 0xfe, 0x68, 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, + 0x1b, 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, + 0xa9, 0x5b, 0x6e, 0x71, 0xfc, 0x2b, 0x7a, 0x27, 0xf7, 0x49, 0x20, 0x8d, 0x85, 0x70, 0x7e, 0x77, + 0x61, 0x6f, 0xe5, 0xe0, 0xa0, 0x31, 0xc5, 0xe1, 0x34, 0x1e, 0xfb, 0x58, 0x27, 0x7b, 0x58, 0x7b, + 0xf9, 0xea, 0xee, 0xdc, 0xbf, 0xaf, 0xee, 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, + 0x1d, 0x41, 0xb8, 0xe0, 0xa4, 0xef, 0x4f, 0x25, 0xfd, 0x34, 0x8f, 0xfc, 0x29, 0x3a, 0x5c, 0x4c, + 0x85, 0x3b, 0xab, 0xf1, 0xeb, 0x25, 0xc0, 0xcf, 0xd1, 0xe6, 0x90, 0xda, 0xd8, 0x08, 0x32, 0xae, + 0xb1, 0xb8, 0x1b, 0xec, 0xad, 0x1c, 0x3c, 0x98, 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, + 0xa9, 0x15, 0x89, 0x8c, 0x8e, 0x34, 0xd0, 0x01, 0x84, 0x4b, 0xce, 0xc0, 0xc3, 0x99, 0x2a, 0xfa, + 0xc8, 0xd3, 0xb4, 0x3d, 0x8b, 0xb7, 0xb0, 0xc5, 0x6e, 0xc0, 0x01, 0xbf, 0x08, 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, + 0x55, 0xf9, 0xe3, 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, + 0xff, 0x1e, 0xa0, 0x9d, 0x02, 0x04, 0xd2, 0x1d, 0x91, 0x72, 0x91, 0x4d, 0x88, 0xde, 0xc6, 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, + 0x71, 0x9c, 0x33, 0x78, 0xdd, 0xf7, 0xe5, 0x04, 0x0c, 0xf0, 0x9f, 0x01, 0xfa, 0x40, 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, + 0x13, 0x9d, 0x00, 0x3b, 0x12, 0x8a, 0x5f, 0xb7, 0xb0, 0x25, 0x6e, 0xc0, 0xa1, 0xfe, 0x62, 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, + 0x8b, 0xe3, 0x0f, 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, 0x0f, 0xa6, 0x7b, - 0x89, 0xc0, 0xca, 0xb3, 0xc3, 0x9b, 0x7b, 0xbf, 0x3c, 0xbb, 0x5a, 0x29, 0x69, 0xfd, 0x39, 0xaa, - 0x4e, 0x9e, 0x06, 0x33, 0x8c, 0xf7, 0x2a, 0x5a, 0xf2, 0x55, 0x9d, 0x77, 0xb8, 0xff, 0x75, 0xf8, - 0xf3, 0xab, 0xcb, 0x5a, 0x70, 0x71, 0x59, 0x0b, 0xfe, 0xb9, 0xac, 0x05, 0x7f, 0x5d, 0xd5, 0xe6, - 0x2e, 0xae, 0x6a, 0x73, 0x7f, 0x5f, 0xd5, 0xe6, 0x9e, 0x3f, 0xea, 0x49, 0xdb, 0x8f, 0xbb, 0x0d, - 0xa6, 0x87, 0x4d, 0xa6, 0x61, 0xa8, 0xa1, 0xf9, 0x26, 0xab, 0xcf, 0x8b, 0x2f, 0x92, 0xe4, 0x41, - 0xf3, 0x7c, 0xfc, 0xb3, 0xc4, 0x8e, 0x22, 0x01, 0xdd, 0x25, 0xf7, 0x45, 0xf2, 0xc5, 0x7f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0xa6, 0x52, 0x42, 0x65, 0x8e, 0x09, 0x00, 0x00, + 0x9f, 0xf6, 0xcd, 0x34, 0x4d, 0xa1, 0x27, 0xf2, 0xfe, 0xf5, 0xe0, 0x4d, 0x42, 0xc5, 0xfd, 0x3e, + 0x12, 0xf6, 0xb1, 0x0b, 0x6b, 0x53, 0x76, 0x2a, 0xec, 0x13, 0x6a, 0x69, 0x7e, 0xd1, 0x3c, 0x7b, + 0xd6, 0x62, 0xb3, 0x4d, 0x80, 0x3f, 0x41, 0x18, 0x06, 0x14, 0xfa, 0x84, 0xeb, 0x33, 0x95, 0x96, + 0x99, 0x50, 0x76, 0xea, 0x9a, 0x55, 0xa5, 0xb3, 0xe1, 0x90, 0x27, 0x1e, 0x78, 0xc4, 0x4e, 0xf1, + 0x73, 0xf4, 0xde, 0xd8, 0x34, 0x21, 0x52, 0x71, 0x71, 0x1e, 0x2e, 0x3b, 0x83, 0x9f, 0x4f, 0xf7, + 0x12, 0x81, 0x95, 0x67, 0x87, 0x37, 0xf7, 0x6e, 0x79, 0x76, 0xb5, 0x52, 0xd2, 0xfa, 0x33, 0x54, + 0x9d, 0x3c, 0x0d, 0x66, 0x18, 0xef, 0x55, 0xb4, 0xe4, 0xab, 0x3a, 0xef, 0x70, 0xff, 0xeb, 0xf0, + 0xe7, 0x97, 0x97, 0xb5, 0xe0, 0xe2, 0xb2, 0x16, 0xfc, 0x73, 0x59, 0x0b, 0xfe, 0xba, 0xaa, 0xcd, + 0x5d, 0x5c, 0xd5, 0xe6, 0xfe, 0xbe, 0xaa, 0xcd, 0x3d, 0x7b, 0xd8, 0x93, 0xb6, 0x1f, 0x77, 0x1b, + 0x4c, 0x0f, 0x9b, 0x4c, 0xc3, 0x50, 0x43, 0xf3, 0x75, 0x56, 0x9f, 0x16, 0x5f, 0x24, 0xc9, 0x17, + 0xcd, 0xf3, 0xf1, 0xcf, 0x12, 0x3b, 0x8a, 0x04, 0x74, 0x97, 0xdc, 0x17, 0xc9, 0x67, 0xff, 0x05, + 0x00, 0x00, 0xff, 0xff, 0xae, 0xb1, 0x22, 0x59, 0x8e, 0x09, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index 323aaa49be..6a9e5a7593 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -4,9 +4,10 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,9 +15,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" - ccv "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // Tests validation of consumer states and params within a provider genesis state @@ -81,7 +82,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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -102,7 +103,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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -123,7 +124,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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -144,7 +145,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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -171,7 +172,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -198,7 +199,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -225,7 +226,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(1000000)}, 600, 24), nil, nil, nil, @@ -252,7 +253,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -279,7 +280,7 @@ func TestValidateGenesisState(t *testing.T) { 0, // 0 vsc timeout here types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -306,7 +307,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, 0, // 0 slash meter replenish period here types.DefaultSlashMeterReplenishFraction, - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -333,7 +334,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, "1.15", - sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 600, 24), + sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -685,7 +686,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", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: math.NewInt(10000000)}, 600, 24), nil, nil, nil, @@ -706,7 +707,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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}, 600, 24), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(-1000000)}, 600, 24), nil, nil, nil, diff --git a/x/ccv/provider/types/key_assignment.go b/x/ccv/provider/types/key_assignment.go index 04192ae53a..ee403e1e49 100644 --- a/x/ccv/provider/types/key_assignment.go +++ b/x/ccv/provider/types/key_assignment.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // A validator's consensus address on the provider chain. diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index ee11633e5c..47231c219f 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) type Status int @@ -194,6 +194,18 @@ const ( // Fully defined key func section // +const ( + // ParametersKey is the is the single byte key for storing provider's parameters. + // note that this was set to the max uint8 type value 0xFF in order to protect + // from using the ICS v5.0.0 provider module by mistake + ParametersByteKey = byte(0xFF) +) + +// ParametersKey returns the key for the parameters of the provider module in the store +func ParametersKey() []byte { + return []byte{ParametersByteKey} +} + // PortKey returns the key to the port ID in the store func PortKey() []byte { return []byte{PortByteKey} diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index a0c14c4ebd..3f6df5cb0a 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -8,8 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - cryptoutil "github.com/cosmos/interchain-security/v4/testutil/crypto" - providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + cryptoutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // Tests that all singular keys, or prefixes to fully resolves keys are non duplicate byte values. @@ -62,6 +62,7 @@ func getAllKeyPrefixes() []byte { providertypes.ConsumerRewardsAllocationBytePrefix, providertypes.ConsumerCommissionRatePrefix, providertypes.MinimumPowerInTopNBytePrefix, + providertypes.ParametersByteKey, } } diff --git a/x/ccv/provider/types/proposal.go b/x/ccv/provider/types/legacy_proposal.go similarity index 97% rename from x/ccv/provider/types/proposal.go rename to x/ccv/provider/types/legacy_proposal.go index 780fda5c44..37c068e1c2 100644 --- a/x/ccv/provider/types/proposal.go +++ b/x/ccv/provider/types/legacy_proposal.go @@ -6,15 +6,16 @@ import ( "strings" time "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + evidencetypes "cosmossdk.io/x/evidence/types" 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" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -96,7 +97,7 @@ func (cccp *ConsumerAdditionProposal) ProposalType() string { } // ValidatePSSFeatures returns an error if the `topN` and `validatorsPowerCap` parameters are no in the correct ranges -func ValidatePSSFeatures(topN, validatorsPowerCap uint32) error { +func ValidatePSSFeatures(topN uint32, validatorsPowerCap uint32) error { // Top N corresponds to the top N% of validators that have to validate the consumer chain and can only be 0 (for an // Opt In chain) or in the range [50, 100] (for a Top N chain). if topN != 0 && (topN < 50 || topN > 100) { @@ -356,12 +357,12 @@ func (crdp *ChangeRewardDenomsProposal) ValidateBasic() error { // Return error if any denom is "invalid" for _, denom := range crdp.DenomsToAdd { - if !sdk.NewCoin(denom, sdk.NewInt(1)).IsValid() { + if !sdk.NewCoin(denom, math.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() { + if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) } } diff --git a/x/ccv/provider/types/proposal_test.go b/x/ccv/provider/types/legacy_proposal_test.go similarity index 98% rename from x/ccv/provider/types/proposal_test.go rename to x/ccv/provider/types/legacy_proposal_test.go index 91254ad265..729a4318ca 100644 --- a/x/ccv/provider/types/proposal_test.go +++ b/x/ccv/provider/types/legacy_proposal_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/protobuf/proto" //nolint:staticcheck // see: https://github.com/cosmos/interchain-security/issues/236 "github.com/stretchr/testify/require" @@ -15,7 +15,7 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestConsumerAdditionProposalValidateBasic(t *testing.T) { diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index b80e608785..f74d8b9d78 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -5,16 +5,17 @@ import ( "fmt" "strings" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // provider message types @@ -28,23 +29,39 @@ const ( ) var ( - _ sdk.Msg = &MsgAssignConsumerKey{} - _ sdk.Msg = &MsgSubmitConsumerMisbehaviour{} - _ sdk.Msg = &MsgSubmitConsumerDoubleVoting{} - _ sdk.Msg = &MsgOptIn{} - _ sdk.Msg = &MsgOptOut{} - _ sdk.Msg = &MsgSetConsumerCommissionRate{} + _ sdk.Msg = (*MsgAssignConsumerKey)(nil) + _ sdk.Msg = (*MsgConsumerAddition)(nil) + _ sdk.Msg = (*MsgConsumerRemoval)(nil) + _ sdk.Msg = (*MsgConsumerModification)(nil) + _ sdk.Msg = (*MsgChangeRewardDenoms)(nil) + _ sdk.Msg = (*MsgSubmitConsumerMisbehaviour)(nil) + _ sdk.Msg = (*MsgSubmitConsumerDoubleVoting)(nil) + _ sdk.Msg = (*MsgOptIn)(nil) + _ sdk.Msg = (*MsgOptOut)(nil) + _ sdk.Msg = (*MsgSetConsumerCommissionRate)(nil) + + _ sdk.HasValidateBasic = (*MsgAssignConsumerKey)(nil) + _ sdk.HasValidateBasic = (*MsgConsumerAddition)(nil) + _ sdk.HasValidateBasic = (*MsgConsumerRemoval)(nil) + _ sdk.HasValidateBasic = (*MsgConsumerModification)(nil) + _ sdk.HasValidateBasic = (*MsgChangeRewardDenoms)(nil) + _ sdk.HasValidateBasic = (*MsgSubmitConsumerMisbehaviour)(nil) + _ sdk.HasValidateBasic = (*MsgSubmitConsumerDoubleVoting)(nil) + _ sdk.HasValidateBasic = (*MsgOptIn)(nil) + _ sdk.HasValidateBasic = (*MsgOptOut)(nil) + _ sdk.HasValidateBasic = (*MsgSetConsumerCommissionRate)(nil) ) // NewMsgAssignConsumerKey creates a new MsgAssignConsumerKey instance. // Delegator address and validator address are the same. func NewMsgAssignConsumerKey(chainID string, providerValidatorAddress sdk.ValAddress, - consumerConsensusPubKey string, + consumerConsensusPubKey, signer string, ) (*MsgAssignConsumerKey, error) { return &MsgAssignConsumerKey{ ChainId: chainID, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, + Signer: signer, }, nil } @@ -210,15 +227,112 @@ func (msg MsgSubmitConsumerDoubleVoting) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +// If the validator address is not same as delegator's, then the validator must +// sign the msg as well. +func (msg *MsgConsumerAddition) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Authority) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgConsumerAddition) ValidateBasic() error { + if strings.TrimSpace(msg.ChainId) == "" { + return ErrBlankConsumerChainID + } + + if msg.InitialHeight.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "initial height cannot be zero") + } + + if len(msg.GenesisHash) == 0 { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "genesis hash cannot be empty") + } + if len(msg.BinaryHash) == 0 { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "binary hash cannot be empty") + } + + if msg.SpawnTime.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "spawn time cannot be zero") + } + + if err := ccvtypes.ValidateStringFraction(msg.ConsumerRedistributionFraction); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerAdditionProposal, "consumer redistribution fraction is invalid: %s", err) + } + + if err := ccvtypes.ValidatePositiveInt64(msg.BlocksPerDistributionTransmission); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "blocks per distribution transmission cannot be < 1") + } + + if err := ccvtypes.ValidateDistributionTransmissionChannel(msg.DistributionTransmissionChannel); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "distribution transmission channel") + } + + if err := ccvtypes.ValidatePositiveInt64(msg.HistoricalEntries); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "historical entries cannot be < 1") + } + + if err := ccvtypes.ValidateDuration(msg.CcvTimeoutPeriod); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "ccv timeout period cannot be zero") + } + + if err := ccvtypes.ValidateDuration(msg.TransferTimeoutPeriod); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "transfer timeout period cannot be zero") + } + + if err := ccvtypes.ValidateDuration(msg.UnbondingPeriod); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "unbonding period cannot be zero") + } + + return nil +} + +func (msg *MsgConsumerRemoval) ValidateBasic() error { + + if strings.TrimSpace(msg.ChainId) == "" { + return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "consumer chain id must not be blank") + } + + if msg.StopTime.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "spawn time cannot be zero") + } + return nil +} + +// ValidateBasic implements the sdk.Msg interface. +func (msg *MsgConsumerModification) ValidateBasic() error { + if strings.TrimSpace(msg.ChainId) == "" { + return ErrBlankConsumerChainID + } + + err := ValidatePSSFeatures(msg.Top_N, msg.ValidatorsPowerCap) + if err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) + } + + return nil +} + // NewMsgOptIn creates a new NewMsgOptIn instance. -func NewMsgOptIn(chainID string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey string) (*MsgOptIn, error) { +func NewMsgOptIn(chainID string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { return &MsgOptIn{ ChainId: chainID, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, + Signer: signer, }, nil } +// Type implements the sdk.Msg interface. +func (msg MsgOptIn) Type() string { + return TypeMsgOptIn +} + // Route implements the sdk.Msg interface. func (msg MsgOptIn) Route() string { return RouterKey } @@ -233,12 +347,6 @@ func (msg MsgOptIn) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{valAddr.Bytes()} } -// GetSignBytes returns the message bytes to sign over. -func (msg MsgOptIn) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - // ValidateBasic implements the sdk.Msg interface. func (msg MsgOptIn) ValidateBasic() error { if strings.TrimSpace(msg.ChainId) == "" { @@ -264,21 +372,22 @@ func (msg MsgOptIn) ValidateBasic() error { } // NewMsgOptOut creates a new NewMsgOptIn instance. -func NewMsgOptOut(chainID string, providerValidatorAddress sdk.ValAddress) (*MsgOptOut, error) { +func NewMsgOptOut(chainID string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { return &MsgOptOut{ ChainId: chainID, ProviderAddr: providerValidatorAddress.String(), + Signer: signer, }, nil } -// Route implements the sdk.Msg interface. -func (msg MsgOptOut) Route() string { return RouterKey } - // Type implements the sdk.Msg interface. -func (msg MsgOptIn) Type() string { - return TypeMsgOptIn +func (msg MsgOptOut) Type() string { + return TypeMsgOptOut } +// Route implements the sdk.Msg interface. +func (msg MsgOptOut) Route() string { return RouterKey } + // GetSigners implements the sdk.Msg interface. It returns the address(es) that // must sign over msg.GetSignBytes(). func (msg MsgOptOut) GetSigners() []sdk.AccAddress { @@ -315,7 +424,7 @@ func (msg MsgOptOut) ValidateBasic() error { } // NewMsgSetConsumerCommissionRate creates a new MsgSetConsumerCommissionRate msg instance. -func NewMsgSetConsumerCommissionRate(chainID string, commission sdk.Dec, providerValidatorAddress sdk.ValAddress) *MsgSetConsumerCommissionRate { +func NewMsgSetConsumerCommissionRate(chainID string, commission math.LegacyDec, providerValidatorAddress sdk.ValAddress) *MsgSetConsumerCommissionRate { return &MsgSetConsumerCommissionRate{ ChainId: chainID, Rate: commission, @@ -323,11 +432,6 @@ func NewMsgSetConsumerCommissionRate(chainID string, commission sdk.Dec, provide } } -// Type implements the sdk.Msg interface. -func (msg MsgOptOut) Type() string { - return TypeMsgOptOut -} - func (msg MsgSetConsumerCommissionRate) Route() string { return RouterKey } @@ -349,13 +453,47 @@ func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { return ErrInvalidProviderAddress } - if msg.Rate.IsNegative() || msg.Rate.GT(sdk.OneDec()) { + if msg.Rate.IsNegative() || msg.Rate.GT(math.LegacyOneDec()) { return errorsmod.Wrapf(ErrInvalidConsumerCommissionRate, "consumer commission rate should be in the range [0, 1]") } return nil } +func (msg *MsgChangeRewardDenoms) ValidateBasic() error { + emptyDenomsToAdd := len(msg.DenomsToAdd) == 0 + emptyDenomsToRemove := len(msg.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 msg.DenomsToAdd { + for _, denomToRemove := range msg.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 msg.DenomsToAdd { + if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + for _, denom := range msg.DenomsToRemove { + if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + + return nil +} + func (msg MsgSetConsumerCommissionRate) GetSigners() []sdk.AccAddress { valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil { diff --git a/x/ccv/provider/types/params.go b/x/ccv/provider/types/params.go index 2c04dd511c..81d69cd7eb 100644 --- a/x/ccv/provider/types/params.go +++ b/x/ccv/provider/types/params.go @@ -4,14 +4,15 @@ import ( "fmt" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -55,6 +56,9 @@ const ( ) // Reflection based keys for params subspace +// Legacy: usage of x/params for parameters is deprecated. +// Use x/ccv/provider/keeper/params instead +// [DEPRECATED] var ( KeyTemplateClient = []byte("TemplateClient") KeyTrustingPeriodFraction = []byte("TrustingPeriodFraction") @@ -124,7 +128,7 @@ func DefaultParams() Params { // Following the pattern from cosmos-sdk/staking/types/params.go sdk.Coin{ Denom: sdk.DefaultBondDenom, - Amount: sdk.NewInt(10000000), + Amount: math.NewInt(10000000), }, DefaultBlocksPerEpoch, DefaultNumberOfEpochsToStartReceivingRewards, diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index bcec7c7c77..8ff8da58f1 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -4,14 +4,15 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/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" + "cosmossdk.io/math" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) func TestValidateParams(t *testing.T) { @@ -24,43 +25,43 @@ 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), true}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), false}, {"blank client", types.NewParams(&ibctmtypes.ClientState{}, - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), 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)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), false}, + {"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), true}, + "0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: math.NewInt(10000000)}, 1000, 24), 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}, 1000, 24), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(-10000000)}, 1000, 24), false}, {"invalid number of epochs to start receiving rewards", 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", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}, 1000, 0), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 1000, 0), false}, } for _, tc := range testCases { diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 8649882e18..e602595797 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -4,18 +4,19 @@ package types import ( + types1 "cosmossdk.io/x/evidence/types" fmt "fmt" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types2 "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - types1 "github.com/cosmos/cosmos-sdk/x/evidence/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" 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/v4/x/ccv/types" + types "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + _07_tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + types3 "github.com/cosmos/interchain-security/v5/x/ccv/types" _ "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/protobuf/types/known/timestamppb" io "io" @@ -41,6 +42,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // chain are expected to validate the consumer chain at spawn time or get // slashed. It is recommended that spawn time occurs after the proposal end // time. +// Use MsgConsumerAddition to submit this proposal type. type ConsumerAdditionProposal struct { // the title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -149,6 +151,7 @@ var xxx_messageInfo_ConsumerAdditionProposal proto.InternalMessageInfo // remove (and stop) a consumer chain. If it passes, all the consumer chain's // state is removed from the provider chain. The outstanding unbonding operation // funds are released. +// Use MsgConsumerRemoval to submit this proposal type. type ConsumerRemovalProposal struct { // the title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -414,6 +417,7 @@ func (m *EquivocationProposal) GetEquivocations() []*types1.Equivocation { // ChangeRewardDenomsProposal is a governance proposal on the provider chain to // mutate the set of denoms accepted by the provider as rewards. +// Use MsgChangeRewardDenoms to submit this proposal type. type ChangeRewardDenomsProposal struct { // the title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -1700,134 +1704,136 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 2022 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x73, 0x1c, 0x47, - 0x15, 0xd7, 0x68, 0x57, 0xd2, 0xee, 0x5b, 0x7d, 0xb6, 0x94, 0x78, 0x64, 0x84, 0x24, 0x4f, 0x70, - 0x10, 0x31, 0xde, 0x8d, 0x1c, 0xa8, 0x72, 0xb9, 0x48, 0xa5, 0xa4, 0x95, 0x13, 0x7f, 0xc4, 0xb6, - 0x32, 0x12, 0x76, 0x11, 0x0e, 0x53, 0xbd, 0x3d, 0xad, 0xdd, 0x46, 0xb3, 0xd3, 0xe3, 0xee, 0xde, - 0x71, 0xf6, 0xc2, 0x99, 0x03, 0x54, 0x85, 0x5b, 0x8a, 0x03, 0x04, 0x4e, 0x14, 0x17, 0xf8, 0x0f, - 0xb8, 0x51, 0x39, 0xe6, 0xc8, 0x29, 0xa1, 0xec, 0x03, 0x07, 0xfe, 0x09, 0xaa, 0x7b, 0x3e, 0x77, - 0x25, 0x99, 0x75, 0x85, 0x5c, 0xa4, 0x99, 0xd7, 0xbf, 0xf7, 0x7b, 0xaf, 0xfb, 0xbd, 0x7e, 0xef, - 0xed, 0xc0, 0x0d, 0x16, 0x2a, 0x2a, 0x48, 0x0f, 0xb3, 0xd0, 0x93, 0x94, 0x0c, 0x04, 0x53, 0xc3, - 0x16, 0x21, 0x71, 0x2b, 0x12, 0x3c, 0x66, 0x3e, 0x15, 0xad, 0x78, 0x37, 0x7f, 0x6e, 0x46, 0x82, - 0x2b, 0x8e, 0xde, 0x38, 0x47, 0xa7, 0x49, 0x48, 0xdc, 0xcc, 0x71, 0xf1, 0xee, 0xe5, 0xab, 0x17, - 0x11, 0xc7, 0xbb, 0xad, 0x67, 0x4c, 0xd0, 0x84, 0xeb, 0xf2, 0x5a, 0x97, 0x77, 0xb9, 0x79, 0x6c, - 0xe9, 0xa7, 0x54, 0xba, 0xd5, 0xe5, 0xbc, 0x1b, 0xd0, 0x96, 0x79, 0xeb, 0x0c, 0x4e, 0x5a, 0x8a, - 0xf5, 0xa9, 0x54, 0xb8, 0x1f, 0xa5, 0x80, 0xcd, 0x71, 0x80, 0x3f, 0x10, 0x58, 0x31, 0x1e, 0x66, - 0x04, 0xac, 0x43, 0x5a, 0x84, 0x0b, 0xda, 0x22, 0x01, 0xa3, 0xa1, 0xd2, 0x56, 0x93, 0xa7, 0x14, - 0xd0, 0xd2, 0x80, 0x80, 0x75, 0x7b, 0x2a, 0x11, 0xcb, 0x96, 0xa2, 0xa1, 0x4f, 0x45, 0x9f, 0x25, - 0xe0, 0xe2, 0x2d, 0x55, 0xd8, 0x28, 0xad, 0x13, 0x31, 0x8c, 0x14, 0x6f, 0x9d, 0xd2, 0xa1, 0x4c, - 0x57, 0xdf, 0x24, 0x5c, 0xf6, 0xb9, 0x6c, 0x51, 0xbd, 0xff, 0x90, 0xd0, 0x56, 0xbc, 0xdb, 0xa1, - 0x0a, 0xef, 0xe6, 0x82, 0xcc, 0xef, 0x14, 0xd7, 0xc1, 0xb2, 0xc0, 0x10, 0xce, 0x32, 0xbf, 0x57, - 0x70, 0x9f, 0x85, 0xbc, 0x65, 0xfe, 0x26, 0x22, 0xe7, 0xd7, 0x35, 0xb0, 0xdb, 0x3c, 0x94, 0x83, - 0x3e, 0x15, 0x7b, 0xbe, 0xcf, 0xf4, 0x2e, 0x0f, 0x05, 0x8f, 0xb8, 0xc4, 0x01, 0x5a, 0x83, 0x19, - 0xc5, 0x54, 0x40, 0x6d, 0x6b, 0xdb, 0xda, 0xa9, 0xbb, 0xc9, 0x0b, 0xda, 0x86, 0x86, 0x4f, 0x25, - 0x11, 0x2c, 0xd2, 0x60, 0x7b, 0xda, 0xac, 0x95, 0x45, 0x68, 0x1d, 0x6a, 0x49, 0x68, 0x98, 0x6f, - 0x57, 0xcc, 0xf2, 0x9c, 0x79, 0xbf, 0xeb, 0xa3, 0x0f, 0x60, 0x91, 0x85, 0x4c, 0x31, 0x1c, 0x78, - 0x3d, 0xaa, 0x0f, 0xc8, 0xae, 0x6e, 0x5b, 0x3b, 0x8d, 0x1b, 0x97, 0x9b, 0xac, 0x43, 0x9a, 0xfa, - 0x4c, 0x9b, 0xe9, 0x49, 0xc6, 0xbb, 0xcd, 0x3b, 0x06, 0xb1, 0x5f, 0xfd, 0xe2, 0xab, 0xad, 0x29, - 0x77, 0x21, 0xd5, 0x4b, 0x84, 0xe8, 0x0a, 0xcc, 0x77, 0x69, 0x48, 0x25, 0x93, 0x5e, 0x0f, 0xcb, - 0x9e, 0x3d, 0xb3, 0x6d, 0xed, 0xcc, 0xbb, 0x8d, 0x54, 0x76, 0x07, 0xcb, 0x1e, 0xda, 0x82, 0x46, - 0x87, 0x85, 0x58, 0x0c, 0x13, 0xc4, 0xac, 0x41, 0x40, 0x22, 0x32, 0x80, 0x36, 0x80, 0x8c, 0xf0, - 0xb3, 0xd0, 0xd3, 0x09, 0x60, 0xcf, 0xa5, 0x8e, 0x24, 0xc1, 0x6f, 0x66, 0xc1, 0x6f, 0x1e, 0x67, - 0xd9, 0xb1, 0x5f, 0xd3, 0x8e, 0x7c, 0xfa, 0xf5, 0x96, 0xe5, 0xd6, 0x8d, 0x9e, 0x5e, 0x41, 0x0f, - 0x61, 0x79, 0x10, 0x76, 0x78, 0xe8, 0xb3, 0xb0, 0xeb, 0x45, 0x54, 0x30, 0xee, 0xdb, 0x35, 0x43, - 0xb5, 0x7e, 0x86, 0xea, 0x20, 0xcd, 0xa3, 0x84, 0xe9, 0x33, 0xcd, 0xb4, 0x94, 0x2b, 0x1f, 0x1a, - 0x5d, 0xf4, 0x11, 0x20, 0x42, 0x62, 0xe3, 0x12, 0x1f, 0xa8, 0x8c, 0xb1, 0x3e, 0x39, 0xe3, 0x32, - 0x21, 0xf1, 0x71, 0xa2, 0x9d, 0x52, 0xfe, 0x1c, 0x2e, 0x29, 0x81, 0x43, 0x79, 0x42, 0xc5, 0x38, - 0x2f, 0x4c, 0xce, 0xfb, 0x5a, 0xc6, 0x31, 0x4a, 0x7e, 0x07, 0xb6, 0x49, 0x9a, 0x40, 0x9e, 0xa0, - 0x3e, 0x93, 0x4a, 0xb0, 0xce, 0x40, 0xeb, 0x7a, 0x27, 0x02, 0x13, 0x93, 0x23, 0x0d, 0x93, 0x04, - 0x9b, 0x19, 0xce, 0x1d, 0x81, 0xbd, 0x9f, 0xa2, 0xd0, 0x23, 0xf8, 0x5e, 0x27, 0xe0, 0xe4, 0x54, - 0x6a, 0xe7, 0xbc, 0x11, 0x26, 0x63, 0xba, 0xcf, 0xa4, 0xd4, 0x6c, 0xf3, 0xdb, 0xd6, 0x4e, 0xc5, - 0xbd, 0x92, 0x60, 0x0f, 0xa9, 0x38, 0x28, 0x21, 0x8f, 0x4b, 0x40, 0x74, 0x1d, 0x50, 0x8f, 0x49, - 0xc5, 0x05, 0x23, 0x38, 0xf0, 0x68, 0xa8, 0x04, 0xa3, 0xd2, 0x5e, 0x30, 0xea, 0x2b, 0xc5, 0xca, - 0xed, 0x64, 0x01, 0xdd, 0x83, 0x2b, 0x17, 0x1a, 0xf5, 0x48, 0x0f, 0x87, 0x21, 0x0d, 0xec, 0x45, - 0xb3, 0x95, 0x2d, 0xff, 0x02, 0x9b, 0xed, 0x04, 0x86, 0x56, 0x61, 0x46, 0xf1, 0xc8, 0x7b, 0x68, - 0x2f, 0x6d, 0x5b, 0x3b, 0x0b, 0x6e, 0x55, 0xf1, 0xe8, 0x21, 0x7a, 0x1b, 0xd6, 0x62, 0x1c, 0x30, - 0x1f, 0x2b, 0x2e, 0xa4, 0x17, 0xf1, 0x67, 0x54, 0x78, 0x04, 0x47, 0xf6, 0xb2, 0xc1, 0xa0, 0x62, - 0xed, 0x50, 0x2f, 0xb5, 0x71, 0x84, 0xde, 0x82, 0x95, 0x5c, 0xea, 0x49, 0xaa, 0x0c, 0x7c, 0xc5, - 0xc0, 0x97, 0xf2, 0x85, 0x23, 0xaa, 0x34, 0x76, 0x03, 0xea, 0x38, 0x08, 0xf8, 0xb3, 0x80, 0x49, - 0x65, 0xa3, 0xed, 0xca, 0x4e, 0xdd, 0x2d, 0x04, 0xe8, 0x32, 0xd4, 0x7c, 0x1a, 0x0e, 0xcd, 0xe2, - 0xaa, 0x59, 0xcc, 0xdf, 0x6f, 0xd5, 0x7e, 0xf5, 0xf9, 0xd6, 0xd4, 0x67, 0x9f, 0x6f, 0x4d, 0x39, - 0x7f, 0xb5, 0xe0, 0x52, 0x3b, 0x8f, 0x52, 0x9f, 0xc7, 0x38, 0xf8, 0x36, 0xab, 0xc1, 0x1e, 0xd4, - 0xa5, 0x3e, 0x26, 0x73, 0xff, 0xaa, 0xaf, 0x70, 0xff, 0x6a, 0x5a, 0x4d, 0x2f, 0x38, 0xbf, 0x9f, - 0x86, 0x8d, 0xcc, 0xe3, 0x07, 0xdc, 0x67, 0x27, 0x8c, 0xe0, 0x6f, 0xbb, 0x88, 0xe5, 0xc1, 0xad, - 0x4e, 0x10, 0xdc, 0x99, 0x57, 0x0b, 0xee, 0xec, 0x04, 0xc1, 0x9d, 0x7b, 0x59, 0x70, 0x6b, 0xa3, - 0xc1, 0x75, 0xfe, 0x60, 0xc1, 0xda, 0xed, 0xa7, 0x03, 0x16, 0xf3, 0xff, 0xd3, 0xc1, 0xdc, 0x87, - 0x05, 0x5a, 0xe2, 0x93, 0x76, 0x65, 0xbb, 0xb2, 0xd3, 0xb8, 0x71, 0xb5, 0x99, 0x74, 0x9f, 0x66, - 0xde, 0x94, 0xd2, 0x0e, 0xd4, 0x2c, 0x5b, 0x77, 0x47, 0x75, 0x6f, 0x4d, 0xdb, 0x96, 0xf3, 0x27, - 0x0b, 0x2e, 0xeb, 0x7b, 0xd3, 0xa5, 0x2e, 0x7d, 0x86, 0x85, 0x7f, 0x40, 0x43, 0xde, 0x97, 0xdf, - 0xd8, 0x4f, 0x07, 0x16, 0x7c, 0xc3, 0xe4, 0x29, 0xee, 0x61, 0xdf, 0x37, 0x7e, 0x1a, 0x8c, 0x16, - 0x1e, 0xf3, 0x3d, 0xdf, 0x47, 0x3b, 0xb0, 0x5c, 0x60, 0x84, 0x4e, 0x78, 0x9d, 0x87, 0x1a, 0xb6, - 0x98, 0xc1, 0xcc, 0x35, 0xa0, 0xce, 0x7f, 0x2c, 0x58, 0xfe, 0x20, 0xe0, 0x1d, 0x1c, 0x1c, 0x05, - 0x58, 0xf6, 0x74, 0xcd, 0x18, 0xea, 0xfc, 0x15, 0x34, 0x2d, 0xd6, 0xc6, 0xbd, 0x89, 0xf3, 0x57, - 0xab, 0x99, 0xf6, 0xf1, 0x1e, 0xac, 0xe4, 0xe5, 0x33, 0xcf, 0x37, 0xb3, 0x9b, 0xfd, 0xd5, 0xe7, - 0x5f, 0x6d, 0x2d, 0x65, 0xb9, 0xdd, 0x36, 0xb9, 0x77, 0xe0, 0x2e, 0x91, 0x11, 0x81, 0x8f, 0x36, - 0xa1, 0xc1, 0x3a, 0xc4, 0x93, 0xf4, 0xa9, 0x17, 0x0e, 0xfa, 0x26, 0x55, 0xab, 0x6e, 0x9d, 0x75, - 0xc8, 0x11, 0x7d, 0xfa, 0x70, 0xd0, 0x47, 0xef, 0xc0, 0xeb, 0xd9, 0xe4, 0xe4, 0xc5, 0x38, 0xf0, - 0xb4, 0xbe, 0x3e, 0x0e, 0x61, 0xb2, 0x77, 0xde, 0x5d, 0xcd, 0x56, 0x1f, 0xe3, 0x40, 0x1b, 0xdb, - 0xf3, 0x7d, 0xe1, 0xfc, 0x7d, 0x16, 0x66, 0x0f, 0xb1, 0xc0, 0x7d, 0x89, 0x8e, 0x61, 0x49, 0xd1, - 0x7e, 0x14, 0x60, 0x45, 0xbd, 0xa4, 0x35, 0xa7, 0x3b, 0xbd, 0x66, 0x5a, 0x76, 0x79, 0xca, 0x69, - 0x96, 0xe6, 0x9a, 0x78, 0xb7, 0xd9, 0x36, 0xd2, 0x23, 0x85, 0x15, 0x75, 0x17, 0x33, 0x8e, 0x44, - 0x88, 0x6e, 0x82, 0xad, 0xc4, 0x40, 0xaa, 0xa2, 0x69, 0x16, 0xdd, 0x22, 0x89, 0xe5, 0xeb, 0xd9, - 0x7a, 0xd2, 0x67, 0xf2, 0x2e, 0x71, 0x7e, 0x7f, 0xac, 0x7c, 0x93, 0xfe, 0x78, 0x04, 0xab, 0x7a, - 0xb8, 0x18, 0xe7, 0xac, 0x4e, 0xce, 0xb9, 0xa2, 0xf5, 0x47, 0x49, 0x3f, 0x02, 0x14, 0x4b, 0x32, - 0xce, 0x39, 0xf3, 0x0a, 0x7e, 0xc6, 0x92, 0x8c, 0x52, 0xfa, 0xb0, 0x21, 0x75, 0xf2, 0x79, 0x7d, - 0xaa, 0x4c, 0xb7, 0x8d, 0x02, 0x1a, 0x32, 0xd9, 0xcb, 0xc8, 0x67, 0x27, 0x27, 0x5f, 0x37, 0x44, - 0x0f, 0x34, 0x8f, 0x9b, 0xd1, 0xa4, 0x56, 0xda, 0xb0, 0x79, 0xbe, 0x95, 0x3c, 0x40, 0x73, 0x26, - 0x40, 0xdf, 0x39, 0x87, 0x22, 0x8f, 0x92, 0x84, 0x37, 0x4b, 0x53, 0x81, 0xbe, 0xd5, 0x9e, 0xb9, - 0x50, 0x9e, 0xa0, 0x5d, 0xdd, 0x3a, 0x71, 0x32, 0x20, 0x50, 0x9a, 0x4f, 0x36, 0x69, 0xf5, 0xd0, - 0xb3, 0x6b, 0x5e, 0x39, 0xda, 0x9c, 0x85, 0xe9, 0xf8, 0xe7, 0x14, 0xc3, 0x43, 0x5e, 0x23, 0xdc, - 0x12, 0xd7, 0xfb, 0x94, 0xea, 0xdb, 0x5c, 0x1a, 0x20, 0x68, 0xc4, 0x49, 0xcf, 0x0c, 0x38, 0x15, - 0x77, 0x31, 0x1f, 0x16, 0x6e, 0x6b, 0x29, 0xfa, 0x18, 0xae, 0x85, 0x83, 0x7e, 0x87, 0x0a, 0x8f, - 0x9f, 0x24, 0x40, 0x53, 0x01, 0xa4, 0xc2, 0x42, 0x79, 0x82, 0x12, 0xca, 0x62, 0x9d, 0x99, 0x89, - 0xe7, 0xd2, 0xcc, 0x2f, 0x15, 0xf7, 0x6a, 0xa2, 0xf2, 0xe8, 0xc4, 0x70, 0xc8, 0x63, 0x7e, 0xa4, - 0xe1, 0x6e, 0x86, 0x4e, 0x1c, 0x93, 0xf7, 0xaa, 0xb5, 0xda, 0x72, 0xdd, 0xf9, 0x01, 0xd4, 0x4d, - 0xa1, 0xd8, 0x23, 0xa7, 0xd2, 0x54, 0x6f, 0xdf, 0x17, 0x54, 0x4a, 0x2a, 0x6d, 0x2b, 0xad, 0xde, - 0x99, 0xc0, 0x51, 0xb0, 0x7e, 0xd1, 0x08, 0x2e, 0xd1, 0x13, 0x98, 0x8b, 0xa8, 0x99, 0x0f, 0x8d, - 0x62, 0xe3, 0xc6, 0xbb, 0xcd, 0x09, 0x7e, 0x20, 0x35, 0x2f, 0x22, 0x74, 0x33, 0x36, 0x47, 0x14, - 0x83, 0xff, 0x58, 0xa7, 0x97, 0xe8, 0xf1, 0xb8, 0xd1, 0x9f, 0xbc, 0x92, 0xd1, 0x31, 0xbe, 0xc2, - 0xe6, 0x35, 0x68, 0xec, 0x25, 0xdb, 0xfe, 0x50, 0xb7, 0xad, 0x33, 0xc7, 0x32, 0x5f, 0x3e, 0x96, - 0x7b, 0xb0, 0x98, 0x4e, 0x53, 0xc7, 0xdc, 0x14, 0x3b, 0xf4, 0x5d, 0x80, 0x74, 0x0c, 0xd3, 0x45, - 0x32, 0x69, 0x07, 0xf5, 0x54, 0x72, 0xd7, 0x1f, 0xe9, 0xd8, 0xd3, 0x23, 0x1d, 0xdb, 0x71, 0x61, - 0xe9, 0xb1, 0x24, 0x3f, 0xcd, 0x46, 0xed, 0x47, 0x91, 0x44, 0xaf, 0xc1, 0xac, 0xbe, 0x9f, 0x29, - 0x51, 0xd5, 0x9d, 0x89, 0x25, 0xb9, 0x6b, 0x3a, 0x42, 0x31, 0xce, 0xf3, 0xc8, 0x63, 0xbe, 0xb4, - 0xa7, 0xb7, 0x2b, 0x3b, 0x55, 0x77, 0x71, 0x50, 0xa8, 0xdf, 0xf5, 0xa5, 0xf3, 0x33, 0x68, 0x94, - 0x08, 0xd1, 0x22, 0x4c, 0xe7, 0x5c, 0xd3, 0xcc, 0x47, 0xb7, 0x60, 0xbd, 0x20, 0x1a, 0x2d, 0xf1, - 0x09, 0x63, 0xdd, 0xbd, 0x94, 0x03, 0x46, 0xaa, 0xbc, 0x74, 0x1e, 0xc1, 0xda, 0xdd, 0xa2, 0xa0, - 0xe4, 0x0d, 0x64, 0x64, 0x87, 0xd6, 0xe8, 0x4c, 0xb2, 0x01, 0xf5, 0xfc, 0x67, 0xac, 0xd9, 0x7d, - 0xd5, 0x2d, 0x04, 0x4e, 0x1f, 0x96, 0x1f, 0x4b, 0x72, 0x44, 0x43, 0xbf, 0x20, 0xbb, 0xe0, 0x00, - 0xf6, 0xc7, 0x89, 0x26, 0xfe, 0x4d, 0x54, 0x98, 0xe3, 0xb0, 0xfe, 0xb8, 0x3c, 0xc0, 0x98, 0xe6, - 0x7e, 0x88, 0xc9, 0x29, 0x55, 0x12, 0xb9, 0x50, 0x35, 0x83, 0x4a, 0x92, 0x59, 0x37, 0x2f, 0xcc, - 0xac, 0x78, 0xb7, 0x79, 0x11, 0xc9, 0x01, 0x56, 0x38, 0xad, 0x0b, 0x86, 0xcb, 0xf9, 0x3e, 0xac, - 0x3e, 0xc0, 0x6a, 0x20, 0xa8, 0x3f, 0x12, 0xe3, 0x65, 0xa8, 0xe8, 0xf8, 0x59, 0x26, 0x7e, 0xfa, - 0x51, 0xcf, 0x1a, 0xf6, 0xed, 0x4f, 0x22, 0x2e, 0x14, 0xf5, 0xcf, 0x9c, 0xc8, 0x4b, 0x8e, 0xf7, - 0x14, 0x56, 0xf5, 0x61, 0x49, 0x1a, 0xfa, 0x5e, 0xbe, 0xcf, 0x24, 0x8e, 0x8d, 0x1b, 0x3f, 0x9e, - 0xe8, 0x76, 0x8c, 0x9b, 0x4b, 0x37, 0xb0, 0x12, 0x8f, 0xc9, 0xa5, 0xf3, 0x5b, 0x0b, 0xec, 0xfb, - 0x74, 0xb8, 0x27, 0x25, 0xeb, 0x86, 0x7d, 0x1a, 0x2a, 0x5d, 0x5f, 0x31, 0xa1, 0xfa, 0x11, 0xbd, - 0x01, 0x0b, 0x79, 0x3f, 0x37, 0x6d, 0xdc, 0x32, 0x6d, 0x7c, 0x3e, 0x13, 0xea, 0x0b, 0x86, 0x6e, - 0x01, 0x44, 0x82, 0xc6, 0x1e, 0xf1, 0x4e, 0xe9, 0x30, 0x8d, 0xe2, 0x46, 0xb9, 0x3d, 0x27, 0x1f, - 0x19, 0x9a, 0x87, 0x83, 0x4e, 0xc0, 0xc8, 0x7d, 0x3a, 0x74, 0x6b, 0x1a, 0xdf, 0xbe, 0x4f, 0x87, - 0x7a, 0xde, 0x32, 0xd3, 0xab, 0xe9, 0xa9, 0x15, 0x37, 0x79, 0x71, 0x7e, 0x67, 0xc1, 0xa5, 0x3c, - 0x1c, 0x59, 0xba, 0x1e, 0x0e, 0x3a, 0x5a, 0xe3, 0x25, 0xe7, 0x76, 0xc6, 0xdb, 0xe9, 0x73, 0xbc, - 0x7d, 0x0f, 0xe6, 0xf3, 0x0b, 0xa2, 0xfd, 0xad, 0x4c, 0xe0, 0x6f, 0x23, 0xd3, 0xb8, 0x4f, 0x87, - 0xce, 0x2f, 0x4b, 0xbe, 0xed, 0x0f, 0x4b, 0xb5, 0x4f, 0xfc, 0x0f, 0xdf, 0x72, 0xb3, 0x65, 0xdf, - 0x48, 0x59, 0xff, 0xcc, 0x06, 0x2a, 0x67, 0x37, 0xe0, 0xfc, 0xd1, 0x82, 0xb5, 0xb2, 0x55, 0x79, - 0xcc, 0x0f, 0xc5, 0x20, 0xa4, 0x2f, 0xb3, 0x5e, 0x5c, 0xbf, 0xe9, 0xf2, 0xf5, 0x7b, 0x02, 0x8b, - 0x23, 0x4e, 0xc9, 0xf4, 0x34, 0xde, 0x9e, 0x28, 0xc7, 0x4a, 0xd5, 0xd5, 0x5d, 0x28, 0xef, 0x43, - 0x3a, 0xff, 0xb0, 0x60, 0x25, 0xf3, 0x31, 0x3f, 0x2c, 0xf4, 0x43, 0x40, 0xf9, 0xf6, 0x8a, 0xc9, - 0x30, 0x49, 0xa9, 0xe5, 0x6c, 0x25, 0x1b, 0x0b, 0x8b, 0xd4, 0x98, 0x2e, 0xa5, 0x06, 0xfa, 0x10, - 0x56, 0x73, 0x97, 0x23, 0x13, 0xa0, 0x89, 0xa3, 0x98, 0xcf, 0xbe, 0xb9, 0x08, 0x6d, 0x41, 0xe3, - 0x17, 0x9c, 0x85, 0xe5, 0xcf, 0x43, 0x15, 0x17, 0xb4, 0x28, 0xf9, 0xf2, 0xe3, 0xfc, 0xc6, 0x2a, - 0xfa, 0x65, 0xda, 0x73, 0xf7, 0x82, 0x20, 0xfd, 0x45, 0x81, 0x22, 0x98, 0xcb, 0xba, 0x76, 0x52, - 0x60, 0x36, 0xce, 0x9d, 0x2c, 0x0e, 0x28, 0x31, 0xc3, 0xc5, 0x4d, 0x7d, 0x07, 0xff, 0xf2, 0xf5, - 0xd6, 0xb5, 0x2e, 0x53, 0xbd, 0x41, 0xa7, 0x49, 0x78, 0xbf, 0x95, 0x7e, 0x45, 0x4b, 0xfe, 0x5d, - 0x97, 0xfe, 0x69, 0x4b, 0x0d, 0x23, 0x2a, 0x33, 0x1d, 0xf9, 0xe7, 0x7f, 0xff, 0xed, 0x2d, 0xcb, - 0xcd, 0xcc, 0xec, 0x3f, 0xf9, 0xe2, 0xf9, 0xa6, 0xf5, 0xe5, 0xf3, 0x4d, 0xeb, 0x5f, 0xcf, 0x37, - 0xad, 0x4f, 0x5f, 0x6c, 0x4e, 0x7d, 0xf9, 0x62, 0x73, 0xea, 0x9f, 0x2f, 0x36, 0xa7, 0x3e, 0x7e, - 0xf7, 0x2c, 0x69, 0x11, 0xc4, 0xeb, 0xf9, 0x77, 0xcb, 0xf8, 0x47, 0xad, 0x4f, 0x46, 0xbf, 0x8a, - 0x1a, 0x7b, 0x9d, 0x59, 0x53, 0x6e, 0xdf, 0xf9, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x49, - 0x1e, 0xe4, 0x46, 0x15, 0x00, 0x00, + // 2052 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xbb, 0x6f, 0x1c, 0xc7, + 0x19, 0xe7, 0xf2, 0x8e, 0x8f, 0xfb, 0x8e, 0xcf, 0x21, 0x6d, 0x2d, 0x19, 0xe6, 0x48, 0xad, 0x23, + 0x85, 0xb1, 0xa2, 0x3b, 0x53, 0x86, 0x01, 0x41, 0x88, 0x61, 0xf0, 0x21, 0x5b, 0x0f, 0x4b, 0xa2, + 0x97, 0x8c, 0x84, 0x38, 0xc5, 0x62, 0x6e, 0x76, 0x78, 0x37, 0xe1, 0xde, 0xce, 0x6a, 0x66, 0x6e, + 0xe9, 0x6b, 0x52, 0xa7, 0x09, 0xe0, 0x74, 0x46, 0x8a, 0xc4, 0x49, 0x15, 0xb8, 0x4a, 0x91, 0x3e, + 0x40, 0x8a, 0xc0, 0x48, 0x13, 0x97, 0xa9, 0xec, 0x40, 0x2a, 0x52, 0xe4, 0x9f, 0x08, 0x66, 0xf6, + 0x79, 0x7c, 0x48, 0x27, 0x38, 0x6e, 0xc8, 0xdb, 0xef, 0xf1, 0xfb, 0xbe, 0x99, 0xef, 0xb9, 0x0b, + 0x37, 0x58, 0xa8, 0xa8, 0x20, 0x5d, 0xcc, 0x42, 0x4f, 0x52, 0xd2, 0x17, 0x4c, 0x0d, 0x5a, 0x84, + 0xc4, 0xad, 0x48, 0xf0, 0x98, 0xf9, 0x54, 0xb4, 0xe2, 0xad, 0xfc, 0x77, 0x33, 0x12, 0x5c, 0x71, + 0xf4, 0xc6, 0x39, 0x3a, 0x4d, 0x42, 0xe2, 0x66, 0x2e, 0x17, 0x6f, 0xad, 0x5e, 0xb9, 0x08, 0x38, + 0xde, 0x6a, 0x9d, 0x30, 0x41, 0x13, 0xac, 0xd5, 0xe5, 0x0e, 0xef, 0x70, 0xf3, 0xb3, 0xa5, 0x7f, + 0xa5, 0xd4, 0xf5, 0x0e, 0xe7, 0x9d, 0x80, 0xb6, 0xcc, 0x53, 0xbb, 0x7f, 0xd4, 0x52, 0xac, 0x47, + 0xa5, 0xc2, 0xbd, 0x28, 0x15, 0x68, 0x9c, 0x16, 0xf0, 0xfb, 0x02, 0x2b, 0xc6, 0xc3, 0x0c, 0x80, + 0xb5, 0x49, 0x8b, 0x70, 0x41, 0x5b, 0x24, 0x60, 0x34, 0x54, 0xda, 0x6a, 0xf2, 0x2b, 0x15, 0x68, + 0x69, 0x81, 0x80, 0x75, 0xba, 0x2a, 0x21, 0xcb, 0x96, 0xa2, 0xa1, 0x4f, 0x45, 0x8f, 0x25, 0xc2, + 0xc5, 0x53, 0xaa, 0xb0, 0x56, 0xe2, 0x13, 0x31, 0x88, 0x14, 0x6f, 0x1d, 0xd3, 0x81, 0x4c, 0xb9, + 0x57, 0x09, 0x97, 0x3d, 0x2e, 0x5b, 0x54, 0x9f, 0x3f, 0x24, 0xb4, 0x15, 0x6f, 0xb5, 0xa9, 0xc2, + 0x5b, 0x39, 0x21, 0xf3, 0x3b, 0x95, 0x6b, 0x63, 0x59, 0xc8, 0x10, 0xce, 0x32, 0xbf, 0x57, 0x12, + 0xbe, 0x97, 0xdc, 0x48, 0xf2, 0x90, 0xb2, 0x16, 0x71, 0x8f, 0x85, 0xbc, 0x65, 0xfe, 0x26, 0x24, + 0xe7, 0x8b, 0x69, 0xb0, 0x77, 0x79, 0x28, 0xfb, 0x3d, 0x2a, 0xb6, 0x7d, 0x9f, 0xe9, 0x0b, 0xd8, + 0x17, 0x3c, 0xe2, 0x12, 0x07, 0x68, 0x19, 0x26, 0x14, 0x53, 0x01, 0xb5, 0xad, 0x0d, 0x6b, 0xb3, + 0xe6, 0x26, 0x0f, 0x68, 0x03, 0xea, 0x3e, 0x95, 0x44, 0xb0, 0x48, 0x0b, 0xdb, 0xe3, 0x86, 0x57, + 0x26, 0xa1, 0x15, 0x98, 0x4e, 0xa2, 0xc6, 0x7c, 0xbb, 0x62, 0xd8, 0x53, 0xe6, 0xf9, 0xae, 0x8f, + 0x3e, 0x80, 0x39, 0x16, 0x32, 0xc5, 0x70, 0xe0, 0x75, 0xa9, 0xbe, 0x3b, 0xbb, 0xba, 0x61, 0x6d, + 0xd6, 0x6f, 0xac, 0x36, 0x59, 0x9b, 0x34, 0xf5, 0x75, 0x37, 0xd3, 0x4b, 0x8e, 0xb7, 0x9a, 0x77, + 0x8c, 0xc4, 0x4e, 0xf5, 0xcb, 0xaf, 0xd7, 0xc7, 0xdc, 0xd9, 0x54, 0x2f, 0x21, 0xa2, 0xcb, 0x30, + 0xd3, 0xa1, 0x21, 0x95, 0x4c, 0x7a, 0x5d, 0x2c, 0xbb, 0xf6, 0xc4, 0x86, 0xb5, 0x39, 0xe3, 0xd6, + 0x53, 0xda, 0x1d, 0x2c, 0xbb, 0x68, 0x1d, 0xea, 0x6d, 0x16, 0x62, 0x31, 0x48, 0x24, 0x26, 0x8d, + 0x04, 0x24, 0x24, 0x23, 0xb0, 0x0b, 0x20, 0x23, 0x7c, 0x12, 0x7a, 0x3a, 0x37, 0xec, 0xa9, 0xd4, + 0x91, 0x24, 0x2f, 0x9a, 0x59, 0x5e, 0x34, 0x0f, 0xb3, 0xc4, 0xd9, 0x99, 0xd6, 0x8e, 0x7c, 0xfa, + 0xcd, 0xba, 0xe5, 0xd6, 0x8c, 0x9e, 0xe6, 0xa0, 0x87, 0xb0, 0xd0, 0x0f, 0xdb, 0x3c, 0xf4, 0x59, + 0xd8, 0xf1, 0x22, 0x2a, 0x18, 0xf7, 0xed, 0x69, 0x03, 0xb5, 0x72, 0x06, 0x6a, 0x2f, 0x4d, 0xb1, + 0x04, 0xe9, 0x33, 0x8d, 0x34, 0x9f, 0x2b, 0xef, 0x1b, 0x5d, 0xf4, 0x11, 0x20, 0x42, 0x62, 0xe3, + 0x12, 0xef, 0xab, 0x0c, 0xb1, 0x36, 0x3a, 0xe2, 0x02, 0x21, 0xf1, 0x61, 0xa2, 0x9d, 0x42, 0xfe, + 0x1c, 0x2e, 0x29, 0x81, 0x43, 0x79, 0x44, 0xc5, 0x69, 0x5c, 0x18, 0x1d, 0xf7, 0xb5, 0x0c, 0x63, + 0x18, 0xfc, 0x0e, 0x6c, 0x90, 0x34, 0x81, 0x3c, 0x41, 0x7d, 0x26, 0x95, 0x60, 0xed, 0xbe, 0xd6, + 0xf5, 0x8e, 0x04, 0x26, 0x26, 0x47, 0xea, 0x26, 0x09, 0x1a, 0x99, 0x9c, 0x3b, 0x24, 0xf6, 0x7e, + 0x2a, 0x85, 0x1e, 0xc1, 0x0f, 0xda, 0x01, 0x27, 0xc7, 0x52, 0x3b, 0xe7, 0x0d, 0x21, 0x19, 0xd3, + 0x3d, 0x26, 0xa5, 0x46, 0x9b, 0xd9, 0xb0, 0x36, 0x2b, 0xee, 0xe5, 0x44, 0x76, 0x9f, 0x8a, 0xbd, + 0x92, 0xe4, 0x61, 0x49, 0x10, 0x5d, 0x07, 0xd4, 0x65, 0x52, 0x71, 0xc1, 0x08, 0x0e, 0x3c, 0x1a, + 0x2a, 0xc1, 0xa8, 0xb4, 0x67, 0x8d, 0xfa, 0x62, 0xc1, 0xb9, 0x9d, 0x30, 0xd0, 0x3d, 0xb8, 0x7c, + 0xa1, 0x51, 0x8f, 0x74, 0x71, 0x18, 0xd2, 0xc0, 0x9e, 0x33, 0x47, 0x59, 0xf7, 0x2f, 0xb0, 0xb9, + 0x9b, 0x88, 0xa1, 0x25, 0x98, 0x50, 0x3c, 0xf2, 0x1e, 0xda, 0xf3, 0x1b, 0xd6, 0xe6, 0xac, 0x5b, + 0x55, 0x3c, 0x7a, 0x88, 0xde, 0x82, 0xe5, 0x18, 0x07, 0xcc, 0xc7, 0x8a, 0x0b, 0xe9, 0x45, 0xfc, + 0x84, 0x0a, 0x8f, 0xe0, 0xc8, 0x5e, 0x30, 0x32, 0xa8, 0xe0, 0xed, 0x6b, 0xd6, 0x2e, 0x8e, 0xd0, + 0x9b, 0xb0, 0x98, 0x53, 0x3d, 0x49, 0x95, 0x11, 0x5f, 0x34, 0xe2, 0xf3, 0x39, 0xe3, 0x80, 0x2a, + 0x2d, 0xbb, 0x06, 0x35, 0x1c, 0x04, 0xfc, 0x24, 0x60, 0x52, 0xd9, 0x68, 0xa3, 0xb2, 0x59, 0x73, + 0x0b, 0x02, 0x5a, 0x85, 0x69, 0x9f, 0x86, 0x03, 0xc3, 0x5c, 0x32, 0xcc, 0xfc, 0xf9, 0xd6, 0xd5, + 0x5f, 0x7d, 0xbe, 0x3e, 0xf6, 0xd9, 0xe7, 0xeb, 0x63, 0xff, 0xf8, 0xcb, 0xf5, 0xd5, 0xb4, 0x63, + 0x74, 0x78, 0xdc, 0x4c, 0xbb, 0x4b, 0x73, 0x97, 0x87, 0x8a, 0x86, 0xca, 0xf9, 0xa7, 0x05, 0x97, + 0x76, 0xf3, 0x18, 0xf6, 0x78, 0x8c, 0x83, 0xef, 0xb2, 0x57, 0x6c, 0x43, 0x4d, 0xea, 0x4b, 0x34, + 0xd5, 0x59, 0x7d, 0x85, 0xea, 0x9c, 0xd6, 0x6a, 0x9a, 0x71, 0xab, 0xf1, 0x92, 0x13, 0xfd, 0x6e, + 0x1c, 0xd6, 0xb2, 0x13, 0x3d, 0xe0, 0x3e, 0x3b, 0x62, 0x04, 0x7f, 0xd7, 0x2d, 0x30, 0x4f, 0x8d, + 0xea, 0x08, 0xa9, 0x31, 0xf1, 0x6a, 0xa9, 0x31, 0x39, 0x42, 0x6a, 0x4c, 0xbd, 0x28, 0x35, 0xa6, + 0x87, 0x53, 0xc3, 0xf9, 0xbd, 0x05, 0xcb, 0xb7, 0x9f, 0xf6, 0x59, 0xcc, 0xff, 0x4f, 0x17, 0x73, + 0x1f, 0x66, 0x69, 0x09, 0x4f, 0xda, 0x95, 0x8d, 0xca, 0x66, 0xfd, 0xc6, 0x95, 0x66, 0x1a, 0xa5, + 0x7c, 0xda, 0x65, 0xa1, 0x2a, 0x5b, 0x77, 0x87, 0x75, 0x6f, 0x8d, 0xdb, 0x96, 0xf3, 0x37, 0x0b, + 0x56, 0x75, 0xd5, 0x75, 0xa8, 0x4b, 0x4f, 0xb0, 0xf0, 0xf7, 0x68, 0xc8, 0x7b, 0xf2, 0x5b, 0xfb, + 0xe9, 0xc0, 0xac, 0x6f, 0x90, 0x3c, 0xc5, 0x3d, 0xec, 0xfb, 0xc6, 0x4f, 0x23, 0xa3, 0x89, 0x87, + 0x7c, 0xdb, 0xf7, 0xd1, 0x26, 0x2c, 0x14, 0x32, 0x42, 0x17, 0x84, 0xce, 0x53, 0x2d, 0x36, 0x97, + 0x89, 0x99, 0x32, 0x79, 0x79, 0x1e, 0xfe, 0xd7, 0x82, 0x85, 0x0f, 0x02, 0xde, 0xc6, 0xc1, 0x41, + 0x80, 0x65, 0x57, 0x77, 0xa4, 0x81, 0xce, 0x7f, 0x41, 0xd3, 0x51, 0x60, 0xdc, 0x1f, 0x39, 0xff, + 0xb5, 0x9a, 0x19, 0x4e, 0xef, 0xc1, 0x62, 0xde, 0x9c, 0xf3, 0x7c, 0x34, 0xa7, 0xdd, 0x59, 0x7a, + 0xf6, 0xf5, 0xfa, 0x7c, 0x96, 0xfb, 0xbb, 0x26, 0x37, 0xf7, 0xdc, 0x79, 0x32, 0x44, 0xf0, 0x51, + 0x03, 0xea, 0xac, 0x4d, 0x3c, 0x49, 0x9f, 0x7a, 0x61, 0xbf, 0x67, 0x52, 0xb9, 0xea, 0xd6, 0x58, + 0x9b, 0x1c, 0xd0, 0xa7, 0x0f, 0xfb, 0x3d, 0xf4, 0x36, 0xbc, 0x9e, 0xad, 0x6c, 0x5e, 0x8c, 0x03, + 0x4f, 0xeb, 0xeb, 0xeb, 0x12, 0x26, 0xbb, 0x67, 0xdc, 0xa5, 0x8c, 0xfb, 0x18, 0x07, 0xda, 0xd8, + 0xb6, 0xef, 0x0b, 0xe7, 0xaf, 0x93, 0x30, 0xb9, 0x8f, 0x05, 0xee, 0x49, 0x74, 0x08, 0xf3, 0x8a, + 0xf6, 0xa2, 0x00, 0x2b, 0xea, 0x25, 0x83, 0x3f, 0x3d, 0xe9, 0x35, 0xb3, 0x10, 0x94, 0xd7, 0xab, + 0x66, 0x69, 0xa1, 0x8a, 0xb7, 0x9a, 0xbb, 0x86, 0x7a, 0xa0, 0xb0, 0xa2, 0xee, 0x5c, 0x86, 0x91, + 0x10, 0xd1, 0x4d, 0xb0, 0x95, 0xe8, 0x4b, 0x55, 0x8c, 0xe4, 0x62, 0x16, 0x25, 0xb1, 0x7e, 0x3d, + 0xe3, 0x27, 0x53, 0x2c, 0x9f, 0x41, 0xe7, 0x4f, 0xdf, 0xca, 0xb7, 0x99, 0xbe, 0x07, 0xb0, 0xa4, + 0x57, 0x97, 0xd3, 0x98, 0xd5, 0xd1, 0x31, 0x17, 0xb5, 0xfe, 0x30, 0xe8, 0x47, 0x80, 0x62, 0x49, + 0x4e, 0x63, 0x4e, 0xbc, 0x82, 0x9f, 0xb1, 0x24, 0xc3, 0x90, 0x3e, 0xac, 0x49, 0x9d, 0x7c, 0x5e, + 0x8f, 0x2a, 0x33, 0xcb, 0xa3, 0x80, 0x86, 0x4c, 0x76, 0x33, 0xf0, 0xc9, 0xd1, 0xc1, 0x57, 0x0c, + 0xd0, 0x03, 0x8d, 0xe3, 0x66, 0x30, 0xa9, 0x95, 0x5d, 0x68, 0x9c, 0x6f, 0x25, 0x0f, 0xd0, 0x94, + 0x09, 0xd0, 0xf7, 0xce, 0x81, 0xc8, 0xa3, 0x24, 0xe1, 0x6a, 0x69, 0xe7, 0xd0, 0x55, 0xef, 0x99, + 0x82, 0xf3, 0x04, 0xed, 0xe8, 0xc1, 0x8c, 0x93, 0xf5, 0x83, 0xd2, 0x7c, 0x6f, 0x4a, 0x6b, 0x4f, + 0x2f, 0xcd, 0xa5, 0xe2, 0x63, 0x61, 0xba, 0x5c, 0x3a, 0xc5, 0x6a, 0x92, 0xf7, 0x10, 0xb7, 0x84, + 0xf5, 0x3e, 0xa5, 0xba, 0xda, 0x4b, 0xeb, 0x09, 0x8d, 0x38, 0xe9, 0x9a, 0xf5, 0xa9, 0xe2, 0xce, + 0xe5, 0xab, 0xc8, 0x6d, 0x4d, 0x45, 0x1f, 0xc3, 0xb5, 0xb0, 0xdf, 0x6b, 0x53, 0xe1, 0xf1, 0xa3, + 0x44, 0xd0, 0x74, 0x08, 0xa9, 0xb0, 0x50, 0x9e, 0xa0, 0x84, 0xb2, 0x58, 0x67, 0x66, 0xe2, 0xb9, + 0x34, 0xdb, 0x51, 0xc5, 0xbd, 0x92, 0xa8, 0x3c, 0x3a, 0x32, 0x18, 0xf2, 0x90, 0x1f, 0x68, 0x71, + 0x37, 0x93, 0x4e, 0x1c, 0x93, 0xf7, 0xaa, 0xd3, 0xd3, 0x0b, 0x35, 0xe7, 0x47, 0x50, 0x33, 0x8d, + 0x62, 0x9b, 0x1c, 0x4b, 0xd3, 0xdd, 0x7d, 0x5f, 0x50, 0x29, 0xa9, 0xb4, 0xad, 0xb4, 0xbb, 0x67, + 0x04, 0x47, 0xc1, 0xca, 0x45, 0x0b, 0xbe, 0x44, 0x4f, 0x60, 0x2a, 0xa2, 0x66, 0xfb, 0x34, 0x8a, + 0xf5, 0x1b, 0xef, 0x36, 0x47, 0x78, 0x33, 0x6b, 0x5e, 0x04, 0xe8, 0x66, 0x68, 0x8e, 0x28, 0x5e, + 0x2b, 0x4e, 0x6d, 0x0a, 0x12, 0x3d, 0x3e, 0x6d, 0xf4, 0x27, 0xaf, 0x64, 0xf4, 0x14, 0x5e, 0x61, + 0xf3, 0x1a, 0xd4, 0xb7, 0x93, 0x63, 0x7f, 0xa8, 0xc7, 0xda, 0x99, 0x6b, 0x99, 0x29, 0x5f, 0xcb, + 0x3d, 0x98, 0x4b, 0x77, 0xb5, 0x43, 0x6e, 0x9a, 0x1d, 0xfa, 0x3e, 0x40, 0xba, 0xe4, 0xe9, 0x26, + 0x99, 0x8c, 0x8b, 0x5a, 0x4a, 0xb9, 0xeb, 0x0f, 0x4d, 0xf4, 0xf1, 0xa1, 0x89, 0xee, 0xb8, 0x30, + 0xff, 0x58, 0x92, 0x9f, 0x66, 0x8b, 0xfc, 0xa3, 0x48, 0xa2, 0xd7, 0x60, 0x52, 0xd7, 0x67, 0x0a, + 0x54, 0x75, 0x27, 0x62, 0x49, 0xee, 0x9a, 0x89, 0x51, 0xbc, 0x2c, 0xf0, 0xc8, 0x63, 0xbe, 0xb4, + 0xc7, 0x37, 0x2a, 0x9b, 0x55, 0x77, 0xae, 0x5f, 0xa8, 0xdf, 0xf5, 0xa5, 0xf3, 0x33, 0xa8, 0x97, + 0x00, 0xd1, 0x1c, 0x8c, 0xe7, 0x58, 0xe3, 0xcc, 0x47, 0xb7, 0x60, 0xa5, 0x00, 0x1a, 0x6e, 0xf1, + 0x09, 0x62, 0xcd, 0xbd, 0x94, 0x0b, 0x0c, 0x75, 0x79, 0xe9, 0x3c, 0x82, 0xe5, 0xbb, 0x45, 0x43, + 0xc9, 0x07, 0xc8, 0xd0, 0x09, 0xad, 0xe1, 0x9d, 0x65, 0x0d, 0x6a, 0xf9, 0xfb, 0xb3, 0x39, 0x7d, + 0xd5, 0x2d, 0x08, 0x4e, 0x0f, 0x16, 0x1e, 0x4b, 0x72, 0x40, 0x43, 0xbf, 0x00, 0xbb, 0xe0, 0x02, + 0x76, 0x4e, 0x03, 0x8d, 0xfc, 0xc6, 0x55, 0x98, 0xe3, 0xb0, 0xf2, 0xb8, 0xbc, 0xe0, 0x98, 0xe1, + 0xbf, 0x8f, 0xc9, 0x31, 0x55, 0x12, 0xb9, 0x50, 0x35, 0x8b, 0x4c, 0x92, 0x59, 0x37, 0x2f, 0xcc, + 0xac, 0x78, 0xab, 0x79, 0x11, 0xc8, 0x1e, 0x56, 0x38, 0xed, 0x0b, 0x06, 0xcb, 0xf9, 0x21, 0x2c, + 0x3d, 0xc0, 0xaa, 0x2f, 0xa8, 0x3f, 0x14, 0xe3, 0x05, 0xa8, 0xe8, 0xf8, 0x59, 0x26, 0x7e, 0xfa, + 0xa7, 0xf3, 0x47, 0x0b, 0xec, 0xdb, 0x9f, 0x44, 0x5c, 0x28, 0xea, 0x9f, 0xb9, 0x91, 0x17, 0x5c, + 0xef, 0x31, 0x2c, 0xe9, 0xcb, 0x92, 0x34, 0xf4, 0xbd, 0xfc, 0x9c, 0x49, 0x1c, 0xeb, 0x37, 0xde, + 0x19, 0xa9, 0x3a, 0x4e, 0x9b, 0x4b, 0x0f, 0xb0, 0x18, 0x9f, 0xa2, 0x4b, 0xe7, 0x37, 0x16, 0xd8, + 0xf7, 0xe9, 0x60, 0x5b, 0x4a, 0xd6, 0x09, 0x7b, 0x34, 0x54, 0xba, 0xbf, 0x62, 0x42, 0xf5, 0x4f, + 0xf4, 0x06, 0xcc, 0xe6, 0xf3, 0xdc, 0x8c, 0x71, 0xcb, 0x8c, 0xf1, 0x99, 0x8c, 0xa8, 0x0b, 0x0c, + 0xdd, 0x02, 0x88, 0x04, 0x8d, 0x3d, 0xe2, 0x1d, 0xd3, 0x41, 0x1a, 0xc5, 0xb5, 0xf2, 0x78, 0x4e, + 0xbe, 0x6e, 0x34, 0xf7, 0xfb, 0xed, 0x80, 0x91, 0xfb, 0x74, 0xe0, 0x4e, 0x6b, 0xf9, 0xdd, 0xfb, + 0x74, 0xa0, 0xf7, 0x31, 0xb3, 0xdd, 0x9a, 0x99, 0x5a, 0x71, 0x93, 0x07, 0xe7, 0xb7, 0x16, 0x5c, + 0xca, 0xc3, 0x91, 0xa5, 0xeb, 0x7e, 0xbf, 0xad, 0x35, 0x5e, 0x70, 0x6f, 0x67, 0xbc, 0x1d, 0x3f, + 0xc7, 0xdb, 0xf7, 0x60, 0x26, 0x2f, 0x10, 0xed, 0x6f, 0x65, 0x04, 0x7f, 0xeb, 0x99, 0xc6, 0x7d, + 0x3a, 0x70, 0x7e, 0x59, 0xf2, 0x6d, 0x67, 0x50, 0xea, 0x7d, 0xe2, 0x25, 0xbe, 0xe5, 0x66, 0xcb, + 0xbe, 0x91, 0xb2, 0xfe, 0x99, 0x03, 0x54, 0xce, 0x1e, 0xc0, 0xf9, 0x83, 0x05, 0xcb, 0x65, 0xab, + 0xf2, 0x90, 0xef, 0x8b, 0x7e, 0x48, 0x5f, 0x64, 0xbd, 0x28, 0xbf, 0xf1, 0x72, 0xf9, 0x3d, 0x81, + 0xb9, 0x21, 0xa7, 0x64, 0x7a, 0x1b, 0x6f, 0x8d, 0x94, 0x63, 0xa5, 0xee, 0xea, 0xce, 0x96, 0xcf, + 0x21, 0x9d, 0xbf, 0x5b, 0xb0, 0x98, 0xf9, 0x98, 0x5f, 0x16, 0xfa, 0x31, 0xa0, 0xfc, 0x78, 0xc5, + 0x66, 0x98, 0xa4, 0xd4, 0x42, 0xc6, 0xc9, 0xd6, 0xc2, 0x22, 0x35, 0xc6, 0x4b, 0xa9, 0x81, 0x3e, + 0x84, 0xa5, 0xdc, 0xe5, 0xc8, 0x04, 0x68, 0xe4, 0x28, 0xe6, 0xbb, 0x6f, 0x4e, 0x42, 0xeb, 0x50, + 0xff, 0x05, 0x67, 0x61, 0xf9, 0xe3, 0x53, 0xc5, 0x05, 0x4d, 0x4a, 0xbe, 0x2b, 0x39, 0xbf, 0xb6, + 0x8a, 0x79, 0x99, 0xce, 0xdc, 0xed, 0x20, 0x48, 0xdf, 0x38, 0x50, 0x04, 0x53, 0xd9, 0xd4, 0x4e, + 0x1a, 0xcc, 0xda, 0xb9, 0x9b, 0xc5, 0x1e, 0x25, 0x66, 0xb9, 0xb8, 0xa9, 0x6b, 0xf0, 0x8b, 0x6f, + 0xd6, 0xaf, 0x75, 0x98, 0xea, 0xf6, 0xdb, 0x4d, 0xc2, 0x7b, 0xe9, 0x17, 0xb9, 0xf4, 0xdf, 0x75, + 0xe9, 0x1f, 0xb7, 0xd4, 0x20, 0xa2, 0x32, 0xd3, 0x91, 0x7f, 0xfa, 0xcf, 0x9f, 0xdf, 0xb4, 0xdc, + 0xcc, 0xcc, 0xce, 0x93, 0x2f, 0x9f, 0x35, 0xac, 0xaf, 0x9e, 0x35, 0xac, 0x7f, 0x3f, 0x6b, 0x58, + 0x9f, 0x3e, 0x6f, 0x8c, 0x7d, 0xf5, 0xbc, 0x31, 0xf6, 0xaf, 0xe7, 0x8d, 0xb1, 0x8f, 0xdf, 0x3d, + 0x0b, 0x5a, 0x04, 0xf1, 0x7a, 0xfe, 0xc1, 0x34, 0x7e, 0xa7, 0xf5, 0xc9, 0xf0, 0xe7, 0x58, 0x63, + 0xaf, 0x3d, 0x69, 0xda, 0xed, 0xdb, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xaa, 0x2b, 0x22, + 0xbf, 0x15, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 4d42311fda..84e610776e 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -5,15 +5,15 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" 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/v4/x/ccv/types" + types "github.com/cosmos/interchain-security/v5/x/ccv/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -1616,7 +1616,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) GetProviderAddress() strin type QueryValidatorConsumerCommissionRateResponse struct { // The rate to charge delegators on the consumer chain, as a fraction - Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` + Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` } func (m *QueryValidatorConsumerCommissionRateResponse) Reset() { @@ -1788,134 +1788,133 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2023 bytes of a gzipped FileDescriptorProto + // 2015 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0xcd, 0x6f, 0xdc, 0xc6, - 0x15, 0x17, 0x57, 0x1f, 0x91, 0x46, 0xf1, 0x47, 0xc6, 0x6a, 0x22, 0x53, 0xca, 0xae, 0xc2, 0xb4, - 0xa9, 0x2c, 0xdb, 0xa4, 0x24, 0x37, 0xa8, 0x63, 0x47, 0x91, 0xb5, 0x5a, 0xdb, 0x59, 0xd8, 0x89, - 0x15, 0x5a, 0x56, 0x0b, 0xb7, 0x28, 0x4d, 0x93, 0x13, 0x89, 0x30, 0x97, 0x43, 0x71, 0x66, 0xd7, - 0x59, 0x18, 0x01, 0x9a, 0x1e, 0xda, 0x9c, 0x8a, 0xa0, 0x1f, 0x40, 0x8f, 0xb9, 0xf4, 0xd8, 0x4b, - 0x51, 0x14, 0xf9, 0x13, 0x72, 0x6b, 0xda, 0x5c, 0x8a, 0x1e, 0xdc, 0xc2, 0xee, 0xa1, 0xe8, 0xa1, - 0x28, 0x8c, 0x02, 0x3d, 0x15, 0x28, 0x38, 0x1c, 0x7e, 0xed, 0x72, 0x77, 0xc9, 0x5d, 0xe5, 0xa4, - 0xe5, 0xcc, 0x9b, 0xdf, 0xbc, 0xf7, 0xe6, 0xbd, 0x37, 0xef, 0x37, 0x02, 0x8a, 0xe5, 0x50, 0xe4, - 0x19, 0x07, 0xba, 0xe5, 0x68, 0x04, 0x19, 0x4d, 0xcf, 0xa2, 0x6d, 0xc5, 0x30, 0x5a, 0x8a, 0xeb, - 0xe1, 0x96, 0x65, 0x22, 0x4f, 0x69, 0xad, 0x29, 0x87, 0x4d, 0xe4, 0xb5, 0x65, 0xd7, 0xc3, 0x14, - 0xc3, 0x57, 0x33, 0x16, 0xc8, 0x86, 0xd1, 0x92, 0xc3, 0x05, 0x72, 0x6b, 0x4d, 0x5c, 0xdc, 0xc7, - 0x78, 0xdf, 0x46, 0x8a, 0xee, 0x5a, 0x8a, 0xee, 0x38, 0x98, 0xea, 0xd4, 0xc2, 0x0e, 0x09, 0x20, - 0xc4, 0xb9, 0x7d, 0xbc, 0x8f, 0xd9, 0x4f, 0xc5, 0xff, 0xc5, 0x47, 0x2b, 0x7c, 0x0d, 0xfb, 0xba, - 0xdf, 0x7c, 0x5f, 0xa1, 0x56, 0x03, 0x11, 0xaa, 0x37, 0x5c, 0x2e, 0xb0, 0x9e, 0x47, 0xd5, 0x48, - 0x8b, 0x60, 0xcd, 0x6a, 0xaf, 0x35, 0xad, 0x35, 0x85, 0x1c, 0xe8, 0x1e, 0x32, 0x35, 0x03, 0x3b, - 0xa4, 0xd9, 0x88, 0x56, 0x7c, 0xa3, 0xcf, 0x8a, 0x87, 0x96, 0x87, 0xb8, 0xd8, 0x22, 0x45, 0x8e, - 0x89, 0xbc, 0x86, 0xe5, 0x50, 0xc5, 0xf0, 0xda, 0x2e, 0xc5, 0xca, 0x03, 0xd4, 0x0e, 0x2d, 0x3c, - 0x6d, 0x60, 0xd2, 0xc0, 0x44, 0x0b, 0x8c, 0x0c, 0x3e, 0x82, 0x29, 0xe9, 0x22, 0x58, 0x78, 0xcf, - 0x77, 0xe7, 0x36, 0xdf, 0xf6, 0x3a, 0x72, 0x10, 0xb1, 0x88, 0x8a, 0x0e, 0x9b, 0x88, 0x50, 0x78, - 0x1a, 0x4c, 0x07, 0x7b, 0x5b, 0xe6, 0xbc, 0xb0, 0x24, 0x2c, 0xcf, 0xa8, 0xcf, 0xb1, 0xef, 0xba, - 0x29, 0x3d, 0x02, 0x8b, 0xd9, 0x2b, 0x89, 0x8b, 0x1d, 0x82, 0xe0, 0xf7, 0xc0, 0xb1, 0xfd, 0x60, - 0x48, 0x23, 0x54, 0xa7, 0x88, 0xad, 0x9f, 0x5d, 0x5f, 0x95, 0x7b, 0x9d, 0x58, 0x6b, 0x4d, 0xee, - 0xc0, 0xba, 0xed, 0xaf, 0xab, 0x4e, 0x7c, 0xfe, 0xb8, 0x32, 0xa6, 0x3e, 0xbf, 0x9f, 0x18, 0x93, - 0x16, 0x81, 0x98, 0xda, 0x7c, 0xdb, 0x87, 0x0b, 0xb5, 0x96, 0xf4, 0x0e, 0xa3, 0xc2, 0x59, 0xae, - 0x59, 0x15, 0x4c, 0xb1, 0xed, 0xc9, 0xbc, 0xb0, 0x34, 0xbe, 0x3c, 0xbb, 0xbe, 0x22, 0xe7, 0x08, - 0x22, 0x99, 0x81, 0xa8, 0x7c, 0xa5, 0x74, 0x06, 0x7c, 0xb3, 0x7b, 0x8b, 0xdb, 0x54, 0xf7, 0xe8, - 0x8e, 0x87, 0x5d, 0x4c, 0x74, 0x3b, 0xd2, 0xe6, 0x63, 0x01, 0x2c, 0x0f, 0x96, 0xe5, 0xba, 0x7d, - 0x1f, 0xcc, 0xb8, 0xe1, 0x20, 0xf7, 0xd8, 0x5b, 0xf9, 0xd4, 0xe3, 0xe0, 0x5b, 0xa6, 0x69, 0xf9, - 0xd1, 0x1d, 0x43, 0xc7, 0x80, 0xd2, 0x32, 0x78, 0x2d, 0x4b, 0x13, 0xec, 0x76, 0x29, 0xfd, 0x63, - 0x21, 0xdb, 0xc0, 0x94, 0x68, 0x74, 0xd2, 0x5d, 0x3a, 0x6f, 0x14, 0xd2, 0x59, 0x45, 0x0d, 0xdc, - 0xd2, 0xed, 0x4c, 0x95, 0x7f, 0x55, 0x02, 0x93, 0x6c, 0xef, 0x3e, 0xb1, 0x08, 0x17, 0xc0, 0x8c, - 0x61, 0x5b, 0xc8, 0xa1, 0xfe, 0x5c, 0x89, 0xcd, 0x4d, 0x07, 0x03, 0x75, 0x13, 0x9e, 0x02, 0x93, - 0x14, 0xbb, 0xda, 0xbb, 0xf3, 0xe3, 0x4b, 0xc2, 0xf2, 0x31, 0x75, 0x82, 0x62, 0xf7, 0x5d, 0xb8, - 0x02, 0x60, 0xc3, 0x72, 0x34, 0x17, 0x3f, 0x44, 0x9e, 0x66, 0x39, 0x5a, 0x20, 0x31, 0xb1, 0x24, - 0x2c, 0x8f, 0xab, 0xc7, 0x1b, 0x96, 0xb3, 0xe3, 0x4f, 0xd4, 0x9d, 0x5d, 0x5f, 0x76, 0x15, 0xcc, - 0xb5, 0x74, 0xdb, 0x32, 0x75, 0x8a, 0x3d, 0xc2, 0x97, 0x18, 0xba, 0x3b, 0x3f, 0xc9, 0xf0, 0x60, - 0x3c, 0xc7, 0x16, 0x6d, 0xeb, 0x2e, 0x5c, 0x01, 0x2f, 0x44, 0xa3, 0x1a, 0x41, 0x94, 0x89, 0x4f, - 0x31, 0xf1, 0x13, 0xd1, 0xc4, 0x6d, 0x44, 0x7d, 0xd9, 0x45, 0x30, 0xa3, 0xdb, 0x36, 0x7e, 0x68, - 0x5b, 0x84, 0xce, 0x3f, 0xb7, 0x34, 0xbe, 0x3c, 0xa3, 0xc6, 0x03, 0x50, 0x04, 0xd3, 0x26, 0x72, - 0xda, 0x6c, 0x72, 0x9a, 0x4d, 0x46, 0xdf, 0xd2, 0x4f, 0x04, 0xf0, 0x0a, 0x3b, 0xa3, 0xbd, 0x10, - 0x32, 0x11, 0x04, 0xde, 0xe0, 0x14, 0x86, 0x1b, 0xe0, 0x64, 0x78, 0x1c, 0x9a, 0x6e, 0x9a, 0x1e, - 0x22, 0x24, 0xf0, 0x5e, 0x15, 0x3e, 0x7b, 0x5c, 0x39, 0xde, 0xd6, 0x1b, 0xf6, 0x25, 0x89, 0x4f, - 0x48, 0xea, 0x89, 0x50, 0x76, 0x2b, 0x18, 0xb9, 0x34, 0xfd, 0xf1, 0xa7, 0x95, 0xb1, 0x7f, 0x7c, - 0x5a, 0x19, 0x93, 0x6e, 0x01, 0xa9, 0x9f, 0x22, 0x3c, 0x4e, 0xce, 0x80, 0x93, 0x61, 0x75, 0x8b, - 0xb6, 0x0b, 0x34, 0x3a, 0x61, 0x24, 0xe4, 0xfd, 0xcd, 0xba, 0x4d, 0xdb, 0x49, 0x6c, 0x9e, 0xcf, - 0xb4, 0xae, 0xbd, 0xfa, 0x98, 0xd6, 0xb1, 0x7f, 0x3f, 0xd3, 0xd2, 0x8a, 0xc4, 0xa6, 0x75, 0x79, - 0x92, 0x9b, 0xd6, 0xe1, 0x35, 0x69, 0x01, 0x9c, 0x66, 0x80, 0xbb, 0x07, 0x1e, 0xa6, 0xd4, 0x46, - 0xac, 0xa0, 0x85, 0x69, 0xf7, 0x47, 0x81, 0x17, 0xb6, 0x8e, 0x59, 0xbe, 0x4d, 0x05, 0xcc, 0x12, - 0x5b, 0x27, 0x07, 0x5a, 0x03, 0x51, 0xe4, 0xb1, 0x1d, 0xc6, 0x55, 0xc0, 0x86, 0xde, 0xf1, 0x47, - 0xe0, 0x3a, 0xf8, 0x5a, 0x42, 0x40, 0x63, 0x71, 0xa4, 0x3b, 0x06, 0x62, 0xb6, 0x8f, 0xab, 0xa7, - 0x62, 0xd1, 0xad, 0x70, 0x0a, 0xfe, 0x00, 0xcc, 0x3b, 0xe8, 0x03, 0xaa, 0x79, 0xc8, 0xb5, 0x91, - 0x63, 0x91, 0x03, 0xcd, 0xd0, 0x1d, 0xd3, 0x37, 0x16, 0xb1, 0x94, 0x99, 0x5d, 0x17, 0xe5, 0xe0, - 0x32, 0x94, 0xc3, 0xcb, 0x50, 0xde, 0x0d, 0x2f, 0xc3, 0xea, 0xb4, 0x5f, 0x9d, 0x3f, 0xf9, 0x6b, - 0x45, 0x50, 0x5f, 0xf4, 0x51, 0xd4, 0x10, 0x64, 0x3b, 0xc4, 0x90, 0xce, 0x81, 0x15, 0x66, 0x92, - 0x8a, 0xf6, 0x2d, 0x42, 0x91, 0x87, 0xcc, 0x38, 0xef, 0x1f, 0xea, 0x9e, 0x59, 0x43, 0x0e, 0x6e, - 0x44, 0x85, 0xe7, 0x2a, 0x38, 0x9b, 0x4b, 0x9a, 0x7b, 0xe4, 0x45, 0x30, 0x65, 0xb2, 0x11, 0x56, - 0xcb, 0x67, 0x54, 0xfe, 0x25, 0x95, 0xf9, 0xed, 0x14, 0xd4, 0x14, 0x64, 0xb2, 0x12, 0x52, 0xaf, - 0x45, 0xdb, 0x7c, 0x24, 0x80, 0x97, 0x7b, 0x08, 0x70, 0xe4, 0x7b, 0xe0, 0xb8, 0x9b, 0x9c, 0x0b, - 0x6f, 0x8b, 0xf5, 0x5c, 0xa5, 0x2d, 0x05, 0xcb, 0xaf, 0xb0, 0x0e, 0x3c, 0xa9, 0x0e, 0x8e, 0xa5, - 0xc4, 0xe0, 0x3c, 0xe0, 0xf1, 0x5b, 0x4b, 0x87, 0x73, 0x0d, 0x96, 0x01, 0x08, 0x4b, 0x62, 0xbd, - 0xc6, 0x0e, 0x73, 0x42, 0x4d, 0x8c, 0x48, 0x37, 0x81, 0xc2, 0xac, 0xd9, 0xb2, 0xed, 0x1d, 0xdd, - 0xf2, 0xc8, 0x9e, 0x6e, 0x6f, 0x63, 0xc7, 0x0f, 0xb9, 0x6a, 0xba, 0x82, 0xd7, 0x6b, 0x39, 0xae, - 0xf6, 0x5f, 0x0b, 0x60, 0x35, 0x3f, 0x1c, 0xf7, 0xd7, 0x21, 0x78, 0xc1, 0xd5, 0x2d, 0x4f, 0x6b, - 0xe9, 0xb6, 0xdf, 0xc4, 0xb0, 0x34, 0xe0, 0x2e, 0xbb, 0x96, 0xcf, 0x65, 0xba, 0xe5, 0xc5, 0x1b, - 0x45, 0x69, 0xe6, 0xc4, 0x01, 0x70, 0xdc, 0x4d, 0x89, 0x48, 0xff, 0x11, 0xc0, 0x2b, 0x03, 0x57, - 0xc1, 0x6b, 0xbd, 0x72, 0xb3, 0xba, 0xf0, 0xec, 0x71, 0xe5, 0xa5, 0xa0, 0x14, 0x74, 0x4a, 0x74, - 0x97, 0x3b, 0x1f, 0xa7, 0x47, 0x49, 0x49, 0xe0, 0x74, 0x4a, 0x74, 0xd7, 0x16, 0xb8, 0x09, 0x9e, - 0x8f, 0xa4, 0x1e, 0xa0, 0x36, 0xcf, 0xb1, 0x45, 0x39, 0x6e, 0xe1, 0xe4, 0xa0, 0x85, 0x93, 0x77, - 0x9a, 0xf7, 0x6d, 0xcb, 0xb8, 0x81, 0xda, 0xea, 0x6c, 0xb8, 0xe2, 0x06, 0x6a, 0x4b, 0x73, 0x00, - 0x06, 0xa1, 0xab, 0x7b, 0x7a, 0x9c, 0x38, 0xf7, 0xc0, 0xa9, 0xd4, 0x28, 0x3f, 0x96, 0x3a, 0x98, - 0x72, 0xd9, 0x08, 0xbf, 0x99, 0xcf, 0xe6, 0x3c, 0x0b, 0x7f, 0x09, 0x8f, 0x5b, 0x0e, 0x20, 0x5d, - 0xe7, 0x89, 0x9c, 0x8a, 0x80, 0x5b, 0x2e, 0x45, 0x66, 0xdd, 0x89, 0xca, 0x63, 0x9e, 0xd6, 0xf1, - 0x90, 0xe7, 0xf8, 0x20, 0xa0, 0xa8, 0x5f, 0x7b, 0x39, 0x79, 0xff, 0x76, 0x9c, 0x14, 0x0a, 0x53, - 0x7f, 0x21, 0x71, 0x11, 0xa7, 0x8f, 0x0e, 0x11, 0xe9, 0x32, 0x28, 0xa7, 0xb6, 0x2c, 0xa4, 0xef, - 0x67, 0x02, 0x58, 0xea, 0xb1, 0x3a, 0xfa, 0x95, 0x79, 0x99, 0x0a, 0xb9, 0x2f, 0xd3, 0xae, 0xa8, - 0x28, 0x15, 0x8c, 0x0a, 0x38, 0x07, 0x26, 0x59, 0x6b, 0xc2, 0xe2, 0x69, 0x5c, 0x0d, 0x3e, 0xfc, - 0xe6, 0xb3, 0xd2, 0xd3, 0x70, 0xee, 0x5f, 0x04, 0x40, 0xec, 0x3a, 0x9e, 0xb2, 0x57, 0x73, 0x85, - 0xc9, 0x20, 0xa7, 0xa8, 0x09, 0x60, 0xe9, 0x90, 0x17, 0x95, 0x74, 0x57, 0x1e, 0xc9, 0xbe, 0xad, - 0x93, 0x5d, 0xcc, 0xbf, 0xc2, 0xfb, 0x70, 0x44, 0xa7, 0x4a, 0x3a, 0x58, 0x2b, 0xb0, 0x25, 0x77, - 0xc7, 0x39, 0x00, 0xa3, 0x93, 0x08, 0x23, 0x22, 0x8c, 0xb1, 0xa8, 0x02, 0x04, 0xd5, 0xcf, 0x64, - 0x9d, 0xca, 0xd9, 0xec, 0xde, 0x67, 0x1b, 0x37, 0x1a, 0x16, 0x21, 0x16, 0x76, 0xd4, 0x84, 0x45, - 0x5f, 0x59, 0x3b, 0x26, 0xfd, 0x50, 0x00, 0xe7, 0xf2, 0x69, 0xc2, 0x0d, 0xdd, 0x01, 0x13, 0x5e, - 0x48, 0xcc, 0x66, 0xaa, 0x6f, 0xfa, 0xb9, 0xfe, 0x97, 0xc7, 0x95, 0xd7, 0xf6, 0x2d, 0x7a, 0xd0, - 0xbc, 0x2f, 0x1b, 0xb8, 0xc1, 0xa9, 0x22, 0xff, 0x73, 0x9e, 0x98, 0x0f, 0x14, 0xda, 0x76, 0x11, - 0x91, 0x6b, 0xc8, 0xf8, 0xd3, 0xef, 0xce, 0x03, 0xce, 0x24, 0x6b, 0xc8, 0x50, 0x19, 0x92, 0xb4, - 0xc1, 0xf3, 0xe4, 0x96, 0x6d, 0x22, 0x42, 0xef, 0x38, 0x06, 0x76, 0xde, 0xb7, 0xbc, 0x06, 0x32, - 0xf7, 0x88, 0x91, 0x23, 0xcf, 0x7e, 0x1a, 0x76, 0x7d, 0xd9, 0xeb, 0xb9, 0xda, 0x16, 0x80, 0x2d, - 0x62, 0x68, 0x04, 0x39, 0xa6, 0x16, 0x91, 0x72, 0x5e, 0xdd, 0x5e, 0xcf, 0x15, 0xb6, 0x7b, 0xc4, - 0xb8, 0x8d, 0x1c, 0x33, 0x6e, 0x62, 0x82, 0x3a, 0x77, 0xb2, 0xd5, 0x31, 0xbe, 0xfe, 0x59, 0x05, - 0x4c, 0x32, 0x85, 0xe0, 0x13, 0x01, 0xcc, 0x65, 0xd1, 0x5d, 0x78, 0xa5, 0x78, 0xa2, 0xa4, 0x39, - 0xb6, 0xb8, 0x35, 0x02, 0x42, 0xe0, 0x12, 0xe9, 0xea, 0x8f, 0xbe, 0xfc, 0xfb, 0xcf, 0x4b, 0x9b, - 0x70, 0x63, 0xf0, 0xfb, 0x49, 0x14, 0xda, 0x9c, 0x4f, 0x2b, 0x8f, 0xc2, 0xd3, 0xf8, 0x10, 0x7e, - 0x29, 0xf0, 0x3b, 0x24, 0x9d, 0x2f, 0x70, 0xb3, 0xb8, 0x86, 0x29, 0x42, 0x2e, 0x5e, 0x19, 0x1e, - 0x80, 0x5b, 0xf8, 0x06, 0xb3, 0xf0, 0x02, 0x5c, 0x2b, 0x60, 0x61, 0x40, 0xd5, 0xe1, 0x47, 0x25, - 0x30, 0xdf, 0x83, 0x7f, 0x13, 0x78, 0x73, 0x48, 0xcd, 0x32, 0xa9, 0xbe, 0xf8, 0xce, 0x11, 0xa1, - 0x71, 0xa3, 0xdf, 0x66, 0x46, 0x57, 0xe1, 0x95, 0xa2, 0x46, 0x6b, 0xc4, 0x07, 0xd4, 0x22, 0x16, - 0x0d, 0xff, 0x27, 0x80, 0x97, 0xb2, 0xe9, 0x3c, 0x81, 0x37, 0x86, 0x56, 0xba, 0xfb, 0xdd, 0x40, - 0xbc, 0x79, 0x34, 0x60, 0xdc, 0x01, 0xd7, 0x99, 0x03, 0xb6, 0xe0, 0xe6, 0x10, 0x0e, 0xc0, 0x6e, - 0xc2, 0xfe, 0x7f, 0x87, 0xbc, 0x2a, 0x93, 0xa1, 0xc2, 0x6b, 0xf9, 0xb5, 0xee, 0xc7, 0xb5, 0xc5, - 0xeb, 0x23, 0xe3, 0x70, 0xc3, 0xb7, 0x98, 0xe1, 0x97, 0xe1, 0x1b, 0x39, 0x1e, 0x44, 0xa3, 0x87, - 0x86, 0x54, 0xef, 0x99, 0x61, 0x72, 0xb2, 0x2b, 0x1a, 0xca, 0xe4, 0x0c, 0x0e, 0x3e, 0x94, 0xc9, - 0x59, 0x14, 0x7a, 0x38, 0x93, 0x53, 0xf7, 0x25, 0xfc, 0x83, 0xc0, 0x3b, 0xe3, 0x14, 0x7b, 0x86, - 0x6f, 0xe5, 0x57, 0x31, 0x8b, 0x94, 0x8b, 0x9b, 0x43, 0xaf, 0xe7, 0xa6, 0x5d, 0x64, 0xa6, 0xad, - 0xc3, 0xd5, 0xc1, 0xa6, 0x51, 0x0e, 0x10, 0xbc, 0x99, 0xc2, 0x5f, 0x96, 0xc0, 0xab, 0x39, 0xe8, - 0x30, 0xbc, 0x95, 0x5f, 0xc5, 0x5c, 0x34, 0x5c, 0xdc, 0x39, 0x3a, 0x40, 0xee, 0x84, 0x1b, 0xcc, - 0x09, 0x57, 0xe1, 0xf6, 0x60, 0x27, 0x78, 0x11, 0x62, 0x1c, 0xd3, 0x1e, 0xc3, 0xd4, 0x02, 0x7a, - 0x0f, 0xff, 0xd9, 0x45, 0xdf, 0xd3, 0xac, 0x94, 0xc0, 0x02, 0xb7, 0x6a, 0x8f, 0x37, 0x02, 0xb1, - 0x3a, 0x0a, 0x04, 0xb7, 0xba, 0xca, 0xac, 0x7e, 0x13, 0x5e, 0x1a, 0x6c, 0x75, 0xf8, 0x3a, 0xa0, - 0x75, 0x5e, 0x60, 0xbf, 0x28, 0xf1, 0x07, 0xe4, 0x1c, 0x74, 0x1c, 0xee, 0xe6, 0x57, 0x3a, 0xff, - 0x63, 0x81, 0x78, 0xe7, 0x88, 0x51, 0xb9, 0x77, 0x2e, 0x33, 0xef, 0xbc, 0x0e, 0x2f, 0x14, 0xae, - 0xef, 0x96, 0x09, 0x7f, 0x2b, 0x80, 0xd9, 0x04, 0xe3, 0x85, 0xdf, 0x2e, 0x70, 0x5c, 0x49, 0xe6, - 0x2c, 0x5e, 0x2c, 0xbe, 0x90, 0xeb, 0xbf, 0xca, 0xf4, 0x5f, 0x81, 0xcb, 0x39, 0x4e, 0x37, 0x50, - 0xf2, 0x67, 0x61, 0x42, 0xf7, 0xe7, 0xbe, 0x45, 0x12, 0x3a, 0x17, 0x1d, 0x2f, 0x92, 0xd0, 0xf9, - 0x68, 0x79, 0x91, 0xee, 0x04, 0xfb, 0x20, 0x9a, 0xe5, 0x68, 0x31, 0x1d, 0x4c, 0xf6, 0x9d, 0xbf, - 0x2f, 0x81, 0x33, 0xb9, 0x79, 0x1a, 0xbc, 0x33, 0x6c, 0x33, 0xd9, 0x97, 0x6a, 0x8a, 0x7b, 0x47, - 0x0d, 0xcb, 0xdd, 0x74, 0x97, 0xb9, 0x69, 0x17, 0xaa, 0x85, 0x3b, 0x57, 0xcd, 0x45, 0x5e, 0xec, - 0x31, 0xe5, 0x51, 0x27, 0x39, 0xfc, 0x10, 0xfe, 0xa6, 0x04, 0xbe, 0x9e, 0x87, 0xf2, 0xc1, 0x9d, - 0x11, 0x1a, 0x93, 0x4c, 0x1e, 0x2b, 0xbe, 0x77, 0x84, 0x88, 0xdc, 0x53, 0xf7, 0x98, 0xa7, 0xee, - 0xc2, 0xef, 0x16, 0xf1, 0x54, 0x04, 0xa5, 0xf9, 0x0c, 0x34, 0x11, 0x55, 0x59, 0xfe, 0xfa, 0xaf, - 0xc0, 0x1f, 0xdf, 0xb3, 0x08, 0x26, 0x2c, 0xf0, 0xe6, 0xd1, 0x87, 0xe0, 0x8a, 0xd7, 0x46, 0x85, - 0x29, 0x7e, 0x61, 0x62, 0x86, 0xa3, 0x35, 0x63, 0x20, 0xad, 0x45, 0x8c, 0x64, 0x8a, 0xfd, 0xab, - 0x93, 0x00, 0x24, 0x6a, 0xcd, 0xf6, 0x28, 0x6f, 0x3d, 0xa1, 0xd5, 0xb5, 0xd1, 0x40, 0x46, 0x60, - 0x3c, 0x99, 0x35, 0xa5, 0xfa, 0x9d, 0xcf, 0x9f, 0x94, 0x85, 0x2f, 0x9e, 0x94, 0x85, 0xbf, 0x3d, - 0x29, 0x0b, 0x9f, 0x3c, 0x2d, 0x8f, 0x7d, 0xf1, 0xb4, 0x3c, 0xf6, 0xe7, 0xa7, 0xe5, 0xb1, 0xbb, - 0x1b, 0xdd, 0x0f, 0x1c, 0xf1, 0x66, 0xe7, 0xa3, 0xcd, 0x5a, 0xdf, 0x52, 0x3e, 0xe8, 0xe8, 0xcd, - 0xda, 0x2e, 0x22, 0xf7, 0xa7, 0xd8, 0x3f, 0x41, 0x2e, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xb7, - 0x19, 0x6f, 0x26, 0xab, 0x20, 0x00, 0x00, + 0x15, 0x17, 0x57, 0x1f, 0x91, 0x46, 0xf1, 0x47, 0xc6, 0x6a, 0x22, 0x53, 0xca, 0xae, 0x42, 0xf7, + 0x43, 0x96, 0x5d, 0x52, 0x92, 0x61, 0xc4, 0xb1, 0xab, 0xc8, 0x5a, 0xc9, 0x76, 0x16, 0x76, 0x62, + 0x85, 0x96, 0xd5, 0xc2, 0x2d, 0x4a, 0x8f, 0xc9, 0xc9, 0x8a, 0x30, 0x97, 0x43, 0x71, 0xb8, 0xeb, + 0x2c, 0x8c, 0x1c, 0xd2, 0x43, 0x9b, 0x53, 0x11, 0xf4, 0x03, 0xe8, 0x31, 0x97, 0x1e, 0x7b, 0xe9, + 0xa1, 0xc8, 0x9f, 0x90, 0x5b, 0x53, 0xe4, 0x52, 0xf4, 0xe0, 0x16, 0x72, 0x0f, 0x45, 0x0f, 0x45, + 0x61, 0x14, 0xe8, 0xa9, 0x40, 0xc1, 0xe1, 0xf0, 0x6b, 0x97, 0xbb, 0x4b, 0xee, 0x2a, 0xb7, 0xe5, + 0xcc, 0xbc, 0xdf, 0xbc, 0xf7, 0xe6, 0xbd, 0x37, 0xef, 0x37, 0x0b, 0x14, 0xd3, 0xf6, 0xb0, 0xab, + 0x1f, 0x20, 0xd3, 0xd6, 0x28, 0xd6, 0x9b, 0xae, 0xe9, 0xb5, 0x15, 0x5d, 0x6f, 0x29, 0x8e, 0x4b, + 0x5a, 0xa6, 0x81, 0x5d, 0xa5, 0xb5, 0xa6, 0x1c, 0x36, 0xb1, 0xdb, 0x96, 0x1d, 0x97, 0x78, 0x04, + 0x9e, 0xcb, 0x10, 0x90, 0x75, 0xbd, 0x25, 0x87, 0x02, 0x72, 0x6b, 0x4d, 0x5c, 0xac, 0x13, 0x52, + 0xb7, 0xb0, 0x82, 0x1c, 0x53, 0x41, 0xb6, 0x4d, 0x3c, 0xe4, 0x99, 0xc4, 0xa6, 0x01, 0x84, 0x38, + 0x57, 0x27, 0x75, 0xc2, 0x7e, 0x2a, 0xfe, 0x2f, 0x3e, 0x5a, 0xe1, 0x32, 0xec, 0xeb, 0x51, 0xf3, + 0x03, 0xc5, 0x33, 0x1b, 0x98, 0x7a, 0xa8, 0xe1, 0xf0, 0x05, 0xeb, 0x79, 0x54, 0x8d, 0xb4, 0x08, + 0x64, 0x56, 0x7b, 0xc9, 0xb4, 0xd6, 0x14, 0x7a, 0x80, 0x5c, 0x6c, 0x68, 0x3a, 0xb1, 0x69, 0xb3, + 0x11, 0x49, 0x7c, 0xab, 0x8f, 0xc4, 0x13, 0xd3, 0xc5, 0x7c, 0xd9, 0xa2, 0x87, 0x6d, 0x03, 0xbb, + 0x0d, 0xd3, 0xf6, 0x14, 0xdd, 0x6d, 0x3b, 0x1e, 0x51, 0x1e, 0xe3, 0x76, 0x68, 0xe1, 0x59, 0x9d, + 0xd0, 0x06, 0xa1, 0x5a, 0x60, 0x64, 0xf0, 0x11, 0x4c, 0x49, 0x57, 0xc0, 0xc2, 0xfb, 0xbe, 0x3b, + 0xb7, 0xf9, 0xb6, 0xb7, 0xb0, 0x8d, 0xa9, 0x49, 0x55, 0x7c, 0xd8, 0xc4, 0xd4, 0x83, 0x67, 0xc1, + 0x74, 0xb0, 0xb7, 0x69, 0xcc, 0x0b, 0x4b, 0xc2, 0xf2, 0x8c, 0xfa, 0x12, 0xfb, 0xae, 0x19, 0xd2, + 0x53, 0xb0, 0x98, 0x2d, 0x49, 0x1d, 0x62, 0x53, 0x0c, 0x7f, 0x08, 0x4e, 0xd4, 0x83, 0x21, 0x8d, + 0x7a, 0xc8, 0xc3, 0x4c, 0x7e, 0x76, 0x7d, 0x55, 0xee, 0x75, 0x62, 0xad, 0x35, 0xb9, 0x03, 0xeb, + 0x9e, 0x2f, 0x57, 0x9d, 0xf8, 0xe2, 0x59, 0x65, 0x4c, 0x7d, 0xb9, 0x9e, 0x18, 0x93, 0x16, 0x81, + 0x98, 0xda, 0x7c, 0xdb, 0x87, 0x0b, 0xb5, 0x96, 0x50, 0x87, 0x51, 0xe1, 0x2c, 0xd7, 0xac, 0x0a, + 0xa6, 0xd8, 0xf6, 0x74, 0x5e, 0x58, 0x1a, 0x5f, 0x9e, 0x5d, 0x5f, 0x91, 0x73, 0x04, 0x91, 0xcc, + 0x40, 0x54, 0x2e, 0x29, 0x9d, 0x07, 0xdf, 0xe9, 0xde, 0xe2, 0x9e, 0x87, 0x5c, 0x6f, 0xd7, 0x25, + 0x0e, 0xa1, 0xc8, 0x8a, 0xb4, 0xf9, 0x44, 0x00, 0xcb, 0x83, 0xd7, 0x72, 0xdd, 0x7e, 0x04, 0x66, + 0x9c, 0x70, 0x90, 0x7b, 0xec, 0xed, 0x7c, 0xea, 0x71, 0xf0, 0x2d, 0xc3, 0x30, 0xfd, 0xe8, 0x8e, + 0xa1, 0x63, 0x40, 0x69, 0x19, 0x7c, 0x3b, 0x4b, 0x13, 0xe2, 0x74, 0x29, 0xfd, 0x53, 0x21, 0xdb, + 0xc0, 0xd4, 0xd2, 0xe8, 0xa4, 0xbb, 0x74, 0xde, 0x28, 0xa4, 0xb3, 0x8a, 0x1b, 0xa4, 0x85, 0xac, + 0x4c, 0x95, 0x7f, 0x53, 0x02, 0x93, 0x6c, 0xef, 0x3e, 0xb1, 0x08, 0x17, 0xc0, 0x8c, 0x6e, 0x99, + 0xd8, 0xf6, 0xfc, 0xb9, 0x12, 0x9b, 0x9b, 0x0e, 0x06, 0x6a, 0x06, 0x3c, 0x03, 0x26, 0x3d, 0xe2, + 0x68, 0xef, 0xcd, 0x8f, 0x2f, 0x09, 0xcb, 0x27, 0xd4, 0x09, 0x8f, 0x38, 0xef, 0xc1, 0x15, 0x00, + 0x1b, 0xa6, 0xad, 0x39, 0xe4, 0x09, 0x76, 0x35, 0xd3, 0xd6, 0x82, 0x15, 0x13, 0x4b, 0xc2, 0xf2, + 0xb8, 0x7a, 0xb2, 0x61, 0xda, 0xbb, 0xfe, 0x44, 0xcd, 0xde, 0xf3, 0xd7, 0xae, 0x82, 0xb9, 0x16, + 0xb2, 0x4c, 0x03, 0x79, 0xc4, 0xa5, 0x5c, 0x44, 0x47, 0xce, 0xfc, 0x24, 0xc3, 0x83, 0xf1, 0x1c, + 0x13, 0xda, 0x46, 0x0e, 0x5c, 0x01, 0xaf, 0x44, 0xa3, 0x1a, 0xc5, 0x1e, 0x5b, 0x3e, 0xc5, 0x96, + 0x9f, 0x8a, 0x26, 0xee, 0x61, 0xcf, 0x5f, 0xbb, 0x08, 0x66, 0x90, 0x65, 0x91, 0x27, 0x96, 0x49, + 0xbd, 0xf9, 0x97, 0x96, 0xc6, 0x97, 0x67, 0xd4, 0x78, 0x00, 0x8a, 0x60, 0xda, 0xc0, 0x76, 0x9b, + 0x4d, 0x4e, 0xb3, 0xc9, 0xe8, 0x5b, 0xfa, 0x99, 0x00, 0xde, 0x60, 0x67, 0xb4, 0x1f, 0x42, 0x26, + 0x82, 0xc0, 0x1d, 0x9c, 0xc2, 0x70, 0x03, 0x9c, 0x0e, 0x8f, 0x43, 0x43, 0x86, 0xe1, 0x62, 0x4a, + 0x03, 0xef, 0x55, 0xe1, 0x8b, 0x67, 0x95, 0x93, 0x6d, 0xd4, 0xb0, 0xae, 0x4a, 0x7c, 0x42, 0x52, + 0x4f, 0x85, 0x6b, 0xb7, 0x82, 0x91, 0xab, 0xd3, 0x9f, 0x7c, 0x56, 0x19, 0xfb, 0xc7, 0x67, 0x95, + 0x31, 0xe9, 0x2e, 0x90, 0xfa, 0x29, 0xc2, 0xe3, 0xe4, 0x3c, 0x38, 0x1d, 0x56, 0xb7, 0x68, 0xbb, + 0x40, 0xa3, 0x53, 0x7a, 0x62, 0xbd, 0xbf, 0x59, 0xb7, 0x69, 0xbb, 0x89, 0xcd, 0xf3, 0x99, 0xd6, + 0xb5, 0x57, 0x1f, 0xd3, 0x3a, 0xf6, 0xef, 0x67, 0x5a, 0x5a, 0x91, 0xd8, 0xb4, 0x2e, 0x4f, 0x72, + 0xd3, 0x3a, 0xbc, 0x26, 0x2d, 0x80, 0xb3, 0x0c, 0x70, 0xef, 0xc0, 0x25, 0x9e, 0x67, 0x61, 0x56, + 0xd0, 0xc2, 0xb4, 0xfb, 0x93, 0xc0, 0x0b, 0x5b, 0xc7, 0x2c, 0xdf, 0xa6, 0x02, 0x66, 0xa9, 0x85, + 0xe8, 0x81, 0xd6, 0xc0, 0x1e, 0x76, 0xd9, 0x0e, 0xe3, 0x2a, 0x60, 0x43, 0xef, 0xfa, 0x23, 0x70, + 0x1d, 0x7c, 0x23, 0xb1, 0x40, 0x63, 0x71, 0x84, 0x6c, 0x1d, 0x33, 0xdb, 0xc7, 0xd5, 0x33, 0xf1, + 0xd2, 0xad, 0x70, 0x0a, 0xfe, 0x18, 0xcc, 0xdb, 0xf8, 0x43, 0x4f, 0x73, 0xb1, 0x63, 0x61, 0xdb, + 0xa4, 0x07, 0x9a, 0x8e, 0x6c, 0xc3, 0x37, 0x16, 0xb3, 0x94, 0x99, 0x5d, 0x17, 0xe5, 0xe0, 0x32, + 0x94, 0xc3, 0xcb, 0x50, 0xde, 0x0b, 0x2f, 0xc3, 0xea, 0xb4, 0x5f, 0x9d, 0x3f, 0xfd, 0x6b, 0x45, + 0x50, 0x5f, 0xf5, 0x51, 0xd4, 0x10, 0x64, 0x3b, 0xc4, 0x90, 0x2e, 0x82, 0x15, 0x66, 0x92, 0x8a, + 0xeb, 0x26, 0xf5, 0xb0, 0x8b, 0x8d, 0x38, 0xef, 0x9f, 0x20, 0xd7, 0xd8, 0xc1, 0x36, 0x69, 0x44, + 0x85, 0xe7, 0x06, 0xb8, 0x90, 0x6b, 0x35, 0xf7, 0xc8, 0xab, 0x60, 0xca, 0x60, 0x23, 0xac, 0x96, + 0xcf, 0xa8, 0xfc, 0x4b, 0x2a, 0xf3, 0xdb, 0x29, 0xa8, 0x29, 0xd8, 0x60, 0x25, 0xa4, 0xb6, 0x13, + 0x6d, 0xf3, 0xb1, 0x00, 0x5e, 0xef, 0xb1, 0x80, 0x23, 0x3f, 0x04, 0x27, 0x9d, 0xe4, 0x5c, 0x78, + 0x5b, 0xac, 0xe7, 0x2a, 0x6d, 0x29, 0x58, 0x7e, 0x85, 0x75, 0xe0, 0x49, 0x35, 0x70, 0x22, 0xb5, + 0x0c, 0xce, 0x03, 0x1e, 0xbf, 0x3b, 0xe9, 0x70, 0xde, 0x81, 0x65, 0x00, 0xc2, 0x92, 0x58, 0xdb, + 0x61, 0x87, 0x39, 0xa1, 0x26, 0x46, 0xa4, 0x3b, 0x40, 0x61, 0xd6, 0x6c, 0x59, 0xd6, 0x2e, 0x32, + 0x5d, 0xba, 0x8f, 0xac, 0x6d, 0x62, 0xfb, 0x21, 0x57, 0x4d, 0x57, 0xf0, 0xda, 0x4e, 0x8e, 0xab, + 0xfd, 0xb7, 0x02, 0x58, 0xcd, 0x0f, 0xc7, 0xfd, 0x75, 0x08, 0x5e, 0x71, 0x90, 0xe9, 0x6a, 0x2d, + 0x64, 0xf9, 0x4d, 0x0c, 0x4b, 0x03, 0xee, 0xb2, 0x9b, 0xf9, 0x5c, 0x86, 0x4c, 0x37, 0xde, 0x28, + 0x4a, 0x33, 0x3b, 0x0e, 0x80, 0x93, 0x4e, 0x6a, 0x89, 0xf4, 0x1f, 0x01, 0xbc, 0x31, 0x50, 0x0a, + 0xde, 0xec, 0x95, 0x9b, 0xd5, 0x85, 0x17, 0xcf, 0x2a, 0xaf, 0x05, 0xa5, 0xa0, 0x73, 0x45, 0x77, + 0xb9, 0xf3, 0x71, 0x7a, 0x94, 0x94, 0x04, 0x4e, 0xe7, 0x8a, 0xee, 0xda, 0x02, 0x37, 0xc1, 0xcb, + 0xd1, 0xaa, 0xc7, 0xb8, 0xcd, 0x73, 0x6c, 0x51, 0x8e, 0x5b, 0x38, 0x39, 0x68, 0xe1, 0xe4, 0xdd, + 0xe6, 0x23, 0xcb, 0xd4, 0x6f, 0xe3, 0xb6, 0x3a, 0x1b, 0x4a, 0xdc, 0xc6, 0x6d, 0x69, 0x0e, 0xc0, + 0x20, 0x74, 0x91, 0x8b, 0xe2, 0xc4, 0x79, 0x08, 0xce, 0xa4, 0x46, 0xf9, 0xb1, 0xd4, 0xc0, 0x94, + 0xc3, 0x46, 0xf8, 0xcd, 0x7c, 0x21, 0xe7, 0x59, 0xf8, 0x22, 0x3c, 0x6e, 0x39, 0x80, 0x74, 0x8b, + 0x27, 0x72, 0x2a, 0x02, 0xee, 0x3a, 0x1e, 0x36, 0x6a, 0x76, 0x54, 0x1e, 0xf3, 0xb4, 0x8e, 0x87, + 0x3c, 0xc7, 0x07, 0x01, 0x45, 0xfd, 0xda, 0xeb, 0xc9, 0xfb, 0xb7, 0xe3, 0xa4, 0x70, 0x98, 0xfa, + 0x0b, 0x89, 0x8b, 0x38, 0x7d, 0x74, 0x98, 0x4a, 0xd7, 0x40, 0x39, 0xb5, 0x65, 0x21, 0x7d, 0x3f, + 0x17, 0xc0, 0x52, 0x0f, 0xe9, 0xe8, 0x57, 0xe6, 0x65, 0x2a, 0xe4, 0xbe, 0x4c, 0xbb, 0xa2, 0xa2, + 0x54, 0x30, 0x2a, 0xe0, 0x1c, 0x98, 0x64, 0xad, 0x09, 0x8b, 0xa7, 0x71, 0x35, 0xf8, 0xf0, 0x9b, + 0xcf, 0x4a, 0x4f, 0xc3, 0xb9, 0x7f, 0x31, 0x00, 0xb1, 0xeb, 0x78, 0xca, 0xde, 0xc8, 0x15, 0x26, + 0x83, 0x9c, 0xa2, 0x26, 0x80, 0xa5, 0x43, 0x5e, 0x54, 0xd2, 0x5d, 0x79, 0xb4, 0xf6, 0x1d, 0x44, + 0xf7, 0x08, 0xff, 0x0a, 0xef, 0xc3, 0x11, 0x9d, 0x2a, 0x21, 0xb0, 0x56, 0x60, 0x4b, 0xee, 0x8e, + 0x8b, 0x00, 0x46, 0x27, 0x11, 0x46, 0x44, 0x18, 0x63, 0x51, 0x05, 0x08, 0xaa, 0x9f, 0xc1, 0x3a, + 0x95, 0x0b, 0xd9, 0xbd, 0xcf, 0x36, 0x69, 0x34, 0x4c, 0x4a, 0x4d, 0x62, 0xab, 0x09, 0x8b, 0xbe, + 0xb6, 0x76, 0x4c, 0xaa, 0x83, 0x8b, 0xf9, 0x14, 0xe1, 0x76, 0xbe, 0x09, 0x26, 0xdc, 0x90, 0x97, + 0xcd, 0x54, 0xcf, 0xf9, 0xa9, 0xfe, 0x97, 0x67, 0x95, 0x85, 0x80, 0x1e, 0x52, 0xe3, 0xb1, 0x6c, + 0x12, 0xa5, 0x81, 0xbc, 0x03, 0xf9, 0x0e, 0xae, 0x23, 0xbd, 0xbd, 0x83, 0x75, 0x95, 0x09, 0x48, + 0x1b, 0x3c, 0x1b, 0xee, 0x5a, 0x06, 0xa6, 0xde, 0x7d, 0x5b, 0x27, 0xf6, 0x07, 0xa6, 0xdb, 0xc0, + 0xc6, 0x3e, 0xd5, 0x73, 0x64, 0xd3, 0xcf, 0xc3, 0xde, 0x2e, 0x5b, 0x9e, 0x6b, 0x67, 0x02, 0xd8, + 0xa2, 0xba, 0x46, 0xb1, 0x6d, 0x68, 0x11, 0xf5, 0xe6, 0x35, 0xec, 0x72, 0xae, 0xe0, 0xdc, 0xa7, + 0xfa, 0x3d, 0x6c, 0x1b, 0x71, 0xab, 0x12, 0x54, 0xb3, 0xd3, 0xad, 0x8e, 0xf1, 0xf5, 0xcf, 0x2b, + 0x60, 0x92, 0x29, 0x04, 0x8f, 0x04, 0x30, 0x97, 0x45, 0x6a, 0xe1, 0xf5, 0xe2, 0xe9, 0x90, 0x66, + 0xd2, 0xe2, 0xd6, 0x08, 0x08, 0x81, 0x4b, 0xa4, 0x1b, 0x3f, 0xf9, 0xea, 0xef, 0xbf, 0x2c, 0x6d, + 0xc2, 0x8d, 0xc1, 0xaf, 0x24, 0x51, 0x00, 0x73, 0xd6, 0xac, 0x3c, 0x0d, 0x4f, 0xe3, 0x23, 0xf8, + 0x95, 0xc0, 0x6f, 0x8a, 0x74, 0x56, 0xc0, 0xcd, 0xe2, 0x1a, 0xa6, 0x68, 0xb7, 0x78, 0x7d, 0x78, + 0x00, 0x6e, 0xe1, 0x5b, 0xcc, 0xc2, 0x4b, 0x70, 0xad, 0x80, 0x85, 0x01, 0x21, 0x87, 0x1f, 0x97, + 0xc0, 0x7c, 0x0f, 0x96, 0x4d, 0xe1, 0x9d, 0x21, 0x35, 0xcb, 0x24, 0xf4, 0xe2, 0xbb, 0xc7, 0x84, + 0xc6, 0x8d, 0x7e, 0x87, 0x19, 0x5d, 0x85, 0xd7, 0x8b, 0x1a, 0xad, 0x51, 0x1f, 0x50, 0x8b, 0xb8, + 0x32, 0xfc, 0x9f, 0x00, 0x5e, 0xcb, 0x26, 0xed, 0x14, 0xde, 0x1e, 0x5a, 0xe9, 0xee, 0xd7, 0x01, + 0xf1, 0xce, 0xf1, 0x80, 0x71, 0x07, 0xdc, 0x62, 0x0e, 0xd8, 0x82, 0x9b, 0x43, 0x38, 0x80, 0x38, + 0x09, 0xfb, 0xff, 0x1d, 0xb2, 0xa7, 0x4c, 0x1e, 0x0a, 0x6f, 0xe6, 0xd7, 0xba, 0x1f, 0xa3, 0x16, + 0x6f, 0x8d, 0x8c, 0xc3, 0x0d, 0xdf, 0x62, 0x86, 0x5f, 0x83, 0x6f, 0xe5, 0x78, 0xf6, 0x8c, 0x9e, + 0x13, 0x52, 0x1d, 0x66, 0x86, 0xc9, 0xc9, 0xde, 0x67, 0x28, 0x93, 0x33, 0x98, 0xf6, 0x50, 0x26, + 0x67, 0x11, 0xe5, 0xe1, 0x4c, 0x4e, 0xdd, 0x8a, 0xf0, 0x8f, 0x02, 0xef, 0x7f, 0x53, 0x1c, 0x19, + 0xbe, 0x9d, 0x5f, 0xc5, 0x2c, 0xea, 0x2d, 0x6e, 0x0e, 0x2d, 0xcf, 0x4d, 0xbb, 0xc2, 0x4c, 0x5b, + 0x87, 0xab, 0x83, 0x4d, 0xf3, 0x38, 0x40, 0xf0, 0x32, 0x0a, 0x7f, 0x5d, 0x02, 0xe7, 0x72, 0x90, + 0x5e, 0x78, 0x37, 0xbf, 0x8a, 0xb9, 0xc8, 0xb6, 0xb8, 0x7b, 0x7c, 0x80, 0xdc, 0x09, 0xb7, 0x99, + 0x13, 0x6e, 0xc0, 0xed, 0xc1, 0x4e, 0x70, 0x23, 0xc4, 0x38, 0xa6, 0x5d, 0x86, 0xa9, 0x05, 0x24, + 0x1e, 0xfe, 0xb3, 0x8b, 0xa4, 0xa7, 0xb9, 0x27, 0x85, 0x05, 0x6e, 0xd5, 0x1e, 0x2f, 0x01, 0x62, + 0x75, 0x14, 0x08, 0x6e, 0x75, 0x95, 0x59, 0xfd, 0x3d, 0x78, 0x75, 0xb0, 0xd5, 0xe1, 0x1b, 0x80, + 0xd6, 0x79, 0x81, 0xfd, 0xaa, 0xc4, 0x9f, 0x89, 0x73, 0x90, 0x6e, 0xb8, 0x97, 0x5f, 0xe9, 0xfc, + 0x4f, 0x02, 0xe2, 0xfd, 0x63, 0x46, 0xe5, 0xde, 0xb9, 0xc6, 0xbc, 0x73, 0x19, 0x5e, 0x2a, 0x5c, + 0xdf, 0x4d, 0x03, 0xfe, 0x5e, 0x00, 0xb3, 0x09, 0x5e, 0x0b, 0xdf, 0x2c, 0x70, 0x5c, 0x49, 0x7e, + 0x2c, 0x5e, 0x29, 0x2e, 0xc8, 0xf5, 0x5f, 0x65, 0xfa, 0xaf, 0xc0, 0xe5, 0x1c, 0xa7, 0x1b, 0x28, + 0xf9, 0x8b, 0x30, 0xa1, 0xfb, 0x33, 0xdc, 0x22, 0x09, 0x9d, 0x8b, 0x74, 0x17, 0x49, 0xe8, 0x7c, + 0xe4, 0xbb, 0x48, 0x77, 0x42, 0x7c, 0x10, 0xcd, 0xb4, 0xb5, 0x98, 0xf4, 0x25, 0xfb, 0xce, 0x3f, + 0x94, 0xc0, 0xf9, 0xdc, 0x6c, 0x0c, 0xde, 0x1f, 0xb6, 0x99, 0xec, 0x4b, 0x28, 0xc5, 0xfd, 0xe3, + 0x86, 0xe5, 0x6e, 0x7a, 0xc0, 0xdc, 0xb4, 0x07, 0xd5, 0xc2, 0x9d, 0xab, 0xe6, 0x60, 0x37, 0xf6, + 0x98, 0xf2, 0xb4, 0x93, 0x02, 0x7e, 0x04, 0x7f, 0x57, 0x02, 0xdf, 0xcc, 0xc3, 0xec, 0xe0, 0xee, + 0x08, 0x8d, 0x49, 0x26, 0x5b, 0x15, 0xdf, 0x3f, 0x46, 0x44, 0xee, 0xa9, 0x87, 0xcc, 0x53, 0x0f, + 0xe0, 0x0f, 0x8a, 0x78, 0x2a, 0x82, 0xd2, 0x7c, 0x06, 0x9a, 0x88, 0xaa, 0x2c, 0x7f, 0xfd, 0x57, + 0xe0, 0x4f, 0xec, 0x59, 0x04, 0x13, 0x16, 0x78, 0xd9, 0xe8, 0x43, 0x70, 0xc5, 0x9b, 0xa3, 0xc2, + 0x14, 0xbf, 0x30, 0x09, 0xc3, 0xd1, 0x9a, 0x31, 0x90, 0xd6, 0xa2, 0x7a, 0x32, 0xc5, 0xfe, 0xd5, + 0x49, 0x00, 0x12, 0xb5, 0x66, 0x7b, 0x94, 0x17, 0x9d, 0xd0, 0xea, 0x9d, 0xd1, 0x40, 0x46, 0x60, + 0x3c, 0x99, 0x35, 0xa5, 0xfa, 0xfd, 0x2f, 0x8e, 0xca, 0xc2, 0x97, 0x47, 0x65, 0xe1, 0x6f, 0x47, + 0x65, 0xe1, 0xd3, 0xe7, 0xe5, 0xb1, 0x2f, 0x9f, 0x97, 0xc7, 0xfe, 0xfc, 0xbc, 0x3c, 0xf6, 0x60, + 0xa3, 0x6e, 0x7a, 0x07, 0xcd, 0x47, 0xb2, 0x4e, 0x1a, 0xfc, 0x1f, 0xef, 0xc4, 0x66, 0xdf, 0x8d, + 0x36, 0x6b, 0x5d, 0x56, 0x3e, 0xec, 0xe8, 0xcd, 0xda, 0x0e, 0xa6, 0x8f, 0xa6, 0xd8, 0x5f, 0x1d, + 0x97, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x4e, 0xa1, 0x75, 0x91, 0x20, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 1fd4869548..be71e8fa18 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -5,27 +5,36 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" types "github.com/cometbft/cometbft/proto/tendermint/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _07_tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + types1 "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + _07_tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "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. @@ -42,6 +51,8 @@ type MsgAssignConsumerKey struct { // in json string format corresponding to proto-any, ex: // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` + // Tx signer address + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgAssignConsumerKey) Reset() { *m = MsgAssignConsumerKey{} } @@ -271,30 +282,26 @@ func (m *MsgSubmitConsumerDoubleVotingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitConsumerDoubleVotingResponse proto.InternalMessageInfo -type MsgOptIn struct { - // the chain id of the consumer chain to opt in to - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // the validator address on the provider - ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` - // (optional) The consensus public key to use on the consumer in json string format corresponding to proto-any, - // for example `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`. - // This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the - // consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. - ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` +// MsgUpdateParams is the Msg/UpdateParams request type +type MsgUpdateParams struct { + // signer is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/provider parameters to update. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } -func (m *MsgOptIn) Reset() { *m = MsgOptIn{} } -func (m *MsgOptIn) String() string { return proto.CompactTextString(m) } -func (*MsgOptIn) ProtoMessage() {} -func (*MsgOptIn) Descriptor() ([]byte, []int) { +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{6} } -func (m *MsgOptIn) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgOptIn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgOptIn.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -304,33 +311,47 @@ func (m *MsgOptIn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *MsgOptIn) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgOptIn.Merge(m, src) +func (m *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) } -func (m *MsgOptIn) XXX_Size() int { +func (m *MsgUpdateParams) XXX_Size() int { return m.Size() } -func (m *MsgOptIn) XXX_DiscardUnknown() { - xxx_messageInfo_MsgOptIn.DiscardUnknown(m) +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) } -var xxx_messageInfo_MsgOptIn proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo -type MsgOptInResponse struct { +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" } -func (m *MsgOptInResponse) Reset() { *m = MsgOptInResponse{} } -func (m *MsgOptInResponse) String() string { return proto.CompactTextString(m) } -func (*MsgOptInResponse) ProtoMessage() {} -func (*MsgOptInResponse) Descriptor() ([]byte, []int) { +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{7} } -func (m *MsgOptInResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgOptInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgOptInResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -340,37 +361,106 @@ func (m *MsgOptInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgOptInResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgOptInResponse.Merge(m, src) +func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) } -func (m *MsgOptInResponse) XXX_Size() int { +func (m *MsgUpdateParamsResponse) XXX_Size() int { return m.Size() } -func (m *MsgOptInResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgOptInResponse.DiscardUnknown(m) +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgOptInResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -type MsgOptOut struct { - // the chain id of the consumer chain to opt out from +// MsgConsumerAddition defines the message used to spawn a new consumer chain using a v1 governance proposal. +// If it passes, then all validators on the provider chain are expected to validate +// the consumer chain at spawn time or get slashed. +// It is recommended that spawn time occurs after the proposal end time. +// +// Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon +type MsgConsumerAddition struct { + // the proposed chain-id of the new consumer chain, must be different from all + // other consumer chain ids of the executing provider chain. ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // the validator address on the provider - ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + // the proposed initial height of new consumer chain. + // For a completely new chain, this will be {0,1}. However, it may be + // different if this is a chain that is converting to a consumer chain. + InitialHeight types1.Height `protobuf:"bytes,2,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height"` + // The hash of the consumer chain genesis state without the consumer CCV + // module genesis params. It is used for off-chain confirmation of + // genesis.json validity by validators and other parties. + GenesisHash []byte `protobuf:"bytes,3,opt,name=genesis_hash,json=genesisHash,proto3" json:"genesis_hash,omitempty"` + // The hash of the consumer chain binary that should be run by validators on + // chain initialization. It is used for off-chain confirmation of binary + // validity by validators and other parties. + BinaryHash []byte `protobuf:"bytes,4,opt,name=binary_hash,json=binaryHash,proto3" json:"binary_hash,omitempty"` + // spawn time is the time on the provider chain at which the consumer chain + // genesis is finalized and all validators will be responsible for starting + // their consumer chain validator node. + SpawnTime time.Time `protobuf:"bytes,5,opt,name=spawn_time,json=spawnTime,proto3,stdtime" json:"spawn_time"` + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + UnbondingPeriod time.Duration `protobuf:"bytes,6,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` + // Sent CCV related IBC packets will timeout after this duration + CcvTimeoutPeriod time.Duration `protobuf:"bytes,7,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,8,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,9,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` + // BlocksPerDistributionTransmission is the number of blocks between + // ibc-token-transfers from the consumer chain to the provider chain. On + // sending transmission event, `consumer_redistribution_fraction` of the + // accumulated tokens are sent to the consumer redistribution address. + BlocksPerDistributionTransmission int64 `protobuf:"varint,10,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,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,11,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` + // The ID of a token transfer channel used for the Reward Distribution + // sub-protocol. If DistributionTransmissionChannel == "", a new transfer + // channel is created on top of the same connection as the CCV channel. + // Note that transfer_channel_id is the ID of the channel end on the consumer + // chain. it is most relevant for chains performing a sovereign to consumer + // changeover in order to maintan the existing ibc transfer channel + DistributionTransmissionChannel string `protobuf:"bytes,12,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"` + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + Top_N uint32 `protobuf:"varint,13,opt,name=top_N,json=topN,proto3" json:"top_N,omitempty"` + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + ValidatorsPowerCap uint32 `protobuf:"varint,14,opt,name=validators_power_cap,json=validatorsPowerCap,proto3" json:"validators_power_cap,omitempty"` + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + ValidatorSetCap uint32 `protobuf:"varint,15,opt,name=validator_set_cap,json=validatorSetCap,proto3" json:"validator_set_cap,omitempty"` + // Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + // the consumer chain. + Allowlist []string `protobuf:"bytes,16,rep,name=allowlist,proto3" json:"allowlist,omitempty"` + // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. + Denylist []string `protobuf:"bytes,17,rep,name=denylist,proto3" json:"denylist,omitempty"` + // signer address + Authority string `protobuf:"bytes,18,opt,name=authority,proto3" json:"authority,omitempty"` } -func (m *MsgOptOut) Reset() { *m = MsgOptOut{} } -func (m *MsgOptOut) String() string { return proto.CompactTextString(m) } -func (*MsgOptOut) ProtoMessage() {} -func (*MsgOptOut) Descriptor() ([]byte, []int) { +func (m *MsgConsumerAddition) Reset() { *m = MsgConsumerAddition{} } +func (m *MsgConsumerAddition) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerAddition) ProtoMessage() {} +func (*MsgConsumerAddition) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{8} } -func (m *MsgOptOut) XXX_Unmarshal(b []byte) error { +func (m *MsgConsumerAddition) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgOptOut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgConsumerAddition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgOptOut.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgConsumerAddition.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -380,33 +470,160 @@ func (m *MsgOptOut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *MsgOptOut) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgOptOut.Merge(m, src) +func (m *MsgConsumerAddition) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerAddition.Merge(m, src) } -func (m *MsgOptOut) XXX_Size() int { +func (m *MsgConsumerAddition) XXX_Size() int { return m.Size() } -func (m *MsgOptOut) XXX_DiscardUnknown() { - xxx_messageInfo_MsgOptOut.DiscardUnknown(m) +func (m *MsgConsumerAddition) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerAddition.DiscardUnknown(m) } -var xxx_messageInfo_MsgOptOut proto.InternalMessageInfo +var xxx_messageInfo_MsgConsumerAddition proto.InternalMessageInfo -type MsgOptOutResponse struct { +func (m *MsgConsumerAddition) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" } -func (m *MsgOptOutResponse) Reset() { *m = MsgOptOutResponse{} } -func (m *MsgOptOutResponse) String() string { return proto.CompactTextString(m) } -func (*MsgOptOutResponse) ProtoMessage() {} -func (*MsgOptOutResponse) Descriptor() ([]byte, []int) { +func (m *MsgConsumerAddition) GetInitialHeight() types1.Height { + if m != nil { + return m.InitialHeight + } + return types1.Height{} +} + +func (m *MsgConsumerAddition) GetGenesisHash() []byte { + if m != nil { + return m.GenesisHash + } + return nil +} + +func (m *MsgConsumerAddition) GetBinaryHash() []byte { + if m != nil { + return m.BinaryHash + } + return nil +} + +func (m *MsgConsumerAddition) GetSpawnTime() time.Time { + if m != nil { + return m.SpawnTime + } + return time.Time{} +} + +func (m *MsgConsumerAddition) GetUnbondingPeriod() time.Duration { + if m != nil { + return m.UnbondingPeriod + } + return 0 +} + +func (m *MsgConsumerAddition) GetCcvTimeoutPeriod() time.Duration { + if m != nil { + return m.CcvTimeoutPeriod + } + return 0 +} + +func (m *MsgConsumerAddition) GetTransferTimeoutPeriod() time.Duration { + if m != nil { + return m.TransferTimeoutPeriod + } + return 0 +} + +func (m *MsgConsumerAddition) GetConsumerRedistributionFraction() string { + if m != nil { + return m.ConsumerRedistributionFraction + } + return "" +} + +func (m *MsgConsumerAddition) GetBlocksPerDistributionTransmission() int64 { + if m != nil { + return m.BlocksPerDistributionTransmission + } + return 0 +} + +func (m *MsgConsumerAddition) GetHistoricalEntries() int64 { + if m != nil { + return m.HistoricalEntries + } + return 0 +} + +func (m *MsgConsumerAddition) GetDistributionTransmissionChannel() string { + if m != nil { + return m.DistributionTransmissionChannel + } + return "" +} + +func (m *MsgConsumerAddition) GetTop_N() uint32 { + if m != nil { + return m.Top_N + } + return 0 +} + +func (m *MsgConsumerAddition) GetValidatorsPowerCap() uint32 { + if m != nil { + return m.ValidatorsPowerCap + } + return 0 +} + +func (m *MsgConsumerAddition) GetValidatorSetCap() uint32 { + if m != nil { + return m.ValidatorSetCap + } + return 0 +} + +func (m *MsgConsumerAddition) GetAllowlist() []string { + if m != nil { + return m.Allowlist + } + return nil +} + +func (m *MsgConsumerAddition) GetDenylist() []string { + if m != nil { + return m.Denylist + } + return nil +} + +func (m *MsgConsumerAddition) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +// MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages +type MsgConsumerAdditionResponse struct { +} + +func (m *MsgConsumerAdditionResponse) Reset() { *m = MsgConsumerAdditionResponse{} } +func (m *MsgConsumerAdditionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerAdditionResponse) ProtoMessage() {} +func (*MsgConsumerAdditionResponse) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{9} } -func (m *MsgOptOutResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgConsumerAdditionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgOptOutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgConsumerAdditionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgOptOutResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgConsumerAdditionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -416,41 +633,46 @@ func (m *MsgOptOutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *MsgOptOutResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgOptOutResponse.Merge(m, src) +func (m *MsgConsumerAdditionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerAdditionResponse.Merge(m, src) } -func (m *MsgOptOutResponse) XXX_Size() int { +func (m *MsgConsumerAdditionResponse) XXX_Size() int { return m.Size() } -func (m *MsgOptOutResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgOptOutResponse.DiscardUnknown(m) +func (m *MsgConsumerAdditionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerAdditionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgOptOutResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgConsumerAdditionResponse proto.InternalMessageInfo -// MsgSetConsumerCommissionRate allows validators to set -// a per-consumer chain commission rate -type MsgSetConsumerCommissionRate struct { - // The validator address on the provider - ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` - // The chain id of the consumer chain to set a commission rate - ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // The rate to charge delegators on the consumer chain, as a fraction - Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` +// MsgConsumerRemoval message contains a governance proposal on the provider chain to +// remove (and stop) a consumer chain. If it passes, all the consumer chain's +// state is removed from the provider chain. The outstanding unbonding operation +// funds are released. +// +// Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon +type MsgConsumerRemoval struct { + // the chain-id of the consumer chain to be stopped + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // the time on the provider chain at which all validators are responsible to + // stop their consumer chain validator node + StopTime time.Time `protobuf:"bytes,2,opt,name=stop_time,json=stopTime,proto3,stdtime" json:"stop_time"` + // signer address + Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` } -func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerCommissionRate{} } -func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } -func (*MsgSetConsumerCommissionRate) ProtoMessage() {} -func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { +func (m *MsgConsumerRemoval) Reset() { *m = MsgConsumerRemoval{} } +func (m *MsgConsumerRemoval) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerRemoval) ProtoMessage() {} +func (*MsgConsumerRemoval) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{10} } -func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { +func (m *MsgConsumerRemoval) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetConsumerCommissionRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgConsumerRemoval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetConsumerCommissionRate.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgConsumerRemoval.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -460,33 +682,55 @@ func (m *MsgSetConsumerCommissionRate) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgSetConsumerCommissionRate) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetConsumerCommissionRate.Merge(m, src) +func (m *MsgConsumerRemoval) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerRemoval.Merge(m, src) } -func (m *MsgSetConsumerCommissionRate) XXX_Size() int { +func (m *MsgConsumerRemoval) XXX_Size() int { return m.Size() } -func (m *MsgSetConsumerCommissionRate) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetConsumerCommissionRate.DiscardUnknown(m) +func (m *MsgConsumerRemoval) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerRemoval.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetConsumerCommissionRate proto.InternalMessageInfo +var xxx_messageInfo_MsgConsumerRemoval proto.InternalMessageInfo -type MsgSetConsumerCommissionRateResponse struct { +func (m *MsgConsumerRemoval) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" } -func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetConsumerCommissionRateResponse{} } -func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} -func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { +func (m *MsgConsumerRemoval) GetStopTime() time.Time { + if m != nil { + return m.StopTime + } + return time.Time{} +} + +func (m *MsgConsumerRemoval) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +// MsgConsumerRemovalResponse defines response type for MsgConsumerRemoval messages +type MsgConsumerRemovalResponse struct { +} + +func (m *MsgConsumerRemovalResponse) Reset() { *m = MsgConsumerRemovalResponse{} } +func (m *MsgConsumerRemovalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerRemovalResponse) ProtoMessage() {} +func (*MsgConsumerRemovalResponse) Descriptor() ([]byte, []int) { return fileDescriptor_43221a4391e9fbf4, []int{11} } -func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgConsumerRemovalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetConsumerCommissionRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgConsumerRemovalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgConsumerRemovalResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -496,945 +740,3991 @@ func (m *MsgSetConsumerCommissionRateResponse) XXX_Marshal(b []byte, determinist return b[:n], nil } } -func (m *MsgSetConsumerCommissionRateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Merge(m, src) +func (m *MsgConsumerRemovalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerRemovalResponse.Merge(m, src) } -func (m *MsgSetConsumerCommissionRateResponse) XXX_Size() int { +func (m *MsgConsumerRemovalResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetConsumerCommissionRateResponse.DiscardUnknown(m) +func (m *MsgConsumerRemovalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerRemovalResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgConsumerRemovalResponse 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((*MsgSubmitConsumerMisbehaviour)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviour") - proto.RegisterType((*MsgSubmitConsumerMisbehaviourResponse)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviourResponse") - proto.RegisterType((*MsgSubmitConsumerDoubleVoting)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVoting") - proto.RegisterType((*MsgSubmitConsumerDoubleVotingResponse)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVotingResponse") - proto.RegisterType((*MsgOptIn)(nil), "interchain_security.ccv.provider.v1.MsgOptIn") - proto.RegisterType((*MsgOptInResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptInResponse") - proto.RegisterType((*MsgOptOut)(nil), "interchain_security.ccv.provider.v1.MsgOptOut") - proto.RegisterType((*MsgOptOutResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptOutResponse") - proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRate") - proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRateResponse") +// ChangeRewardDenomsProposal is a governance proposal on the provider chain to +// mutate the set of denoms accepted by the provider as rewards. +// +// Note: this replaces ChangeRewardDenomsProposal which is deprecated and will be removed soon +type MsgChangeRewardDenoms struct { + // the list of consumer reward denoms to add + DenomsToAdd []string `protobuf:"bytes,1,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,2,rep,name=denoms_to_remove,json=denomsToRemove,proto3" json:"denoms_to_remove,omitempty"` + // signer address + Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` } -func init() { - proto.RegisterFile("interchain_security/ccv/provider/v1/tx.proto", fileDescriptor_43221a4391e9fbf4) +func (m *MsgChangeRewardDenoms) Reset() { *m = MsgChangeRewardDenoms{} } +func (m *MsgChangeRewardDenoms) String() string { return proto.CompactTextString(m) } +func (*MsgChangeRewardDenoms) ProtoMessage() {} +func (*MsgChangeRewardDenoms) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{12} } - -var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 787 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x4f, 0xd4, 0x4e, - 0x18, 0xde, 0xc2, 0xef, 0xc7, 0xc7, 0x80, 0x46, 0x2a, 0x04, 0x68, 0x70, 0x57, 0x57, 0x05, 0x0f, - 0x6c, 0x1b, 0xf0, 0x2b, 0x12, 0x3d, 0xb0, 0x60, 0x22, 0x9a, 0x0d, 0xa4, 0x24, 0x98, 0x78, 0xb0, - 0x69, 0xa7, 0x43, 0x77, 0xc2, 0x76, 0xa6, 0xe9, 0x4c, 0x1b, 0xf6, 0xee, 0x81, 0xc4, 0x8b, 0x9e, - 0x8c, 0x37, 0xae, 0x26, 0x1e, 0xfd, 0x23, 0x38, 0x19, 0xe2, 0xc9, 0x78, 0x20, 0x06, 0x2e, 0x9e, - 0xfd, 0x0b, 0xcc, 0x4e, 0x3f, 0xb6, 0x1b, 0x96, 0x65, 0x81, 0x18, 0x4f, 0xbb, 0x33, 0xef, 0x33, - 0xcf, 0xfb, 0x3c, 0x6f, 0xa7, 0x4f, 0x0a, 0x66, 0x31, 0xe1, 0xc8, 0x87, 0x55, 0x13, 0x13, 0x83, - 0x21, 0x18, 0xf8, 0x98, 0xd7, 0x35, 0x08, 0x43, 0xcd, 0xf3, 0x69, 0x88, 0x6d, 0xe4, 0x6b, 0xe1, - 0x9c, 0xc6, 0xb7, 0x55, 0xcf, 0xa7, 0x9c, 0xca, 0x37, 0xdb, 0xa0, 0x55, 0x08, 0x43, 0x35, 0x41, - 0xab, 0xe1, 0x9c, 0x32, 0xea, 0x50, 0x87, 0x0a, 0xbc, 0xd6, 0xf8, 0x17, 0x1d, 0x55, 0x26, 0x21, - 0x65, 0x2e, 0x65, 0x46, 0x54, 0x88, 0x16, 0x49, 0xc9, 0xa1, 0xd4, 0xa9, 0x21, 0x4d, 0xac, 0xac, - 0x60, 0x53, 0x33, 0x49, 0x3d, 0x2e, 0x69, 0xd8, 0x82, 0x5a, 0x0d, 0x3b, 0x55, 0x0e, 0x6b, 0x18, - 0x11, 0xce, 0x34, 0x8e, 0x88, 0x8d, 0x7c, 0x17, 0x13, 0x2e, 0x94, 0xa5, 0xab, 0xf8, 0x40, 0x21, - 0x53, 0xe7, 0x75, 0x0f, 0x31, 0x0d, 0x35, 0x84, 0x11, 0x88, 0x22, 0x40, 0xf1, 0x83, 0x04, 0x46, - 0x2b, 0xcc, 0x59, 0x64, 0x0c, 0x3b, 0x64, 0x89, 0x12, 0x16, 0xb8, 0xc8, 0x7f, 0x81, 0xea, 0xf2, - 0x24, 0x18, 0x88, 0x8c, 0x61, 0x7b, 0x42, 0xba, 0x2e, 0xdd, 0x19, 0xd4, 0xfb, 0xc5, 0x7a, 0xc5, - 0x96, 0x1f, 0x82, 0x4b, 0x89, 0x41, 0xc3, 0xb4, 0x6d, 0x7f, 0xa2, 0xa7, 0x51, 0x2f, 0xcb, 0xbf, - 0x0f, 0x0a, 0x97, 0xeb, 0xa6, 0x5b, 0x5b, 0x28, 0x36, 0x76, 0x11, 0x63, 0x45, 0x7d, 0x38, 0x01, - 0x2e, 0xda, 0xb6, 0x2f, 0xdf, 0x00, 0xc3, 0x30, 0x6e, 0x61, 0x6c, 0xa1, 0xfa, 0x44, 0xaf, 0xe0, - 0x1d, 0x82, 0xcd, 0xb6, 0x0b, 0x03, 0x3b, 0xbb, 0x85, 0xdc, 0xaf, 0xdd, 0x42, 0xae, 0x98, 0x07, - 0x53, 0xed, 0x84, 0xe9, 0x88, 0x79, 0x94, 0x30, 0x54, 0xfc, 0x28, 0x81, 0x6b, 0x15, 0xe6, 0xac, - 0x07, 0x96, 0x8b, 0x79, 0x02, 0xa8, 0x60, 0x66, 0xa1, 0xaa, 0x19, 0x62, 0x1a, 0xf8, 0xf2, 0x14, - 0x18, 0x64, 0xa2, 0xca, 0x91, 0x1f, 0x7b, 0x68, 0x6e, 0xc8, 0x6b, 0x60, 0xd8, 0xcd, 0xa0, 0x85, - 0x89, 0xa1, 0xf9, 0x59, 0x15, 0x5b, 0x50, 0xcd, 0x8e, 0x58, 0xcd, 0x0c, 0x35, 0x9c, 0x53, 0xb3, - 0x1d, 0xf4, 0x16, 0x86, 0x8c, 0xf6, 0x19, 0x70, 0xbb, 0xa3, 0xb4, 0xd4, 0xc4, 0x4e, 0x4f, 0x1b, - 0x13, 0xcb, 0x34, 0xb0, 0x6a, 0x68, 0x83, 0x72, 0x4c, 0x9c, 0x53, 0x4c, 0x18, 0x60, 0xdc, 0x0e, - 0xbc, 0x1a, 0x86, 0x26, 0x47, 0x46, 0x48, 0x39, 0x32, 0x92, 0xe7, 0x1b, 0xfb, 0x99, 0xc9, 0xca, - 0x17, 0x37, 0x40, 0x5d, 0x4e, 0x0e, 0x6c, 0x50, 0x8e, 0x9e, 0xc6, 0x70, 0x7d, 0xcc, 0x6e, 0xb7, - 0x2d, 0xbf, 0x06, 0xe3, 0x98, 0x6c, 0xfa, 0x26, 0xe4, 0x98, 0x12, 0xc3, 0xaa, 0x51, 0xb8, 0x65, - 0x54, 0x91, 0x69, 0x23, 0x5f, 0x3c, 0xbd, 0xa1, 0xf9, 0xe9, 0xd3, 0x06, 0xf6, 0x4c, 0xa0, 0xf5, - 0xb1, 0x26, 0x4d, 0xb9, 0xc1, 0x12, 0x6d, 0x9f, 0x32, 0xb3, 0xec, 0x24, 0xd2, 0x99, 0xbd, 0x95, - 0xc0, 0x40, 0x85, 0x39, 0xab, 0x1e, 0x5f, 0x21, 0xff, 0xfe, 0x9a, 0xca, 0xe0, 0x4a, 0x22, 0x26, - 0x55, 0x88, 0xc1, 0x60, 0xb4, 0xb7, 0x1a, 0xf0, 0xbf, 0xa1, 0x30, 0xd3, 0xfe, 0x2a, 0x18, 0x49, - 0x5b, 0xa5, 0xfd, 0xbf, 0x4a, 0xe2, 0xdd, 0x59, 0x47, 0xe9, 0x20, 0x97, 0xa8, 0xeb, 0x62, 0xc6, - 0x30, 0x25, 0xba, 0xc9, 0xd1, 0xf1, 0xc6, 0x52, 0x97, 0xa3, 0xc9, 0x9a, 0xe9, 0x69, 0x35, 0xb3, - 0x06, 0xfe, 0xf3, 0x4d, 0x8e, 0xa2, 0x69, 0x95, 0x1f, 0xef, 0x1d, 0x14, 0x72, 0x3f, 0x0e, 0x0a, - 0xd3, 0x0e, 0xe6, 0xd5, 0xc0, 0x52, 0x21, 0x75, 0xe3, 0x94, 0x8b, 0x7f, 0x4a, 0xcc, 0xde, 0xd2, - 0xe2, 0x0b, 0x89, 0xe0, 0xb7, 0x2f, 0x25, 0x10, 0x87, 0xe0, 0x32, 0x82, 0xba, 0x60, 0xca, 0xb8, - 0x9c, 0x06, 0xb7, 0x3a, 0xf9, 0x49, 0x8c, 0xcf, 0xbf, 0xe9, 0x07, 0xbd, 0x15, 0xe6, 0xc8, 0xef, - 0x25, 0x30, 0x72, 0x3c, 0xd2, 0x1e, 0xa9, 0x5d, 0xe4, 0xb5, 0xda, 0x2e, 0x74, 0x94, 0xc5, 0x73, - 0x1f, 0x4d, 0xb4, 0xc9, 0x9f, 0x25, 0xa0, 0x74, 0x08, 0xab, 0x72, 0xb7, 0x1d, 0x4e, 0xe6, 0x50, - 0x9e, 0x5f, 0x9c, 0xa3, 0x83, 0xdc, 0x96, 0x58, 0x3a, 0xa7, 0xdc, 0x2c, 0xc7, 0x79, 0xe5, 0xb6, - 0x0b, 0x05, 0xd9, 0x05, 0xff, 0x47, 0x81, 0x50, 0xea, 0x96, 0x54, 0xc0, 0x95, 0xfb, 0x67, 0x82, - 0xa7, 0xed, 0x3c, 0xd0, 0x17, 0xbf, 0xde, 0xea, 0x19, 0x08, 0x56, 0x03, 0xae, 0x3c, 0x38, 0x1b, - 0x3e, 0xed, 0xf8, 0x49, 0x02, 0x93, 0x27, 0xbf, 0xd0, 0x5d, 0xdf, 0xcf, 0x13, 0x29, 0x94, 0x95, - 0x0b, 0x53, 0x24, 0x5a, 0xcb, 0x2f, 0xf7, 0x0e, 0xf3, 0xd2, 0xfe, 0x61, 0x5e, 0xfa, 0x79, 0x98, - 0x97, 0xde, 0x1d, 0xe5, 0x73, 0xfb, 0x47, 0xf9, 0xdc, 0xf7, 0xa3, 0x7c, 0xee, 0xd5, 0x93, 0xe3, - 0x71, 0xd0, 0xec, 0x5a, 0x4a, 0xbf, 0xb8, 0xc2, 0x7b, 0xda, 0x76, 0xeb, 0x67, 0x97, 0x48, 0x0a, - 0xab, 0x4f, 0x7c, 0xb4, 0xdc, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x76, 0xb7, 0xbf, 0x16, 0xa7, - 0x09, 0x00, 0x00, +func (m *MsgChangeRewardDenoms) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// 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) - SubmitConsumerMisbehaviour(ctx context.Context, in *MsgSubmitConsumerMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitConsumerMisbehaviourResponse, error) - SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) - OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) - OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) - SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) +func (m *MsgChangeRewardDenoms) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChangeRewardDenoms.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } } - -type msgClient struct { - cc grpc1.ClientConn +func (m *MsgChangeRewardDenoms) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChangeRewardDenoms.Merge(m, src) } - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} +func (m *MsgChangeRewardDenoms) XXX_Size() int { + return m.Size() +} +func (m *MsgChangeRewardDenoms) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChangeRewardDenoms.DiscardUnknown(m) } -func (c *msgClient) AssignConsumerKey(ctx context.Context, in *MsgAssignConsumerKey, opts ...grpc.CallOption) (*MsgAssignConsumerKeyResponse, error) { - out := new(MsgAssignConsumerKeyResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/AssignConsumerKey", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_MsgChangeRewardDenoms proto.InternalMessageInfo + +func (m *MsgChangeRewardDenoms) GetDenomsToAdd() []string { + if m != nil { + return m.DenomsToAdd } - return out, nil + return nil } -func (c *msgClient) SubmitConsumerMisbehaviour(ctx context.Context, in *MsgSubmitConsumerMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitConsumerMisbehaviourResponse, error) { - out := new(MsgSubmitConsumerMisbehaviourResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerMisbehaviour", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChangeRewardDenoms) GetDenomsToRemove() []string { + if m != nil { + return m.DenomsToRemove } - return out, nil + return nil } -func (c *msgClient) SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) { - out := new(MsgSubmitConsumerDoubleVotingResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerDoubleVoting", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChangeRewardDenoms) GetAuthority() string { + if m != nil { + return m.Authority } - return out, nil + return "" } -func (c *msgClient) OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) { - out := new(MsgOptInResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/OptIn", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// MsgChangeRewardDenomsResponse defines response type for MsgChangeRewardDenoms messages +type MsgChangeRewardDenomsResponse struct { } -func (c *msgClient) OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) { - out := new(MsgOptOutResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/OptOut", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *MsgChangeRewardDenomsResponse) Reset() { *m = MsgChangeRewardDenomsResponse{} } +func (m *MsgChangeRewardDenomsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgChangeRewardDenomsResponse) ProtoMessage() {} +func (*MsgChangeRewardDenomsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{13} } - -func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { - out := new(MsgSetConsumerCommissionRateResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", in, out, opts...) - if err != nil { - return nil, err +func (m *MsgChangeRewardDenomsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgChangeRewardDenomsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgChangeRewardDenomsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil } - -// MsgServer is the server API for Msg service. -type MsgServer interface { - AssignConsumerKey(context.Context, *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) - SubmitConsumerMisbehaviour(context.Context, *MsgSubmitConsumerMisbehaviour) (*MsgSubmitConsumerMisbehaviourResponse, error) - SubmitConsumerDoubleVoting(context.Context, *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) - OptIn(context.Context, *MsgOptIn) (*MsgOptInResponse, error) - OptOut(context.Context, *MsgOptOut) (*MsgOptOutResponse, error) - SetConsumerCommissionRate(context.Context, *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) +func (m *MsgChangeRewardDenomsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgChangeRewardDenomsResponse.Merge(m, src) +} +func (m *MsgChangeRewardDenomsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgChangeRewardDenomsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgChangeRewardDenomsResponse.DiscardUnknown(m) } -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { +var xxx_messageInfo_MsgChangeRewardDenomsResponse proto.InternalMessageInfo + +type MsgOptIn struct { + // the chain id of the consumer chain to opt in to + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // the validator address on the provider + ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + // (optional) The consensus public key to use on the consumer in json string format corresponding to proto-any, + // for example `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`. + // This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the + // consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. + ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` + // signer address + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` } -func (*UnimplementedMsgServer) AssignConsumerKey(ctx context.Context, req *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AssignConsumerKey not implemented") +func (m *MsgOptIn) Reset() { *m = MsgOptIn{} } +func (m *MsgOptIn) String() string { return proto.CompactTextString(m) } +func (*MsgOptIn) ProtoMessage() {} +func (*MsgOptIn) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{14} } -func (*UnimplementedMsgServer) SubmitConsumerMisbehaviour(ctx context.Context, req *MsgSubmitConsumerMisbehaviour) (*MsgSubmitConsumerMisbehaviourResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitConsumerMisbehaviour not implemented") +func (m *MsgOptIn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedMsgServer) SubmitConsumerDoubleVoting(ctx context.Context, req *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitConsumerDoubleVoting not implemented") +func (m *MsgOptIn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOptIn.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 (*UnimplementedMsgServer) OptIn(ctx context.Context, req *MsgOptIn) (*MsgOptInResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OptIn not implemented") +func (m *MsgOptIn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOptIn.Merge(m, src) } -func (*UnimplementedMsgServer) OptOut(ctx context.Context, req *MsgOptOut) (*MsgOptOutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method OptOut not implemented") +func (m *MsgOptIn) XXX_Size() int { + return m.Size() } -func (*UnimplementedMsgServer) SetConsumerCommissionRate(ctx context.Context, req *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetConsumerCommissionRate not implemented") +func (m *MsgOptIn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOptIn.DiscardUnknown(m) } -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} +var xxx_messageInfo_MsgOptIn proto.InternalMessageInfo -func _Msg_AssignConsumerKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAssignConsumerKey) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).AssignConsumerKey(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/AssignConsumerKey", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AssignConsumerKey(ctx, req.(*MsgAssignConsumerKey)) - } - return interceptor(ctx, in, info, handler) +type MsgOptInResponse struct { } -func _Msg_SubmitConsumerMisbehaviour_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubmitConsumerMisbehaviour) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SubmitConsumerMisbehaviour(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerMisbehaviour", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitConsumerMisbehaviour(ctx, req.(*MsgSubmitConsumerMisbehaviour)) - } - return interceptor(ctx, in, info, handler) +func (m *MsgOptInResponse) Reset() { *m = MsgOptInResponse{} } +func (m *MsgOptInResponse) String() string { return proto.CompactTextString(m) } +func (*MsgOptInResponse) ProtoMessage() {} +func (*MsgOptInResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{15} } - -func _Msg_SubmitConsumerDoubleVoting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubmitConsumerDoubleVoting) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SubmitConsumerDoubleVoting(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerDoubleVoting", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitConsumerDoubleVoting(ctx, req.(*MsgSubmitConsumerDoubleVoting)) +func (m *MsgOptInResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgOptInResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOptInResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *MsgOptInResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOptInResponse.Merge(m, src) +} +func (m *MsgOptInResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgOptInResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOptInResponse.DiscardUnknown(m) } -func _Msg_OptIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgOptIn) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).OptIn(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/OptIn", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).OptIn(ctx, req.(*MsgOptIn)) - } - return interceptor(ctx, in, info, handler) +var xxx_messageInfo_MsgOptInResponse proto.InternalMessageInfo + +type MsgOptOut struct { + // the chain id of the consumer chain to opt out from + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // the validator address on the provider + ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } -func _Msg_OptOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgOptOut) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).OptOut(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/OptOut", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).OptOut(ctx, req.(*MsgOptOut)) +func (m *MsgOptOut) Reset() { *m = MsgOptOut{} } +func (m *MsgOptOut) String() string { return proto.CompactTextString(m) } +func (*MsgOptOut) ProtoMessage() {} +func (*MsgOptOut) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{16} +} +func (m *MsgOptOut) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgOptOut) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOptOut.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *MsgOptOut) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOptOut.Merge(m, src) +} +func (m *MsgOptOut) XXX_Size() int { + return m.Size() +} +func (m *MsgOptOut) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOptOut.DiscardUnknown(m) } -func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetConsumerCommissionRate) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetConsumerCommissionRate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetConsumerCommissionRate(ctx, req.(*MsgSetConsumerCommissionRate)) - } - return interceptor(ctx, in, info, handler) +var xxx_messageInfo_MsgOptOut proto.InternalMessageInfo + +type MsgOptOutResponse struct { } -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "interchain_security.ccv.provider.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "AssignConsumerKey", - Handler: _Msg_AssignConsumerKey_Handler, - }, - { - MethodName: "SubmitConsumerMisbehaviour", - Handler: _Msg_SubmitConsumerMisbehaviour_Handler, - }, - { - MethodName: "SubmitConsumerDoubleVoting", - Handler: _Msg_SubmitConsumerDoubleVoting_Handler, - }, - { - MethodName: "OptIn", - Handler: _Msg_OptIn_Handler, - }, - { - MethodName: "OptOut", - Handler: _Msg_OptOut_Handler, - }, - { - MethodName: "SetConsumerCommissionRate", - Handler: _Msg_SetConsumerCommissionRate_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "interchain_security/ccv/provider/v1/tx.proto", +func (m *MsgOptOutResponse) Reset() { *m = MsgOptOutResponse{} } +func (m *MsgOptOutResponse) String() string { return proto.CompactTextString(m) } +func (*MsgOptOutResponse) ProtoMessage() {} +func (*MsgOptOutResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{17} } - -func (m *MsgAssignConsumerKey) 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 (m *MsgOptOutResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgOptOutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgOptOutResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *MsgAssignConsumerKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgOptOutResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgOptOutResponse.Merge(m, src) +} +func (m *MsgOptOutResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgOptOutResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgOptOutResponse.DiscardUnknown(m) } -func (m *MsgAssignConsumerKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ConsumerKey) > 0 { - i -= len(m.ConsumerKey) - copy(dAtA[i:], m.ConsumerKey) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerKey))) - i-- - dAtA[i] = 0x1a - } - if len(m.ProviderAddr) > 0 { - i -= len(m.ProviderAddr) - copy(dAtA[i:], m.ProviderAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +var xxx_messageInfo_MsgOptOutResponse proto.InternalMessageInfo + +// MsgSetConsumerCommissionRate allows validators to set +// a per-consumer chain commission rate +type MsgSetConsumerCommissionRate struct { + // The validator address on the provider + ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + // The chain id of the consumer chain to set a commission rate + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // The rate to charge delegators on the consumer chain, as a fraction + // TODO: migrate rate from sdk.Dec to math.LegacyDec + Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` } -func (m *MsgAssignConsumerKeyResponse) 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 (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerCommissionRate{} } +func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRate) ProtoMessage() {} +func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{18} +} +func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil } - -func (m *MsgAssignConsumerKeyResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgSetConsumerCommissionRate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRate.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRate) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRate.DiscardUnknown(m) } -func (m *MsgAssignConsumerKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +var xxx_messageInfo_MsgSetConsumerCommissionRate proto.InternalMessageInfo + +type MsgSetConsumerCommissionRateResponse struct { } -func (m *MsgSubmitConsumerMisbehaviour) 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 (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetConsumerCommissionRateResponse{} } +func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} +func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{19} +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.DiscardUnknown(m) } -func (m *MsgSubmitConsumerMisbehaviour) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo + +// MsgConsumerModification message contains a governance proposal on the provider chain to +// modify a running consumer chain. If it passes, the consumer chain's +// parameters are updated. +// +// Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon +type MsgConsumerModification 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 chain-id of the consumer chain to be modified + ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + Top_N uint32 `protobuf:"varint,4,opt,name=top_N,json=topN,proto3" json:"top_N,omitempty"` + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + ValidatorsPowerCap uint32 `protobuf:"varint,5,opt,name=validators_power_cap,json=validatorsPowerCap,proto3" json:"validators_power_cap,omitempty"` + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + ValidatorSetCap uint32 `protobuf:"varint,6,opt,name=validator_set_cap,json=validatorSetCap,proto3" json:"validator_set_cap,omitempty"` + // Corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate + // the consumer chain. + Allowlist []string `protobuf:"bytes,7,rep,name=allowlist,proto3" json:"allowlist,omitempty"` + // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. + Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` + // signer address + Authority string `protobuf:"bytes,9,opt,name=authority,proto3" json:"authority,omitempty"` } -func (m *MsgSubmitConsumerMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Misbehaviour != nil { - { - size, err := m.Misbehaviour.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) +func (m *MsgConsumerModification) Reset() { *m = MsgConsumerModification{} } +func (m *MsgConsumerModification) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerModification) ProtoMessage() {} +func (*MsgConsumerModification) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{20} +} +func (m *MsgConsumerModification) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConsumerModification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConsumerModification.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0x12 + return b[:n], nil } - if len(m.Submitter) > 0 { - i -= len(m.Submitter) - copy(dAtA[i:], m.Submitter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) - i-- - dAtA[i] = 0xa +} +func (m *MsgConsumerModification) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerModification.Merge(m, src) +} +func (m *MsgConsumerModification) XXX_Size() int { + return m.Size() +} +func (m *MsgConsumerModification) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerModification.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgConsumerModification proto.InternalMessageInfo + +func (m *MsgConsumerModification) GetTitle() string { + if m != nil { + return m.Title } - return len(dAtA) - i, nil + return "" } -func (m *MsgSubmitConsumerMisbehaviourResponse) 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 (m *MsgConsumerModification) GetDescription() string { + if m != nil { + return m.Description } - return dAtA[:n], nil + return "" } -func (m *MsgSubmitConsumerMisbehaviourResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgConsumerModification) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" } -func (m *MsgSubmitConsumerMisbehaviourResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (m *MsgConsumerModification) GetTop_N() uint32 { + if m != nil { + return m.Top_N + } + return 0 } -func (m *MsgSubmitConsumerDoubleVoting) 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 (m *MsgConsumerModification) GetValidatorsPowerCap() uint32 { + if m != nil { + return m.ValidatorsPowerCap } - return dAtA[:n], nil + return 0 } -func (m *MsgSubmitConsumerDoubleVoting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgConsumerModification) GetValidatorSetCap() uint32 { + if m != nil { + return m.ValidatorSetCap + } + return 0 } -func (m *MsgSubmitConsumerDoubleVoting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.InfractionBlockHeader != nil { - { - size, err := m.InfractionBlockHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.DuplicateVoteEvidence != nil { - { - size, err := m.DuplicateVoteEvidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Submitter) > 0 { - i -= len(m.Submitter) - copy(dAtA[i:], m.Submitter) - i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) - i-- - dAtA[i] = 0xa +func (m *MsgConsumerModification) GetAllowlist() []string { + if m != nil { + return m.Allowlist } - return len(dAtA) - i, nil + return nil } -func (m *MsgSubmitConsumerDoubleVotingResponse) 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 (m *MsgConsumerModification) GetDenylist() []string { + if m != nil { + return m.Denylist } - return dAtA[:n], nil + return nil } -func (m *MsgSubmitConsumerDoubleVotingResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *MsgConsumerModification) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" } -func (m *MsgSubmitConsumerDoubleVotingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +type MsgConsumerModificationResponse struct { } -func (m *MsgOptIn) 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 (m *MsgConsumerModificationResponse) Reset() { *m = MsgConsumerModificationResponse{} } +func (m *MsgConsumerModificationResponse) String() string { return proto.CompactTextString(m) } +func (*MsgConsumerModificationResponse) ProtoMessage() {} +func (*MsgConsumerModificationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{21} +} +func (m *MsgConsumerModificationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgConsumerModificationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgConsumerModificationResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return dAtA[:n], nil +} +func (m *MsgConsumerModificationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgConsumerModificationResponse.Merge(m, src) +} +func (m *MsgConsumerModificationResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgConsumerModificationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgConsumerModificationResponse.DiscardUnknown(m) } -func (m *MsgOptIn) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +var xxx_messageInfo_MsgConsumerModificationResponse 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((*MsgSubmitConsumerMisbehaviour)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviour") + proto.RegisterType((*MsgSubmitConsumerMisbehaviourResponse)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerMisbehaviourResponse") + proto.RegisterType((*MsgSubmitConsumerDoubleVoting)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVoting") + proto.RegisterType((*MsgSubmitConsumerDoubleVotingResponse)(nil), "interchain_security.ccv.provider.v1.MsgSubmitConsumerDoubleVotingResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "interchain_security.ccv.provider.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "interchain_security.ccv.provider.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgConsumerAddition)(nil), "interchain_security.ccv.provider.v1.MsgConsumerAddition") + proto.RegisterType((*MsgConsumerAdditionResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerAdditionResponse") + proto.RegisterType((*MsgConsumerRemoval)(nil), "interchain_security.ccv.provider.v1.MsgConsumerRemoval") + proto.RegisterType((*MsgConsumerRemovalResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerRemovalResponse") + proto.RegisterType((*MsgChangeRewardDenoms)(nil), "interchain_security.ccv.provider.v1.MsgChangeRewardDenoms") + proto.RegisterType((*MsgChangeRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.MsgChangeRewardDenomsResponse") + proto.RegisterType((*MsgOptIn)(nil), "interchain_security.ccv.provider.v1.MsgOptIn") + proto.RegisterType((*MsgOptInResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptInResponse") + proto.RegisterType((*MsgOptOut)(nil), "interchain_security.ccv.provider.v1.MsgOptOut") + proto.RegisterType((*MsgOptOutResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptOutResponse") + proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRate") + proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRateResponse") + proto.RegisterType((*MsgConsumerModification)(nil), "interchain_security.ccv.provider.v1.MsgConsumerModification") + proto.RegisterType((*MsgConsumerModificationResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerModificationResponse") } -func (m *MsgOptIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ConsumerKey) > 0 { - i -= len(m.ConsumerKey) - copy(dAtA[i:], m.ConsumerKey) - i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerKey))) - i-- - dAtA[i] = 0x1a - } - if len(m.ProviderAddr) > 0 { - i -= len(m.ProviderAddr) - copy(dAtA[i:], m.ProviderAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +func init() { + proto.RegisterFile("interchain_security/ccv/provider/v1/tx.proto", fileDescriptor_43221a4391e9fbf4) } -func (m *MsgOptInResponse) 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 +var fileDescriptor_43221a4391e9fbf4 = []byte{ + // 1687 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcf, 0x6f, 0xe4, 0x48, + 0x15, 0x8e, 0xf3, 0x6b, 0xba, 0xab, 0xf3, 0xd3, 0x93, 0x21, 0x1d, 0x6f, 0xb6, 0x3b, 0x69, 0x96, + 0xdd, 0x68, 0xd8, 0xd8, 0x9b, 0xc0, 0xee, 0x42, 0xb4, 0x08, 0x92, 0xf4, 0xc0, 0x64, 0x21, 0x93, + 0xe0, 0x09, 0x8b, 0x04, 0x12, 0x56, 0xb5, 0x5d, 0x71, 0x97, 0xc6, 0x76, 0x59, 0x55, 0xd5, 0x9d, + 0xed, 0x1b, 0xda, 0x13, 0x12, 0x02, 0x2d, 0x37, 0xc4, 0x69, 0x0f, 0x08, 0x09, 0x09, 0xa4, 0x39, + 0xec, 0x89, 0x1b, 0xe2, 0x32, 0x07, 0x0e, 0xcb, 0x8a, 0x03, 0xe2, 0x30, 0xa0, 0x99, 0xc3, 0x72, + 0xe6, 0x2f, 0x40, 0x55, 0x2e, 0xbb, 0xdd, 0x49, 0xa7, 0xa7, 0xbb, 0x03, 0x07, 0x2e, 0xad, 0x76, + 0xbd, 0xef, 0x7d, 0xf5, 0x7d, 0xcf, 0xae, 0x57, 0x65, 0x83, 0xd7, 0x71, 0xc4, 0x11, 0x75, 0x9b, + 0x10, 0x47, 0x0e, 0x43, 0x6e, 0x8b, 0x62, 0xde, 0xb1, 0x5c, 0xb7, 0x6d, 0xc5, 0x94, 0xb4, 0xb1, + 0x87, 0xa8, 0xd5, 0xde, 0xb1, 0xf8, 0xfb, 0x66, 0x4c, 0x09, 0x27, 0xfa, 0xe7, 0xfb, 0xa0, 0x4d, + 0xd7, 0x6d, 0x9b, 0x29, 0xda, 0x6c, 0xef, 0x18, 0xcb, 0x30, 0xc4, 0x11, 0xb1, 0xe4, 0x6f, 0x92, + 0x67, 0xac, 0xfb, 0x84, 0xf8, 0x01, 0xb2, 0x60, 0x8c, 0x2d, 0x18, 0x45, 0x84, 0x43, 0x8e, 0x49, + 0xc4, 0x54, 0xb4, 0xaa, 0xa2, 0xf2, 0xaa, 0xd1, 0x3a, 0xb7, 0x38, 0x0e, 0x11, 0xe3, 0x30, 0x8c, + 0x15, 0xa0, 0x72, 0x19, 0xe0, 0xb5, 0xa8, 0x64, 0x50, 0xf1, 0xb5, 0xcb, 0x71, 0x18, 0x75, 0x54, + 0x68, 0xc5, 0x27, 0x3e, 0x91, 0x7f, 0x2d, 0xf1, 0x2f, 0x4d, 0x70, 0x09, 0x0b, 0x09, 0x73, 0x92, + 0x40, 0x72, 0xa1, 0x42, 0xab, 0xc9, 0x95, 0x15, 0x32, 0x5f, 0x58, 0x0f, 0x99, 0x9f, 0xaa, 0xc4, + 0x0d, 0xd7, 0x72, 0x09, 0x45, 0x96, 0x1b, 0x60, 0x14, 0x71, 0x11, 0x4d, 0xfe, 0x29, 0xc0, 0xee, + 0x30, 0xa5, 0xcc, 0x0a, 0x95, 0xe4, 0x58, 0x82, 0x34, 0xc0, 0x7e, 0x93, 0x27, 0x54, 0xcc, 0xe2, + 0x28, 0xf2, 0x10, 0x0d, 0x71, 0x32, 0x41, 0xf7, 0x2a, 0x55, 0x91, 0x8b, 0xf3, 0x4e, 0x8c, 0x98, + 0x85, 0x04, 0x5f, 0xe4, 0xa2, 0x04, 0x50, 0xfb, 0xab, 0x06, 0x56, 0x8e, 0x99, 0xbf, 0xcf, 0x18, + 0xf6, 0xa3, 0x43, 0x12, 0xb1, 0x56, 0x88, 0xe8, 0xb7, 0x51, 0x47, 0x5f, 0x03, 0x85, 0x44, 0x1b, + 0xf6, 0xca, 0xda, 0x86, 0xb6, 0x55, 0xb4, 0x6f, 0xc9, 0xeb, 0x23, 0x4f, 0x7f, 0x1b, 0xcc, 0xa7, + 0xba, 0x1c, 0xe8, 0x79, 0xb4, 0x3c, 0x29, 0xe2, 0x07, 0xfa, 0xbf, 0x9f, 0x56, 0x17, 0x3a, 0x30, + 0x0c, 0xf6, 0x6a, 0x62, 0x14, 0x31, 0x56, 0xb3, 0xe7, 0x52, 0xe0, 0xbe, 0xe7, 0x51, 0x7d, 0x13, + 0xcc, 0xb9, 0x6a, 0x0a, 0xe7, 0x11, 0xea, 0x94, 0xa7, 0x24, 0x6f, 0xc9, 0xcd, 0x4d, 0xfb, 0x06, + 0x98, 0x15, 0x4a, 0x10, 0x2d, 0x4f, 0x4b, 0xd2, 0xf2, 0xa7, 0x1f, 0x6f, 0xaf, 0xa8, 0x8a, 0xef, + 0x27, 0xac, 0x0f, 0x39, 0xc5, 0x91, 0x6f, 0x2b, 0xdc, 0xde, 0xed, 0x9f, 0x7c, 0x54, 0x9d, 0xf8, + 0xd7, 0x47, 0xd5, 0x89, 0x0f, 0x3e, 0x7b, 0x7c, 0x57, 0x0d, 0xd6, 0x2a, 0x60, 0xbd, 0x9f, 0x2b, + 0x1b, 0xb1, 0x98, 0x44, 0x0c, 0xd5, 0xfe, 0xa8, 0x81, 0x97, 0x8f, 0x99, 0xff, 0xb0, 0xd5, 0x08, + 0x31, 0x4f, 0x01, 0xc7, 0x98, 0x35, 0x50, 0x13, 0xb6, 0x31, 0x69, 0x51, 0xfd, 0x2d, 0x50, 0x64, + 0x32, 0xca, 0x11, 0x4d, 0x0a, 0x30, 0x40, 0x4b, 0x17, 0xaa, 0x9f, 0x82, 0xb9, 0x30, 0xc7, 0x23, + 0x6b, 0x53, 0xda, 0x7d, 0xdd, 0xc4, 0x0d, 0xd7, 0xcc, 0xdf, 0x39, 0x33, 0x77, 0xaf, 0xda, 0x3b, + 0x66, 0x7e, 0x6e, 0xbb, 0x87, 0x61, 0xef, 0x73, 0x79, 0x83, 0xdd, 0x99, 0x6a, 0xaf, 0x81, 0x2f, + 0x0c, 0xb4, 0x90, 0x99, 0x7d, 0x3c, 0xd9, 0xc7, 0x6c, 0x9d, 0xb4, 0x1a, 0x01, 0x7a, 0x8f, 0x70, + 0x1c, 0xf9, 0x63, 0x9b, 0x75, 0xc0, 0xaa, 0xd7, 0x8a, 0x03, 0xec, 0x42, 0x8e, 0x9c, 0x36, 0xe1, + 0xc8, 0x49, 0x1f, 0x2f, 0xe5, 0xfb, 0xb5, 0xbc, 0x4d, 0xf9, 0x00, 0x9a, 0xf5, 0x34, 0xe1, 0x3d, + 0xc2, 0xd1, 0x3d, 0x05, 0xb7, 0xef, 0x78, 0xfd, 0x86, 0xf5, 0x1f, 0x81, 0x55, 0x1c, 0x9d, 0x53, + 0xe8, 0x8a, 0xe5, 0xeb, 0x34, 0x02, 0xe2, 0x3e, 0x72, 0x9a, 0x08, 0x7a, 0x88, 0xca, 0x87, 0xa7, + 0xb4, 0xfb, 0xea, 0x8b, 0x0a, 0x7b, 0x5f, 0xa2, 0xed, 0x3b, 0x5d, 0x9a, 0x03, 0xc1, 0x92, 0x0c, + 0x8f, 0x54, 0xdb, 0x7c, 0xc5, 0xb2, 0xda, 0xfe, 0x5a, 0x03, 0x8b, 0xc7, 0xcc, 0xff, 0x5e, 0xec, + 0x41, 0x8e, 0x4e, 0x21, 0x85, 0x21, 0x13, 0xd5, 0x84, 0x2d, 0xde, 0x24, 0x62, 0x45, 0xbf, 0xb8, + 0x9a, 0x19, 0x54, 0x3f, 0x02, 0xb3, 0xb1, 0x64, 0x50, 0xc5, 0xfb, 0xa2, 0x39, 0x44, 0xff, 0x34, + 0x93, 0x49, 0x0f, 0xa6, 0x9f, 0x3c, 0xad, 0x4e, 0xd8, 0x8a, 0x60, 0x6f, 0x41, 0xfa, 0xc9, 0xa8, + 0x6b, 0x6b, 0x60, 0xf5, 0x92, 0xca, 0xcc, 0xc1, 0xcf, 0x0a, 0xe0, 0xf6, 0x31, 0xf3, 0x53, 0x97, + 0xfb, 0x9e, 0x87, 0x45, 0x95, 0x06, 0x35, 0x80, 0x6f, 0x81, 0x05, 0x1c, 0x61, 0x8e, 0x61, 0xe0, + 0x34, 0x91, 0x28, 0xbd, 0x12, 0x6c, 0xc8, 0x9b, 0x21, 0x9a, 0x9e, 0xa9, 0x5a, 0x9d, 0xbc, 0x01, + 0x02, 0xa1, 0xf4, 0xcd, 0xab, 0xbc, 0x64, 0x50, 0x34, 0x04, 0x1f, 0x45, 0x88, 0x61, 0xe6, 0x34, + 0x21, 0x6b, 0xca, 0x7b, 0x3a, 0x67, 0x97, 0xd4, 0xd8, 0x7d, 0xc8, 0x9a, 0x7a, 0x15, 0x94, 0x1a, + 0x38, 0x82, 0xb4, 0x93, 0x20, 0xa6, 0x25, 0x02, 0x24, 0x43, 0x12, 0x70, 0x08, 0x00, 0x8b, 0xe1, + 0x45, 0xe4, 0x88, 0x6d, 0xa0, 0x3c, 0xa3, 0x84, 0x24, 0x2d, 0xde, 0x4c, 0x5b, 0xbc, 0x79, 0x96, + 0xee, 0x11, 0x07, 0x05, 0x21, 0xe4, 0xc3, 0x7f, 0x54, 0x35, 0xbb, 0x28, 0xf3, 0x44, 0x44, 0x7f, + 0x00, 0x96, 0x5a, 0x51, 0x83, 0x44, 0x1e, 0x8e, 0x7c, 0x27, 0x46, 0x14, 0x13, 0xaf, 0x3c, 0x2b, + 0xa9, 0xd6, 0xae, 0x50, 0xd5, 0xd5, 0x6e, 0x92, 0x30, 0xfd, 0x52, 0x30, 0x2d, 0x66, 0xc9, 0xa7, + 0x32, 0x57, 0xff, 0x2e, 0xd0, 0x5d, 0xb7, 0x2d, 0x25, 0x91, 0x16, 0x4f, 0x19, 0x6f, 0x0d, 0xcf, + 0xb8, 0xe4, 0xba, 0xed, 0xb3, 0x24, 0x5b, 0x51, 0xfe, 0x10, 0xac, 0x72, 0x0a, 0x23, 0x76, 0x8e, + 0xe8, 0x65, 0xde, 0xc2, 0xf0, 0xbc, 0x77, 0x52, 0x8e, 0x5e, 0xf2, 0xfb, 0x60, 0x23, 0xeb, 0xcc, + 0x14, 0x79, 0x98, 0x71, 0x8a, 0x1b, 0x2d, 0xb9, 0xe8, 0xd2, 0x65, 0x53, 0x2e, 0xca, 0x87, 0xa0, + 0x92, 0xe2, 0xec, 0x1e, 0xd8, 0x37, 0x15, 0x4a, 0x3f, 0x01, 0xaf, 0xc8, 0x65, 0xca, 0x84, 0x38, + 0xa7, 0x87, 0x49, 0x4e, 0x1d, 0x62, 0xc6, 0x04, 0x1b, 0xd8, 0xd0, 0xb6, 0xa6, 0xec, 0xcd, 0x04, + 0x7b, 0x8a, 0x68, 0x3d, 0x87, 0x3c, 0xcb, 0x01, 0xf5, 0x6d, 0xa0, 0x37, 0x31, 0xe3, 0x84, 0x62, + 0x17, 0x06, 0x0e, 0x8a, 0x38, 0xc5, 0x88, 0x95, 0x4b, 0x32, 0x7d, 0xb9, 0x1b, 0xb9, 0x97, 0x04, + 0xf4, 0x77, 0xc1, 0xe6, 0xb5, 0x93, 0x3a, 0x6e, 0x13, 0x46, 0x11, 0x0a, 0xca, 0x73, 0xd2, 0x4a, + 0xd5, 0xbb, 0x66, 0xce, 0xc3, 0x04, 0xa6, 0xdf, 0x06, 0x33, 0x9c, 0xc4, 0xce, 0x83, 0xf2, 0xfc, + 0x86, 0xb6, 0x35, 0x6f, 0x4f, 0x73, 0x12, 0x3f, 0xd0, 0xdf, 0x00, 0x2b, 0x6d, 0x18, 0x60, 0x0f, + 0x72, 0x42, 0x99, 0x13, 0x93, 0x0b, 0x44, 0x1d, 0x17, 0xc6, 0xe5, 0x05, 0x89, 0xd1, 0xbb, 0xb1, + 0x53, 0x11, 0x3a, 0x84, 0xb1, 0x7e, 0x17, 0x2c, 0x67, 0xa3, 0x0e, 0x43, 0x5c, 0xc2, 0x17, 0x25, + 0x7c, 0x31, 0x0b, 0x3c, 0x44, 0x5c, 0x60, 0xd7, 0x41, 0x11, 0x06, 0x01, 0xb9, 0x08, 0x30, 0xe3, + 0xe5, 0xa5, 0x8d, 0xa9, 0xad, 0xa2, 0xdd, 0x1d, 0xd0, 0x0d, 0x50, 0xf0, 0x50, 0xd4, 0x91, 0xc1, + 0x65, 0x19, 0xcc, 0xae, 0x7b, 0xbb, 0x8e, 0x3e, 0x74, 0xd7, 0xb9, 0xd2, 0x2a, 0x5e, 0x06, 0x2f, + 0xf5, 0x69, 0x07, 0x59, 0xbb, 0xf8, 0x83, 0x06, 0xf4, 0x5c, 0xdc, 0x46, 0x21, 0x69, 0xc3, 0x60, + 0x50, 0xb7, 0xd8, 0x07, 0x45, 0x26, 0xca, 0x28, 0xd7, 0xe7, 0xe4, 0x08, 0xeb, 0xb3, 0x20, 0xd2, + 0xe4, 0xf2, 0xec, 0xf1, 0x36, 0x35, 0xbe, 0xb7, 0x75, 0x60, 0x5c, 0xd5, 0x9e, 0x59, 0xfb, 0xbd, + 0x06, 0xee, 0x88, 0x70, 0x13, 0x46, 0x3e, 0xb2, 0xd1, 0x05, 0xa4, 0x5e, 0x1d, 0x45, 0x24, 0x64, + 0x7a, 0x0d, 0xcc, 0x7b, 0xf2, 0x9f, 0xc3, 0x89, 0x38, 0xf2, 0x94, 0x35, 0x59, 0xfc, 0x52, 0x32, + 0x78, 0x46, 0xf6, 0x3d, 0x4f, 0xdf, 0x02, 0x4b, 0x5d, 0x0c, 0x15, 0xd4, 0xc2, 0xad, 0x80, 0x2d, + 0xa4, 0x30, 0x39, 0xe1, 0x7f, 0xcf, 0x4d, 0x55, 0x6e, 0xeb, 0x57, 0xe5, 0x66, 0x86, 0x9e, 0x68, + 0xa0, 0x70, 0xcc, 0xfc, 0x93, 0x98, 0x1f, 0x45, 0xff, 0xe7, 0x07, 0x3a, 0x1d, 0x2c, 0xa5, 0x4e, + 0x32, 0x7b, 0xbf, 0xd1, 0x40, 0x31, 0x19, 0x3c, 0x69, 0xf1, 0xff, 0x89, 0xbf, 0xae, 0xf8, 0xa9, + 0x9b, 0x88, 0xbf, 0x0d, 0x96, 0x33, 0x9d, 0x99, 0xfa, 0x3f, 0x69, 0xf2, 0x8c, 0x2a, 0xd6, 0xbd, + 0x2a, 0xd7, 0x21, 0x09, 0x55, 0x03, 0xb2, 0x21, 0x47, 0x57, 0x55, 0x6b, 0x43, 0xaa, 0xce, 0x57, + 0x62, 0xb2, 0xb7, 0x12, 0xf7, 0xc0, 0x34, 0x85, 0x1c, 0x29, 0x3b, 0x3b, 0x62, 0xa9, 0xfd, 0xfd, + 0x69, 0xf5, 0xa5, 0xc4, 0x12, 0xf3, 0x1e, 0x99, 0x98, 0x58, 0x21, 0xe4, 0x4d, 0xf3, 0x3b, 0xc8, + 0x87, 0x6e, 0xa7, 0x8e, 0xdc, 0x4f, 0x3f, 0xde, 0x06, 0xca, 0x71, 0x1d, 0xb9, 0xb6, 0x4c, 0xdf, + 0x2b, 0xa4, 0x2e, 0x6b, 0xaf, 0x82, 0x57, 0x06, 0x99, 0xc8, 0xdc, 0xfe, 0x65, 0x52, 0x9e, 0x40, + 0xb2, 0x73, 0x2a, 0xf1, 0xf0, 0xb9, 0x38, 0xee, 0x89, 0x0e, 0xbf, 0x02, 0x66, 0x38, 0xe6, 0x01, + 0x52, 0xb7, 0x2d, 0xb9, 0xd0, 0x37, 0x40, 0xc9, 0x43, 0xcc, 0xa5, 0x38, 0x96, 0xbb, 0x4f, 0x62, + 0x24, 0x3f, 0xd4, 0xe3, 0x73, 0xaa, 0xd7, 0x67, 0xd6, 0xb9, 0xa7, 0x87, 0xe8, 0xdc, 0x33, 0xa3, + 0x75, 0xee, 0xd9, 0x21, 0x3a, 0xf7, 0xad, 0x41, 0x9d, 0xbb, 0x30, 0xa8, 0x73, 0x17, 0x87, 0xee, + 0x07, 0xb5, 0x4d, 0x50, 0xbd, 0xa6, 0xa4, 0x69, 0xd9, 0x77, 0xff, 0x5c, 0x02, 0x53, 0xc7, 0xcc, + 0xd7, 0x7f, 0xa1, 0x81, 0xe5, 0xab, 0xef, 0x78, 0x5f, 0x1d, 0xea, 0x80, 0xd9, 0xef, 0x45, 0xca, + 0xd8, 0x1f, 0x3b, 0x35, 0xd5, 0xa6, 0xff, 0x4e, 0x03, 0xc6, 0x80, 0x17, 0xb0, 0x83, 0x61, 0x67, + 0xb8, 0x9e, 0xc3, 0x78, 0xf7, 0xe6, 0x1c, 0x03, 0xe4, 0xf6, 0xbc, 0x42, 0x8d, 0x29, 0x37, 0xcf, + 0x31, 0xae, 0xdc, 0x7e, 0x2f, 0x26, 0xfa, 0xcf, 0x35, 0xb0, 0x74, 0xe5, 0x4c, 0xff, 0x95, 0x61, + 0x27, 0xb8, 0x9c, 0x69, 0x7c, 0x63, 0xdc, 0xcc, 0x4c, 0xd0, 0x4f, 0x35, 0xb0, 0x78, 0xf9, 0xd4, + 0xf0, 0xf6, 0xa8, 0xac, 0x2a, 0xd1, 0xf8, 0xfa, 0x98, 0x89, 0x99, 0x9a, 0x0f, 0x34, 0x30, 0xd7, + 0xf3, 0xd2, 0xf6, 0xe5, 0x61, 0x19, 0xf3, 0x59, 0xc6, 0x3b, 0xe3, 0x64, 0x65, 0x22, 0x42, 0x30, + 0x93, 0xec, 0xcd, 0xdb, 0xc3, 0xd2, 0x48, 0xb8, 0xf1, 0xe6, 0x48, 0xf0, 0x6c, 0xba, 0x18, 0xcc, + 0xaa, 0xbd, 0xd2, 0x1c, 0x81, 0xe0, 0xa4, 0xc5, 0x8d, 0xb7, 0x46, 0xc3, 0x67, 0x33, 0xfe, 0x56, + 0x03, 0x6b, 0xd7, 0x6f, 0x70, 0x43, 0xf7, 0x90, 0x6b, 0x29, 0x8c, 0xa3, 0x1b, 0x53, 0x64, 0x5a, + 0x7f, 0xa5, 0x81, 0x95, 0xbe, 0xdb, 0xd3, 0x3b, 0xa3, 0x3e, 0x6b, 0xf9, 0x6c, 0xa3, 0x7e, 0x93, + 0xec, 0x54, 0x9c, 0x31, 0xf3, 0xe3, 0xcf, 0x1e, 0xdf, 0xd5, 0x0e, 0xbe, 0xff, 0xe4, 0x59, 0x45, + 0xfb, 0xe4, 0x59, 0x45, 0xfb, 0xe7, 0xb3, 0x8a, 0xf6, 0xe1, 0xf3, 0xca, 0xc4, 0x27, 0xcf, 0x2b, + 0x13, 0x7f, 0x7b, 0x5e, 0x99, 0xf8, 0xc1, 0xd7, 0x7c, 0xcc, 0x9b, 0xad, 0x86, 0xe9, 0x92, 0x50, + 0x7d, 0xa0, 0xb4, 0xba, 0xf3, 0x6e, 0x67, 0xdf, 0x17, 0xdb, 0x6f, 0x5a, 0xef, 0xf7, 0x7e, 0x64, + 0x94, 0x1f, 0x65, 0x1a, 0xb3, 0xf2, 0x20, 0xfe, 0xa5, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x39, + 0xec, 0x0a, 0x75, 0xe0, 0x15, 0x00, 0x00, } -func (m *MsgOptInResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// 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) + SubmitConsumerMisbehaviour(ctx context.Context, in *MsgSubmitConsumerMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitConsumerMisbehaviourResponse, error) + SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) + ConsumerAddition(ctx context.Context, in *MsgConsumerAddition, opts ...grpc.CallOption) (*MsgConsumerAdditionResponse, error) + ConsumerRemoval(ctx context.Context, in *MsgConsumerRemoval, opts ...grpc.CallOption) (*MsgConsumerRemovalResponse, error) + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) + OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) + SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) + ConsumerModification(ctx context.Context, in *MsgConsumerModification, opts ...grpc.CallOption) (*MsgConsumerModificationResponse, error) } -func (m *MsgOptInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +type msgClient struct { + cc grpc1.ClientConn } -func (m *MsgOptOut) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AssignConsumerKey(ctx context.Context, in *MsgAssignConsumerKey, opts ...grpc.CallOption) (*MsgAssignConsumerKeyResponse, error) { + out := new(MsgAssignConsumerKeyResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/AssignConsumerKey", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgOptOut) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) SubmitConsumerMisbehaviour(ctx context.Context, in *MsgSubmitConsumerMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitConsumerMisbehaviourResponse, error) { + out := new(MsgSubmitConsumerMisbehaviourResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerMisbehaviour", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgOptOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ProviderAddr) > 0 { - i -= len(m.ProviderAddr) - copy(dAtA[i:], m.ProviderAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) - i-- - dAtA[i] = 0x12 - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa +func (c *msgClient) SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) { + out := new(MsgSubmitConsumerDoubleVotingResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerDoubleVoting", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *MsgOptOutResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) ConsumerAddition(ctx context.Context, in *MsgConsumerAddition, opts ...grpc.CallOption) (*MsgConsumerAdditionResponse, error) { + out := new(MsgConsumerAdditionResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerAddition", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgOptOutResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) ConsumerRemoval(ctx context.Context, in *MsgConsumerRemoval, opts ...grpc.CallOption) (*MsgConsumerRemovalResponse, error) { + out := new(MsgConsumerRemovalResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerRemoval", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgOptOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgSetConsumerCommissionRate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) { + out := new(MsgOptInResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/OptIn", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgSetConsumerCommissionRate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) { + out := new(MsgOptOutResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/OptOut", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Rate.Size() - i -= size - if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0x12 - } - if len(m.ProviderAddr) > 0 { - i -= len(m.ProviderAddr) - copy(dAtA[i:], m.ProviderAddr) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) - i-- - dAtA[i] = 0xa +func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { + out := new(MsgSetConsumerCommissionRateResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *MsgSetConsumerCommissionRateResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *msgClient) ConsumerModification(ctx context.Context, in *MsgConsumerModification, opts ...grpc.CallOption) (*MsgConsumerModificationResponse, error) { + out := new(MsgConsumerModificationResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerModification", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *MsgSetConsumerCommissionRateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// MsgServer is the server API for Msg service. +type MsgServer interface { + AssignConsumerKey(context.Context, *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) + SubmitConsumerMisbehaviour(context.Context, *MsgSubmitConsumerMisbehaviour) (*MsgSubmitConsumerMisbehaviourResponse, error) + SubmitConsumerDoubleVoting(context.Context, *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) + ConsumerAddition(context.Context, *MsgConsumerAddition) (*MsgConsumerAdditionResponse, error) + ConsumerRemoval(context.Context, *MsgConsumerRemoval) (*MsgConsumerRemovalResponse, error) + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + OptIn(context.Context, *MsgOptIn) (*MsgOptInResponse, error) + OptOut(context.Context, *MsgOptOut) (*MsgOptOutResponse, error) + SetConsumerCommissionRate(context.Context, *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) + ConsumerModification(context.Context, *MsgConsumerModification) (*MsgConsumerModificationResponse, error) } -func (m *MsgSetConsumerCommissionRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base +func (*UnimplementedMsgServer) AssignConsumerKey(ctx context.Context, req *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AssignConsumerKey not implemented") } -func (m *MsgAssignConsumerKey) Size() (n int) { - if m == nil { - return 0 +func (*UnimplementedMsgServer) SubmitConsumerMisbehaviour(ctx context.Context, req *MsgSubmitConsumerMisbehaviour) (*MsgSubmitConsumerMisbehaviourResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitConsumerMisbehaviour not implemented") +} +func (*UnimplementedMsgServer) SubmitConsumerDoubleVoting(ctx context.Context, req *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitConsumerDoubleVoting not implemented") +} +func (*UnimplementedMsgServer) ConsumerAddition(ctx context.Context, req *MsgConsumerAddition) (*MsgConsumerAdditionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsumerAddition not implemented") +} +func (*UnimplementedMsgServer) ConsumerRemoval(ctx context.Context, req *MsgConsumerRemoval) (*MsgConsumerRemovalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsumerRemoval not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) OptIn(ctx context.Context, req *MsgOptIn) (*MsgOptInResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptIn not implemented") +} +func (*UnimplementedMsgServer) OptOut(ctx context.Context, req *MsgOptOut) (*MsgOptOutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OptOut not implemented") +} +func (*UnimplementedMsgServer) SetConsumerCommissionRate(ctx context.Context, req *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetConsumerCommissionRate not implemented") +} +func (*UnimplementedMsgServer) ConsumerModification(ctx context.Context, req *MsgConsumerModification) (*MsgConsumerModificationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ConsumerModification not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AssignConsumerKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAssignConsumerKey) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if interceptor == nil { + return srv.(MsgServer).AssignConsumerKey(ctx, in) } - l = len(m.ProviderAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/AssignConsumerKey", } - l = len(m.ConsumerKey) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AssignConsumerKey(ctx, req.(*MsgAssignConsumerKey)) } - return n + return interceptor(ctx, in, info, handler) } -func (m *MsgAssignConsumerKeyResponse) Size() (n int) { - if m == nil { - return 0 +func _Msg_SubmitConsumerMisbehaviour_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitConsumerMisbehaviour) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - return n -} - -func (m *MsgSubmitConsumerMisbehaviour) Size() (n int) { - if m == nil { - return 0 + if interceptor == nil { + return srv.(MsgServer).SubmitConsumerMisbehaviour(ctx, in) } - var l int - _ = l - l = len(m.Submitter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerMisbehaviour", } - if m.Misbehaviour != nil { - l = m.Misbehaviour.Size() - n += 1 + l + sovTx(uint64(l)) + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitConsumerMisbehaviour(ctx, req.(*MsgSubmitConsumerMisbehaviour)) } - return n + return interceptor(ctx, in, info, handler) } -func (m *MsgSubmitConsumerMisbehaviourResponse) Size() (n int) { - if m == nil { - return 0 +func _Msg_SubmitConsumerDoubleVoting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitConsumerDoubleVoting) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - return n + if interceptor == nil { + return srv.(MsgServer).SubmitConsumerDoubleVoting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/SubmitConsumerDoubleVoting", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitConsumerDoubleVoting(ctx, req.(*MsgSubmitConsumerDoubleVoting)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgSubmitConsumerDoubleVoting) Size() (n int) { - if m == nil { - return 0 +func _Msg_ConsumerAddition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgConsumerAddition) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - l = len(m.Submitter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if interceptor == nil { + return srv.(MsgServer).ConsumerAddition(ctx, in) } - if m.DuplicateVoteEvidence != nil { - l = m.DuplicateVoteEvidence.Size() - n += 1 + l + sovTx(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/ConsumerAddition", } - if m.InfractionBlockHeader != nil { - l = m.InfractionBlockHeader.Size() - n += 1 + l + sovTx(uint64(l)) + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ConsumerAddition(ctx, req.(*MsgConsumerAddition)) } - return n + return interceptor(ctx, in, info, handler) } -func (m *MsgSubmitConsumerDoubleVotingResponse) Size() (n int) { - if m == nil { - return 0 +func _Msg_ConsumerRemoval_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgConsumerRemoval) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - return n + if interceptor == nil { + return srv.(MsgServer).ConsumerRemoval(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/ConsumerRemoval", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ConsumerRemoval(ctx, req.(*MsgConsumerRemoval)) + } + return interceptor(ctx, in, info, handler) } -func (m *MsgOptIn) Size() (n int) { - if m == nil { - return 0 +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) } - l = len(m.ProviderAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/UpdateParams", } - l = len(m.ConsumerKey) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) } - return n + return interceptor(ctx, in, info, handler) } -func (m *MsgOptInResponse) Size() (n int) { - if m == nil { - return 0 +func _Msg_OptIn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgOptIn) + if err := dec(in); err != nil { + return nil, err } - var l int - _ = l - return n -} - -func (m *MsgOptOut) Size() (n int) { - if m == nil { - return 0 + if interceptor == nil { + return srv.(MsgServer).OptIn(ctx, in) } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/OptIn", } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).OptIn(ctx, req.(*MsgOptIn)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_OptOut_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgOptOut) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).OptOut(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/OptOut", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).OptOut(ctx, req.(*MsgOptOut)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetConsumerCommissionRate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, req.(*MsgSetConsumerCommissionRate)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ConsumerModification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgConsumerModification) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ConsumerModification(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/ConsumerModification", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ConsumerModification(ctx, req.(*MsgConsumerModification)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "interchain_security.ccv.provider.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AssignConsumerKey", + Handler: _Msg_AssignConsumerKey_Handler, + }, + { + MethodName: "SubmitConsumerMisbehaviour", + Handler: _Msg_SubmitConsumerMisbehaviour_Handler, + }, + { + MethodName: "SubmitConsumerDoubleVoting", + Handler: _Msg_SubmitConsumerDoubleVoting_Handler, + }, + { + MethodName: "ConsumerAddition", + Handler: _Msg_ConsumerAddition_Handler, + }, + { + MethodName: "ConsumerRemoval", + Handler: _Msg_ConsumerRemoval_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "OptIn", + Handler: _Msg_OptIn_Handler, + }, + { + MethodName: "OptOut", + Handler: _Msg_OptOut_Handler, + }, + { + MethodName: "SetConsumerCommissionRate", + Handler: _Msg_SetConsumerCommissionRate_Handler, + }, + { + MethodName: "ConsumerModification", + Handler: _Msg_ConsumerModification_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "interchain_security/ccv/provider/v1/tx.proto", +} + +func (m *MsgAssignConsumerKey) 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 *MsgAssignConsumerKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAssignConsumerKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.ConsumerKey) > 0 { + i -= len(m.ConsumerKey) + copy(dAtA[i:], m.ConsumerKey) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerKey))) + i-- + dAtA[i] = 0x1a + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAssignConsumerKeyResponse) 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 *MsgAssignConsumerKeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAssignConsumerKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSubmitConsumerMisbehaviour) 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 *MsgSubmitConsumerMisbehaviour) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitConsumerMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Misbehaviour != nil { + { + size, err := m.Misbehaviour.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitConsumerMisbehaviourResponse) 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 *MsgSubmitConsumerMisbehaviourResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitConsumerMisbehaviourResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSubmitConsumerDoubleVoting) 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 *MsgSubmitConsumerDoubleVoting) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitConsumerDoubleVoting) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.InfractionBlockHeader != nil { + { + size, err := m.InfractionBlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.DuplicateVoteEvidence != nil { + { + size, err := m.DuplicateVoteEvidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitConsumerDoubleVotingResponse) 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 *MsgSubmitConsumerDoubleVotingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitConsumerDoubleVotingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgConsumerAddition) 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 *MsgConsumerAddition) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerAddition) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } + if len(m.Denylist) > 0 { + for iNdEx := len(m.Denylist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denylist[iNdEx]) + copy(dAtA[i:], m.Denylist[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denylist[iNdEx]))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + } + if len(m.Allowlist) > 0 { + for iNdEx := len(m.Allowlist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Allowlist[iNdEx]) + copy(dAtA[i:], m.Allowlist[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Allowlist[iNdEx]))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + } + if m.ValidatorSetCap != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ValidatorSetCap)) + i-- + dAtA[i] = 0x78 + } + if m.ValidatorsPowerCap != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ValidatorsPowerCap)) + i-- + dAtA[i] = 0x70 + } + if m.Top_N != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Top_N)) + i-- + dAtA[i] = 0x68 + } + if len(m.DistributionTransmissionChannel) > 0 { + i -= len(m.DistributionTransmissionChannel) + copy(dAtA[i:], m.DistributionTransmissionChannel) + i = encodeVarintTx(dAtA, i, uint64(len(m.DistributionTransmissionChannel))) + i-- + dAtA[i] = 0x62 + } + if m.HistoricalEntries != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.HistoricalEntries)) + i-- + dAtA[i] = 0x58 + } + if m.BlocksPerDistributionTransmission != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) + i-- + dAtA[i] = 0x50 + } + if len(m.ConsumerRedistributionFraction) > 0 { + i -= len(m.ConsumerRedistributionFraction) + copy(dAtA[i:], m.ConsumerRedistributionFraction) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerRedistributionFraction))) + i-- + dAtA[i] = 0x4a + } + n5, err5 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintTx(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x42 + n6, err6 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintTx(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0x3a + n7, err7 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err7 != nil { + return 0, err7 + } + i -= n7 + i = encodeVarintTx(dAtA, i, uint64(n7)) + i-- + dAtA[i] = 0x32 + n8, err8 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.SpawnTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SpawnTime):]) + if err8 != nil { + return 0, err8 + } + i -= n8 + i = encodeVarintTx(dAtA, i, uint64(n8)) + i-- + dAtA[i] = 0x2a + if len(m.BinaryHash) > 0 { + i -= len(m.BinaryHash) + copy(dAtA[i:], m.BinaryHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.BinaryHash))) + i-- + dAtA[i] = 0x22 + } + if len(m.GenesisHash) > 0 { + i -= len(m.GenesisHash) + copy(dAtA[i:], m.GenesisHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.GenesisHash))) + i-- + dAtA[i] = 0x1a + } + { + size, err := m.InitialHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConsumerAdditionResponse) 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 *MsgConsumerAdditionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerAdditionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgConsumerRemoval) 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 *MsgConsumerRemoval) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerRemoval) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x1a + } + n10, err10 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StopTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime):]) + if err10 != nil { + return 0, err10 + } + i -= n10 + i = encodeVarintTx(dAtA, i, uint64(n10)) + i-- + dAtA[i] = 0x12 + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConsumerRemovalResponse) 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 *MsgConsumerRemovalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerRemovalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgChangeRewardDenoms) 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 *MsgChangeRewardDenoms) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChangeRewardDenoms) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x1a + } + 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 = encodeVarintTx(dAtA, i, uint64(len(m.DenomsToRemove[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + 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 = encodeVarintTx(dAtA, i, uint64(len(m.DenomsToAdd[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgChangeRewardDenomsResponse) 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 *MsgChangeRewardDenomsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgChangeRewardDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgOptIn) 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 *MsgOptIn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOptIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.ConsumerKey) > 0 { + i -= len(m.ConsumerKey) + copy(dAtA[i:], m.ConsumerKey) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerKey))) + i-- + dAtA[i] = 0x1a + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgOptInResponse) 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 *MsgOptInResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOptInResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgOptOut) 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 *MsgOptOut) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOptOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0x12 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgOptOutResponse) 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 *MsgOptOutResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgOptOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetConsumerCommissionRate) 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 *MsgSetConsumerCommissionRate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetConsumerCommissionRateResponse) 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 *MsgSetConsumerCommissionRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgConsumerModification) 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 *MsgConsumerModification) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerModification) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x4a + } + if len(m.Denylist) > 0 { + for iNdEx := len(m.Denylist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denylist[iNdEx]) + copy(dAtA[i:], m.Denylist[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denylist[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + if len(m.Allowlist) > 0 { + for iNdEx := len(m.Allowlist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Allowlist[iNdEx]) + copy(dAtA[i:], m.Allowlist[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Allowlist[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + if m.ValidatorSetCap != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ValidatorSetCap)) + i-- + dAtA[i] = 0x30 + } + if m.ValidatorsPowerCap != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ValidatorsPowerCap)) + i-- + dAtA[i] = 0x28 + } + if m.Top_N != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Top_N)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(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 = encodeVarintTx(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgConsumerModificationResponse) 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 *MsgConsumerModificationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgConsumerModificationResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAssignConsumerKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerKey) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAssignConsumerKeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitConsumerMisbehaviour) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Misbehaviour != nil { + l = m.Misbehaviour.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitConsumerMisbehaviourResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitConsumerDoubleVoting) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DuplicateVoteEvidence != nil { + l = m.DuplicateVoteEvidence.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.InfractionBlockHeader != nil { + l = m.InfractionBlockHeader.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitConsumerDoubleVotingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgConsumerAddition) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.InitialHeight.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.GenesisHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BinaryHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SpawnTime) + n += 1 + l + sovTx(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod) + n += 1 + l + sovTx(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod) + n += 1 + l + sovTx(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod) + n += 1 + l + sovTx(uint64(l)) + l = len(m.ConsumerRedistributionFraction) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.BlocksPerDistributionTransmission != 0 { + n += 1 + sovTx(uint64(m.BlocksPerDistributionTransmission)) + } + if m.HistoricalEntries != 0 { + n += 1 + sovTx(uint64(m.HistoricalEntries)) + } + l = len(m.DistributionTransmissionChannel) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Top_N != 0 { + n += 1 + sovTx(uint64(m.Top_N)) + } + if m.ValidatorsPowerCap != 0 { + n += 1 + sovTx(uint64(m.ValidatorsPowerCap)) + } + if m.ValidatorSetCap != 0 { + n += 1 + sovTx(uint64(m.ValidatorSetCap)) + } + if len(m.Allowlist) > 0 { + for _, s := range m.Allowlist { + l = len(s) + n += 2 + l + sovTx(uint64(l)) + } + } + if len(m.Denylist) > 0 { + for _, s := range m.Denylist { + l = len(s) + n += 2 + l + sovTx(uint64(l)) + } + } + l = len(m.Authority) + if l > 0 { + n += 2 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgConsumerAdditionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgConsumerRemoval) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime) + n += 1 + l + sovTx(uint64(l)) + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgConsumerRemovalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgChangeRewardDenoms) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.DenomsToAdd) > 0 { + for _, s := range m.DenomsToAdd { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.DenomsToRemove) > 0 { + for _, s := range m.DenomsToRemove { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgChangeRewardDenomsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgOptIn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerKey) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgOptInResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgOptOut) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgOptOutResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetConsumerCommissionRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l l = len(m.ProviderAddr) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgConsumerModification) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Top_N != 0 { + n += 1 + sovTx(uint64(m.Top_N)) + } + if m.ValidatorsPowerCap != 0 { + n += 1 + sovTx(uint64(m.ValidatorsPowerCap)) + } + if m.ValidatorSetCap != 0 { + n += 1 + sovTx(uint64(m.ValidatorSetCap)) + } + if len(m.Allowlist) > 0 { + for _, s := range m.Allowlist { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + if len(m.Denylist) > 0 { + for _, s := range m.Denylist { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgConsumerModificationResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgAssignConsumerKey) 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: MsgAssignConsumerKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAssignConsumerKey: 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 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.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", 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.ProviderAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", 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.ConsumerKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = 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 *MsgAssignConsumerKeyResponse) 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: MsgAssignConsumerKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAssignConsumerKeyResponse: 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 (m *MsgSubmitConsumerMisbehaviour) 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: MsgSubmitConsumerMisbehaviour: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", 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.Submitter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Misbehaviour", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Misbehaviour == nil { + m.Misbehaviour = &_07_tendermint.Misbehaviour{} + } + if err := m.Misbehaviour.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgSubmitConsumerMisbehaviourResponse) 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: MsgSubmitConsumerMisbehaviourResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviourResponse: 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 (m *MsgSubmitConsumerDoubleVoting) 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: MsgSubmitConsumerDoubleVoting: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitConsumerDoubleVoting: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", 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.Submitter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DuplicateVoteEvidence", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DuplicateVoteEvidence == nil { + m.DuplicateVoteEvidence = &types.DuplicateVoteEvidence{} + } + if err := m.DuplicateVoteEvidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InfractionBlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InfractionBlockHeader == nil { + m.InfractionBlockHeader = &_07_tendermint.Header{} + } + if err := m.InfractionBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgSubmitConsumerDoubleVotingResponse) 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: MsgSubmitConsumerDoubleVotingResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitConsumerDoubleVotingResponse: 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 (m *MsgUpdateParams) 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgUpdateParamsResponse) 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: 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 (m *MsgConsumerAddition) 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: MsgConsumerAddition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConsumerAddition: 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 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.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InitialHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GenesisHash = append(m.GenesisHash[:0], dAtA[iNdEx:postIndex]...) + if m.GenesisHash == nil { + m.GenesisHash = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BinaryHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BinaryHash = append(m.BinaryHash[:0], dAtA[iNdEx:postIndex]...) + if m.BinaryHash == nil { + m.BinaryHash = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpawnTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.SpawnTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 7: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 8: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + 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 9: + 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 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.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HistoricalEntries |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + 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 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.DistributionTransmissionChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Top_N", wireType) + } + m.Top_N = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Top_N |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsPowerCap", wireType) + } + m.ValidatorsPowerCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorsPowerCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSetCap", wireType) + } + m.ValidatorSetCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorSetCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowlist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Allowlist = append(m.Allowlist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denylist", 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.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 18: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = 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 *MsgConsumerAdditionResponse) 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: MsgConsumerAdditionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConsumerAdditionResponse: 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 (m *MsgConsumerRemoval) 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: MsgConsumerRemoval: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConsumerRemoval: 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 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.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StopTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StopTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", 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.Authority = 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 + } + } -func (m *MsgOptOutResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n + return nil } - -func (m *MsgSetConsumerCommissionRate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProviderAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgConsumerRemovalResponse) 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: MsgConsumerRemovalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConsumerRemovalResponse: 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 + } } - l = m.Rate.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} -func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { +func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1457,15 +4747,15 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAssignConsumerKey: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeRewardDenoms: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAssignConsumerKey: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeRewardDenoms: 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) + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToAdd", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1493,11 +4783,11 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.DenomsToAdd = append(m.DenomsToAdd, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToRemove", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1525,11 +4815,11 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.DenomsToRemove = append(m.DenomsToRemove, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1557,7 +4847,7 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ConsumerKey = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1580,7 +4870,7 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAssignConsumerKeyResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChangeRewardDenomsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1603,10 +4893,10 @@ func (m *MsgAssignConsumerKeyResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAssignConsumerKeyResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAssignConsumerKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1630,7 +4920,7 @@ func (m *MsgAssignConsumerKeyResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { +func (m *MsgOptIn) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1653,15 +4943,15 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviour: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptIn: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptIn: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1689,13 +4979,13 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Submitter = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Misbehaviour", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1705,27 +4995,87 @@ func (m *MsgSubmitConsumerMisbehaviour) 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 ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Misbehaviour == nil { - m.Misbehaviour = &_07_tendermint.Misbehaviour{} + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", wireType) } - if err := m.Misbehaviour.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + 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.ConsumerKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1748,7 +5098,7 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitConsumerMisbehaviourResponse) Unmarshal(dAtA []byte) error { +func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1771,10 +5121,10 @@ func (m *MsgSubmitConsumerMisbehaviourResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviourResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptInResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitConsumerMisbehaviourResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptInResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1798,7 +5148,7 @@ func (m *MsgSubmitConsumerMisbehaviourResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { +func (m *MsgOptOut) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1821,15 +5171,15 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitConsumerDoubleVoting: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptOut: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitConsumerDoubleVoting: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptOut: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1857,13 +5207,13 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Submitter = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DuplicateVoteEvidence", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1873,33 +5223,29 @@ func (m *MsgSubmitConsumerDoubleVoting) 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 ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.DuplicateVoteEvidence == nil { - m.DuplicateVoteEvidence = &types.DuplicateVoteEvidence{} - } - if err := m.DuplicateVoteEvidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InfractionBlockHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1909,27 +5255,23 @@ func (m *MsgSubmitConsumerDoubleVoting) 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 ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if m.InfractionBlockHeader == nil { - m.InfractionBlockHeader = &_07_tendermint.Header{} - } - if err := m.InfractionBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1952,7 +5294,7 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitConsumerDoubleVotingResponse) Unmarshal(dAtA []byte) error { +func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1975,10 +5317,10 @@ func (m *MsgSubmitConsumerDoubleVotingResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitConsumerDoubleVotingResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptOutResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitConsumerDoubleVotingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2002,7 +5344,7 @@ func (m *MsgSubmitConsumerDoubleVotingResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptIn) Unmarshal(dAtA []byte) error { +func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2025,15 +5367,15 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptIn: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptIn: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: 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) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2061,11 +5403,11 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2093,11 +5435,11 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2125,7 +5467,9 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ConsumerKey = string(dAtA[iNdEx:postIndex]) + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -2148,7 +5492,7 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2171,10 +5515,10 @@ func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptInResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptInResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2198,7 +5542,7 @@ func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptOut) Unmarshal(dAtA []byte) error { +func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2221,15 +5565,15 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptOut: wiretype end group for non-group") + return fmt.Errorf("proto: MsgConsumerModification: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptOut: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgConsumerModification: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2257,11 +5601,11 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.Title = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2289,111 +5633,100 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + 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 + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgOptOutResponse) 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 + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx } - if iNdEx >= l { + if postIndex > 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: MsgOptOutResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Top_N", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + m.Top_N = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Top_N |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsPowerCap", wireType) } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSetConsumerCommissionRate) 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 + m.ValidatorsPowerCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorsPowerCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - if iNdEx >= l { - return io.ErrUnexpectedEOF + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSetCap", wireType) } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.ValidatorSetCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorSetCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Allowlist", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2421,11 +5754,11 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.Allowlist = append(m.Allowlist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 2: + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denylist", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2453,11 +5786,11 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 3: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2485,9 +5818,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2510,7 +5841,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { +func (m *MsgConsumerModificationResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2533,10 +5864,10 @@ func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgConsumerModificationResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgConsumerModificationResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index f1c543405e..fbfbd61111 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -4,22 +4,20 @@ import ( context "context" "time" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" "cosmossdk.io/math" - + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - auth "github.com/cosmos/cosmos-sdk/x/auth/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + abci "github.com/cometbft/cometbft/abci/types" ) @@ -27,48 +25,48 @@ import ( // of the provider validator set. This version of the interchain-security protocol will mirror the provider chain's changes // so we do not need a registry module between the staking module and CCV. type StakingKeeper interface { - GetValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate - UnbondingCanComplete(ctx sdk.Context, id uint64) error - UnbondingTime(ctx sdk.Context) time.Duration - GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool) - GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) (power int64) - Jail(sdk.Context, sdk.ConsAddress) // jail a validator - Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) math.Int - SlashWithInfractionReason(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec, stakingtypes.Infraction) math.Int - SlashUnbondingDelegation(sdk.Context, stakingtypes.UnbondingDelegation, int64, sdk.Dec) math.Int - SlashRedelegation(sdk.Context, stakingtypes.Validator, stakingtypes.Redelegation, int64, sdk.Dec) math.Int - Unjail(ctx sdk.Context, addr sdk.ConsAddress) - GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) - IterateLastValidatorPowers(ctx sdk.Context, cb func(addr sdk.ValAddress, power int64) (stop bool)) - PowerReduction(ctx sdk.Context) math.Int - PutUnbondingOnHold(ctx sdk.Context, id uint64) error - GetUnbondingDelegationByUnbondingID(ctx sdk.Context, id uint64) (ubd stakingtypes.UnbondingDelegation, found bool) - GetRedelegationByUnbondingID(ctx sdk.Context, id uint64) (red stakingtypes.Redelegation, found bool) - GetValidatorByUnbondingID(ctx sdk.Context, id uint64) (val stakingtypes.Validator, found bool) - IterateValidators(ctx sdk.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) - Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI - IsValidatorJailed(ctx sdk.Context, addr sdk.ConsAddress) bool - ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) stakingtypes.ValidatorI - Delegation(ctx sdk.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) stakingtypes.DelegationI - MaxValidators(ctx sdk.Context) uint32 - GetLastTotalPower(ctx sdk.Context) math.Int - BondDenom(ctx sdk.Context) (res string) - GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.ValAddress) (ubds []stakingtypes.UnbondingDelegation) - GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.ValAddress) (reds []stakingtypes.Redelegation) - GetUnbondingType(ctx sdk.Context, id uint64) (unbondingType stakingtypes.UnbondingType, found bool) - MinCommissionRate(ctx sdk.Context) math.LegacyDec + GetValidatorUpdates(ctx context.Context) ([]abci.ValidatorUpdate, error) + UnbondingCanComplete(ctx context.Context, id uint64) error + UnbondingTime(ctx context.Context) (time.Duration, error) + GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, error) + GetLastValidatorPower(ctx context.Context, operator sdk.ValAddress) (int64, error) + Jail(context.Context, sdk.ConsAddress) error // jail a validator + Slash(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec) (math.Int, error) + SlashWithInfractionReason(ctx context.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor math.LegacyDec, infraction stakingtypes.Infraction) (math.Int, error) + SlashUnbondingDelegation(ctx context.Context, unbondingDelegation stakingtypes.UnbondingDelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) + SlashRedelegation(ctx context.Context, srcValidator stakingtypes.Validator, redelegation stakingtypes.Redelegation, infractionHeight int64, slashFactor math.LegacyDec) (math.Int, error) + Unjail(ctx context.Context, addr sdk.ConsAddress) error + GetValidator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.Validator, error) + IterateLastValidatorPowers(ctx context.Context, cb func(addr sdk.ValAddress, power int64) (stop bool)) error + PowerReduction(ctx context.Context) math.Int + PutUnbondingOnHold(ctx context.Context, id uint64) error + IterateValidators(ctx context.Context, f func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error + Validator(ctx context.Context, addr sdk.ValAddress) (stakingtypes.ValidatorI, error) + IsValidatorJailed(ctx context.Context, addr sdk.ConsAddress) (bool, error) + ValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (stakingtypes.ValidatorI, error) + Delegation(ctx context.Context, addr sdk.AccAddress, valAddr sdk.ValAddress) (stakingtypes.DelegationI, error) + MaxValidators(ctx context.Context) (uint32, error) + GetLastTotalPower(ctx context.Context) (math.Int, error) + BondDenom(ctx context.Context) (string, error) + GetUnbondingDelegationsFromValidator(ctx context.Context, valAddr sdk.ValAddress) ([]stakingtypes.UnbondingDelegation, error) + GetRedelegationsFromSrcValidator(ctx context.Context, valAddr sdk.ValAddress) ([]stakingtypes.Redelegation, error) + GetUnbondingType(ctx context.Context, id uint64) (stakingtypes.UnbondingType, error) + MinCommissionRate(ctx context.Context) (math.LegacyDec, error) + GetUnbondingDelegationByUnbondingID(ctx context.Context, id uint64) (stakingtypes.UnbondingDelegation, error) + GetRedelegationByUnbondingID(ctx context.Context, id uint64) (stakingtypes.Redelegation, error) + GetValidatorByUnbondingID(ctx context.Context, id uint64) (stakingtypes.Validator, error) } // SlashingKeeper defines the contract expected to perform ccv slashing type SlashingKeeper interface { - JailUntil(sdk.Context, sdk.ConsAddress, time.Time) // called from provider keeper only - GetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress) (info slashingtypes.ValidatorSigningInfo, found bool) - SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) - DowntimeJailDuration(sdk.Context) time.Duration - SlashFractionDowntime(sdk.Context) sdk.Dec - SlashFractionDoubleSign(ctx sdk.Context) (res sdk.Dec) - Tombstone(sdk.Context, sdk.ConsAddress) - IsTombstoned(sdk.Context, sdk.ConsAddress) bool + JailUntil(context.Context, sdk.ConsAddress, time.Time) error // called from provider keeper only + GetValidatorSigningInfo(context.Context, sdk.ConsAddress) (slashingtypes.ValidatorSigningInfo, error) + SetValidatorSigningInfo(context.Context, sdk.ConsAddress, slashingtypes.ValidatorSigningInfo) error + DowntimeJailDuration(context.Context) (time.Duration, error) + SlashFractionDowntime(context.Context) (math.LegacyDec, error) + SlashFractionDoubleSign(context.Context) (math.LegacyDec, error) + Tombstone(context.Context, sdk.ConsAddress) error + IsTombstoned(context.Context, sdk.ConsAddress) bool } // ChannelKeeper defines the expected IBC channel keeper @@ -105,35 +103,33 @@ type ClientKeeper interface { GetClientState(ctx sdk.Context, clientID string) (ibcexported.ClientState, bool) GetLatestClientConsensusState(ctx sdk.Context, clientID string) (ibcexported.ConsensusState, bool) GetSelfConsensusState(ctx sdk.Context, height ibcexported.Height) (ibcexported.ConsensusState, error) - ClientStore(ctx sdk.Context, clientID string) sdk.KVStore + ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore SetClientState(ctx sdk.Context, clientID string, clientState ibcexported.ClientState) GetClientConsensusState(ctx sdk.Context, clientID string, height ibcexported.Height) (ibcexported.ConsensusState, bool) } // DistributionKeeper defines the expected interface of the distribution keeper type DistributionKeeper interface { - FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error - GetFeePool(ctx sdk.Context) distrtypes.FeePool - SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool) - GetCommunityTax(ctx sdk.Context) math.LegacyDec - AllocateTokensToValidator(ctx sdk.Context, validator stakingtypes.ValidatorI, reward sdk.DecCoins) + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error + GetCommunityTax(ctx context.Context) (math.LegacyDec, error) + AllocateTokensToValidator(ctx context.Context, validator stakingtypes.ValidatorI, reward sdk.DecCoins) error } // ConsumerHooks event hooks for newly bonded cross-chain validators type ConsumerHooks interface { - AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddresses sdk.ValAddress) error + AfterValidatorBonded(ctx context.Context, consAddr sdk.ConsAddress, valAddresses sdk.ValAddress) error } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins + SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error } // AccountKeeper defines the expected account keeper used for simulations type AccountKeeper interface { - GetModuleAccount(ctx sdk.Context, name string) auth.ModuleAccountI + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI } // IBCTransferKeeper defines the expected interface needed for distribution transfer @@ -156,7 +152,3 @@ type ScopedKeeper interface { AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error } - -type GovKeeper interface { - GetProposal(ctx sdk.Context, proposalID uint64) (v1.Proposal, bool) -} diff --git a/x/ccv/types/genesis.go b/x/ccv/types/genesis.go index 4189c2ec51..a7534b1289 100644 --- a/x/ccv/types/genesis.go +++ b/x/ccv/types/genesis.go @@ -1,7 +1,7 @@ package types import ( - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" diff --git a/x/ccv/types/params.go b/x/ccv/types/params.go index 5759ce28f9..475389d7df 100644 --- a/x/ccv/types/params.go +++ b/x/ccv/types/params.go @@ -4,6 +4,7 @@ import ( fmt "fmt" time "time" + "cosmossdk.io/math" 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" @@ -26,6 +27,9 @@ const ( // decimal number. For example "0.75" would represent 75%. DefaultConsumerRedistributeFrac = "0.75" + // By default, the bottom 5% of the validator set can opt out of validating consumer chains + DefaultSoftOptOutThreshold = "0.05" + // Default number of historical info entries to persist in store. // We use the same default as the staking module, but use a signed integer // so that negative values can be caught during parameter validation in a readable way, @@ -51,11 +55,20 @@ var ( KeyConsumerRedistributionFrac = []byte("ConsumerRedistributionFraction") KeyHistoricalEntries = []byte("HistoricalEntries") KeyConsumerUnbondingPeriod = []byte("UnbondingPeriod") + KeySoftOptOutThreshold = []byte("SoftOptOutThreshold") KeyRewardDenoms = []byte("RewardDenoms") KeyProviderRewardDenoms = []byte("ProviderRewardDenoms") KeyRetryDelayPeriod = []byte("RetryDelayPeriod") ) +// helper interface +// sdk::paramtypes.ParamSpace implicitly implements this interface because it +// implements the Get(ctx sdk.Context, key []byte, ptr interface{}) +// since only Get(...) is needed to migrate params we can ignore the other methods on paramtypes.ParamSpace. +type LegacyParamSubspace interface { + Get(ctx sdktypes.Context, key []byte, ptr interface{}) +} + // ParamKeyTable type declaration for parameters func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&ConsumerParams{}) @@ -66,7 +79,7 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, distributionTransmissionChannel, providerFeePoolAddrStr string, ccvTimeoutPeriod, transferTimeoutPeriod time.Duration, consumerRedistributionFraction string, historicalEntries int64, - consumerUnbondingPeriod time.Duration, + consumerUnbondingPeriod time.Duration, softOptOutThreshold string, rewardDenoms, providerRewardDenoms []string, retryDelayPeriod time.Duration, ) ConsumerParams { return ConsumerParams{ @@ -79,11 +92,10 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, ConsumerRedistributionFraction: consumerRedistributionFraction, HistoricalEntries: historicalEntries, UnbondingPeriod: consumerUnbondingPeriod, - // DEPRECATED but setting here to 0 (i.e., disabled) for older versions of interchain-security - SoftOptOutThreshold: "0", - RewardDenoms: rewardDenoms, - ProviderRewardDenoms: providerRewardDenoms, - RetryDelayPeriod: retryDelayPeriod, + SoftOptOutThreshold: softOptOutThreshold, + RewardDenoms: rewardDenoms, + ProviderRewardDenoms: providerRewardDenoms, + RetryDelayPeriod: retryDelayPeriod, } } @@ -101,6 +113,7 @@ func DefaultParams() ConsumerParams { DefaultConsumerRedistributeFrac, DefaultHistoricalEntries, DefaultConsumerUnbondingPeriod, + DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, DefaultRetryDelayPeriod, @@ -186,6 +199,24 @@ func ValidateProviderFeePoolAddrStr(i interface{}) error { return nil } +func ValidateSoftOptOutThreshold(i interface{}) error { + str, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + dec, err := math.LegacyNewDecFromStr(str) + if err != nil { + return err + } + if dec.IsNegative() { + return fmt.Errorf("soft opt out threshold cannot be negative, got %s", str) + } + if !dec.Sub(math.LegacyMustNewDecFromStr("0.2")).IsNegative() { + return fmt.Errorf("soft opt out threshold cannot be greater than 0.2, got %s", str) + } + return nil +} + func ValidateDenoms(i interface{}) error { v, ok := i.([]string) if !ok { @@ -196,7 +227,7 @@ func ValidateDenoms(i interface{}) error { for _, denom := range v { coin := sdktypes.Coin{ Denom: denom, - Amount: sdktypes.NewInt(0), + Amount: math.NewInt(0), } if err := coin.Validate(); err != nil { diff --git a/x/ccv/types/shared_consumer.pb.go b/x/ccv/types/shared_consumer.pb.go index 92d7105d41..92d0d82e6a 100644 --- a/x/ccv/types/shared_consumer.pb.go +++ b/x/ccv/types/shared_consumer.pb.go @@ -9,7 +9,7 @@ import ( _ "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" + _07_tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" @@ -342,57 +342,57 @@ func init() { var fileDescriptor_d0a8be0efc64dfbc = []byte{ // 817 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x41, 0x6f, 0xe4, 0x34, - 0x14, 0x6e, 0x3a, 0x4b, 0x77, 0xea, 0x69, 0xb7, 0x8b, 0x29, 0x4b, 0xe8, 0x4a, 0xd3, 0x6c, 0xe1, - 0x30, 0x02, 0x6d, 0x42, 0x4b, 0x25, 0x24, 0x6e, 0xb4, 0x65, 0x59, 0xf6, 0xd0, 0xce, 0xa6, 0x65, - 0x91, 0xe0, 0x60, 0x39, 0xf6, 0x9b, 0x89, 0x45, 0x62, 0x47, 0xb6, 0x93, 0xd2, 0x5f, 0xc0, 0x95, - 0x23, 0x3f, 0x69, 0xb9, 0xed, 0x91, 0x13, 0xa0, 0xf6, 0x8f, 0xa0, 0x38, 0x49, 0x9b, 0x41, 0x14, - 0xca, 0xcd, 0xcf, 0xef, 0xfb, 0xbe, 0xe4, 0x7b, 0xf6, 0x7b, 0x46, 0x9f, 0x08, 0x69, 0x41, 0xb3, - 0x94, 0x0a, 0x49, 0x0c, 0xb0, 0x52, 0x0b, 0x7b, 0x11, 0x31, 0x56, 0x45, 0xd5, 0x6e, 0x64, 0x52, - 0xaa, 0x81, 0x13, 0xa6, 0xa4, 0x29, 0x73, 0xd0, 0x61, 0xa1, 0x95, 0x55, 0x78, 0xeb, 0x1f, 0x18, - 0x21, 0x63, 0x55, 0x58, 0xed, 0x6e, 0x3d, 0xb6, 0x20, 0x39, 0xe8, 0x5c, 0x48, 0x1b, 0xd1, 0x84, - 0x89, 0xc8, 0x5e, 0x14, 0x60, 0x1a, 0xe2, 0x56, 0x24, 0x12, 0x16, 0x65, 0x62, 0x9e, 0x5a, 0x96, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x41, 0x73, 0xdc, 0x34, + 0x14, 0x8e, 0xb3, 0x25, 0xdd, 0x68, 0x93, 0xa6, 0x88, 0x50, 0x4c, 0x3a, 0xb3, 0x71, 0x03, 0x87, + 0x1d, 0x98, 0xda, 0x24, 0x94, 0x61, 0x86, 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, 0x01, 0x93, 0xfc, 0x11, 0xc6, 0xb2, 0x9d, 0x78, 0x19, 0x02, + 0xe9, 0x4d, 0x4f, 0xef, 0xfb, 0x3e, 0xfb, 0x7b, 0xd2, 0x7b, 0x42, 0x9f, 0x08, 0x69, 0x41, 0xb3, + 0x94, 0x0a, 0x49, 0x0c, 0xb0, 0x52, 0x0b, 0x7b, 0x1e, 0x31, 0x56, 0x45, 0xd5, 0x6e, 0x64, 0x52, + 0xaa, 0x81, 0x13, 0xa6, 0xa4, 0x29, 0x73, 0xd0, 0x61, 0xa1, 0x95, 0x55, 0x78, 0xeb, 0x5f, 0x18, + 0x21, 0x63, 0x55, 0x58, 0xed, 0x6e, 0x3d, 0xb4, 0x20, 0x39, 0xe8, 0x5c, 0x48, 0x1b, 0xd1, 0x84, + 0x89, 0xc8, 0x9e, 0x17, 0x60, 0x1a, 0xe2, 0x56, 0x24, 0x12, 0x16, 0x65, 0x62, 0x9e, 0x5a, 0x96, 0x09, 0x90, 0xd6, 0x44, 0x3d, 0x74, 0xb5, 0xdb, 0x8b, 0x5a, 0xc2, 0x78, 0xae, 0xd4, 0x3c, 0x83, 0xc8, 0x45, 0x49, 0x39, 0x8b, 0x78, 0xa9, 0xa9, 0x15, 0x4a, 0xb6, 0xf9, 0xcd, 0xb9, 0x9a, 0x2b, - 0xb7, 0x8c, 0xea, 0x55, 0xb3, 0xbb, 0x73, 0xb5, 0x82, 0x1e, 0x1c, 0xb6, 0xbf, 0x3c, 0xa5, 0x9a, - 0xe6, 0x06, 0xfb, 0xe8, 0x3e, 0x48, 0x9a, 0x64, 0xc0, 0x7d, 0x2f, 0xf0, 0x26, 0xc3, 0xb8, 0x0b, - 0xf1, 0x09, 0xfa, 0x30, 0xc9, 0x14, 0xfb, 0xc1, 0x90, 0x02, 0x34, 0xe1, 0xc2, 0x58, 0x2d, 0x92, + 0xb7, 0x8c, 0xea, 0x55, 0xb3, 0xbb, 0x73, 0xb9, 0x82, 0xee, 0x1d, 0xb4, 0xbf, 0x3c, 0xa5, 0x9a, + 0xe6, 0x06, 0xfb, 0xe8, 0x2e, 0x48, 0x9a, 0x64, 0xc0, 0x7d, 0x2f, 0xf0, 0x26, 0xc3, 0xb8, 0x0b, + 0xf1, 0x31, 0xfa, 0x30, 0xc9, 0x14, 0xfb, 0xd1, 0x90, 0x02, 0x34, 0xe1, 0xc2, 0x58, 0x2d, 0x92, 0xb2, 0xfe, 0x06, 0xb1, 0x9a, 0x4a, 0x93, 0x0b, 0x63, 0x84, 0x92, 0xfe, 0x72, 0xe0, 0x4d, 0x06, - 0xf1, 0x93, 0x06, 0x3b, 0x05, 0x7d, 0xd4, 0x43, 0x9e, 0xf5, 0x80, 0xf8, 0x05, 0x7a, 0x72, 0xab, - 0x0a, 0x61, 0x29, 0x95, 0x12, 0x32, 0x7f, 0x10, 0x78, 0x93, 0xd5, 0x78, 0x9b, 0xdf, 0x22, 0x72, - 0xd8, 0xc0, 0xf0, 0xe7, 0x68, 0xab, 0xd0, 0xaa, 0x12, 0x1c, 0x34, 0x99, 0x01, 0x90, 0x42, 0xa9, - 0x8c, 0x50, 0xce, 0x35, 0x31, 0x56, 0xfb, 0xf7, 0x9c, 0xc8, 0xa3, 0x0e, 0xf1, 0x0c, 0x60, 0xaa, - 0x54, 0xf6, 0x05, 0xe7, 0xfa, 0xd4, 0x6a, 0xfc, 0x12, 0x61, 0xc6, 0x2a, 0x62, 0x45, 0x0e, 0xaa, + 0xf1, 0xa3, 0x06, 0x3b, 0x05, 0x7d, 0xd8, 0x43, 0x9e, 0xf6, 0x80, 0xf8, 0x39, 0x7a, 0x74, 0xa3, + 0x0a, 0x61, 0x29, 0x95, 0x12, 0x32, 0x7f, 0x10, 0x78, 0x93, 0xd5, 0x78, 0x9b, 0xdf, 0x20, 0x72, + 0xd0, 0xc0, 0xf0, 0x17, 0x68, 0xab, 0xd0, 0xaa, 0x12, 0x1c, 0x34, 0x99, 0x01, 0x90, 0x42, 0xa9, + 0x8c, 0x50, 0xce, 0x35, 0x31, 0x56, 0xfb, 0x77, 0x9c, 0xc8, 0x83, 0x0e, 0xf1, 0x14, 0x60, 0xaa, + 0x54, 0xf6, 0x25, 0xe7, 0xfa, 0xc4, 0x6a, 0xfc, 0x02, 0x61, 0xc6, 0x2a, 0x62, 0x45, 0x0e, 0xaa, 0xb4, 0xb5, 0x3b, 0xa1, 0xb8, 0xff, 0x56, 0xe0, 0x4d, 0x46, 0x7b, 0xef, 0x87, 0x4d, 0x61, 0xc3, - 0xae, 0xb0, 0xe1, 0x51, 0x5b, 0xd8, 0x83, 0xe1, 0xeb, 0xdf, 0xb7, 0x97, 0x7e, 0xf9, 0x63, 0xdb, - 0x8b, 0x1f, 0x32, 0x56, 0x9d, 0x35, 0xec, 0xa9, 0x23, 0xe3, 0xef, 0xd1, 0x7b, 0xce, 0xcd, 0x0c, - 0xf4, 0xdf, 0x75, 0x57, 0xee, 0xae, 0xfb, 0x6e, 0xa7, 0xb1, 0x28, 0xfe, 0x1c, 0x05, 0xdd, 0x3d, - 0x23, 0x1a, 0x16, 0x4a, 0x38, 0xd3, 0x94, 0xd5, 0x0b, 0xff, 0xbe, 0x73, 0x3c, 0xee, 0x70, 0xf1, - 0x02, 0xec, 0x59, 0x8b, 0xc2, 0x4f, 0x11, 0x4e, 0x85, 0xb1, 0x4a, 0x0b, 0x46, 0x33, 0x02, 0xd2, - 0x6a, 0x01, 0xc6, 0x1f, 0xba, 0x03, 0x7c, 0xfb, 0x26, 0xf3, 0x65, 0x93, 0xc0, 0xc7, 0xe8, 0x61, - 0x29, 0x13, 0x25, 0xb9, 0x90, 0xf3, 0xce, 0xce, 0xea, 0xdd, 0xed, 0x6c, 0x5c, 0x93, 0x5b, 0x23, - 0x9f, 0xa1, 0x47, 0x46, 0xcd, 0x2c, 0x51, 0x85, 0x25, 0x75, 0x85, 0x6c, 0xaa, 0xc1, 0xa4, 0x2a, - 0xe3, 0x3e, 0xaa, 0x7f, 0xff, 0x60, 0xd9, 0xf7, 0xe2, 0x77, 0x6a, 0xc4, 0x49, 0x61, 0x4f, 0x4a, - 0x7b, 0xd6, 0xa5, 0xf1, 0x07, 0x68, 0x5d, 0xc3, 0x39, 0xd5, 0x9c, 0x70, 0x90, 0x2a, 0x37, 0xfe, - 0x28, 0x18, 0x4c, 0x56, 0xe3, 0xb5, 0x66, 0xf3, 0xc8, 0xed, 0xe1, 0x7d, 0x74, 0x7d, 0xe0, 0x64, - 0x11, 0xbd, 0xe6, 0xd0, 0x9b, 0x5d, 0x36, 0xee, 0xb3, 0x5e, 0x22, 0xac, 0xc1, 0xea, 0x0b, 0xc2, - 0x21, 0xa3, 0x17, 0x9d, 0xcb, 0xf5, 0xff, 0x71, 0x19, 0x1c, 0xfd, 0xa8, 0x66, 0x37, 0x36, 0x77, - 0x7e, 0xf5, 0xd0, 0x66, 0xd7, 0x65, 0x5f, 0x81, 0x04, 0x23, 0xcc, 0xa9, 0xa5, 0x16, 0xf0, 0x73, - 0xb4, 0x52, 0xb8, 0xae, 0x73, 0xad, 0x36, 0xda, 0xfb, 0x28, 0xbc, 0x7d, 0x5e, 0x84, 0x8b, 0x7d, - 0x7a, 0x70, 0xaf, 0xfe, 0x60, 0xdc, 0xf2, 0xf1, 0x0b, 0x34, 0xec, 0xdc, 0xb8, 0xfe, 0x1b, 0xed, - 0x4d, 0xfe, 0x4d, 0x6b, 0xda, 0x62, 0xbf, 0x96, 0x33, 0xd5, 0x2a, 0x5d, 0xf3, 0xf1, 0x63, 0xb4, - 0x2a, 0xe1, 0x9c, 0x38, 0xa6, 0x6b, 0xbf, 0x61, 0x3c, 0x94, 0x70, 0x7e, 0x58, 0xc7, 0x3b, 0x3f, - 0x2d, 0xa3, 0xb5, 0x3e, 0x1b, 0x1f, 0xa3, 0xb5, 0x66, 0x44, 0x11, 0x53, 0x7b, 0x6a, 0x9d, 0x7c, + 0xae, 0xb0, 0xe1, 0x61, 0x5b, 0xd8, 0xfd, 0xe1, 0xab, 0x3f, 0xb6, 0x97, 0x7e, 0xfd, 0x73, 0xdb, + 0x8b, 0xef, 0x33, 0x56, 0x9d, 0x36, 0xec, 0xa9, 0x23, 0xe3, 0x1f, 0xd0, 0x7b, 0xce, 0xcd, 0x0c, + 0xf4, 0x3f, 0x75, 0x57, 0x6e, 0xaf, 0xfb, 0x6e, 0xa7, 0xb1, 0x28, 0xfe, 0x0c, 0x05, 0xdd, 0x3d, + 0x23, 0x1a, 0x16, 0x4a, 0x38, 0xd3, 0x94, 0xd5, 0x0b, 0xff, 0xae, 0x73, 0x3c, 0xee, 0x70, 0xf1, + 0x02, 0xec, 0x69, 0x8b, 0xc2, 0x8f, 0x11, 0x4e, 0x85, 0xb1, 0x4a, 0x0b, 0x46, 0x33, 0x02, 0xd2, + 0x6a, 0x01, 0xc6, 0x1f, 0xba, 0x03, 0x7c, 0xfb, 0x3a, 0xf3, 0x55, 0x93, 0xc0, 0x47, 0xe8, 0x7e, + 0x29, 0x13, 0x25, 0xb9, 0x90, 0xf3, 0xce, 0xce, 0xea, 0xed, 0xed, 0x6c, 0x5c, 0x91, 0x5b, 0x23, + 0x9f, 0xa3, 0x07, 0x46, 0xcd, 0x2c, 0x51, 0x85, 0x25, 0x75, 0x85, 0x6c, 0xaa, 0xc1, 0xa4, 0x2a, + 0xe3, 0x3e, 0xaa, 0x7f, 0x7f, 0x7f, 0xd9, 0xf7, 0xe2, 0x77, 0x6a, 0xc4, 0x71, 0x61, 0x8f, 0x4b, + 0x7b, 0xda, 0xa5, 0xf1, 0x07, 0x68, 0x5d, 0xc3, 0x19, 0xd5, 0x9c, 0x70, 0x90, 0x2a, 0x37, 0xfe, + 0x28, 0x18, 0x4c, 0x56, 0xe3, 0xb5, 0x66, 0xf3, 0xd0, 0xed, 0xe1, 0x27, 0xe8, 0xea, 0xc0, 0xc9, + 0x22, 0x7a, 0xcd, 0xa1, 0x37, 0xbb, 0x6c, 0xdc, 0x67, 0xbd, 0x40, 0x58, 0x83, 0xd5, 0xe7, 0x84, + 0x43, 0x46, 0xcf, 0x3b, 0x97, 0xeb, 0x6f, 0x70, 0x19, 0x1c, 0xfd, 0xb0, 0x66, 0x37, 0x36, 0x77, + 0x7e, 0xf3, 0xd0, 0x66, 0xd7, 0x65, 0x5f, 0x83, 0x04, 0x23, 0xcc, 0x89, 0xa5, 0x16, 0xf0, 0x33, + 0xb4, 0x52, 0xb8, 0xae, 0x73, 0xad, 0x36, 0xda, 0xfb, 0x28, 0xbc, 0x79, 0x5e, 0x84, 0x8b, 0x7d, + 0xba, 0x7f, 0xa7, 0xfe, 0x60, 0xdc, 0xf2, 0xf1, 0x73, 0x34, 0xec, 0xdc, 0xb8, 0xfe, 0x1b, 0xed, + 0x4d, 0xfe, 0x4b, 0x6b, 0xda, 0x62, 0xbf, 0x91, 0x33, 0xd5, 0x2a, 0x5d, 0xf1, 0xf1, 0x43, 0xb4, + 0x2a, 0xe1, 0x8c, 0x38, 0xa6, 0x6b, 0xbf, 0x61, 0x3c, 0x94, 0x70, 0x76, 0x50, 0xc7, 0x3b, 0x3f, + 0x2f, 0xa3, 0xb5, 0x3e, 0x1b, 0x1f, 0xa1, 0xb5, 0x66, 0x44, 0x11, 0x53, 0x7b, 0x6a, 0x9d, 0x7c, 0x1c, 0x8a, 0x84, 0x85, 0xfd, 0x01, 0x16, 0xf6, 0x46, 0x56, 0xed, 0xc6, 0xed, 0xba, 0x32, 0xc4, - 0x23, 0x76, 0x13, 0xe0, 0x6f, 0xd1, 0x46, 0x7d, 0x69, 0x41, 0x9a, 0xd2, 0xb4, 0x92, 0x8d, 0xa1, - 0xf0, 0x3f, 0x25, 0x3b, 0x5a, 0xa3, 0xfa, 0x80, 0x2d, 0xc4, 0xf8, 0x18, 0x6d, 0x08, 0x29, 0xac, + 0x23, 0x76, 0x1d, 0xe0, 0xef, 0xd0, 0x46, 0x7d, 0x69, 0x41, 0x9a, 0xd2, 0xb4, 0x92, 0x8d, 0xa1, + 0xf0, 0x7f, 0x25, 0x3b, 0x5a, 0xa3, 0x7a, 0x8f, 0x2d, 0xc4, 0xf8, 0x08, 0x6d, 0x08, 0x29, 0xac, 0xa0, 0x19, 0xa9, 0x68, 0x46, 0x0c, 0x58, 0x7f, 0x10, 0x0c, 0x26, 0xa3, 0xbd, 0xa0, 0xaf, 0x53, - 0x4f, 0xe2, 0xf0, 0x15, 0xcd, 0x04, 0xa7, 0x56, 0xe9, 0x6f, 0x0a, 0x4e, 0x2d, 0xb4, 0x15, 0x5a, - 0x6f, 0xe9, 0xaf, 0x68, 0x76, 0x0a, 0xf6, 0xe0, 0xf8, 0xf5, 0xe5, 0xd8, 0x7b, 0x73, 0x39, 0xf6, - 0xfe, 0xbc, 0x1c, 0x7b, 0x3f, 0x5f, 0x8d, 0x97, 0xde, 0x5c, 0x8d, 0x97, 0x7e, 0xbb, 0x1a, 0x2f, - 0x7d, 0xb7, 0x3f, 0x17, 0x36, 0x2d, 0x93, 0x90, 0xa9, 0x3c, 0x62, 0xca, 0xe4, 0xca, 0x44, 0x37, - 0x67, 0xf1, 0xf4, 0xfa, 0xe5, 0xa8, 0xf6, 0xa3, 0x1f, 0xdd, 0xf3, 0xe1, 0x06, 0x7f, 0xb2, 0xe2, - 0x2e, 0xd5, 0xa7, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x67, 0x6a, 0xf6, 0x66, 0x06, 0x00, + 0x4f, 0xe2, 0xf0, 0x25, 0xcd, 0x04, 0xa7, 0x56, 0xe9, 0x6f, 0x0b, 0x4e, 0x2d, 0xb4, 0x15, 0x5a, + 0x6f, 0xe9, 0x2f, 0x69, 0x76, 0x02, 0x76, 0xff, 0xe8, 0xd5, 0xc5, 0xd8, 0x7b, 0x7d, 0x31, 0xf6, + 0xfe, 0xba, 0x18, 0x7b, 0xbf, 0x5c, 0x8e, 0x97, 0x5e, 0x5f, 0x8e, 0x97, 0x7e, 0xbf, 0x1c, 0x2f, + 0x7d, 0xff, 0x64, 0x2e, 0x6c, 0x5a, 0x26, 0x21, 0x53, 0x79, 0xc4, 0x94, 0xc9, 0x95, 0x89, 0xae, + 0xcf, 0xe2, 0xf1, 0xd5, 0xcb, 0x51, 0x7d, 0x16, 0xfd, 0xe4, 0x9e, 0x0f, 0x37, 0xf8, 0x93, 0x15, + 0x77, 0xa9, 0x3e, 0xfd, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x00, 0xe4, 0xb0, 0x69, 0x66, 0x06, 0x00, 0x00, } diff --git a/x/ccv/types/shared_params.go b/x/ccv/types/shared_params.go index 566737c0b9..fa2e28c81c 100644 --- a/x/ccv/types/shared_params.go +++ b/x/ccv/types/shared_params.go @@ -4,7 +4,8 @@ import ( fmt "fmt" "time" - ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "cosmossdk.io/math" + ibchost "github.com/cosmos/ibc-go/v8/modules/core/24-host" sdktypes "github.com/cosmos/cosmos-sdk/types" ) @@ -90,21 +91,21 @@ func ValidateStringFraction(i interface{}) error { if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - dec, err := sdktypes.NewDecFromStr(str) + dec, err := math.LegacyNewDecFromStr(str) if err != nil { return err } if dec.IsNegative() { return fmt.Errorf("param cannot be negative, got %s", str) } - if dec.Sub(sdktypes.NewDec(1)).IsPositive() { + if dec.Sub(math.LegacyNewDec(1)).IsPositive() { return fmt.Errorf("param cannot be greater than 1, got %s", str) } return nil } func CalculateTrustPeriod(unbondingPeriod time.Duration, defaultTrustPeriodFraction string) (time.Duration, error) { - trustDec, err := sdktypes.NewDecFromStr(defaultTrustPeriodFraction) + trustDec, err := math.LegacyNewDecFromStr(defaultTrustPeriodFraction) if err != nil { return time.Duration(0), err } diff --git a/x/ccv/types/utils.go b/x/ccv/types/utils.go index 236fee21cf..cb174168e8 100644 --- a/x/ccv/types/utils.go +++ b/x/ccv/types/utils.go @@ -7,11 +7,11 @@ import ( "strings" "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" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v8/modules/core/24-host" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -19,7 +19,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" ) @@ -126,18 +125,25 @@ func GetConsAddrFromBech32(bech32str string) (sdk.ConsAddress, error) { return sdk.ConsAddress(addr), nil } -func GetLastBondedValidatorsUtil(ctx sdk.Context, stakingKeeper StakingKeeper, logger log.Logger) []stakingtypes.Validator { - maxVals := stakingKeeper.MaxValidators(ctx) +func GetLastBondedValidatorsUtil(ctx sdk.Context, stakingKeeper StakingKeeper, logger log.Logger) ([]stakingtypes.Validator, error) { + maxVals, err := stakingKeeper.MaxValidators(ctx) + if err != nil { + return nil, err + } lastPowers := make([]stakingtypes.LastValidatorPower, maxVals) i := 0 - stakingKeeper.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) { + err = stakingKeeper.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) { lastPowers[i] = stakingtypes.LastValidatorPower{Address: addr.String(), Power: power} i++ return i >= int(maxVals) // stop iteration if true }) + if err != nil { + return nil, err + } + // truncate the lastPowers lastPowers = lastPowers[:i] @@ -150,14 +156,14 @@ func GetLastBondedValidatorsUtil(ctx sdk.Context, stakingKeeper StakingKeeper, l continue } - val, found := stakingKeeper.GetValidator(ctx, addr) - if !found { - logger.Error("Validator not found", "address", addr.String()) + val, err := stakingKeeper.GetValidator(ctx, addr) + if err != nil { + logger.Error(err.Error(), addr.String()) continue } // gather all the bonded validators in order to construct the consumer validator set for consumer chain `chainID` bondedValidators[index] = val } - return bondedValidators + return bondedValidators, nil } diff --git a/x/ccv/types/utils_test.go b/x/ccv/types/utils_test.go index f7ecd83197..081570abf2 100644 --- a/x/ccv/types/utils_test.go +++ b/x/ccv/types/utils_test.go @@ -3,21 +3,21 @@ package types_test import ( "testing" - ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func TestAccumulateChanges(t *testing.T) { _, testKeys, _ := ibctesting.GenerateKeys(t, 2) - tmPubKey, _ := cryptocodec.ToTmProtoPublicKey(testKeys[0]) - tmPubKey2, _ := cryptocodec.ToTmProtoPublicKey(testKeys[1]) + tmPubKey, _ := cryptocodec.ToCmtProtoPublicKey(testKeys[0]) + tmPubKey2, _ := cryptocodec.ToCmtProtoPublicKey(testKeys[1]) testCases := []struct { name string diff --git a/x/ccv/types/wire.pb.go b/x/ccv/types/wire.pb.go index 1cdeb237a7..a0cdc795c2 100644 --- a/x/ccv/types/wire.pb.go +++ b/x/ccv/types/wire.pb.go @@ -593,60 +593,60 @@ func init() { } 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, 0xda, 0x15, 0x6c, 0xc8, 0x8f, 0x4b, 0x0d, 0xd3, 0x34, 0xb2, 0x93, 0x8c, - 0x86, 0x8d, 0x75, 0x63, 0xdf, 0x26, 0x57, 0x49, 0x7c, 0x2d, 0xdf, 0x1b, 0x0f, 0x79, 0x03, 0x94, - 0x15, 0x2f, 0x90, 0x15, 0x62, 0x31, 0x8f, 0xc1, 0x6e, 0x96, 0x23, 0xb1, 0x99, 0x0d, 0x23, 0xd4, - 0xbe, 0x01, 0x4f, 0x80, 0xec, 0xfc, 0x36, 0x71, 0x2b, 0x8d, 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, 0xe2, 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, - 0xf2, 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, 0xd7, 0xef, 0x9e, 0x70, 0x7f, 0xbf, 0x7b, 0x22, 0x4d, 0xe0, 0x68, - 0xf8, 0xb5, 0xba, 0x43, 0xa4, 0x5a, 0x42, 0x74, 0x1b, 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, 0x17, 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, 0xef, 0xd6, 0xa1, 0x2a, 0x2d, 0x14, - 0x10, 0xb6, 0x14, 0x50, 0xad, 0x35, 0xcd, 0x7b, 0xb4, 0x5c, 0x05, 0x00, 0xfb, 0x57, 0x21, 0x74, - 0x19, 0x26, 0xbe, 0xb4, 0xa7, 0xf0, 0xc5, 0x5c, 0x59, 0xd5, 0xe6, 0xc3, 0xa1, 0x2d, 0x87, 0x61, - 0x31, 0x1c, 0x9a, 0xb9, 0xca, 0xb4, 0x36, 0x50, 0xea, 0x6f, 0x19, 0x20, 0xd6, 0x88, 0x4f, 0xc7, - 0x23, 0x14, 0x6e, 0x34, 0x76, 0x06, 0xf6, 0xe3, 0xc1, 0x48, 0x7a, 0xca, 0x95, 0xcb, 0xda, 0xdd, - 0xd3, 0xa8, 0xed, 0xa2, 0x5b, 0x93, 0x00, 0x59, 0x09, 0x5e, 0x7c, 0x0e, 0x0e, 0xe9, 0x6d, 0xcd, - 0x92, 0x5e, 0xb2, 0xe5, 0x2f, 0xef, 0xa3, 0xdc, 0x92, 0xf9, 0x9c, 0xb3, 0xb6, 0x59, 0xc4, 0x2b, - 0x90, 0x8f, 0xa8, 0xbb, 0xe3, 0x67, 0xa2, 0x42, 0xb6, 0xfc, 0xd5, 0x7d, 0xec, 0x69, 0x73, 0x70, - 0xce, 0x59, 0xa9, 0x7c, 0xd5, 0x07, 0x60, 0xdf, 0x83, 0x0c, 0xaa, 0x5d, 0x70, 0x74, 0x0e, 0x7d, - 0x8f, 0xf6, 0xe1, 0x00, 0x5d, 0x20, 0x06, 0xe3, 0xa0, 0x78, 0x02, 0x1e, 0x05, 0x21, 0x89, 0xb0, - 0x87, 0x42, 0xe7, 0x0a, 0x21, 0x27, 0x20, 0x64, 0xe8, 0x40, 0xcf, 0x9b, 0xcf, 0xc2, 0x81, 0xf5, - 0x70, 0x79, 0x7a, 0x86, 0x50, 0x93, 0x90, 0x61, 0xc5, 0xf3, 0x42, 0x51, 0x02, 0x1f, 0x44, 0x28, - 0xa4, 0xb1, 0x65, 0x99, 0x24, 0x6b, 0xf9, 0xab, 0xbe, 0xca, 0x80, 0xfc, 0xae, 0x9a, 0x9d, 0xd2, - 0xbf, 0xe6, 0xc6, 0x8b, 0xbb, 0xdc, 0x78, 0xfa, 0x1e, 0x6e, 0x74, 0x4a, 0xff, 0x07, 0x3f, 0xfe, - 0xe4, 0xc1, 0xd1, 0x4e, 0x61, 0xff, 0xf1, 0x7b, 0xfc, 0x3e, 0xe5, 0x3d, 0x1e, 0xdf, 0xd7, 0xf9, - 0xfa, 0x4d, 0x26, 0x26, 0x6d, 0xa0, 0x8f, 0x7f, 0xe7, 0xc1, 0xa3, 0x74, 0x2f, 0xc5, 0x6f, 0x80, - 0x52, 0xbb, 0x6c, 0xd8, 0xed, 0x0b, 0xc3, 0x72, 0x9a, 0x95, 0xda, 0x0f, 0x46, 0xcb, 0x69, 0xbd, - 0x68, 0x1a, 0x4e, 0xbb, 0x61, 0x37, 0x8d, 0x9a, 0x79, 0x66, 0x1a, 0x75, 0x81, 0x93, 0x3f, 0x9e, - 0xce, 0x94, 0xa3, 0xb6, 0x4f, 0x03, 0xe4, 0xe2, 0x2b, 0xbc, 0xd4, 0x50, 0xd4, 0x81, 0x9c, 0x0a, - 0xb6, 0x9f, 0x55, 0xec, 0x73, 0x81, 0x97, 0x0f, 0xa7, 0x33, 0x25, 0xbb, 0x21, 0xac, 0x78, 0x02, - 0x3e, 0x49, 0x05, 0xc4, 0xae, 0x09, 0x19, 0x39, 0x3f, 0x9d, 0x29, 0x42, 0x67, 0xcb, 0x29, 0x79, - 0xff, 0xe7, 0x5f, 0x0b, 0xdc, 0xf1, 0x2b, 0x1e, 0xe4, 0x6e, 0xb7, 0x28, 0x9e, 0x82, 0xc7, 0x66, - 0xe3, 0xcc, 0xaa, 0xd4, 0x5a, 0xe6, 0x65, 0x23, 0xad, 0xec, 0x87, 0xd3, 0x99, 0x72, 0xb8, 0x06, - 0x19, 0xa3, 0x80, 0x4d, 0x44, 0x7d, 0x17, 0x55, 0xbf, 0x6c, 0x57, 0x9f, 0x19, 0x8e, 0x6d, 0x7e, - 0xd7, 0x10, 0x78, 0x39, 0x37, 0x9d, 0x29, 0xa0, 0x4e, 0xc6, 0xdd, 0x21, 0xb2, 0x71, 0xcf, 0x17, - 0x8f, 0x81, 0xb4, 0x0b, 0x78, 0xde, 0x68, 0x99, 0x17, 0x86, 0x90, 0x91, 0x3f, 0x9a, 0xce, 0x94, - 0x0f, 0xeb, 0xe4, 0xa5, 0xcf, 0xf0, 0x08, 0xcd, 0x6b, 0xad, 0x36, 0x5e, 0x5f, 0x17, 0xf8, 0x37, - 0xd7, 0x05, 0xfe, 0xaf, 0xeb, 0x02, 0xff, 0xcb, 0x4d, 0x81, 0x7b, 0x73, 0x53, 0xe0, 0xde, 0xde, - 0x14, 0xb8, 0x1f, 0x4f, 0x7b, 0x98, 0xf5, 0xc7, 0x5d, 0xcd, 0x25, 0x23, 0x7d, 0xb1, 0x78, 0xd7, - 0x96, 0x3e, 0x5d, 0xad, 0xf0, 0xe8, 0x54, 0xff, 0x29, 0xd9, 0xe3, 0xc9, 0x42, 0xed, 0x3e, 0x48, - 0x36, 0xea, 0xc9, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4f, 0x03, 0x77, 0x3e, 0xef, 0x07, 0x00, - 0x00, + // 834 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x26, 0x65, 0x23, 0xad, 0x57, 0x85, 0x4c, 0x33, 0x6a, 0xc0, 0x32, 0xad, 0x42, 0x10, 0x2d, + 0x20, 0xb8, 0x08, 0x59, 0xc9, 0xe9, 0xa5, 0xbd, 0x54, 0x3f, 0x74, 0xcd, 0x36, 0x96, 0x05, 0x52, + 0x52, 0x90, 0x5e, 0x88, 0x15, 0xb9, 0x96, 0x16, 0x92, 0xb8, 0x04, 0x77, 0xc5, 0x54, 0x6f, 0x50, + 0xe8, 0xd4, 0x17, 0xd0, 0xa9, 0xe8, 0x21, 0x8f, 0xd1, 0x5b, 0x8e, 0x01, 0x7a, 0xc9, 0xa5, 0x41, + 0x61, 0xbf, 0x41, 0x9f, 0xa0, 0x20, 0xf5, 0x6b, 0x89, 0x36, 0x10, 0xa0, 0x40, 0x73, 0x23, 0x67, + 0xe7, 0xfb, 0x76, 0xe6, 0xfb, 0x66, 0x31, 0xe0, 0x0b, 0xec, 0x33, 0x14, 0xba, 0x7d, 0x88, 0x7d, + 0x87, 0x22, 0x77, 0x1c, 0x62, 0x36, 0xd1, 0x5d, 0x37, 0xd2, 0xa3, 0x92, 0xfe, 0x02, 0x87, 0x48, + 0x0b, 0x42, 0xc2, 0x88, 0x28, 0xa7, 0xa4, 0x69, 0xae, 0x1b, 0x69, 0x51, 0x49, 0xfe, 0xdc, 0x25, + 0x74, 0x44, 0xa8, 0x4e, 0x19, 0x1c, 0x60, 0xbf, 0xa7, 0x47, 0xa5, 0x2e, 0x62, 0xb0, 0xb4, 0xfc, + 0x9f, 0x33, 0xc8, 0xf9, 0x1e, 0xe9, 0x91, 0xe4, 0x53, 0x8f, 0xbf, 0x16, 0xd1, 0x87, 0x0c, 0xf9, + 0x1e, 0x0a, 0x47, 0xd8, 0x67, 0x3a, 0xec, 0xba, 0x58, 0x67, 0x93, 0x00, 0xd1, 0xf9, 0xa1, 0xfa, + 0x86, 0x07, 0x9f, 0x76, 0xe0, 0x10, 0x7b, 0x90, 0x91, 0xd0, 0x46, 0xac, 0xd6, 0x87, 0x7e, 0x0f, + 0x35, 0xa1, 0x3b, 0x40, 0xac, 0x0e, 0x19, 0x14, 0x09, 0x38, 0x8a, 0x96, 0xe7, 0xce, 0x38, 0xf0, + 0x20, 0x43, 0x54, 0xe2, 0x95, 0xbd, 0x62, 0xb6, 0xac, 0x68, 0x6b, 0x66, 0x2d, 0x66, 0xd6, 0x56, + 0x4c, 0xed, 0x24, 0xb1, 0xaa, 0xbc, 0x7a, 0xfb, 0x88, 0xfb, 0xe7, 0xed, 0x23, 0x69, 0x02, 0x47, + 0xc3, 0x6f, 0xd4, 0x1d, 0x22, 0xd5, 0x12, 0xa2, 0x9b, 0x10, 0x2a, 0x16, 0x41, 0x1c, 0xa3, 0x88, + 0x2d, 0x92, 0x1c, 0xec, 0x49, 0x19, 0x85, 0x2f, 0xee, 0x5b, 0xb9, 0x79, 0x7c, 0x9e, 0x68, 0x7a, + 0xe2, 0x67, 0x00, 0xd0, 0x21, 0xa4, 0x7d, 0x07, 0xba, 0x03, 0x2a, 0xed, 0x29, 0x7b, 0xc5, 0x03, + 0xeb, 0x20, 0x89, 0x54, 0xdc, 0x01, 0x55, 0xbf, 0x03, 0xf9, 0x8e, 0x5d, 0x3b, 0x87, 0x6c, 0x1c, + 0x22, 0x6f, 0xa3, 0xa3, 0xb4, 0x0b, 0xf8, 0xb4, 0x0b, 0xd4, 0x3f, 0x79, 0x70, 0x68, 0xc7, 0x7c, + 0x1b, 0x68, 0x0b, 0x1c, 0xac, 0x4a, 0x4e, 0x60, 0xd9, 0xb2, 0x7c, 0xbb, 0x0e, 0x55, 0x69, 0xa1, + 0x80, 0xb0, 0xa5, 0x80, 0x6a, 0xad, 0x69, 0xde, 0xa1, 0xe5, 0x2a, 0x00, 0xd8, 0xbf, 0x0c, 0xa1, + 0xcb, 0x30, 0xf1, 0xa5, 0x3d, 0x85, 0x2f, 0xe6, 0xca, 0xaa, 0x36, 0x1f, 0x0e, 0x6d, 0x39, 0x0c, + 0x8b, 0xe1, 0xd0, 0xcc, 0x55, 0xa6, 0xb5, 0x81, 0x52, 0x7f, 0xcf, 0x00, 0xb1, 0x46, 0x7c, 0x3a, + 0x1e, 0xa1, 0x70, 0xa3, 0xb1, 0x53, 0xb0, 0x1f, 0x0f, 0x46, 0xd2, 0x53, 0xae, 0x5c, 0xd6, 0x6e, + 0x9f, 0x46, 0x6d, 0x17, 0xdd, 0x9a, 0x04, 0xc8, 0x4a, 0xf0, 0xe2, 0x33, 0x70, 0x48, 0x6f, 0x6a, + 0x96, 0xf4, 0x92, 0x2d, 0x7f, 0x79, 0x17, 0xe5, 0x96, 0xcc, 0x67, 0x9c, 0xb5, 0xcd, 0x22, 0x5e, + 0x82, 0x7c, 0x44, 0xdd, 0x1d, 0x3f, 0x13, 0x15, 0xb2, 0xe5, 0xaf, 0xee, 0x62, 0x4f, 0x9b, 0x83, + 0x33, 0xce, 0x4a, 0xe5, 0xab, 0xde, 0x03, 0xfb, 0x1e, 0x64, 0x50, 0xed, 0x82, 0xa3, 0x33, 0xe8, + 0x7b, 0xb4, 0x0f, 0x07, 0xe8, 0x1c, 0x31, 0x18, 0x07, 0xc5, 0x13, 0xf0, 0x20, 0x08, 0x49, 0x84, + 0x3d, 0x14, 0x3a, 0x97, 0x08, 0x39, 0x01, 0x21, 0x43, 0x07, 0x7a, 0xde, 0x7c, 0x16, 0x0e, 0xac, + 0xfb, 0xcb, 0xd3, 0x53, 0x84, 0x9a, 0x84, 0x0c, 0x2b, 0x9e, 0x17, 0x8a, 0x12, 0xf8, 0x20, 0x42, + 0x21, 0x8d, 0x2d, 0xcb, 0x24, 0x59, 0xcb, 0x5f, 0xf5, 0x65, 0x06, 0xe4, 0x77, 0xd5, 0xec, 0x94, + 0xfe, 0x33, 0x37, 0x9e, 0xdf, 0xe6, 0xc6, 0xe3, 0x77, 0x70, 0xa3, 0x53, 0x7a, 0x1f, 0xfc, 0xf8, + 0x8b, 0x07, 0x47, 0x3b, 0x85, 0xfd, 0xcf, 0xef, 0xf1, 0x87, 0x94, 0xf7, 0x78, 0x7c, 0x57, 0xe7, + 0xeb, 0x37, 0x99, 0x98, 0xb4, 0x81, 0x3e, 0xfe, 0x83, 0x07, 0x0f, 0xd2, 0xbd, 0x14, 0xbf, 0x05, + 0x4a, 0xed, 0xa2, 0x61, 0xb7, 0xcf, 0x0d, 0xcb, 0x69, 0x56, 0x6a, 0x3f, 0x1a, 0x2d, 0xa7, 0xf5, + 0xbc, 0x69, 0x38, 0xed, 0x86, 0xdd, 0x34, 0x6a, 0xe6, 0xa9, 0x69, 0xd4, 0x05, 0x4e, 0xfe, 0x78, + 0x3a, 0x53, 0x8e, 0xda, 0x3e, 0x0d, 0x90, 0x8b, 0x2f, 0xf1, 0x52, 0x43, 0x51, 0x07, 0x72, 0x2a, + 0xd8, 0x7e, 0x5a, 0xb1, 0xcf, 0x04, 0x5e, 0x3e, 0x9c, 0xce, 0x94, 0xec, 0x86, 0xb0, 0xe2, 0x09, + 0xf8, 0x24, 0x15, 0x10, 0xbb, 0x26, 0x64, 0xe4, 0xfc, 0x74, 0xa6, 0x08, 0x9d, 0x2d, 0xa7, 0xe4, + 0xfd, 0x5f, 0x7e, 0x2b, 0x70, 0xc7, 0x2f, 0x79, 0x90, 0xbb, 0xd9, 0xa2, 0xf8, 0x04, 0x3c, 0x34, + 0x1b, 0xa7, 0x56, 0xa5, 0xd6, 0x32, 0x2f, 0x1a, 0x69, 0x65, 0xdf, 0x9f, 0xce, 0x94, 0xc3, 0x35, + 0xc8, 0x18, 0x05, 0x6c, 0x22, 0xea, 0xbb, 0xa8, 0xfa, 0x45, 0xbb, 0xfa, 0xd4, 0x70, 0x6c, 0xf3, + 0xfb, 0x86, 0xc0, 0xcb, 0xb9, 0xe9, 0x4c, 0x01, 0x75, 0x32, 0xee, 0x0e, 0x91, 0x8d, 0x7b, 0xbe, + 0x78, 0x0c, 0xa4, 0x5d, 0xc0, 0xb3, 0x46, 0xcb, 0x3c, 0x37, 0x84, 0x8c, 0xfc, 0xd1, 0x74, 0xa6, + 0x7c, 0x58, 0x27, 0x2f, 0x7c, 0x86, 0x47, 0x68, 0x5e, 0x6b, 0xb5, 0xf1, 0xea, 0xaa, 0xc0, 0xbf, + 0xbe, 0x2a, 0xf0, 0x7f, 0x5f, 0x15, 0xf8, 0x5f, 0xaf, 0x0b, 0xdc, 0xeb, 0xeb, 0x02, 0xf7, 0xe6, + 0xba, 0xc0, 0xfd, 0xf4, 0xa4, 0x87, 0x59, 0x7f, 0xdc, 0xd5, 0x5c, 0x32, 0xd2, 0x17, 0x8b, 0x77, + 0x6d, 0xe9, 0xe3, 0xd5, 0x0a, 0x8f, 0xbe, 0xd6, 0x7f, 0x4e, 0xf6, 0x78, 0xb2, 0x50, 0xbb, 0xf7, + 0x92, 0x8d, 0x7a, 0xf2, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x80, 0xad, 0xa1, 0xef, 0x07, + 0x00, 0x00, } func (m *ValidatorSetChangePacketData) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/types/wire_test.go b/x/ccv/types/wire_test.go index ab6692912e..300ed7071f 100644 --- a/x/ccv/types/wire_test.go +++ b/x/ccv/types/wire_test.go @@ -12,12 +12,12 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v4/testutil/crypto" - "github.com/cosmos/interchain-security/v4/x/ccv/types" + "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/cosmos/interchain-security/v5/x/ccv/types" ) func TestPacketDataValidateBasic(t *testing.T) { - pk, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) cases := []struct { @@ -67,9 +67,9 @@ func TestPacketDataValidateBasic(t *testing.T) { } func TestMarshalPacketData(t *testing.T) { - pk1, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk1, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) - pk2, err := cryptocodec.ToTmProtoPublicKey(ed25519.GenPrivKey().PubKey()) + pk2, err := cryptocodec.ToCmtProtoPublicKey(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) vpd := types.NewValidatorSetChangePacketData(