From d9781d2996f49d04ce5f5d1432bd301cdd0a34a7 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+shaspitz@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:48:39 -0700 Subject: [PATCH] feat!: completed throttle v2 (provider changes + migration + testing) (#1321) * merge main into throttle feat branch (#1267) * build(deps): bump actions/checkout from 3 to 4 (#1257) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps)!: bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 (#1258) * build(deps): bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 Bumps [github.com/cosmos/ibc-go/v7](https://github.com/cosmos/ibc-go) from 7.2.0 to 7.3.0. - [Release notes](https://github.com/cosmos/ibc-go/releases) - [Changelog](https://github.com/cosmos/ibc-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/ibc-go/compare/v7.2.0...v7.3.0) --- updated-dependencies: - dependency-name: github.com/cosmos/ibc-go/v7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.4 to 0.47.5 (#1259) * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.3 to 0.47.5 Bumps [github.com/cosmos/cosmos-sdk](https://github.com/cosmos/cosmos-sdk) from 0.47.3 to 0.47.5. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/compare/v0.47.3...v0.47.5) --- updated-dependencies: - dependency-name: github.com/cosmos/cosmos-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * chore: Separate semver (#1217) separate semver * docs: cleanup changelog (#1260) fix changelog * fix!: validate MsgTransfer before calling Transfer() (#1244) * validate MsgTransfer * add TestSendRewardsToProvider * update DefaultConsumerUnbondingPeriod to 14 days * update changelog * fix linter * fix test * apply review suggestions * update changelog * docs: Create adr-012-separate-releasing.md (#1229) * Create adr-011-separate-releasing.md * Update docs/docs/adrs/adr-011-separate-releasing.md Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * adr 12 not 11 * correct that we use postfix not prefix * explanation on example release flow --------- Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * fix: remove addr validation for provider fee pool addr param (#1262) * fix: remove validation for provider chain address since we cannot validate it properly on consumer * add changelog entry --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> Co-authored-by: Dmitry Kolupaev * feat!: throttle with retries provider changes (#1230) * wip, tests not fixed yet * rm packet query on provider * rm unneeded UTs * rm tests from relay_test * rm query and more tests * rm more tests * builds again and rm debug tests * lint * fix handling of slash packet and integration test * Fix TestMultiConsumerSlashPacketThrottling * fix two more slashing integration tests * Update TestSlashRetries, cleanup neededc * cleaned up TestSlashRetries * UT for TestOnRecvDowntimeSlashPacket * cleans * use helper in throttle test * lintz * Revert "rm packet query on provider" This reverts commit a10a2398cc6b878a889e196252e97a1b67c65be4. * cmd file too * fully restore query * Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes" This reverts commit 73db33b3ed906d29dac643daa8a600f191076eee, reversing changes made to 78a8269db9e041df1449be180098daab17a42f06. * make e2e test pass, with todos * clean * Revert "Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes"" This reverts commit 5bfccc39dc130d6f4be9ed7c0932176357618296. * lint * Update CHANGELOG.md * slightly longer buffer * build(deps): bump actions/checkout from 3 to 4 (#1257) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps)!: bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 (#1258) * build(deps): bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 Bumps [github.com/cosmos/ibc-go/v7](https://github.com/cosmos/ibc-go) from 7.2.0 to 7.3.0. - [Release notes](https://github.com/cosmos/ibc-go/releases) - [Changelog](https://github.com/cosmos/ibc-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/ibc-go/compare/v7.2.0...v7.3.0) --- updated-dependencies: - dependency-name: github.com/cosmos/ibc-go/v7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.4 to 0.47.5 (#1259) * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.3 to 0.47.5 Bumps [github.com/cosmos/cosmos-sdk](https://github.com/cosmos/cosmos-sdk) from 0.47.3 to 0.47.5. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/compare/v0.47.3...v0.47.5) --- updated-dependencies: - dependency-name: github.com/cosmos/cosmos-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * chore: Separate semver (#1217) separate semver * docs: cleanup changelog (#1260) fix changelog * fix!: validate MsgTransfer before calling Transfer() (#1244) * validate MsgTransfer * add TestSendRewardsToProvider * update DefaultConsumerUnbondingPeriod to 14 days * update changelog * fix linter * fix test * apply review suggestions * update changelog * docs: Create adr-012-separate-releasing.md (#1229) * Create adr-011-separate-releasing.md * Update docs/docs/adrs/adr-011-separate-releasing.md Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * adr 12 not 11 * correct that we use postfix not prefix * explanation on example release flow --------- Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * fix: remove addr validation for provider fee pool addr param (#1262) * fix: remove validation for provider chain address since we cannot validate it properly on consumer * add changelog entry * Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes" This reverts commit 6bdfff9db15da62b61244b813f045f49b56fc6c3, reversing changes made to d8f569020b45b7fa6048983a9ccef91b9c8dfc38. * fmt * Update steps_downtime.go * Update tests/e2e/steps_downtime.go Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * waittime instead of sleep * Update x/ccv/provider/client/cli/query.go Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * Update x/ccv/provider/client/cli/query.go Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * rm throttled packets from query * rm provider query * whoopsies forgot to rm some boilerplate --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> Co-authored-by: Dmitry Kolupaev * feat: consumer throttle state query (#1285) * wip, tests not fixed yet * rm packet query on provider * rm unneeded UTs * rm tests from relay_test * rm query and more tests * rm more tests * builds again and rm debug tests * lint * fix handling of slash packet and integration test * Fix TestMultiConsumerSlashPacketThrottling * fix two more slashing integration tests * Update TestSlashRetries, cleanup neededc * cleaned up TestSlashRetries * UT for TestOnRecvDowntimeSlashPacket * cleans * use helper in throttle test * lintz * Revert "rm packet query on provider" This reverts commit a10a2398cc6b878a889e196252e97a1b67c65be4. * cmd file too * fully restore query * Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes" This reverts commit 73db33b3ed906d29dac643daa8a600f191076eee, reversing changes made to 78a8269db9e041df1449be180098daab17a42f06. * make e2e test pass, with todos * clean * Revert "Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes"" This reverts commit 5bfccc39dc130d6f4be9ed7c0932176357618296. * lint * Update CHANGELOG.md * slightly longer buffer * build(deps): bump actions/checkout from 3 to 4 (#1257) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps)!: bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 (#1258) * build(deps): bump github.com/cosmos/ibc-go/v7 from 7.2.0 to 7.3.0 Bumps [github.com/cosmos/ibc-go/v7](https://github.com/cosmos/ibc-go) from 7.2.0 to 7.3.0. - [Release notes](https://github.com/cosmos/ibc-go/releases) - [Changelog](https://github.com/cosmos/ibc-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/ibc-go/compare/v7.2.0...v7.3.0) --- updated-dependencies: - dependency-name: github.com/cosmos/ibc-go/v7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.4 to 0.47.5 (#1259) * build(deps): bump github.com/cosmos/cosmos-sdk from 0.47.3 to 0.47.5 Bumps [github.com/cosmos/cosmos-sdk](https://github.com/cosmos/cosmos-sdk) from 0.47.3 to 0.47.5. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/compare/v0.47.3...v0.47.5) --- updated-dependencies: - dependency-name: github.com/cosmos/cosmos-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * add changelog entries --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke * chore: Separate semver (#1217) separate semver * docs: cleanup changelog (#1260) fix changelog * fix!: validate MsgTransfer before calling Transfer() (#1244) * validate MsgTransfer * add TestSendRewardsToProvider * update DefaultConsumerUnbondingPeriod to 14 days * update changelog * fix linter * fix test * apply review suggestions * update changelog * docs: Create adr-012-separate-releasing.md (#1229) * Create adr-011-separate-releasing.md * Update docs/docs/adrs/adr-011-separate-releasing.md Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * adr 12 not 11 * correct that we use postfix not prefix * explanation on example release flow --------- Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * fix: remove addr validation for provider fee pool addr param (#1262) * fix: remove validation for provider chain address since we cannot validate it properly on consumer * add changelog entry * Revert "Merge branch 'main' into shawn/throttle-with-retries-provider-changes" This reverts commit 6bdfff9db15da62b61244b813f045f49b56fc6c3, reversing changes made to d8f569020b45b7fa6048983a9ccef91b9c8dfc38. * fmt * protobuf gen * impl query resp * add query assertion to e2e tests * lint * add consumer to pending packets name * add panic for invalid bytes --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> Co-authored-by: Dmitry Kolupaev * feat: retry delay period as param (#1308) * boilerplate * fix test * Update proposal_test.go * apply new param to keeper code * Update params_test.go * tests: throttle retry e2e tests (#1312) * boilerplate * fix test * Update proposal_test.go * apply new param to keeper code * wip * add action * incorporate queue assertions. Also make retry delay period 200s * correct queue size assertion * make wait time just 30 seconds * change naming * feat!: throttle v2 provider migration (#1317) * migration.go and incr consensus version * throttle v1 code for migration * old methods * finish test * register those migs * Update migration_test.go * lint * consumer keeper -> provider keeper * some fixes * fix the rest o the shit * lint * Addressing simon's comments * whoopies * height assertion * Update x/ccv/provider/keeper/migration.go Co-authored-by: Simon Noetzlin * action boilerplate * feat: remove max throttled packets param (#1332) * rm param * Update proto/interchain_security/ccv/provider/v1/provider.proto Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --------- Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> * merge fixes * update e2e jsons --------- Signed-off-by: dependabot[bot] Co-authored-by: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mpoke Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> Co-authored-by: Dmitry Kolupaev Co-authored-by: Simon Noetzlin (cherry picked from commit 88499b7c650ea0fb2c448af2b182ad5fee94d795) # Conflicts: # CHANGELOG.md # tests/e2e/action_rapid_test.go # tests/e2e/actions.go # tests/e2e/json_utils.go # tests/e2e/main.go # tests/e2e/state.go # tests/e2e/state_rapid_test.go # tests/e2e/steps_downtime.go # tests/e2e/tracehandler_testdata/changeover.json # tests/e2e/tracehandler_testdata/democracy.json # tests/e2e/tracehandler_testdata/democracyRewardsSteps.json # tests/e2e/tracehandler_testdata/happyPath.json # tests/e2e/tracehandler_testdata/multipleConsumers.json # tests/e2e/tracehandler_testdata/shorthappy.json # tests/e2e/tracehandler_testdata/slashThrottle.json # tests/integration/common.go # tests/integration/slashing.go # tests/integration/throttle.go # tests/integration/throttle_retry.go # x/ccv/consumer/types/query.pb.go # x/ccv/provider/types/provider.pb.go # x/ccv/provider/types/query.pb.go # x/ccv/types/params.go # x/ccv/types/shared_consumer.pb.go --- CHANGELOG.md | 5 + .../ccv/consumer/v1/query.proto | 14 + .../ccv/provider/v1/provider.proto | 8 +- .../ccv/provider/v1/query.proto | 37 - .../ccv/v1/shared_consumer.proto | 4 + tests/difference/core/driver/setup.go | 1 + tests/e2e/action_rapid_test.go | 508 ++++ tests/e2e/actions.go | 50 +- tests/e2e/config.go | 3 +- tests/e2e/json_utils.go | 380 +++ tests/e2e/main.go | 7 + tests/e2e/state.go | 56 + tests/e2e/state_rapid_test.go | 248 ++ tests/e2e/steps_downtime.go | 114 +- .../e2e/tracehandler_testdata/changeover.json | 586 +++++ .../e2e/tracehandler_testdata/democracy.json | 918 +++++++ .../democracyRewardsSteps.json | 924 +++++++ .../e2e/tracehandler_testdata/happyPath.json | 1935 ++++++++++++++ .../multipleConsumers.json | 2284 +++++++++++++++++ .../e2e/tracehandler_testdata/shorthappy.json | 1523 +++++++++++ .../tracehandler_testdata/slashThrottle.json | 805 ++++++ tests/integration/common.go | 42 + tests/integration/slashing.go | 63 +- tests/integration/stop_consumer.go | 48 - tests/integration/throttle.go | 177 +- tests/integration/throttle_retry.go | 177 +- testutil/integration/debug_test.go | 16 - testutil/keeper/unit_test_helpers.go | 9 - x/ccv/consumer/client/cli/query.go | 28 + x/ccv/consumer/keeper/grpc_query.go | 23 + x/ccv/consumer/keeper/params.go | 7 + x/ccv/consumer/keeper/params_test.go | 3 +- x/ccv/consumer/keeper/throttle_retry.go | 6 +- x/ccv/consumer/keeper/throttle_retry_test.go | 7 +- x/ccv/consumer/types/genesis_test.go | 3 + x/ccv/consumer/types/params_test.go | 36 +- x/ccv/consumer/types/query.pb.go | 456 +++- x/ccv/consumer/types/query.pb.gw.go | 65 + x/ccv/provider/client/cli/query.go | 37 - x/ccv/provider/keeper/grpc_query.go | 85 - x/ccv/provider/keeper/migration.go | 138 + x/ccv/provider/keeper/migration_test.go | 117 + x/ccv/provider/keeper/params.go | 9 - x/ccv/provider/keeper/params_test.go | 1 - x/ccv/provider/keeper/proposal.go | 16 +- x/ccv/provider/keeper/proposal_test.go | 27 +- x/ccv/provider/keeper/relay.go | 113 +- x/ccv/provider/keeper/relay_test.go | 209 +- x/ccv/provider/keeper/throttle.go | 438 ---- x/ccv/provider/keeper/throttle_test.go | 844 ------ x/ccv/provider/module.go | 8 +- x/ccv/provider/types/genesis_test.go | 53 +- x/ccv/provider/types/params.go | 12 - x/ccv/provider/types/params_test.go | 27 +- x/ccv/provider/types/provider.pb.go | 148 +- x/ccv/provider/types/query.pb.go | 1236 +-------- x/ccv/provider/types/query.pb.gw.go | 83 - x/ccv/types/params.go | 18 + x/ccv/types/shared_consumer.pb.go | 174 +- 59 files changed, 12072 insertions(+), 3297 deletions(-) create mode 100644 tests/e2e/action_rapid_test.go create mode 100644 tests/e2e/json_utils.go create mode 100644 tests/e2e/state_rapid_test.go create mode 100644 tests/e2e/tracehandler_testdata/changeover.json create mode 100644 tests/e2e/tracehandler_testdata/democracy.json create mode 100644 tests/e2e/tracehandler_testdata/democracyRewardsSteps.json create mode 100644 tests/e2e/tracehandler_testdata/happyPath.json create mode 100644 tests/e2e/tracehandler_testdata/multipleConsumers.json create mode 100644 tests/e2e/tracehandler_testdata/shorthappy.json create mode 100644 tests/e2e/tracehandler_testdata/slashThrottle.json create mode 100644 x/ccv/provider/keeper/migration.go create mode 100644 x/ccv/provider/keeper/migration_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b2fe2605..5a9303766c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Add an entry to the unreleased provider section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a provider release. +<<<<<<< HEAD +======= +* (feat!) [#1230](https://github.com/cosmos/interchain-security/pull/1230) Throttle with retries provider changes. +* (feature!) [#1280](https://github.com/cosmos/interchain-security/pull/1280) provider proposal for changing reward denoms +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) * (feature!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Update the default consumer unbonding period to 2 weeks. * (deps) [#1259](https://github.com/cosmos/interchain-security/pull/1259) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.5). * (deps!) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.3.0](https://github.com/cosmos/ibc-go/releases/tag/v7.3.0). diff --git a/proto/interchain_security/ccv/consumer/v1/query.proto b/proto/interchain_security/ccv/consumer/v1/query.proto index ff2a5901fe..3ad1f24df8 100644 --- a/proto/interchain_security/ccv/consumer/v1/query.proto +++ b/proto/interchain_security/ccv/consumer/v1/query.proto @@ -7,6 +7,7 @@ option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/typ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "interchain_security/ccv/consumer/v1/consumer.proto"; +import "interchain_security/ccv/v1/wire.proto"; service Query { // ConsumerGenesis queries the genesis state needed to start a consumer chain @@ -24,6 +25,11 @@ service Query { rpc QueryProviderInfo(QueryProviderInfoRequest) returns (QueryProviderInfoResponse) { option (google.api.http).get = "/interchain_security/ccv/consumer/provider-info"; } + + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + rpc QueryThrottleState(QueryThrottleStateRequest) returns (QueryThrottleStateResponse) { + option (google.api.http).get = "/interchain_security/ccv/consumer/throttle_state"; + } } // NextFeeDistributionEstimate holds information about next fee distribution @@ -65,6 +71,14 @@ message QueryProviderInfoResponse { ChainInfo provider = 2 [ (gogoproto.nullable) = false ]; } +message QueryThrottleStateRequest {} + +message QueryThrottleStateResponse { + SlashRecord slash_record = 1 [ (gogoproto.nullable) = true ]; + repeated interchain_security.ccv.v1.ConsumerPacketData packet_data_queue = 2 [ (gogoproto.nullable) = false ]; +} + + message ChainInfo { string chainID = 1; string clientID = 2; diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 9423e1f924..80ab101c00 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -139,6 +139,10 @@ message GlobalSlashEntry { // Params defines the parameters for CCV Provider module message Params { + + // Reserve 8th slot for removed max throttled packet param + reserved 8; + ibc.lightclients.tendermint.v1.ClientState template_client = 1; // TrustingPeriodFraction is used to compute the consumer and provider IBC // client's TrustingPeriod from the chain defined UnbondingPeriod @@ -166,10 +170,6 @@ message Params { // total voting power that the slash meter can hold. string slash_meter_replenish_fraction = 7; - // The maximum amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - int64 max_throttled_packets = 8; - // The fee required to be paid to add a reward denom cosmos.base.v1beta1.Coin consumer_reward_denom_registration_fee = 9 [ (gogoproto.nullable) = false ]; diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index b0c1dc2b47..089df6bfec 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -65,14 +65,6 @@ service Query { "/interchain_security/ccv/provider/throttle_state"; } - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - rpc QueryThrottledConsumerPacketData(QueryThrottledConsumerPacketDataRequest) - returns (QueryThrottledConsumerPacketDataResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/pending_consumer_packets"; - } - // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered rpc QueryRegisteredConsumerRewardDenoms( @@ -151,35 +143,6 @@ message QueryThrottleStateResponse { // full google.protobuf.Timestamp next_replenish_candidate = 3 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - // data relevant to currently throttled slash packets - repeated ThrottledSlashPacket packets = 4; -} - -message QueryThrottledConsumerPacketDataRequest { string chain_id = 1; } - -message QueryThrottledConsumerPacketDataResponse { - string chain_id = 1; - uint64 size = 2; - repeated ThrottledPacketDataWrapper packetDataInstances = 3 - [ (gogoproto.nullable) = false ]; -} - -// A query wrapper type for the global entry and data relevant to a throttled -// slash packet. -message ThrottledSlashPacket { - interchain_security.ccv.provider.v1.GlobalSlashEntry global_entry = 1 - [ (gogoproto.nullable) = false ]; - interchain_security.ccv.v1.SlashPacketData data = 2 - [ (gogoproto.nullable) = false ]; -} - -// ThrottledPacketDataWrapper contains either SlashPacketData or -// VSCMaturedPacketData -message ThrottledPacketDataWrapper { - oneof data { - interchain_security.ccv.v1.SlashPacketData slash_packet = 1; - interchain_security.ccv.v1.VSCMaturedPacketData vsc_matured_packet = 2; - } } message QueryRegisteredConsumerRewardDenomsRequest {} diff --git a/proto/interchain_security/ccv/v1/shared_consumer.proto b/proto/interchain_security/ccv/v1/shared_consumer.proto index 825a84e346..f43f6cf65d 100644 --- a/proto/interchain_security/ccv/v1/shared_consumer.proto +++ b/proto/interchain_security/ccv/v1/shared_consumer.proto @@ -77,6 +77,10 @@ message Params { // Provider-originated reward denoms. These are denoms coming from the // provider which are allowed to be used as rewards. e.g. "uatom" repeated string provider_reward_denoms = 12; + + // The period after which a consumer can retry sending a throttled packet. + google.protobuf.Duration retry_delay_period = 13 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; } // GenesisState defines the CCV consumer chain genesis state. diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 9ca6d00b9f..ebeb9e1876 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -537,6 +537,7 @@ func (b *Builder) createConsumerGenesis(client *ibctmtypes.ClientState) *ccv.Gen "0", // disable soft opt-out []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, ) return ccv.NewInitialGenesisState(client, providerConsState, valUpdates, params) } diff --git a/tests/e2e/action_rapid_test.go b/tests/e2e/action_rapid_test.go new file mode 100644 index 0000000000..09d28abacf --- /dev/null +++ b/tests/e2e/action_rapid_test.go @@ -0,0 +1,508 @@ +package main + +import ( + "encoding/json" + "fmt" + "testing" + "time" + + "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +// This file contains tests for serialization/deserialization of actions. +// The tests are written using the rapid testing library, which allows us to +// generate arbitrary actions and test that they can be serialized and +// deserialized without error. +// The generators for the various actions are defined in this file, and +// essentially tell rapid how to build these actions. + +func TestActionMarshalling(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + action := GetActionGen().Draw(t, "Action") + err := MarshalAndUnmarshalAction(action) + if err != nil { + t.Fatalf("error marshalling and unmarshalling action: %v", err) + } + }) +} + +func MarshalAndUnmarshalAction(action interface{}) error { + // wraps the action with a step, since it needs custom unmarshalling that is called by the step unmarshaller + step := Step{ + Action: action, + } + jsonobj, err := json.Marshal(step) + if err != nil { + return fmt.Errorf("error marshalling action inside step: %v", err) + } + + var got Step + err = json.Unmarshal(jsonobj, &got) + if err != nil { + return fmt.Errorf("error unmarshalling action inside step: %v", err) + } + + diff := cmp.Diff(step, got) + if diff != "" { + return fmt.Errorf("got (-), want (+): %v", diff) + } + + return nil +} + +// This needs to be adjusted manually when new actions are added and should +// include generators for all actions that are mentioned in main.go/runStep. +func GetActionGen() *rapid.Generator[any] { + return rapid.OneOf( + GetStartSovereignChainActionGen().AsAny(), + GetSubmitLegacyUpgradeProposalActionGen().AsAny(), + GetWaitUntilBlockActionGen().AsAny(), + GetChangeoverChainActionGen().AsAny(), + GetSendTokensActionGen().AsAny(), + GetStartChainActionGen().AsAny(), + GetSubmitTextProposalActionGen().AsAny(), + GetSubmitConsumerAdditionProposalActionGen().AsAny(), + GetSubmitConsumerRemovalProposalActionGen().AsAny(), + GetSubmitParamChangeProposalActionGen().AsAny(), + GetSubmitEquivocationProposalActionGen().AsAny(), + GetVoteGovProposalActionGen().AsAny(), + GetStartConsumerChainActionGen().AsAny(), + GetAddChainToRelayerActionGen().AsAny(), + GetAddIbcConnectionActionGen().AsAny(), + GetAddIbcChannelActionGen().AsAny(), + GetStartRelayerActionGen().AsAny(), + GetTransferChannelCompleteActionGen().AsAny(), + GetRelayPacketsActionGen().AsAny(), + GetRelayRewardPacketsToProviderActionGen().AsAny(), + GetDelegateTokensActionGen().AsAny(), + GetUnbondTokensActionGen().AsAny(), + GetRedelegateTokensActionGen().AsAny(), + GetDowntimeSlashActionGen().AsAny(), + GetUnjailValidatorActionGen().AsAny(), + GetRegisterRepresentativeActionGen().AsAny(), + GetDoublesignSlashActionGen().AsAny(), + GetAssignConsumerPubKeyActionGen().AsAny(), + GetCreateIbcClientsActionGen().AsAny(), + GetSlashMeterReplenishmentAction().AsAny(), + GetWaitTimeAction().AsAny(), + CreateCancelUnbondTokensActionGen().AsAny(), + CreateLightClientEquivocationAttackActionGen().AsAny(), + CreateLightClientAmnesiaAttackActionGen().AsAny(), + CreateLightClientLunaticAttackActionGen().AsAny(), + ) +} + +func CreateSubmitChangeRewardDenomsProposalActionGen() *rapid.Generator[submitChangeRewardDenomsProposalAction] { + return rapid.Custom(func(t *rapid.T) submitChangeRewardDenomsProposalAction { + return submitChangeRewardDenomsProposalAction{ + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Denom: rapid.String().Draw(t, "Denom"), + } + }) +} + +func CreateLightClientEquivocationAttackActionGen() *rapid.Generator[lightClientEquivocationAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientEquivocationAttackAction { + return lightClientEquivocationAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateLightClientAmnesiaAttackActionGen() *rapid.Generator[lightClientAmnesiaAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientAmnesiaAttackAction { + return lightClientAmnesiaAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateLightClientLunaticAttackActionGen() *rapid.Generator[lightClientLunaticAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientLunaticAttackAction { + return lightClientLunaticAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateCancelUnbondTokensActionGen() *rapid.Generator[cancelUnbondTokensAction] { + return rapid.Custom(func(t *rapid.T) cancelUnbondTokensAction { + return cancelUnbondTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Delegator: GetValidatorIDGen().Draw(t, "Delegator"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetCreateIbcClientsActionGen() *rapid.Generator[createIbcClientsAction] { + return rapid.Custom(func(t *rapid.T) createIbcClientsAction { + return createIbcClientsAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + } + }) +} + +func GetStartSovereignChainActionGen() *rapid.Generator[StartSovereignChainAction] { + return rapid.Custom(func(t *rapid.T) StartSovereignChainAction { + return StartSovereignChainAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetSubmitLegacyUpgradeProposalActionGen() *rapid.Generator[LegacyUpgradeProposalAction] { + return rapid.Custom(func(t *rapid.T) LegacyUpgradeProposalAction { + return LegacyUpgradeProposalAction{ + ChainID: GetChainIDGen().Draw(t, "ChainID"), + UpgradeTitle: rapid.String().Draw(t, "UpgradeTitle"), + Proposer: GetValidatorIDGen().Draw(t, "Proposer"), + UpgradeHeight: rapid.Uint64().Draw(t, "UpgradeHeight"), + } + }) +} + +func GetWaitUntilBlockActionGen() *rapid.Generator[waitUntilBlockAction] { + return rapid.Custom(func(t *rapid.T) waitUntilBlockAction { + return waitUntilBlockAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Block: rapid.Uint().Draw(t, "Block"), + } + }) +} + +func GetChangeoverChainActionGen() *rapid.Generator[ChangeoverChainAction] { + return rapid.Custom(func(t *rapid.T) ChangeoverChainAction { + return ChangeoverChainAction{ + SovereignChain: GetChainIDGen().Draw(t, "SovereignChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetSendTokensActionGen() *rapid.Generator[SendTokensAction] { + return rapid.Custom(func(t *rapid.T) SendTokensAction { + return SendTokensAction{ + Amount: rapid.Uint().Draw(t, "Amount"), + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + To: GetValidatorIDGen().Draw(t, "To"), + } + }) +} + +func GetStartChainActionGen() *rapid.Generator[StartChainAction] { + return rapid.Custom(func(t *rapid.T) StartChainAction { + return StartChainAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + SkipGentx: rapid.Bool().Draw(t, "SkipGentx"), + } + }) +} + +func GetStartChainValidatorsGen() *rapid.Generator[[]StartChainValidator] { + return rapid.Custom(func(t *rapid.T) []StartChainValidator { + return rapid.SliceOf(GetStartChainValidatorGen()).Draw(t, "StartChainValidators") + }) +} + +func GetStartChainValidatorGen() *rapid.Generator[StartChainValidator] { + return rapid.Custom(func(t *rapid.T) StartChainValidator { + return StartChainValidator{ + Id: GetValidatorIDGen().Draw(t, "Id"), + Allocation: rapid.Uint().Draw(t, "Allocation"), + Stake: rapid.Uint().Draw(t, "Stake"), + } + }) +} + +func GetSubmitTextProposalActionGen() *rapid.Generator[submitTextProposalAction] { + return rapid.Custom(func(t *rapid.T) submitTextProposalAction { + return submitTextProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Title: rapid.String().Draw(t, "Title"), + Description: rapid.String().Draw(t, "Description"), + } + }) +} + +func GetSubmitConsumerAdditionProposalActionGen() *rapid.Generator[submitConsumerAdditionProposalAction] { + return rapid.Custom(func(t *rapid.T) submitConsumerAdditionProposalAction { + return submitConsumerAdditionProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + SpawnTime: rapid.Uint().Draw(t, "SpawnTime"), + InitialHeight: GetHeightGen().Draw(t, "InitialHeight"), + } + }) +} + +func GetSubmitConsumerRemovalProposalActionGen() *rapid.Generator[submitConsumerRemovalProposalAction] { + return rapid.Custom(func(t *rapid.T) submitConsumerRemovalProposalAction { + return submitConsumerRemovalProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + StopTimeOffset: time.Duration(rapid.Int64().Draw(t, "StopTimeOffset")), + } + }) +} + +func GetSubmitParamChangeProposalActionGen() *rapid.Generator[submitParamChangeLegacyProposalAction] { + return rapid.Custom(func(t *rapid.T) submitParamChangeLegacyProposalAction { + return submitParamChangeLegacyProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Subspace: rapid.String().Draw(t, "Subspace"), + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), // could make this more generic in the future, since Value takes interfaces + } + }) +} + +func GetSubmitEquivocationProposalActionGen() *rapid.Generator[submitEquivocationProposalAction] { + return rapid.Custom(func(t *rapid.T) submitEquivocationProposalAction { + return submitEquivocationProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Height: rapid.Int64().Draw(t, "Height"), + Time: GetTimeGen().Draw(t, "Time"), + Power: rapid.Int64().Draw(t, "Power"), + } + }) +} + +func TestMarshalAndUnmarshalTime(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + time1 := GetTimeGen().Draw(t, "time") + data, err := time1.MarshalJSON() + require.NoError(t, err) + var time2 time.Time + err = time2.UnmarshalJSON(data) + require.NoError(t, err) + require.True(t, time1.Equal(time2)) + }) +} + +func GetTimeGen() *rapid.Generator[time.Time] { + return rapid.Custom(func(t *rapid.T) time.Time { + return time.Unix(rapid.Int64Range(-5.9959e+10, 1.5779e+11).Draw(t, "unix time"), 0).UTC() + }) +} + +func GetVoteGovProposalActionGen() *rapid.Generator[voteGovProposalAction] { + return rapid.Custom(func(t *rapid.T) voteGovProposalAction { + return voteGovProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: rapid.SliceOf(GetValidatorIDGen()).Draw(t, "From"), + Vote: rapid.SliceOf(rapid.String()).Draw(t, "Vote"), + PropNumber: rapid.Uint().Draw(t, "PropNumber"), + } + }) +} + +func GetStartConsumerChainActionGen() *rapid.Generator[startConsumerChainAction] { + return rapid.Custom(func(t *rapid.T) startConsumerChainAction { + return startConsumerChainAction{ + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetAddChainToRelayerActionGen() *rapid.Generator[addChainToRelayerAction] { + return rapid.Custom(func(t *rapid.T) addChainToRelayerAction { + return addChainToRelayerAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetAddIbcConnectionActionGen() *rapid.Generator[addIbcConnectionAction] { + return rapid.Custom(func(t *rapid.T) addIbcConnectionAction { + return addIbcConnectionAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ClientA: rapid.Uint().Draw(t, "ClientA"), + ClientB: rapid.Uint().Draw(t, "ClientB"), + } + }) +} + +func GetAddIbcChannelActionGen() *rapid.Generator[addIbcChannelAction] { + return rapid.Custom(func(t *rapid.T) addIbcChannelAction { + return addIbcChannelAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ConnectionA: rapid.Uint().Draw(t, "ConnectionA"), + PortA: rapid.String().Draw(t, "PortA"), + PortB: rapid.String().Draw(t, "PortB"), + Order: rapid.String().Draw(t, "Order"), + } + }) +} + +func GetStartRelayerActionGen() *rapid.Generator[startRelayerAction] { + return rapid.Just(startRelayerAction{}) +} + +func GetTransferChannelCompleteActionGen() *rapid.Generator[transferChannelCompleteAction] { + return rapid.Custom(func(t *rapid.T) transferChannelCompleteAction { + return transferChannelCompleteAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ConnectionA: rapid.Uint().Draw(t, "ConnectionA"), + PortA: rapid.String().Draw(t, "PortA"), + PortB: rapid.String().Draw(t, "PortB"), + Order: rapid.String().Draw(t, "Order"), + ChannelA: rapid.Uint().Draw(t, "ChannelA"), + ChannelB: rapid.Uint().Draw(t, "ChannelB"), + } + }) +} + +func GetRelayPacketsActionGen() *rapid.Generator[relayPacketsAction] { + return rapid.Custom(func(t *rapid.T) relayPacketsAction { + return relayPacketsAction{ + ChainA: GetChainIDGen().Draw(t, "Chain"), + ChainB: GetChainIDGen().Draw(t, "Chain"), + Port: rapid.String().Draw(t, "Port"), + Channel: rapid.Uint().Draw(t, "Channel"), + } + }) +} + +func GetRelayRewardPacketsToProviderActionGen() *rapid.Generator[relayRewardPacketsToProviderAction] { + return rapid.Custom(func(t *rapid.T) relayRewardPacketsToProviderAction { + return relayRewardPacketsToProviderAction{ + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Port: rapid.String().Draw(t, "Port"), + Channel: rapid.Uint().Draw(t, "Channel"), + } + }) +} + +func GetDelegateTokensActionGen() *rapid.Generator[delegateTokensAction] { + return rapid.Custom(func(t *rapid.T) delegateTokensAction { + return delegateTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + From: GetValidatorIDGen().Draw(t, "From"), + To: GetValidatorIDGen().Draw(t, "To"), + } + }) +} + +func GetUnbondTokensActionGen() *rapid.Generator[unbondTokensAction] { + return rapid.Custom(func(t *rapid.T) unbondTokensAction { + return unbondTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Sender: GetValidatorIDGen().Draw(t, "Sender"), + UnbondFrom: GetValidatorIDGen().Draw(t, "UnbondFrom"), + } + }) +} + +func GetRedelegateTokensActionGen() *rapid.Generator[redelegateTokensAction] { + return rapid.Custom(func(t *rapid.T) redelegateTokensAction { + return redelegateTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Src: GetValidatorIDGen().Draw(t, "Src"), + Dst: GetValidatorIDGen().Draw(t, "Dst"), + TxSender: GetValidatorIDGen().Draw(t, "TxSender"), + } + }) +} + +func GetDowntimeSlashActionGen() *rapid.Generator[downtimeSlashAction] { + return rapid.Custom(func(t *rapid.T) downtimeSlashAction { + return downtimeSlashAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetUnjailValidatorActionGen() *rapid.Generator[unjailValidatorAction] { + return rapid.Custom(func(t *rapid.T) unjailValidatorAction { + return unjailValidatorAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Provider: GetChainIDGen().Draw(t, "Provider"), + } + }) +} + +func GetRegisterRepresentativeActionGen() *rapid.Generator[registerRepresentativeAction] { + return rapid.Custom(func(t *rapid.T) registerRepresentativeAction { + return registerRepresentativeAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Representatives: rapid.SliceOf(GetValidatorIDGen()).Draw(t, "Representatives"), + Stakes: rapid.SliceOf(rapid.Uint()).Draw(t, "Stakes"), + } + }) +} + +func GetDoublesignSlashActionGen() *rapid.Generator[doublesignSlashAction] { + return rapid.Custom(func(t *rapid.T) doublesignSlashAction { + return doublesignSlashAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetAssignConsumerPubKeyActionGen() *rapid.Generator[assignConsumerPubKeyAction] { + return rapid.Custom(func(t *rapid.T) assignConsumerPubKeyAction { + return assignConsumerPubKeyAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + ConsumerPubkey: rapid.String().Draw(t, "ConsumerPubkey"), + ReconfigureNode: rapid.Bool().Draw(t, "ReconfigureNode"), + ExpectError: rapid.Bool().Draw(t, "ExpectError"), + } + }) +} + +func GetSlashMeterReplenishmentAction() *rapid.Generator[slashMeterReplenishmentAction] { + return rapid.Custom(func(t *rapid.T) slashMeterReplenishmentAction { + return slashMeterReplenishmentAction{ + TargetValue: rapid.Int64().Draw(t, "TargetValue"), + Timeout: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, + } + }) +} + +func GetWaitTimeAction() *rapid.Generator[waitTimeAction] { + return rapid.Custom(func(t *rapid.T) waitTimeAction { + return waitTimeAction{ + WaitTime: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, + } + }) +} diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index fccc27a957..8e7d0ad538 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1937,6 +1937,7 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos tr.waitBlocks(chainID("provi"), 2, 30*time.Second) } +<<<<<<< HEAD // slashThrottleDequeue polls slash queue sizes until nextQueueSize is achieved type slashThrottleDequeue struct { chain chainID @@ -1955,8 +1956,28 @@ func (tr TestRun) waitForSlashThrottleDequeue( if initialGlobalQueueSize != action.currentQueueSize { panic(fmt.Sprintf("wrong initial queue size: %d - expected global queue: %d\n", initialGlobalQueueSize, action.currentQueueSize)) +======= +// slashMeterReplenishmentAction polls the slash meter on provider until value is achieved +type slashMeterReplenishmentAction struct { + TargetValue int64 + // panic if timeout is exceeded + Timeout time.Duration +} + +func (tr TestConfig) waitForSlashMeterReplenishment( + action slashMeterReplenishmentAction, + verbose bool, +) { + timeout := time.Now().Add(action.Timeout) + initialSlashMeter := tr.getSlashMeter() + + if initialSlashMeter >= 0 { + panic(fmt.Sprintf("No need to wait for slash meter replenishment, current value: %d", initialSlashMeter)) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } + for { +<<<<<<< HEAD globalQueueSize := int(tr.getGlobalSlashQueueSize()) chainQueueSize := int(tr.getConsumerChainPacketQueueSize(action.chain)) if verbose { @@ -1965,22 +1986,45 @@ func (tr TestRun) waitForSlashThrottleDequeue( // check if global queue size is equal to chain queue size if globalQueueSize == chainQueueSize && globalQueueSize == action.nextQueueSize { //nolint:gocritic // this is the comparison that we want here. +======= + slashMeter := tr.getSlashMeter() + if verbose { + fmt.Printf("waiting for slash meter to be replenished, current value: %d\n", slashMeter) + } + + // check if meter has reached target value + if slashMeter >= action.TargetValue { +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) break } if time.Now().After(timeout) { +<<<<<<< HEAD panic(fmt.Sprintf("\n\n\nwaitForSlashThrottleDequeuemethod has timed out after: %s\n\n", action.timeout)) +======= + panic(fmt.Sprintf("\n\nwaitForSlashMeterReplenishment has timed out after: %s\n\n", action.Timeout)) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } - time.Sleep(500 * time.Millisecond) + tr.WaitTime(5 * time.Second) } +<<<<<<< HEAD // wair for 2 blocks to be created // allowing the jailing to be incorporated into voting power tr.waitBlocks(action.chain, 2, time.Minute) +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } -func uintPointer(i uint) *uint { - return &i +type waitTimeAction struct { + WaitTime time.Duration +} + +func (tr TestConfig) waitForTime( + action waitTimeAction, + verbose bool, +) { + tr.WaitTime(action.WaitTime) } // GetPathNameForGorelayer returns the name of the path between two given chains used by Gorelayer. diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 373281162d..093e32de81 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -186,7 +186,8 @@ func SlashThrottleTestRun() TestRun { ".app_state.slashing.params.signed_blocks_window = \"15\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + - ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"", + ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " + + ".app_state.ccvconsumer.params.retry_delay_period = \"30s\"", }, }, tendermintConfigOverride: `s/timeout_commit = "5s"/timeout_commit = "1s"/;` + diff --git a/tests/e2e/json_utils.go b/tests/e2e/json_utils.go new file mode 100644 index 0000000000..3d5867d42a --- /dev/null +++ b/tests/e2e/json_utils.go @@ -0,0 +1,380 @@ +package main + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// stores a proposal as a raw json, together with its type +type ProposalAndType struct { + RawProposal json.RawMessage + Type string +} + +type ( + // to have a ChainState object that does not have the overridden Marshal/Unmarshal method + ChainStateCopy ChainState + + // duplicated from the ChainState with a minor change to the Proposals field + ChainStateWithProposalTypes struct { + ChainStateCopy + Proposals *map[uint]ProposalAndType // the only thing changed from the real ChainState + } +) + +// MarshalJSON marshals a step into JSON while including the type of the action. +func (step Step) MarshalJSON() ([]byte, error) { + actionType := reflect.TypeOf(step.Action) + + result := struct { + ActionType string + Action interface{} + State State + }{ + ActionType: actionType.String(), + Action: step.Action, + State: step.State, + } + + return json.Marshal(result) +} + +// UnmarshalJSON unmarshals a step from JSON while including the type of the action. +func (step *Step) UnmarshalJSON(data []byte) error { + var tmp struct { + ActionType string + Action json.RawMessage + State State + } + if err := json.Unmarshal(data, &tmp); err != nil { + return err + } + + action, err := UnmarshalMapToActionType(tmp.Action, tmp.ActionType) + if err != nil { + return err + } + + step.Action = action + step.State = tmp.State + return nil +} + +// UnmarshalMapToActionType takes a JSON object and an action type and marshals into an object of the corresponding action. +func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string) (interface{}, error) { + var err error + switch actionTypeString { + case "main.submitConsumerAdditionProposalAction": + var a submitConsumerAdditionProposalAction + err = json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.SendTokensAction": + var a SendTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.StartChainAction": + var a StartChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitTextProposalAction": + var a submitTextProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitConsumerRemovalProposalAction": + var a submitConsumerRemovalProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitEquivocationProposalAction": + var a submitEquivocationProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitParamChangeLegacyProposalAction": + var a submitParamChangeLegacyProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.voteGovProposalAction": + var a voteGovProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.startConsumerChainAction": + var a startConsumerChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addChainToRelayerAction": + var a addChainToRelayerAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addIbcConnectionAction": + var a addIbcConnectionAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addIbcChannelAction": + var a addIbcChannelAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.transferChannelCompleteAction": + var a transferChannelCompleteAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.unjailValidatorAction": + var a unjailValidatorAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.assignConsumerPubKeyAction": + var a assignConsumerPubKeyAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.delegateTokensAction": + var a delegateTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.relayPacketsAction": + var a relayPacketsAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.registerRepresentativeAction": + var a registerRepresentativeAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.relayRewardPacketsToProviderAction": + var a relayRewardPacketsToProviderAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitChangeRewardDenomsProposalAction": + var a submitChangeRewardDenomsProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.downtimeSlashAction": + var a downtimeSlashAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.unbondTokensAction": + var a unbondTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.cancelUnbondTokensAction": + var a cancelUnbondTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.redelegateTokensAction": + var a redelegateTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.doublesignSlashAction": + var a doublesignSlashAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.startRelayerAction": + var a startRelayerAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.slashMeterReplenishmentAction": + var a slashMeterReplenishmentAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.waitTimeAction": + var a waitTimeAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.createIbcClientsAction": + var a createIbcClientsAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.LegacyUpgradeProposalAction": + var a LegacyUpgradeProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.waitUntilBlockAction": + var a waitUntilBlockAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.ChangeoverChainAction": + var a ChangeoverChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.StartSovereignChainAction": + var a StartSovereignChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientEquivocationAttackAction": + var a lightClientEquivocationAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientAmnesiaAttackAction": + var a lightClientAmnesiaAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientLunaticAttackAction": + var a lightClientLunaticAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + default: + return nil, fmt.Errorf("unknown action type: %s", actionTypeString) + } + return nil, err +} + +// custom marshal and unmarshal functions for the chainstate that convert proposals to/from the auxiliary type with type info + +// MarshalJSON transforms the ChainState into a ChainStateWithProposalTypes by adding type info to the proposals +func (c ChainState) MarshalJSON() ([]byte, error) { + chainStateCopy := ChainStateCopy(c) + chainStateWithProposalTypes := ChainStateWithProposalTypes{chainStateCopy, nil} + if c.Proposals != nil { + proposalsWithTypes := make(map[uint]ProposalAndType) + for k, v := range *c.Proposals { + rawMessage, err := json.Marshal(v) + if err != nil { + return nil, err + } + proposalsWithTypes[k] = ProposalAndType{rawMessage, reflect.TypeOf(v).String()} + } + chainStateWithProposalTypes.Proposals = &proposalsWithTypes + } + return json.Marshal(chainStateWithProposalTypes) +} + +// UnmarshalJSON unmarshals the ChainStateWithProposalTypes into a ChainState by removing the type info from the proposals and getting back standard proposals +func (c *ChainState) UnmarshalJSON(data []byte) error { + chainStateWithProposalTypes := ChainStateWithProposalTypes{} + err := json.Unmarshal(data, &chainStateWithProposalTypes) + if err != nil { + return err + } + + chainState := ChainState(chainStateWithProposalTypes.ChainStateCopy) + *c = chainState + + if chainStateWithProposalTypes.Proposals != nil { + proposals := make(map[uint]Proposal) + for k, v := range *chainStateWithProposalTypes.Proposals { + proposal, err := UnmarshalProposalWithType(v.RawProposal, v.Type) + if err != nil { + return err + } + proposals[k] = proposal + } + c.Proposals = &proposals + } + return nil +} + +// UnmarshalProposalWithType takes a JSON object and a proposal type and marshals into an object of the corresponding proposal. +func UnmarshalProposalWithType(inputMap json.RawMessage, proposalType string) (Proposal, error) { + var err error + switch proposalType { + case "main.TextProposal": + prop := TextProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ConsumerAdditionProposal": + prop := ConsumerAdditionProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.UpgradeProposal": + prop := UpgradeProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ConsumerRemovalProposal": + prop := ConsumerRemovalProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.EquivocationProposal": + prop := EquivocationProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ParamsProposal": + prop := ParamsProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + default: + return nil, fmt.Errorf("%s is not a known proposal type", proposalType) + } + + return nil, err +} diff --git a/tests/e2e/main.go b/tests/e2e/main.go index e9336422ae..f8f004a3a6 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -242,8 +242,15 @@ func (tr *TestRun) runStep(step Step, verbose bool) { tr.registerRepresentative(action, verbose) case assignConsumerPubKeyAction: tr.assignConsumerPubKey(action, verbose) +<<<<<<< HEAD case slashThrottleDequeue: tr.waitForSlashThrottleDequeue(action, verbose) +======= + case slashMeterReplenishmentAction: + tr.waitForSlashMeterReplenishment(action, verbose) + case waitTimeAction: + tr.waitForTime(action, verbose) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) case startRelayerAction: tr.startRelayer(action, verbose) case registerConsumerRewardDenomAction: diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 8cc343ef00..1ba4c90b92 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -23,11 +23,18 @@ type ChainState struct { RepresentativePowers *map[validatorID]uint Params *[]Param Rewards *Rewards +<<<<<<< HEAD ConsumerChains *map[chainID]bool AssignedKeys *map[validatorID]string ProviderKeys *map[validatorID]string // validatorID: validator provider key ConsumerChainQueueSizes *map[chainID]uint GlobalSlashQueueSize *uint +======= + ConsumerChains *map[ChainID]bool + AssignedKeys *map[ValidatorID]string + ProviderKeys *map[ValidatorID]string // validatorID: validator provider key + ConsumerPendingPacketQueueSize *uint // Only relevant to consumer chains +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) RegisteredConsumerRewardDenoms *[]string } @@ -168,6 +175,7 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState chainState.ProviderKeys = &providerKeys } +<<<<<<< HEAD if modelState.GlobalSlashQueueSize != nil { globalQueueSize := tr.getGlobalSlashQueueSize() chainState.GlobalSlashQueueSize = &globalQueueSize @@ -181,11 +189,18 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState chainState.ConsumerChainQueueSizes = &consumerChainQueueSizes } +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) if modelState.RegisteredConsumerRewardDenoms != nil { registeredConsumerRewardDenoms := tr.getRegisteredConsumerRewardDenoms(chain) chainState.RegisteredConsumerRewardDenoms = ®isteredConsumerRewardDenoms } + if modelState.ConsumerPendingPacketQueueSize != nil { + pendingPacketQueueSize := tr.getPendingPacketQueueSize(chain) + chainState.ConsumerPendingPacketQueueSize = &pendingPacketQueueSize + } + if *verbose { log.Println("Done getting chain state:\n" + pretty.Sprint(chainState)) } @@ -667,9 +682,16 @@ func (tr TestRun) getProviderAddressFromConsumer(consumerChain chainID, validato return addr } +<<<<<<< HEAD func (tr TestRun) getGlobalSlashQueueSize() uint { //#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 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, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) "query", "provider", "throttle-state", `--node`, tr.getQueryNode(chainID("provi")), @@ -680,6 +702,7 @@ func (tr TestRun) getGlobalSlashQueueSize() uint { log.Fatal(err, "\n", string(bz)) } +<<<<<<< HEAD packets := gjson.Get(string(bz), "packets").Array() return uint(len(packets)) } @@ -700,6 +723,10 @@ func (tr TestRun) getConsumerChainPacketQueueSize(consumerChain chainID) uint { size := gjson.Get(string(bz), "size").Uint() return uint(size) +======= + slashMeter := gjson.Get(string(bz), "slash_meter") + return slashMeter.Int() +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { @@ -724,7 +751,32 @@ func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { return rewardDenoms } +<<<<<<< HEAD func (tr TestRun) getValidatorNode(chain chainID, validator validatorID) string { +======= +func (tr TestConfig) getPendingPacketQueueSize(chain ChainID) uint { + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, + + "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 TestConfig) getValidatorNode(chain ChainID, validator ValidatorID) string { +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // for CometMock, validatorNodes are all the same address as the query node (which is CometMocks address) if tr.useCometmock { return tr.getQueryNode(chain) @@ -772,3 +824,7 @@ func (tr TestRun) curlJsonRPCRequest(method, params, address string) { verbosity := false executeCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) } + +func uintPtr(i uint) *uint { + return &i +} diff --git a/tests/e2e/state_rapid_test.go b/tests/e2e/state_rapid_test.go new file mode 100644 index 0000000000..b6ac12f111 --- /dev/null +++ b/tests/e2e/state_rapid_test.go @@ -0,0 +1,248 @@ +package main + +import ( + "testing" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "pgregory.net/rapid" +) + +// This file contains tests for serialization/deserialization of state. +// The tests are written using the rapid testing library, which allows us to +// generate arbitrary state structs and test that they can be serialized and +// deserialized without error. +// The generators for the various parts of the state are defined in this file, and +// essentially tell rapid how to build the state. + +func TestChainStateMarshalling(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + chainState := GetChainStateGen().Draw(t, "ChainState") + err := MarshalAndUnmarshalChainState(chainState) + if err != nil { + t.Fatalf("error marshalling and unmarshalling chain state: %v", err) + } + }) +} + +// Below this are utility functions for Rapid that define generators for the various structs that can appear in testing. +// These are used in the rapid tests and generate arbitrary test traces for fuzzing. +// These traces will not in general be useful to execute as e2e tests, since they are filled with essentially completely random values. +func GetStateGen() *rapid.Generator[State] { + return rapid.Custom(func(t *rapid.T) State { + return rapid.MapOf(GetChainIDGen(), GetChainStateGen()).Draw(t, "State") + }) +} + +func GetChainStateGen() *rapid.Generator[ChainState] { + return rapid.Custom( + func(t *rapid.T) ChainState { + valBalances := GetValBalancesGen().Draw(t, "ValBalances") + proposals := GetProposalsGen().Draw(t, "Proposals") + valPowers := GetValPowersGen().Draw(t, "ValPowers") + stakedTokens := GetStakedTokensGen().Draw(t, "StakedTokens") + params := GetParamsGen().Draw(t, "Params") + rewards := GetRewardsGen().Draw(t, "Rewards") + consumerChains := GetConsumerChainsGen().Draw(t, "ConsumerChains") + assignedKeys := GetAssignedKeysGen().Draw(t, "AssignedKeys") + providerKeys := GetProviderKeysGen().Draw(t, "ProviderKeys") + consumerPacketQueueSize := GetConsumerChainQueueSizesGen().Draw(t, "ConsumerChainQueueSizes") + registeredConsumerRewardDenoms := GetRegisteredConsumerRewardDenomsGen().Draw(t, "RegisteredConsumerRewardDenoms") + + return ChainState{ + ValBalances: &valBalances, + Proposals: &proposals, + ValPowers: &valPowers, + StakedTokens: &stakedTokens, + Params: ¶ms, + Rewards: &rewards, + ConsumerChains: &consumerChains, + AssignedKeys: &assignedKeys, + ProviderKeys: &providerKeys, + ConsumerPendingPacketQueueSize: &consumerPacketQueueSize, + RegisteredConsumerRewardDenoms: ®isteredConsumerRewardDenoms, + } + }) +} + +func GetRegisteredConsumerRewardDenomsGen() *rapid.Generator[[]string] { + return rapid.Custom(func(t *rapid.T) []string { + return rapid.SliceOf(rapid.String()).Draw(t, "RegisteredConsumerRewardDenoms") + }) +} + +func GetConsumerChainQueueSizesGen() *rapid.Generator[uint] { + return rapid.Custom(func(t *rapid.T) uint { + return rapid.Uint().Draw(t, "ConsumerChainQueueSizes") + }) +} + +func GetProviderKeysGen() *rapid.Generator[map[ValidatorID]string] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]string { + return rapid.MapOf(GetValidatorIDGen(), rapid.String()).Draw(t, "ProviderKeys") + }) +} + +func GetAssignedKeysGen() *rapid.Generator[map[ValidatorID]string] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]string { + return rapid.MapOf(GetValidatorIDGen(), rapid.String()).Draw(t, "AssignedKeys") + }) +} + +func GetChainIDGen() *rapid.Generator[ChainID] { + return rapid.Custom(func(t *rapid.T) ChainID { + return ChainID(rapid.String().Draw(t, "ChainID")) + }) +} + +func GetConsumerChainsGen() *rapid.Generator[map[ChainID]bool] { + return rapid.Custom(func(t *rapid.T) map[ChainID]bool { + return rapid.MapOf(GetChainIDGen(), rapid.Bool()).Draw(t, "ConsumerChains") + }) +} + +func GetRewardsGen() *rapid.Generator[Rewards] { + return rapid.Custom(func(t *rapid.T) Rewards { + return Rewards{ + IsIncrementalReward: rapid.Bool().Draw(t, "IsIncrementalReward"), + IsNativeDenom: rapid.Bool().Draw(t, "IsNativeDenom"), + IsRewarded: rapid.MapOf(GetValidatorIDGen(), rapid.Bool()).Draw(t, "IsRewarded"), + } + }) +} + +func GetParamsGen() *rapid.Generator[[]Param] { + return rapid.Custom(func(t *rapid.T) []Param { + return rapid.SliceOf(GetParamGen()).Draw(t, "Params") + }) +} + +func GetParamGen() *rapid.Generator[Param] { + return rapid.Custom(func(t *rapid.T) Param { + return Param{ + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), + } + }) +} + +func GetStakedTokensGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "StakedTokens") + }) +} + +func GetValPowersGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "ValPowers") + }) +} + +func GetValBalancesGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "ValBalances") + }) +} + +func GetValidatorIDGen() *rapid.Generator[ValidatorID] { + return rapid.Custom(func(t *rapid.T) ValidatorID { + return ValidatorID(rapid.String().Draw(t, "ValidatorID")) + }) +} + +func GetProposalsGen() *rapid.Generator[map[uint]Proposal] { + return rapid.Custom(func(t *rapid.T) map[uint]Proposal { + return rapid.MapOf( + rapid.Uint(), + GetProposalGen(), + ).Draw(t, "Proposals") + }) +} + +func GetProposalGen() *rapid.Generator[Proposal] { + return rapid.Custom(func(t *rapid.T) Proposal { + gen := rapid.OneOf( + GetConsumerAdditionProposalGen().AsAny(), + GetConsumerRemovalProposalGen().AsAny(), + GetEquivocationProposalGen().AsAny(), + GetTextProposalGen().AsAny(), + GetParamsProposalGen().AsAny(), + ) + return gen.Draw(t, "Proposal").(Proposal) + }) +} + +func GetConsumerAdditionProposalGen() *rapid.Generator[ConsumerAdditionProposal] { + return rapid.Custom(func(t *rapid.T) ConsumerAdditionProposal { + return ConsumerAdditionProposal{ + Deposit: rapid.Uint().Draw(t, "Deposit"), + Chain: GetChainIDGen().Draw(t, "Chain"), + SpawnTime: rapid.Int().Draw(t, "SpawnTime"), + InitialHeight: GetHeightGen().Draw(t, "InitialHeight"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetConsumerRemovalProposalGen() *rapid.Generator[ConsumerRemovalProposal] { + return rapid.Custom(func(t *rapid.T) ConsumerRemovalProposal { + return ConsumerRemovalProposal{ + Deposit: rapid.Uint().Draw(t, "Deposit"), + Chain: GetChainIDGen().Draw(t, "Chain"), + StopTime: rapid.Int().Draw(t, "StopTime"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetEquivocationProposalGen() *rapid.Generator[EquivocationProposal] { + return rapid.Custom(func(t *rapid.T) EquivocationProposal { + return EquivocationProposal{ + Power: rapid.Uint().Draw(t, "Power"), + Height: rapid.Uint().Draw(t, "Height"), + ConsensusAddress: rapid.String().Draw(t, "ConesnsuAddress"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetTextProposalGen() *rapid.Generator[TextProposal] { + return rapid.Custom(func(t *rapid.T) TextProposal { + return TextProposal{ + Title: rapid.String().Draw(t, "Title"), + Description: rapid.String().Draw(t, "Description"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetParamsProposalGen() *rapid.Generator[ParamsProposal] { + return rapid.Custom(func(t *rapid.T) ParamsProposal { + return ParamsProposal{ + Subspace: rapid.String().Draw(t, "Subspace"), + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetHeightGen() *rapid.Generator[clienttypes.Height] { + return rapid.Custom(func(t *rapid.T) clienttypes.Height { + return clienttypes.Height{ + RevisionNumber: rapid.Uint64().Draw(t, "RevisionNumber"), + RevisionHeight: rapid.Uint64().Draw(t, "RevisionHeight"), + } + }) +} diff --git a/tests/e2e/steps_downtime.go b/tests/e2e/steps_downtime.go index e6d320bec1..3ef7284601 100644 --- a/tests/e2e/steps_downtime.go +++ b/tests/e2e/steps_downtime.go @@ -53,11 +53,20 @@ func stepsDowntime(consumerName string) []Step { validatorID("carol"): 501, }, }, +<<<<<<< HEAD chainID(consumerName): ChainState{ ValPowers: &map[validatorID]uint{ validatorID("alice"): 509, validatorID("bob"): 500, validatorID("carol"): 501, +======= + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + // Bob's stake may or may not be slashed at this point depending on comet vs cometmock + // See https://github.com/cosmos/interchain-security/issues/1304 + ValidatorID("carol"): 501, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) }, }, }, @@ -277,6 +286,7 @@ func stepsThrottledDowntime(consumerName string) []Step { chain: chainID(consumerName), validator: validatorID("bob"), }, +<<<<<<< HEAD state: State{ // slash packet queued on consumer, but powers not affected on either chain yet chainID("provi"): ChainState{ @@ -284,6 +294,15 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("alice"): 511, validatorID("bob"): 500, validatorID("carol"): 500, +======= + State: State{ + // slash packet queued for bob on consumer, but powers not affected on either chain yet + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) }, }, chainID(consumerName): ChainState{ @@ -292,6 +311,7 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("bob"): 500, validatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // bob's downtime slash packet is queued }, }, }, @@ -312,11 +332,14 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("bob"): 0, // bob is jailed validatorID("carol"): 500, }, +<<<<<<< HEAD // no provider throttling engaged yet GlobalSlashQueueSize: uintPointer(0), ConsumerChainQueueSizes: &map[chainID]uint{ chainID(consumerName): uint(0), }, +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) }, chainID(consumerName): ChainState{ // VSC packet applying jailing is not yet relayed to consumer @@ -325,14 +348,17 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("bob"): 500, validatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(0), // slash packet handled ack clears consumer queue }, }, }, + // Invoke carol downtime slash on consumer { action: downtimeSlashAction{ chain: chainID(consumerName), validator: validatorID("carol"), }, +<<<<<<< HEAD state: State{ // powers not affected on either chain yet chainID("provi"): ChainState{ @@ -348,10 +374,27 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("alice"): 511, validatorID("bob"): 500, validatorID("carol"): 500, +======= + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, // VSC packet jailing bob is not yet relayed to consumer + ValidatorID("carol"): 500, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) + }, + ConsumerPendingPacketQueueSize: uintPtr(1), // carol's downtime slash packet is queued + }, }, }, + // Relay slash packet to provider, and ack back to consumer { action: relayPacketsAction{ chainA: chainID("provi"), @@ -359,6 +402,7 @@ func stepsThrottledDowntime(consumerName string) []Step { port: "provider", channel: 0, }, +<<<<<<< HEAD state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ @@ -376,11 +420,28 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("alice"): 511, validatorID("bob"): 0, validatorID("carol"): 500, +======= + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, // slash packet for carol recv by provider, carol not slashed due to throttling }, }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, // VSC packet applying bob jailing is also relayed and recv by consumer + ValidatorID("carol"): 500, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) + }, + ConsumerPendingPacketQueueSize: uintPtr(1), // slash packet bounced ack keeps carol's downtime slash packet queued + }, }, }, { +<<<<<<< HEAD action: slashThrottleDequeue{ chain: chainID(consumerName), currentQueueSize: 1, @@ -400,6 +461,22 @@ func stepsThrottledDowntime(consumerName string) []Step { GlobalSlashQueueSize: uintPointer(0), // slash packets dequeued ConsumerChainQueueSizes: &map[chainID]uint{ chainID(consumerName): 0, +======= + Action: slashMeterReplenishmentAction{ + TargetValue: 0, // We just want slash meter to be non-negative + + // Slash meter replenish fraction is set to 10%, replenish period is 20 seconds, see config.go + // Meter is initially at 10%, decremented to -23% from bob being jailed. It'll then take three replenishments + // for meter to become positive again. 3*20 = 60 seconds + buffer = 100 seconds + Timeout: 100 * time.Second, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, // Carol still not slashed, packet must be retried +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) }, }, chainID(consumerName): ChainState{ @@ -409,11 +486,31 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("bob"): 0, validatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued }, }, }, - // A block is incremented each action, hence why VSC is committed on provider, - // and can now be relayed as packet to consumer + // Wait for retry delay period to pass. + // Retry delay period is set to 30 seconds, see config.go, + // wait this amount of time to elapse the period. + { + Action: waitTimeAction{ + WaitTime: 30 * time.Second, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, + }, + }, + ChainID(consumerName): ChainState{ + ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued + }, + }, + }, + // Relay now that retry delay period has passed, confirm provider applies jailing { action: relayPacketsAction{ chainA: chainID("provi"), @@ -421,6 +518,7 @@ func stepsThrottledDowntime(consumerName string) []Step { port: "provider", channel: 0, }, +<<<<<<< HEAD state: State{ chainID("provi"): ChainState{ ValPowers: &map[validatorID]uint{ @@ -440,6 +538,18 @@ func stepsThrottledDowntime(consumerName string) []Step { validatorID("bob"): 0, validatorID("carol"): 0, }, +======= + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 0, // jailed! + }, + }, + ChainID(consumerName): ChainState{ + ConsumerPendingPacketQueueSize: uintPtr(0), // relayed slash packet handled ack clears consumer queue +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) }, }, }, diff --git a/tests/e2e/tracehandler_testdata/changeover.json b/tests/e2e/tracehandler_testdata/changeover.json new file mode 100644 index 0000000000..8f90a114e3 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/changeover.json @@ -0,0 +1,586 @@ +[ + { + "ActionType": "main.StartSovereignChainAction", + "Action": { + "Chain": "sover", + "Validators": [ + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "" + }, + "State": { + "sover": { + "ValBalances": { + "alice": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.createIbcClientsAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi" + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "Version": "ics20-1" + }, + "State": {} + }, + { + "ActionType": "main.LegacyUpgradeProposalAction", + "Action": { + "ChainID": "sover", + "UpgradeTitle": "sovereign-changeover", + "Proposer": "alice", + "UpgradeHeight": 110 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Title": "sovereign-changeover", + "Description": "", + "UpgradeHeight": 110, + "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + "Deposit": 10000000, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.UpgradeProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "sover", + "From": [ + "alice" + ], + "Vote": [ + "yes" + ], + "PropNumber": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Title": "sovereign-changeover", + "Description": "", + "UpgradeHeight": 110, + "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + "Deposit": 10000000, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.UpgradeProposal" + } + } + } + } + }, + { + "ActionType": "main.waitUntilBlockAction", + "Action": { + "Block": 110, + "Chain": "sover" + }, + "State": {} + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": true, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "DistributionChannel": "channel-0" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.ChangeoverChainAction", + "Action": { + "SovereignChain": "sover", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ClientA": 1, + "ClientB": 1 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ConnectionA": 1, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "bob", + "Amount": 100 + }, + "State": { + "sover": { + "ValBalances": { + "bob": 0 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "sover", + "Port": "provider", + "Channel": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "bob", + "Amount": 100 + }, + "State": { + "sover": { + "ValBalances": { + "bob": 100 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "sover", + "Port": "provider", + "Channel": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/democracy.json b/tests/e2e/tracehandler_testdata/democracy.json new file mode 100644 index 0000000000..a696258ab9 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/democracy.json @@ -0,0 +1,918 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.transferChannelCompleteAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "ChannelA": 1, + "ChannelB": 1 + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.registerRepresentativeAction", + "Action": { + "Chain": "democ", + "Representatives": [ + "alice", + "bob" + ], + "Stakes": [ + 100000000, + 40000000 + ] + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": { + "alice": 100000000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": false + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "democ", + "From": "carol", + "To": "alice", + "Amount": 500000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitParamChangeLegacyProposalAction", + "Action": { + "Chain": "democ", + "From": "alice", + "Deposit": 10000001, + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": true + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9889999998, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "democ", + "From": [ + "alice", + "bob" + ], + "Vote": [ + "yes", + "no" + ], + "PropNumber": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9899999999, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.submitChangeRewardDenomsProposalAction", + "Action": { + "Denom": "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [ + "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9" + ], + "Proposals": null + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "democ", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json new file mode 100644 index 0000000000..aa79dcd5d8 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json @@ -0,0 +1,924 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.transferChannelCompleteAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "ChannelA": 1, + "ChannelB": 1 + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.registerRepresentativeAction", + "Action": { + "Chain": "democ", + "Representatives": [ + "alice", + "bob" + ], + "Stakes": [ + 100000000, + 40000000 + ] + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": { + "alice": 100000000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": false + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "democ", + "From": "carol", + "To": "alice", + "Amount": 500000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitParamChangeLegacyProposalAction", + "Action": { + "Chain": "democ", + "From": "alice", + "Deposit": 10000001, + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": true + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9889999998, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "false" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "democ", + "From": [ + "alice", + "bob" + ], + "Vote": [ + "yes", + "no" + ], + "PropNumber": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9899999999, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.submitChangeRewardDenomsProposalAction", + "Action": { + "Denom": "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [ + "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9" + ], + "Proposals": null + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "democ", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/happyPath.json b/tests/e2e/tracehandler_testdata/happyPath.json new file mode 100644 index 0000000000..c7b891777d --- /dev/null +++ b/tests/e2e/tracehandler_testdata/happyPath.json @@ -0,0 +1,1935 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o=\"}", + "ReconfigureNode": true, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "bob": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "bob": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.cancelUnbondTokensAction", + "Action": { + "Chain": "provi", + "Delegator": "alice", + "Validator": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 450000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "alice" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "carol", + "Dst": "alice", + "TxSender": "carol", + "Amount": 449000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883367+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Title": "", + "Description": "", + "Deposit": 0, + "Status": "" + }, + "Type": "main.TextProposal" + } + } + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.88337+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.startRelayerAction", + "Action": {}, + "State": {} + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "no", + "no", + "no" + ], + "PropNumber": 3 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_REJECTED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 4 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/multipleConsumers.json b/tests/e2e/tracehandler_testdata/multipleConsumers.json new file mode 100644 index 0000000000..1cb46af06c --- /dev/null +++ b/tests/e2e/tracehandler_testdata/multipleConsumers.json @@ -0,0 +1,2284 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "densu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "densu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "densu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "densu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "densu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 1 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "densu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/shorthappy.json b/tests/e2e/tracehandler_testdata/shorthappy.json new file mode 100644 index 0000000000..70486add49 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/shorthappy.json @@ -0,0 +1,1523 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883385+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Title": "", + "Description": "", + "Deposit": 0, + "Status": "" + }, + "Type": "main.TextProposal" + } + } + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883388+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.startRelayerAction", + "Action": {}, + "State": {} + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "no", + "no", + "no" + ], + "PropNumber": 3 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_REJECTED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 4 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/slashThrottle.json b/tests/e2e/tracehandler_testdata/slashThrottle.json new file mode 100644 index 0000000000..d0173d03a8 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/slashThrottle.json @@ -0,0 +1,805 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 0, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.slashMeterReplenishmentAction", + "Action": { + "TargetValue": 0, + "Timeout": 100000000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.waitTimeAction", + "Action": { + "WaitTime": 30000000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 0, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/integration/common.go b/tests/integration/common.go index 7d5175d5d7..340a9656d7 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -414,6 +414,7 @@ func (suite *CCVTestSuite) commitConsumerPacket(ctx sdk.Context, packetData ccv. func (s *CCVTestSuite) constructSlashPacketFromConsumer(bundle icstestingutils.ConsumerBundle, tmVal tmtypes.Validator, infractionType stakingtypes.Infraction, ibcSeqNum uint64, ) channeltypes.Packet { +<<<<<<< HEAD valsetUpdateId := bundle.GetKeeper().GetHeightValsetUpdateID( bundle.GetCtx(), uint64(bundle.GetCtx().BlockHeight())) @@ -458,6 +459,35 @@ func (s *CCVTestSuite) constructVSCMaturedPacketFromConsumer(bundle icstestingut } return channeltypes.NewPacket(data.GetBytes(), +======= + packet, _ := s.constructSlashPacketFromConsumerWithData(bundle, tmVal, infractionType, ibcSeqNum) + return packet +} + +func (s *CCVTestSuite) constructSlashPacketFromConsumerWithData(bundle icstestingutils.ConsumerBundle, + tmVal tmtypes.Validator, infractionType stakingtypes.Infraction, ibcSeqNum uint64, +) (channeltypes.Packet, ccv.SlashPacketData) { + valsetUpdateId := bundle.GetKeeper().GetHeightValsetUpdateID( + bundle.GetCtx(), uint64(bundle.GetCtx().BlockHeight())) + + spdData := ccv.SlashPacketData{ + Validator: abci.Validator{ + Address: tmVal.Address, + Power: tmVal.VotingPower, + }, + ValsetUpdateId: valsetUpdateId, + Infraction: infractionType, + } + + cpdData := ccv.ConsumerPacketData{ + Type: ccv.SlashPacket, + Data: &ccv.ConsumerPacketData_SlashPacketData{ + SlashPacketData: &spdData, + }, + } + + return channeltypes.NewPacket(cpdData.GetBytes(), +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) ibcSeqNum, ccv.ConsumerPortID, // Src port bundle.Path.EndpointA.ChannelID, // Src channel @@ -465,7 +495,11 @@ func (s *CCVTestSuite) constructVSCMaturedPacketFromConsumer(bundle icstestingut bundle.Path.EndpointB.ChannelID, // Dst channel clienttypes.Height{}, uint64(bundle.GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()), +<<<<<<< HEAD ) +======= + ), spdData +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } // incrementTime increments the overall time by jumpPeriod @@ -615,3 +649,11 @@ func (s *CCVTestSuite) setupValidatorPowers() { } s.Require().Equal(int64(4000), stakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) } + +// mustGetStakingValFromTmVal returns the staking validator from the current state of the staking keeper, +// corresponding to a given tendermint validator. Note this func will fail the test if the validator is not found. +func (s *CCVTestSuite) mustGetStakingValFromTmVal(tmVal tmtypes.Validator) (stakingVal stakingtypes.Validator) { + stakingVal, found := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), sdk.ConsAddress(tmVal.Address)) + s.Require().True(found) + return stakingVal +} diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go index 1ce7d11db8..d94877d1a0 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -68,31 +68,46 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) // Send slash packet from the first consumer chain +<<<<<<< HEAD packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) err = s.getFirstBundle().Path.EndpointA.SendPacket(packet) +======= + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) + ) + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + sequence, err := s.getFirstBundle().Path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) s.Require().NoError(err) // Set outstanding slashing flag for first consumer, it's important to use the consumer's cons addr here firstConsumerKeeper.SetOutstandingDowntime(s.consumerCtx(), consumerConsAddr.ToSdkConsAddr()) // Note: RecvPacket advances two blocks. Let's say the provider is currently at height N. - // The received slash packet will be queued during N, and handled by the ccv module during - // the endblocker of N. The staking module will then register a validator update from that - // packet during the endblocker of N+1 (note that staking endblocker runs before ccv endblocker, - // hence why the VSC is registered on N+1). Then the ccv module sends VSC packets to each consumer - // during the endblocker of N+1. The new validator set will be committed to in block N+2, - // and will be in effect for the provider during block N+3. + // The received slash packet will be handled during N. The staking module will then register + // a validator update from that packet during the endblocker of N. Then the ccv module sends + // VSC packets to each consumer during the endblocker of N (note ccv endblocker runs after staking). + // The new validator set will be committed to in block N+1, and will be in effect + // for the provider during block N+2. valsetUpdateIdN := providerKeeper.GetValidatorSetUpdateId(s.providerCtx()) // receive the slash packet on the provider chain. RecvPacket() calls the provider endblocker twice +<<<<<<< HEAD +======= + packet := s.newPacketFromConsumer(slashPacket.GetData(), sequence, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp) + heightBefore := s.providerCtx().BlockHeight() +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) err = s.path.EndpointB.RecvPacket(packet) + heightAfter := s.providerCtx().BlockHeight() s.Require().NoError(err) + s.Require().Equal(heightBefore+2, heightAfter) // We've now advanced two blocks. - // VSC packets should have been sent from provider during block N+1 to each consumer - expectedSentValsetUpdateId := valsetUpdateIdN + 1 + // VSC packets should have been sent from provider during block N to each consumer + expectedSentValsetUpdateId := valsetUpdateIdN for _, bundle := range s.consumerBundles { _, found := providerKeeper.GetVscSendTimestamp(s.providerCtx(), bundle.Chain.ChainID, expectedSentValsetUpdateId) @@ -104,10 +119,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { s.Require().Equal(valsetUpdateIdN+2, providerKeeper.GetValidatorSetUpdateId(s.providerCtx())) - // Call next block so provider is now on block N + 3 mentioned above - s.providerChain.NextBlock() - - // check that the validator was removed from the provider validator set by N + 3 + // check that the validator was removed from the provider validator set by N + 2 s.Require().Len(s.providerChain.Vals.Validators, validatorsPerChain-1) for _, bundle := range s.consumerBundles { @@ -151,9 +163,10 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { pFlag := firstConsumerKeeper.OutstandingDowntime(s.consumerCtx(), consumerConsAddr.ToSdkConsAddr()) s.Require().False(pFlag) - // check that slashing packet gets acknowledged successfully - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) + // Check that first consumer can recv ack from provider. + // Provider has returned SlashPacketHandledResult. + ack := channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) s.Require().NoError(err) } @@ -196,6 +209,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) // Send slash packet from the first consumer chain +<<<<<<< HEAD packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1) err = s.getFirstBundle().Path.EndpointA.SendPacket(packet) s.Require().NoError(err) @@ -203,6 +217,14 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { // receive the slash packet on the provider chain. RecvPacket() advances two blocks err = s.path.EndpointB.RecvPacket(packet) s.Require().NoError(err) +======= + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) + ) + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1) + packet := sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // Advance a few more blocks to make sure any voting power changes would be reflected s.providerChain.NextBlock() @@ -234,8 +256,9 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { // check that validator was NOT tombstoned on provider s.Require().False(valSignInfo.Tombstoned) - // check that slashing packet gets acknowledged successfully - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + // check that slashing packet gets acknowledged successfully, + // provider returns V1Result acks for double sign packets + ack := channeltypes.NewResultAcknowledgement(ccv.V1Result) err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) s.Require().NoError(err) } @@ -426,16 +449,10 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() { errAck = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashingPkt) suite.Require().False(errAck.Success()) - // Expect nothing was queued - suite.Require().Equal(0, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) - suite.Require().Equal(uint64(0), (providerKeeper.GetThrottledPacketDataSize(ctx, consumerChainID))) - // expect to queue entries for the slash request slashingPkt.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME ack = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashingPkt) suite.Require().True(ack.Success()) - suite.Require().Equal(1, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) - suite.Require().Equal(uint64(1), (providerKeeper.GetThrottledPacketDataSize(ctx, consumerChainID))) } // TestValidatorDowntime tests if a slash packet is sent diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index b3d32ee6a4..452b28e3b1 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -80,33 +79,6 @@ func (s *CCVTestSuite) TestStopConsumerChain() { return nil }, }, - { - func(suite *CCVTestSuite) error { - // Queue slash and vsc packet data for consumer 0, these queue entries will be removed - firstBundle := s.getFirstBundle() - globalEntry := types.NewGlobalSlashEntry(s.providerCtx().BlockTime(), firstBundle.Chain.ChainID, 7, types.ProviderConsAddress{Address: []byte{}}) - providerKeeper.QueueGlobalSlashEntry(s.providerCtx(), globalEntry) - err := providerKeeper.QueueThrottledSlashPacketData(s.providerCtx(), firstBundle.Chain.ChainID, 1, - ccv.SlashPacketData{ValsetUpdateId: 1}) - suite.Require().NoError(err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(s.providerCtx(), - firstBundle.Chain.ChainID, 2, ccv.VSCMaturedPacketData{ValsetUpdateId: 2}) - suite.Require().NoError(err) - - // Queue slash and vsc packet data for consumer 1, these queue entries will be not be removed - secondBundle := s.getBundleByIdx(1) - globalEntry = types.NewGlobalSlashEntry(s.providerCtx().BlockTime(), secondBundle.Chain.ChainID, 7, types.ProviderConsAddress{Address: []byte{}}) - providerKeeper.QueueGlobalSlashEntry(s.providerCtx(), globalEntry) - err = providerKeeper.QueueThrottledSlashPacketData(s.providerCtx(), secondBundle.Chain.ChainID, 1, - ccv.SlashPacketData{ValsetUpdateId: 1}) - suite.Require().NoError(err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(s.providerCtx(), - secondBundle.Chain.ChainID, 2, ccv.VSCMaturedPacketData{ValsetUpdateId: 2}) - suite.Require().NoError(err) - - return nil - }, - }, } for _, so := range setupOperations { @@ -120,15 +92,6 @@ func (s *CCVTestSuite) TestStopConsumerChain() { // check all states are removed and the unbonding operation released s.checkConsumerChainIsRemoved(firstBundle.Chain.ChainID, true) - - // check entries related to second consumer chain are not removed - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 1) - - secondBundle := s.getBundleByIdx(1) - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), secondBundle.Chain.ChainID) - s.Require().Len(slashData, 1) - s.Require().Len(vscMaturedData, 1) } // TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end @@ -199,15 +162,4 @@ func (s *CCVTestSuite) checkConsumerChainIsRemoved(chainID string, checkChannel s.Require().Nil(providerKeeper.GetSlashAcks(s.providerCtx(), chainID)) s.Require().Zero(providerKeeper.GetInitChainHeight(s.providerCtx(), chainID)) s.Require().Empty(providerKeeper.GetPendingVSCPackets(s.providerCtx(), chainID)) - - // No remaining global entries for this consumer - allGlobalEntries := providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - for _, entry := range allGlobalEntries { - s.Require().NotEqual(chainID, entry.ConsumerChainID) - } - - // No remaining per-chain entries for this consumer - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData(s.providerCtx(), chainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMaturedData) } diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go index 0505d6257a..d947e410d6 100644 --- a/tests/integration/throttle.go +++ b/tests/integration/throttle.go @@ -63,8 +63,13 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { // Send a slash packet from consumer to provider s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[0]) tmVal := s.providerChain.Vals.Validators[0] +<<<<<<< HEAD packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet) +======= + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // Assert validator 0 is jailed and has no power vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) @@ -82,10 +87,16 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { // Now send a second slash packet from consumer to provider for a different validator. s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[2]) tmVal = s.providerChain.Vals.Validators[2] +<<<<<<< HEAD packet = s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet) +======= + slashPacket = s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) - // Require that slash packet has not been handled + // Require that slash packet has not been handled, a bounce result would have + // been returned, but the IBC helper throws out acks. vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) s.Require().False(vals[2].IsJailed()) @@ -135,11 +146,14 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { slashMeter = s.providerApp.GetProviderKeeper().GetSlashMeter(cacheCtx) s.Require().True(slashMeter.IsPositive()) - // Assert validator 2 is jailed once pending slash packets are handled in ccv endblocker. - s.providerChain.NextBlock() - vals = providerStakingKeeper.GetAllValidators(cacheCtx) - slashedVal = vals[2] - s.Require().True(slashedVal.IsJailed()) + // Assert validator 2 is jailed once slash packet is retried. + tmVal2 := s.providerChain.Vals.Validators[2] + packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), + *tmVal2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) // make sure to use a new seq num + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + stakingVal2 := s.mustGetStakingValFromTmVal(*tmVal2) + s.Require().True(stakingVal2.IsJailed()) // Assert validator 2 has no power, this should be apparent next block, // since the staking endblocker runs before the ccv endblocker. @@ -156,6 +170,7 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.SetupAllCCVChannels() s.setupValidatorPowers() +<<<<<<< HEAD providerKeeper := s.providerApp.GetProviderKeeper() providerStakingKeeper := s.providerApp.GetTestStakingKeeper() @@ -172,6 +187,14 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), consumerChainID)) } +======= + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) + + providerStakingKeeper := s.providerApp.GetTestStakingKeeper() +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // Choose 3 consumer bundles. It doesn't matter which ones. idx := 0 @@ -184,7 +207,7 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { idx++ } - // Send some packets to provider from the 3 chosen consumers. + // Send some slash packets to provider from the 3 chosen consumers. // They will each slash a different validator according to idx. idx = 0 valsToSlash := []tmtypes.Validator{} @@ -200,6 +223,7 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { *bundle, *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, +<<<<<<< HEAD 3, // use sequence 3, 1 and 2 are used above. ) sendOnConsumerRecvOnProvider(s, bundle.Path, packet) @@ -209,45 +233,72 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { sendOnConsumerRecvOnProvider(s, bundle.Path, packet) packet = s.constructVSCMaturedPacketFromConsumer(*bundle, 5) // use sequence 5 sendOnConsumerRecvOnProvider(s, bundle.Path, packet) +======= + 1, // all consumers use 1 seq num + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) idx++ } - // Confirm that the slash packet and trailing VSC matured packet - // were handled immediately for the first consumer (this packet was recv first). + // Confirm that the slash packet for the first consumer was handled (this packet was recv first). s.confirmValidatorJailed(valsToSlash[0], true) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[0].Chain.ChainID)) - // Packets were queued for the second and third consumers. + // Packets were bounced for the second and third consumers. s.confirmValidatorNotJailed(valsToSlash[1], 1000) - s.Require().Equal(uint64(3), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[1].Chain.ChainID)) s.confirmValidatorNotJailed(valsToSlash[2], 1000) - s.Require().Equal(uint64(3), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[2].Chain.ChainID)) // Total power is now 3000 s.Require().Equal(int64(3000), providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) // Now replenish the slash meter and confirm one of two queued slash - // packet entries are then handled. Order is irrelevant here since those - // two packets were sent and recv at the same block time when being queued. + // packet entries are then handled, when both are retried. s.replenishSlashMeterTillPositive() - // 1st NextBlock will handle the slash packet, 2nd will update staking module val powers + // Retry from consumer with idx 1 + bundle := senderBundles[1] + packet := s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[1], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 2, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // retry from consumer with idx 2 + bundle = senderBundles[2] + packet = s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[2], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 2, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // Call NextBlocks to update staking module val powers s.providerChain.NextBlock() s.providerChain.NextBlock() - // If one of the entires was handled, total power will be 2000 (1000 power was slashed) + // If one of the entires was handled, total power will be 2000 (1000 power was just slashed) s.Require().Equal(int64(2000), providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) // Now replenish one more time, and handle final slash packet. s.replenishSlashMeterTillPositive() - // 1st NextBlock will handle the slash packet, 2nd will update last validator power + // Retry from consumer with idx 2 + bundle = senderBundles[2] + packet = s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[2], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 3, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // Call NextBlocks to update staking module val powers s.providerChain.NextBlock() s.providerChain.NextBlock() @@ -260,15 +311,6 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { for _, val := range valsToSlash { s.confirmValidatorJailed(val, true) } - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[0].Chain.ChainID)) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[1].Chain.ChainID)) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[2].Chain.ChainID)) - - // All global queue entries are gone too - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) } // TestPacketSpam confirms that the provider can handle a large number of @@ -312,7 +354,12 @@ func (s *CCVTestSuite) TestPacketSpam() { infractionType = stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN } valToJail := s.providerChain.Vals.Validators[ibcSeqNum%3] +<<<<<<< HEAD packets = append(packets, s.constructSlashPacketFromConsumer(firstBundle, *valToJail, infractionType, ibcSeqNum)) +======= + slashPacket := s.constructSlashPacketFromConsumer(firstBundle, *valToJail, infractionType, ibcSeqNum) + packetsData = append(packetsData, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } // Recv 500 packets from consumer to provider in same block @@ -322,17 +369,14 @@ func (s *CCVTestSuite) TestPacketSpam() { providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) } - // Execute block to handle packets in endblock + // Execute block s.providerChain.NextBlock() - // Confirm all packets are handled or dropped (queues empty) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), firstBundle.Chain.ChainID)) - slashData, vscMData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMData) - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) + // Confirm 3 expected vals are jailed + for i := 0; i < 3; i++ { + val := s.providerChain.Vals.Validators[i] + s.confirmValidatorJailed(*val, true) + } } func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { @@ -366,7 +410,12 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { // Increment ibc seq num for each packet (starting at 1) ibcSeqNum++ valToJail := s.providerChain.Vals.Validators[ibcSeqNum%3] +<<<<<<< HEAD packets = append(packets, s.constructSlashPacketFromConsumer(firstBundle, *valToJail, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, ibcSeqNum)) +======= + slashPacket := s.constructSlashPacketFromConsumer(firstBundle, *valToJail, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, ibcSeqNum) + packetsData = append(packetsData, slashPacket.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } // Recv 500 packets from consumer to provider in same block @@ -379,15 +428,6 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { // Execute block to handle packets in endblock s.providerChain.NextBlock() - // Confirm all packets are dropped (queues empty) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), firstBundle.Chain.ChainID)) - slashData, vscMData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMData) - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) - // Confirm that slash meter is not affected s.Require().Equal(providerKeeper.GetSlashMeterAllowance(s.providerCtx()), providerKeeper.GetSlashMeter(s.providerCtx())) @@ -417,6 +457,7 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { } } +<<<<<<< HEAD // TestQueueOrdering validates that the ordering of slash packet entries // in the global queue (relevant to a single chain) matches the ordering of slash packet // data in the chain specific queues, even in the presence of packet spam. @@ -566,6 +607,8 @@ func (s *CCVTestSuite) TestQueueOrdering() { s.Require().Equal(0, len(vscMaturedPacketData)) } +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // TestSlashingSmallValidators tests that multiple slash packets from validators with small // power can be handled by the provider chain in a non-throttled manner. func (s *CCVTestSuite) TestSlashingSmallValidators() { @@ -598,12 +641,21 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() { tmval1 := s.providerChain.Vals.Validators[1] tmval2 := s.providerChain.Vals.Validators[2] tmval3 := s.providerChain.Vals.Validators[3] +<<<<<<< HEAD packet1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) packet2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) packet3 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet1) sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet2) sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet3) +======= + slashPacket1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + slashPacket2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) + slashPacket3 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket1.GetData()) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket2.GetData()) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket3.GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // Default slash meter replenish fraction is 0.05, so all sent packets should be handled immediately. vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) @@ -645,6 +697,7 @@ func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() { s.Require().Equal(int64(1200), providerKeeper.GetSlashMeterAllowance(s.providerCtx()).Int64()) } +<<<<<<< HEAD // TestSlashSameValidator tests the edge case that that the total slashed validator power // queued up for a single block exceeds the slash meter allowance, // but some of the slash packets are for the same validator, and therefore some packets @@ -698,6 +751,8 @@ func (s *CCVTestSuite) TestSlashSameValidator() { s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 0) } +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, // and in the first packets recv for that block. // This edge case should not occur in practice, but is useful to validate that @@ -726,18 +781,29 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes // Instantiate a slash packet for each validator, // these first 4 packets should jail 100% of the total power. + ibcSeqNum := uint64(1) for _, val := range s.providerChain.Vals.Validators { s.setDefaultValSigningInfo(*val) +<<<<<<< HEAD packets = append(packets, s.constructSlashPacketFromConsumer( s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum)) +======= + packetsData = append(packetsData, s.constructSlashPacketFromConsumer( + s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum).GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) ibcSeqNum++ } // add 5 more slash packets for each validator, that will be handled in the same block. for _, val := range s.providerChain.Vals.Validators { for i := 0; i < 5; i++ { +<<<<<<< HEAD packets = append(packets, s.constructSlashPacketFromConsumer( s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum)) +======= + packetsData = append(packetsData, s.constructSlashPacketFromConsumer( + s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum).GetData()) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) ibcSeqNum++ } } @@ -749,17 +815,7 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) } - // We should have 24 pending slash packet entries queued. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 24) - - // Call next block to process all pending slash packets in end blocker. - s.providerChain.NextBlock() - - // All slash packets should have been handled immediately, - // even though the first 4 packets jailed 100% of the total power. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 0) - - // Sanity check that all validators are jailed. + // Check that all validators are jailed. for _, val := range s.providerChain.Vals.Validators { // Do not check power, since val power is not yet updated by staking endblocker. s.confirmValidatorJailed(*val, false) @@ -769,6 +825,7 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes // "applying the validator changes would result in empty set". } +<<<<<<< HEAD func (s *CCVTestSuite) TestLeadingVSCMaturedAreDequeued() { s.SetupAllCCVChannels() providerKeeper := s.providerApp.GetProviderKeeper() @@ -911,6 +968,8 @@ func (s *CCVTestSuite) TestVscMaturedHandledPerBlockLimit() { s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) // empty global entries = all slash packets handled } +======= +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) func (s *CCVTestSuite) confirmValidatorJailed(tmVal tmtypes.Validator, checkPower bool) { sdkVal, found := s.providerApp.GetTestStakingKeeper().GetValidator( s.providerCtx(), sdk.ValAddress(tmVal.Address)) diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go index ae15aac977..cecf76c1df 100644 --- a/tests/integration/throttle_retry.go +++ b/tests/integration/throttle_retry.go @@ -1,32 +1,28 @@ package integration import ( +<<<<<<< HEAD +======= + "time" + +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - provider "github.com/cosmos/interchain-security/v3/x/ccv/provider" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// TestSlashRetries tests the throttling v2 retry logic. Without provider changes, -// the consumer will queue up a slash packet, the provider will return a v1 result, -// and the consumer will never need to retry. -// -// Once provider changes are made (slash packet queuing is removed), the consumer may retry packets -// via new result acks from the provider. -// -// TODO: This test will need updating once provider changes are made. +// TestSlashRetries tests the throttling v2 retry logic at an integration level. func (s *CCVTestSuite) TestSlashRetries() { s.SetupAllCCVChannels() + s.SendEmptyVSCPacket() // Establish ccv channel s.setupValidatorPowers() // // Provider setup // providerKeeper := s.providerApp.GetProviderKeeper() - providerModule := provider.NewAppModule(&providerKeeper, s.providerApp.GetSubspace(providertypes.ModuleName)) // Initialize slash meter providerKeeper.InitializeSlashMeter(s.providerCtx()) // Assert that we start out with no jailings @@ -35,13 +31,24 @@ func (s *CCVTestSuite) TestSlashRetries() { for _, val := range vals { s.Require().False(val.IsJailed()) } + + // We jail two different validators in this test, referred to as val1 and val2. + // This may or may not correspond to the indexes 1 and 2 in various validator slices, + // depending on how the slice is constructed. + + // The s.providerChain.Vals.Validators set will change depending on jailings, + // so we cache these two val objects now to be the canonical val1 and val2. + tmval1 := s.providerChain.Vals.Validators[1] + tmval2 := s.providerChain.Vals.Validators[2] + // Setup signing info for jailings - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[1]) + s.setDefaultValSigningInfo(*tmval1) + s.setDefaultValSigningInfo(*tmval2) // // Consumer setup // - consumerKeeper := s.consumerApp.GetConsumerKeeper() + consumerKeeper := s.getFirstBundle().App.GetConsumerKeeper() // Assert no slash record exists _, found := consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) @@ -50,101 +57,181 @@ func (s *CCVTestSuite) TestSlashRetries() { // Test section: See FSM explanation in throttle_retry.go // +<<<<<<< HEAD // Construct a mock slash packet from consumer tmval1 := s.providerChain.Vals.Validators[1] packet1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) // Mock the sending of the packet on consumer +======= + // Construct a slash packet + packet1, data := s.constructSlashPacketFromConsumerWithData( + s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + + // Append packet to be sent by consumer +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) consumerKeeper.AppendPendingPacket(s.consumerCtx(), ccvtypes.SlashPacket, &ccvtypes.ConsumerPacketData_SlashPacketData{ - SlashPacketData: &ccvtypes.SlashPacketData{}, + SlashPacketData: &data, }, ) - consumerKeeper.UpdateSlashRecordOnSend(s.consumerCtx()) + + sendTime := s.consumerCtx().BlockTime() + + // Advance block on consumer to send pending packet + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send slashRecord, found := consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().True(found) s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) - // Recv packet on provider and assert ack. Provider should return v1 result. - ack := providerModule.OnRecvPacket(s.providerCtx(), packet1, nil) - expectedv1Ack := channeltypes.NewResultAcknowledgement([]byte(ccvtypes.V1Result)) - s.Require().Equal(expectedv1Ack.Acknowledgement(), ack.Acknowledgement()) + // Packet sending blocked until provider returns slash packet handled ack + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Recv packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // Couple blocks pass on provider for provider staking keeper to process jailing s.providerChain.NextBlock() s.providerChain.NextBlock() // Default slash meter replenish fraction is 0.05, so packet should be handled on provider. - vals = s.providerApp.GetTestStakingKeeper().GetAllValidators(s.providerCtx()) - s.Require().True(vals[1].IsJailed()) + stakingVal1 := s.mustGetStakingValFromTmVal(*tmval1) + s.Require().True(stakingVal1.IsJailed()) s.Require().Equal(int64(0), - s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), vals[1].GetOperator())) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), - s.getFirstBundle().Chain.ChainID)) + s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal1.GetOperator())) // Now slash meter should be negative on provider s.Require().True(s.providerApp.GetProviderKeeper().GetSlashMeter(s.providerCtx()).IsNegative()) // Apply ack back on consumer - ackForConsumer := expectedv1Ack - err := consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet1, ackForConsumer) + expectedAck := channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) + err := s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet1, expectedAck.Acknowledgement()) s.Require().NoError(err) - // Slash record should have been deleted, head of pending packets should have been popped - // Since provider has handled the packet + // Slash record should have been deleted, head of pending packets should have been popped, + // since provider has handled the packet. _, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) s.Require().Empty(consumerKeeper.GetPendingPackets(s.consumerCtx())) + // Packet sending should now be unblocked + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + // pass two blocks on provider and consumer for good measure s.providerChain.NextBlock() s.providerChain.NextBlock() s.consumerChain.NextBlock() s.consumerChain.NextBlock() +<<<<<<< HEAD // Construct and mock the sending of a second packet on consumer tmval2 := s.providerChain.Vals.Validators[2] packet2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) +======= + // Have consumer queue a new slash packet for a different validator. + packet2, data := s.constructSlashPacketFromConsumerWithData( + s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) consumerKeeper.AppendPendingPacket(s.consumerCtx(), ccvtypes.SlashPacket, &ccvtypes.ConsumerPacketData_SlashPacketData{ - SlashPacketData: &ccvtypes.SlashPacketData{}, + SlashPacketData: &data, }, ) - consumerKeeper.UpdateSlashRecordOnSend(s.consumerCtx()) + + // Advance block on consumer to send pending packet + sendTime = s.consumerCtx().BlockTime() + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().True(found) s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) - // Recv 2nd slash packet on provider for different validator. - // Provider should return the same v1 result ack even tho the packet was queued. - ack = providerModule.OnRecvPacket(s.providerCtx(), packet2, nil) - expectedv1Ack = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.V1Result)) - s.Require().Equal(expectedv1Ack.Acknowledgement(), ack.Acknowledgement()) + // Packet sending blocked until provider returns slash packet handled ack + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Recv 2nd packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // Couple blocks pass on provider for staking keeper to process jailings s.providerChain.NextBlock() s.providerChain.NextBlock() - // Val shouldn't be jailed on provider. Slash packet was queued - s.Require().False(vals[2].IsJailed()) + // Val 2 shouldn't be jailed on provider. Slash packet should have been bounced. + stakingVal2 := s.mustGetStakingValFromTmVal(*tmval2) + s.Require().False(stakingVal2.IsJailed()) s.Require().Equal(int64(1000), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[2].GetOperator())) - s.Require().Equal(uint64(1), providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), - s.getFirstBundle().Chain.ChainID)) + providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), stakingVal2.GetOperator())) // Apply ack on consumer - ackForConsumer = expectedv1Ack - err = consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet2, ackForConsumer) + expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketBouncedResult)) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet2, expectedAck.Acknowledgement()) s.Require().NoError(err) - // TODO: when provider changes are made, slashRecord.WaitingOnReply should have been updated to false on consumer. Slash Packet will still be in consumer's pending packets queue. + // Now consumer should have updated it's slash record on receipt of bounce ack + slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) + s.Require().True(found) + s.Require().False(slashRecord.WaitingOnReply) + // Packet still at head of queue + s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) + + // Packet sending should still be blocked, WaitingOnReply is false, + // but retry delay hasn't passed yet. + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // IBC testing framework doesn't have a way to advance time, + // so we manually mutate send time in the slash record to be in the past. + slashRecord.SendTime = slashRecord.SendTime.Add(-time.Hour - time.Minute) + consumerKeeper.SetSlashRecord(s.consumerCtx(), slashRecord) + + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Set slash meter on provider to positive value, + // now allowing handling of the slash packet + providerKeeper.InitializeSlashMeter(s.providerCtx()) + + // Advance block on consumer, now consumer should retry the sending of the slash packet. + sendTime = s.consumerCtx().BlockTime() + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send + slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) + s.Require().True(found) + s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) + s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) + + // Recv retried packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) + + // Couple blocks pass on provider for provider staking keeper to process jailing + s.providerChain.NextBlock() + s.providerChain.NextBlock() + + // Provider should have now jailed val 2 + stakingVal2 = s.mustGetStakingValFromTmVal(*tmval2) + s.Require().True(stakingVal2.IsJailed()) + s.Require().Equal(int64(0), + s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal2.GetOperator())) + + // Apply ack on consumer + expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet2, expectedAck.Acknowledgement()) + s.Require().NoError(err) - // Slash record should have been deleted, head of pending packets should have been popped - // Since provider has handled the packet + // Consumer state is properly cleared again _, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) s.Require().Empty(consumerKeeper.GetPendingPackets(s.consumerCtx())) + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) } diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 6b9415440e..ab1c78af7f 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -181,10 +181,6 @@ func TestDoubleSignDoesNotAffectThrottling(t *testing.T) { runCCVTestByName(t, "TestDoubleSignDoesNotAffectThrottling") } -func TestQueueOrdering(t *testing.T) { - runCCVTestByName(t, "TestQueueOrdering") -} - func TestSlashingSmallValidators(t *testing.T) { runCCVTestByName(t, "TestSlashingSmallValidators") } @@ -193,22 +189,10 @@ func TestSlashMeterAllowanceChanges(t *testing.T) { runCCVTestByName(t, "TestSlashMeterAllowanceChanges") } -func TestSlashSameValidator(t *testing.T) { - runCCVTestByName(t, "TestSlashSameValidator") -} - func TestSlashAllValidators(t *testing.T) { runCCVTestByName(t, "TestSlashAllValidators") } -func TestLeadingVSCMaturedAreDequeued(t *testing.T) { - runCCVTestByName(t, "TestLeadingVSCMaturedAreDequeued") -} - -func TestVscMaturedHandledPerBlockLimit(t *testing.T) { - runCCVTestByName(t, "TestVscMaturedHandledPerBlockLimit") -} - // // Unbonding tests // diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index b58d6d2471..77b4df9c10 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -254,15 +254,6 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) require.Empty(t, providerKeeper.GetAllKeyAssignmentReplacements(ctx, expectedChainID)) require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) - - allGlobalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - for _, entry := range allGlobalEntries { - require.NotEqual(t, expectedChainID, entry.ConsumerChainID) - } - - slashPacketData, vscMaturedPacketData, _, _ := providerKeeper.GetAllThrottledPacketData(ctx, expectedChainID) - require.Empty(t, slashPacketData) - require.Empty(t, vscMaturedPacketData) } func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { diff --git a/x/ccv/consumer/client/cli/query.go b/x/ccv/consumer/client/cli/query.go index dc1ecfc2f4..f1a0c0f258 100644 --- a/x/ccv/consumer/client/cli/query.go +++ b/x/ccv/consumer/client/cli/query.go @@ -22,6 +22,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand( CmdNextFeeDistribution(), CmdProviderInfo(), + CmdThrottleState(), ) return cmd @@ -80,3 +81,30 @@ func CmdProviderInfo() *cobra.Command { return cmd } + +func CmdThrottleState() *cobra.Command { + cmd := &cobra.Command{ + Use: "throttle-state", + Short: "Query throttle state", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryThrottleStateRequest{} + res, err := queryClient.QueryThrottleState(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/ccv/consumer/keeper/grpc_query.go b/x/ccv/consumer/keeper/grpc_query.go index 80e6b695a9..0d1bb78d16 100644 --- a/x/ccv/consumer/keeper/grpc_query.go +++ b/x/ccv/consumer/keeper/grpc_query.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) var _ types.QueryServer = Keeper{} //nolint:golint @@ -51,3 +52,25 @@ func (k Keeper) QueryProviderInfo(c context.Context, //nolint:golint return k.GetProviderInfo(ctx) } + +func (k Keeper) QueryThrottleState(c context.Context, + req *types.QueryThrottleStateRequest, +) (*types.QueryThrottleStateResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + resp := types.QueryThrottleStateResponse{} + + slashRecord, found := k.GetSlashRecord(ctx) + if found { + resp.SlashRecord = &slashRecord + } else { + resp.SlashRecord = nil + } + + resp.PacketDataQueue = make([]ccvtypes.ConsumerPacketData, 0) + pendingPackets := k.GetAllPendingPacketsWithIdx(ctx) + for _, packet := range pendingPackets { + resp.PacketDataQueue = append(resp.PacketDataQueue, packet.ConsumerPacketData) + } + return &resp, nil +} diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index 770edf229e..f3863a0a64 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -25,6 +25,7 @@ func (k Keeper) GetConsumerParams(ctx sdk.Context) ccvtypes.Params { k.GetSoftOptOutThreshold(ctx), k.GetRewardDenoms(ctx), k.GetProviderRewardDenoms(ctx), + k.GetRetryDelayPeriod(ctx), ) } @@ -138,3 +139,9 @@ func (k Keeper) GetProviderRewardDenoms(ctx sdk.Context) []string { k.paramStore.Get(ctx, ccvtypes.KeyProviderRewardDenoms, &denoms) return denoms } + +func (k Keeper) GetRetryDelayPeriod(ctx sdk.Context) time.Duration { + var period time.Duration + k.paramStore.Get(ctx, ccvtypes.KeyRetryDelayPeriod, &period) + return period +} diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index 49b1816520..e575e26185 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -31,6 +31,7 @@ func TestParams(t *testing.T) { ccv.DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, + ccv.DefaultRetryDelayPeriod, ) // these are the default params, IBC suite independently sets enabled=true params := consumerKeeper.GetConsumerParams(ctx) @@ -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, "0.05", []string{"untrn"}, []string{"uatom"}) + 7*24*time.Hour, 25*time.Hour, "0.5", 500, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour) consumerKeeper.SetParams(ctx, newParams) params = consumerKeeper.GetConsumerParams(ctx) require.Equal(t, newParams, params) diff --git a/x/ccv/consumer/keeper/throttle_retry.go b/x/ccv/consumer/keeper/throttle_retry.go index 4c4585cb1d..7f8d85191d 100644 --- a/x/ccv/consumer/keeper/throttle_retry.go +++ b/x/ccv/consumer/keeper/throttle_retry.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - "time" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -44,9 +43,6 @@ import ( // This design is implemented below, and in relay.go under SendPackets() and OnAcknowledgementPacket(). // -// Retry delay period could be implemented as a param, but 1 hour is reasonable -const RetryDelayPeriod = time.Hour - // PacketSendingPermitted returns whether the consumer is allowed to send packets // from the pending packets queue. func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool { @@ -60,7 +56,7 @@ func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool { return false } // If retry delay period has elapsed, we can send again - return ctx.BlockTime().After(record.SendTime.Add(RetryDelayPeriod)) + return ctx.BlockTime().After(record.SendTime.Add(k.GetRetryDelayPeriod(ctx))) } func (k Keeper) UpdateSlashRecordOnSend(ctx sdktypes.Context) { diff --git a/x/ccv/consumer/keeper/throttle_retry_test.go b/x/ccv/consumer/keeper/throttle_retry_test.go index cc14ce3cdd..50157df843 100644 --- a/x/ccv/consumer/keeper/throttle_retry_test.go +++ b/x/ccv/consumer/keeper/throttle_retry_test.go @@ -7,14 +7,16 @@ import ( "github.com/stretchr/testify/require" testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) func TestPacketSendingPermitted(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testutil.GetConsumerKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerKeeper.SetParams(ctx, ccvtypes.DefaultParams()) + ctx = ctx.WithBlockTime(time.Now()) // No slash record exists, send is permitted @@ -42,7 +44,8 @@ func TestPacketSendingPermitted(t *testing.T) { require.False(t, consumerKeeper.PacketSendingPermitted(ctx)) // Elapse retry delay period - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * consumerkeeper.RetryDelayPeriod)) + period := consumerKeeper.GetRetryDelayPeriod(ctx) + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * period)) // Now packet sending is permitted again require.True(t, consumerKeeper.PacketSendingPermitted(ctx)) diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index 453a3aab20..88a58e5b62 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -222,6 +222,7 @@ func TestValidateInitialGenesisState(t *testing.T) { types.DefaultSoftOptOutThreshold, []string{}, []string{}, + types.DefaultRetryDelayPeriod, )), true, }, @@ -241,6 +242,7 @@ func TestValidateInitialGenesisState(t *testing.T) { types.DefaultSoftOptOutThreshold, []string{}, []string{}, + types.DefaultRetryDelayPeriod, )), true, }, @@ -442,6 +444,7 @@ func TestValidateRestartGenesisState(t *testing.T) { types.DefaultSoftOptOutThreshold, []string{}, []string{}, + types.DefaultRetryDelayPeriod, )), true, }, diff --git a/x/ccv/consumer/types/params_test.go b/x/ccv/consumer/types/params_test.go index ff5d0f325f..43c7f185cf 100644 --- a/x/ccv/consumer/types/params_test.go +++ b/x/ccv/consumer/types/params_test.go @@ -19,59 +19,67 @@ 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, "0.05", []string{"untrn"}, []string{"uatom"}), true, + ccvtypes.NewParams(true, 5, "", "", 1004, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), true, }, { "custom invalid params, block per dist transmission", - ccvtypes.NewParams(true, -5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, -5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, dist transmission channel", - ccvtypes.NewParams(true, 5, "badchannel/", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "badchannel/", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, ccv timeout", - ccvtypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, transfer timeout", - ccvtypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, consumer redist fraction is negative", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, consumer redist fraction is over 1", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, bad consumer redist fraction ", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "notFrac", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "notFrac", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, negative num historical entries", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", -100, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", -100, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, negative unbonding period", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, -24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, -24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, invalid soft opt out threshold", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "-0.05", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "-0.05", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid soft opt out threshold", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.5", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.5", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid reward denom", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid provider reward denom", - ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{"a"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{"a"}, 2*time.Hour), false, + }, + { + "custom invalid params, retry delay period is negative", + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{}, -2*time.Hour), false, + }, + { + "custom invalid params, retry delay period is zero", + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{}, 0), false, }, } diff --git a/x/ccv/consumer/types/query.pb.go b/x/ccv/consumer/types/query.pb.go index 5ed38da3f8..94e3fb8557 100644 --- a/x/ccv/consumer/types/query.pb.go +++ b/x/ccv/consumer/types/query.pb.go @@ -384,6 +384,94 @@ func (m *QueryProviderInfoResponse) GetProvider() ChainInfo { return ChainInfo{} } +type QueryThrottleStateRequest struct { +} + +func (m *QueryThrottleStateRequest) Reset() { *m = QueryThrottleStateRequest{} } +func (m *QueryThrottleStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryThrottleStateRequest) ProtoMessage() {} +func (*QueryThrottleStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f627751d3cc10225, []int{7} +} +func (m *QueryThrottleStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryThrottleStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryThrottleStateRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryThrottleStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryThrottleStateRequest.Merge(m, src) +} +func (m *QueryThrottleStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryThrottleStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryThrottleStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryThrottleStateRequest proto.InternalMessageInfo + +type QueryThrottleStateResponse struct { + SlashRecord *SlashRecord `protobuf:"bytes,1,opt,name=slash_record,json=slashRecord,proto3" json:"slash_record,omitempty"` + PacketDataQueue []types.ConsumerPacketData `protobuf:"bytes,2,rep,name=packet_data_queue,json=packetDataQueue,proto3" json:"packet_data_queue"` +} + +func (m *QueryThrottleStateResponse) Reset() { *m = QueryThrottleStateResponse{} } +func (m *QueryThrottleStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryThrottleStateResponse) ProtoMessage() {} +func (*QueryThrottleStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f627751d3cc10225, []int{8} +} +func (m *QueryThrottleStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryThrottleStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryThrottleStateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryThrottleStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryThrottleStateResponse.Merge(m, src) +} +func (m *QueryThrottleStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryThrottleStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryThrottleStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryThrottleStateResponse proto.InternalMessageInfo + +func (m *QueryThrottleStateResponse) GetSlashRecord() *SlashRecord { + if m != nil { + return m.SlashRecord + } + return nil +} + +func (m *QueryThrottleStateResponse) GetPacketDataQueue() []types.ConsumerPacketData { + if m != nil { + return m.PacketDataQueue + } + return nil +} + type ChainInfo struct { ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"` ClientID string `protobuf:"bytes,2,opt,name=clientID,proto3" json:"clientID,omitempty"` @@ -395,7 +483,7 @@ func (m *ChainInfo) Reset() { *m = ChainInfo{} } func (m *ChainInfo) String() string { return proto.CompactTextString(m) } func (*ChainInfo) ProtoMessage() {} func (*ChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_f627751d3cc10225, []int{7} + return fileDescriptor_f627751d3cc10225, []int{9} } func (m *ChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -460,6 +548,8 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "interchain_security.ccv.consumer.v1.QueryParamsResponse") proto.RegisterType((*QueryProviderInfoRequest)(nil), "interchain_security.ccv.consumer.v1.QueryProviderInfoRequest") proto.RegisterType((*QueryProviderInfoResponse)(nil), "interchain_security.ccv.consumer.v1.QueryProviderInfoResponse") + proto.RegisterType((*QueryThrottleStateRequest)(nil), "interchain_security.ccv.consumer.v1.QueryThrottleStateRequest") + proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.consumer.v1.QueryThrottleStateResponse") proto.RegisterType((*ChainInfo)(nil), "interchain_security.ccv.consumer.v1.ChainInfo") } @@ -468,6 +558,7 @@ func init() { } var fileDescriptor_f627751d3cc10225 = []byte{ +<<<<<<< HEAD // 686 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6b, 0x13, 0x41, 0x14, 0xcf, 0xa6, 0x4d, 0xdb, 0x4c, 0xf5, 0xe0, 0x18, 0x21, 0xae, 0x65, 0x2d, 0xab, 0x60, 0x14, @@ -512,6 +603,61 @@ var fileDescriptor_f627751d3cc10225 = []byte{ 0x0e, 0x55, 0xdd, 0x70, 0xd3, 0xc3, 0xbc, 0xef, 0x63, 0x2e, 0xfb, 0x5c, 0x66, 0xb8, 0xeb, 0x43, 0xee, 0x68, 0xc1, 0xdf, 0x19, 0x4d, 0xa0, 0x76, 0x07, 0x44, 0x6e, 0x4e, 0xe8, 0x3f, 0xcf, 0xc2, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x18, 0x69, 0x59, 0x43, 0x6b, 0x07, 0x00, 0x00, +======= + // 825 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xd3, 0x36, 0xbb, 0x99, 0x2e, 0x42, 0x3b, 0x04, 0xc9, 0x78, 0x57, 0xa1, 0x32, 0x20, + 0xc2, 0x4a, 0xb1, 0x93, 0xf4, 0xd0, 0xe5, 0xb0, 0x2c, 0xda, 0x86, 0xaa, 0x91, 0x00, 0xb5, 0x6e, + 0x25, 0x04, 0x17, 0x33, 0x9d, 0x4c, 0x13, 0x8b, 0xc4, 0xe3, 0xce, 0x8c, 0x4d, 0x7b, 0x43, 0x70, + 0x47, 0x48, 0x7c, 0x13, 0xbe, 0x00, 0xd7, 0x4a, 0x1c, 0xa8, 0xc4, 0x01, 0xb8, 0x20, 0xd4, 0xf2, + 0x21, 0x38, 0xa2, 0x19, 0x8f, 0x53, 0xa7, 0x4d, 0x13, 0xb7, 0xec, 0xcd, 0xf3, 0xfe, 0xfc, 0xde, + 0xef, 0xf7, 0x66, 0xde, 0x4b, 0x80, 0x1b, 0x84, 0x82, 0x30, 0x3c, 0x44, 0x41, 0xe8, 0x73, 0x82, + 0x63, 0x16, 0x88, 0x13, 0x17, 0xe3, 0xc4, 0xc5, 0x34, 0xe4, 0xf1, 0x98, 0x30, 0x37, 0x69, 0xbb, + 0x47, 0x31, 0x61, 0x27, 0x4e, 0xc4, 0xa8, 0xa0, 0xf0, 0xad, 0x19, 0x09, 0x0e, 0xc6, 0x89, 0x93, + 0x25, 0x38, 0x49, 0xdb, 0x6a, 0xdd, 0x84, 0x9a, 0xb4, 0x5d, 0x3e, 0x44, 0x8c, 0xf4, 0xfd, 0x49, + 0xb8, 0x82, 0xb5, 0x6a, 0x03, 0x3a, 0xa0, 0xea, 0xd3, 0x95, 0x5f, 0xda, 0xfa, 0x78, 0x40, 0xe9, + 0x60, 0x44, 0x5c, 0x14, 0x05, 0x2e, 0x0a, 0x43, 0x2a, 0x90, 0x08, 0x68, 0xc8, 0xb5, 0xb7, 0x53, + 0x84, 0xfb, 0x95, 0x3a, 0xef, 0xcc, 0x61, 0xf6, 0x75, 0xc0, 0x48, 0x1a, 0x66, 0x7f, 0x5f, 0x06, + 0x8f, 0x3e, 0x25, 0xc7, 0x62, 0x8b, 0x90, 0x6e, 0xc0, 0x05, 0x0b, 0x0e, 0x62, 0x59, 0xf9, 0x23, + 0x2e, 0x82, 0x31, 0x12, 0x04, 0xbe, 0x0d, 0x5e, 0xc1, 0x31, 0x63, 0x24, 0x14, 0xdb, 0x24, 0x18, + 0x0c, 0x85, 0x69, 0xac, 0x19, 0x8d, 0x25, 0x6f, 0xda, 0x08, 0xeb, 0x00, 0x8c, 0x10, 0xcf, 0x42, + 0xca, 0x2a, 0x24, 0x67, 0x91, 0xfe, 0x90, 0x1c, 0x67, 0xfe, 0xa5, 0xd4, 0x7f, 0x69, 0x81, 0xeb, + 0xe0, 0xf5, 0x7e, 0xae, 0xba, 0x7f, 0xc8, 0x10, 0x96, 0x1f, 0xe6, 0xf2, 0x9a, 0xd1, 0xa8, 0x7a, + 0xb5, 0xbc, 0x73, 0x4b, 0xfb, 0x60, 0x0d, 0xac, 0x08, 0x2a, 0xd0, 0xc8, 0x5c, 0x51, 0x41, 0xe9, + 0x41, 0x96, 0x12, 0x74, 0x87, 0xd1, 0x24, 0xe8, 0x13, 0x66, 0x56, 0x94, 0x2b, 0x67, 0x49, 0xfd, + 0x9b, 0xba, 0x57, 0xe6, 0xbd, 0xcc, 0x9f, 0x59, 0xec, 0xf7, 0xc0, 0xbb, 0xbb, 0xf2, 0x15, 0xcc, + 0x69, 0x8a, 0x47, 0x8e, 0x62, 0xc2, 0x85, 0xfd, 0x8d, 0x01, 0x1a, 0x8b, 0x63, 0x79, 0x44, 0x43, + 0x4e, 0xe0, 0x3e, 0x58, 0xee, 0x23, 0x81, 0x54, 0xff, 0x56, 0x3b, 0x1f, 0x3a, 0x05, 0x5e, 0x97, + 0x33, 0x0f, 0x57, 0xa1, 0xd9, 0x35, 0x00, 0x15, 0x83, 0x1d, 0xc4, 0xd0, 0x98, 0x67, 0xc4, 0x7c, + 0xf0, 0xda, 0x94, 0x55, 0x53, 0xd8, 0x06, 0x95, 0x48, 0x59, 0x34, 0x89, 0x27, 0x37, 0x92, 0x48, + 0xda, 0x4e, 0xd6, 0x90, 0x14, 0xe3, 0xc5, 0xf2, 0xe9, 0x5f, 0x6f, 0x96, 0x3c, 0x9d, 0x6f, 0x5b, + 0xc0, 0x4c, 0x0b, 0xe8, 0xae, 0xf6, 0xc2, 0x43, 0x9a, 0x15, 0xff, 0xd9, 0x00, 0x6f, 0xcc, 0x70, + 0x6a, 0x0e, 0x3b, 0xe0, 0x7e, 0xa6, 0x50, 0xb3, 0x70, 0x0a, 0xb5, 0x62, 0x53, 0xba, 0x25, 0x92, + 0x66, 0x32, 0x41, 0x91, 0x88, 0x51, 0x76, 0xdd, 0xe5, 0xff, 0x83, 0x98, 0xa1, 0xd8, 0x8f, 0xb4, + 0x80, 0xfd, 0x21, 0xa3, 0x42, 0x8c, 0xc8, 0x9e, 0xc8, 0x5d, 0xfa, 0x9f, 0x06, 0xb0, 0x66, 0x79, + 0xb5, 0xbe, 0xcf, 0xc1, 0x03, 0x3e, 0x42, 0x7c, 0xe8, 0x33, 0x82, 0x29, 0xeb, 0x6b, 0x8d, 0xad, + 0x42, 0x8c, 0xf6, 0x64, 0xa2, 0xa7, 0xf2, 0x14, 0x27, 0xc3, 0x5b, 0xe5, 0x97, 0x26, 0xf8, 0x25, + 0x78, 0x18, 0x21, 0xfc, 0x15, 0x11, 0xbe, 0xbc, 0x7a, 0xff, 0x28, 0x26, 0x31, 0x31, 0xcb, 0x6b, + 0x4b, 0x73, 0x15, 0x4f, 0xdd, 0xa4, 0x4c, 0xee, 0x22, 0x81, 0xb4, 0xe2, 0x57, 0xa3, 0x89, 0x65, + 0x57, 0x82, 0xd9, 0xdf, 0x19, 0xa0, 0x3a, 0x69, 0x0b, 0x34, 0xc1, 0x3d, 0x05, 0xd8, 0xeb, 0x2a, + 0x15, 0x55, 0x2f, 0x3b, 0x42, 0x0b, 0xdc, 0xc7, 0xa3, 0x80, 0x84, 0xa2, 0xd7, 0x55, 0x2d, 0xaf, + 0x7a, 0x93, 0x33, 0xb4, 0xc1, 0x03, 0x4c, 0xc3, 0x90, 0xa8, 0x19, 0xed, 0x75, 0xd5, 0xb0, 0x57, + 0xbd, 0x29, 0x1b, 0x7c, 0x0c, 0xaa, 0x78, 0x88, 0xc2, 0x90, 0x8c, 0x7a, 0x5d, 0x3d, 0xe2, 0x97, + 0x86, 0xce, 0xef, 0x15, 0xb0, 0xa2, 0x3a, 0x0c, 0xff, 0x35, 0xf4, 0x3b, 0x9b, 0x31, 0x08, 0xf0, + 0xe3, 0x42, 0x3d, 0x2d, 0x38, 0xcb, 0xd6, 0x27, 0x2f, 0x09, 0x2d, 0x7d, 0x06, 0xf6, 0xf3, 0x6f, + 0x7f, 0xfb, 0xe7, 0xc7, 0xf2, 0xfb, 0x70, 0x63, 0xf1, 0xcf, 0x8e, 0x5c, 0x83, 0xcd, 0x43, 0x42, + 0x9a, 0xf9, 0x25, 0x07, 0x7f, 0x32, 0xc0, 0x6a, 0x6e, 0x86, 0xe1, 0x46, 0x71, 0x7e, 0x53, 0xbb, + 0xc0, 0x7a, 0x7a, 0xfb, 0x44, 0xad, 0xa1, 0xa5, 0x34, 0x3c, 0x81, 0x8d, 0xc5, 0x1a, 0xd2, 0xb5, + 0x00, 0x7f, 0x31, 0xc0, 0xc3, 0x6b, 0xa3, 0x0f, 0x9f, 0xdd, 0x82, 0xc1, 0xf5, 0x7d, 0x62, 0x7d, + 0x70, 0xd7, 0x74, 0x2d, 0x63, 0x43, 0xc9, 0x68, 0x43, 0xb7, 0x80, 0x0c, 0x9d, 0xdf, 0x0c, 0x24, + 0xef, 0x5f, 0x0d, 0xbd, 0x5c, 0xa7, 0x26, 0x1d, 0xde, 0x82, 0xcf, 0xac, 0x05, 0x62, 0x3d, 0xbf, + 0x73, 0xbe, 0x16, 0xf4, 0x54, 0x09, 0xea, 0xc0, 0xd6, 0x62, 0x41, 0x42, 0x03, 0xf8, 0x5c, 0x22, + 0xbc, 0xf8, 0xec, 0xf4, 0xbc, 0x6e, 0x9c, 0x9d, 0xd7, 0x8d, 0xbf, 0xcf, 0xeb, 0xc6, 0x0f, 0x17, + 0xf5, 0xd2, 0xd9, 0x45, 0xbd, 0xf4, 0xc7, 0x45, 0xbd, 0xf4, 0xc5, 0xb3, 0x41, 0x20, 0x86, 0xf1, + 0x81, 0x83, 0xe9, 0xd8, 0xc5, 0x94, 0x8f, 0x29, 0xcf, 0x81, 0x37, 0x27, 0xe0, 0xc9, 0xba, 0x7b, + 0x7c, 0xa5, 0xc2, 0x49, 0x44, 0xf8, 0x41, 0x45, 0xfd, 0x99, 0x58, 0xff, 0x2f, 0x00, 0x00, 0xff, + 0xff, 0x0e, 0x14, 0x5a, 0xa9, 0x65, 0x09, 0x00, 0x00, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } // Reference imports to suppress errors if they are not otherwise used. @@ -532,6 +678,8 @@ type QueryClient interface { // QueryParams queries the ccv/consumer module parameters. QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) QueryProviderInfo(ctx context.Context, in *QueryProviderInfoRequest, opts ...grpc.CallOption) (*QueryProviderInfoResponse, error) + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) } type queryClient struct { @@ -569,6 +717,15 @@ func (c *queryClient) QueryProviderInfo(ctx context.Context, in *QueryProviderIn return out, nil } +func (c *queryClient) QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) { + out := new(QueryThrottleStateResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.consumer.v1.Query/QueryThrottleState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ConsumerGenesis queries the genesis state needed to start a consumer chain @@ -577,6 +734,8 @@ type QueryServer interface { // QueryParams queries the ccv/consumer module parameters. QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) QueryProviderInfo(context.Context, *QueryProviderInfoRequest) (*QueryProviderInfoResponse, error) + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + QueryThrottleState(context.Context, *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -592,6 +751,9 @@ func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryPara func (*UnimplementedQueryServer) QueryProviderInfo(ctx context.Context, req *QueryProviderInfoRequest) (*QueryProviderInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryProviderInfo not implemented") } +func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryThrottleState not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -651,6 +813,24 @@ func _Query_QueryProviderInfo_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_QueryThrottleState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryThrottleStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryThrottleState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.consumer.v1.Query/QueryThrottleState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryThrottleState(ctx, req.(*QueryThrottleStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.consumer.v1.Query", HandlerType: (*QueryServer)(nil), @@ -667,6 +847,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryProviderInfo", Handler: _Query_QueryProviderInfo_Handler, }, + { + MethodName: "QueryThrottleState", + Handler: _Query_QueryThrottleState_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/consumer/v1/query.proto", @@ -918,6 +1102,78 @@ func (m *QueryProviderInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryThrottleStateRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryThrottleStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryThrottleStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryThrottleStateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryThrottleStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketDataQueue) > 0 { + for iNdEx := len(m.PacketDataQueue) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketDataQueue[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.SlashRecord != nil { + { + size, err := m.SlashRecord.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ChainInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1078,6 +1334,34 @@ func (m *QueryProviderInfoResponse) Size() (n int) { return n } +func (m *QueryThrottleStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryThrottleStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SlashRecord != nil { + l = m.SlashRecord.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.PacketDataQueue) > 0 { + for _, e := range m.PacketDataQueue { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *ChainInfo) Size() (n int) { if m == nil { return 0 @@ -1779,6 +2063,176 @@ func (m *QueryProviderInfoResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryThrottleStateRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryThrottleStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryThrottleStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryThrottleStateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryThrottleStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryThrottleStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashRecord", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SlashRecord == nil { + m.SlashRecord = &SlashRecord{} + } + if err := m.SlashRecord.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketDataQueue", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PacketDataQueue = append(m.PacketDataQueue, types.ConsumerPacketData{}) + if err := m.PacketDataQueue[len(m.PacketDataQueue)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ChainInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/consumer/types/query.pb.gw.go b/x/ccv/consumer/types/query.pb.gw.go index 1151ab0b60..46ad461324 100644 --- a/x/ccv/consumer/types/query.pb.gw.go +++ b/x/ccv/consumer/types/query.pb.gw.go @@ -87,6 +87,24 @@ func local_request_Query_QueryProviderInfo_0(ctx context.Context, marshaler runt } +func request_Query_QueryThrottleState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryThrottleStateRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryThrottleState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryThrottleState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryThrottleStateRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryThrottleState(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -162,6 +180,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryThrottleState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryThrottleState_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryThrottleState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -263,6 +304,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryThrottleState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryThrottleState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryThrottleState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -272,6 +333,8 @@ var ( pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryProviderInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "provider-info"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryThrottleState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "throttle_state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -280,4 +343,6 @@ var ( forward_Query_QueryParams_0 = runtime.ForwardResponseMessage forward_Query_QueryProviderInfo_0 = runtime.ForwardResponseMessage + + forward_Query_QueryThrottleState_0 = runtime.ForwardResponseMessage ) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 1240e242f0..80746ff5d2 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -31,7 +31,6 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdConsumerValidatorKeyAssignment()) cmd.AddCommand(CmdProviderValidatorKey()) cmd.AddCommand(CmdThrottleState()) - cmd.AddCommand(CmdThrottledConsumerPacketData()) cmd.AddCommand(CmdRegisteredConsumerRewardDenoms()) return cmd @@ -286,42 +285,6 @@ $ %s query provider throttle-state return cmd } -func CmdThrottledConsumerPacketData() *cobra.Command { - cmd := &cobra.Command{ - Use: "throttled-consumer-packet-data [chainid]", - Short: "Query pending VSCMatured and slash packet data for a consumer chainId", - Long: strings.TrimSpace( - fmt.Sprintf(`Returns the current pending VSCMatured and slash packet data instances for a consumer chainId. - Queue is ordered by ibc sequence number. -Example: -$ %s query provider throttled-consumer-packet-data foochain -`, - version.AppName, - ), - ), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - req := &types.QueryThrottledConsumerPacketDataRequest{ChainId: args[0]} - res, err := queryClient.QueryThrottledConsumerPacketData(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - func CmdRegisteredConsumerRewardDenoms() *cobra.Command { cmd := &cobra.Command{ Use: "registered-consumer-reward-denoms", diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 2b522ea9ef..881a6b1a98 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -148,98 +147,14 @@ func (k Keeper) QueryThrottleState(goCtx context.Context, req *types.QueryThrott meter := k.GetSlashMeter(ctx) allowance := k.GetSlashMeterAllowance(ctx) candidate := k.GetSlashMeterReplenishTimeCandidate(ctx) // always UTC - packets := []*types.ThrottledSlashPacket{} - - // iterate global slash entries from all consumer chains - // and fetch corresponding SlashPacketData from the per-chain throttled packet data queue - allGlobalEntries := k.GetAllGlobalSlashEntries(ctx) - - for _, entry := range allGlobalEntries { - // Obtain slash packet data instance for the given global entry - slashData, found := k.getSlashPacketData(ctx, entry.ConsumerChainID, entry.IbcSeqNum) - if !found { - // silently skip over invalid data - continue - } - - packets = append(packets, &types.ThrottledSlashPacket{ - GlobalEntry: entry, - Data: slashData, - }) - } return &types.QueryThrottleStateResponse{ SlashMeter: meter.Int64(), SlashMeterAllowance: allowance.Int64(), NextReplenishCandidate: candidate, - Packets: packets, - }, nil -} - -func (k Keeper) QueryThrottledConsumerPacketData(goCtx context.Context, req *types.QueryThrottledConsumerPacketDataRequest) (*types.QueryThrottledConsumerPacketDataResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if req.ChainId == "" { - return nil, status.Error(codes.InvalidArgument, "invalid chain-id") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - if _, found := k.GetChainToChannel(ctx, req.ChainId); !found { - return nil, status.Error(codes.InvalidArgument, "invalid chain-id") - } - - packetDataInstances := []types.ThrottledPacketDataWrapper{} - _, _, rawOrderedData, _ := k.GetAllThrottledPacketData(ctx, req.ChainId) - - for _, raw := range rawOrderedData { - switch data := raw.(type) { - case ccvtypes.SlashPacketData: - w := &types.ThrottledPacketDataWrapper_SlashPacket{SlashPacket: &data} - packetDataInstances = append(packetDataInstances, types.ThrottledPacketDataWrapper{ - Data: w, - }) - case ccvtypes.VSCMaturedPacketData: - w := &types.ThrottledPacketDataWrapper_VscMaturedPacket{VscMaturedPacket: &data} - packetDataInstances = append(packetDataInstances, types.ThrottledPacketDataWrapper{ - Data: w, - }) - default: - k.Logger(ctx).Error(fmt.Sprintf("unexpected packet data type: %T", data)) - } - } - - return &types.QueryThrottledConsumerPacketDataResponse{ - ChainId: req.ChainId, - Size_: k.GetThrottledPacketDataSize(ctx, req.ChainId), - PacketDataInstances: packetDataInstances, }, nil } -// getSlashPacketData fetches a slash packet data from the store using consumerChainId and ibcSeqNum (direct access) -// If the returned bytes do not unmarshal to SlashPacketData, the data is considered not found. -func (k Keeper) getSlashPacketData(ctx sdk.Context, consumerChainID string, ibcSeqNum uint64) (ccvtypes.SlashPacketData, bool) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) - if len(bz) == 0 { - return ccvtypes.SlashPacketData{}, false - } - - if bz[0] != slashPacketData { - return ccvtypes.SlashPacketData{}, false - } - - packet := ccvtypes.SlashPacketData{} - err := packet.Unmarshal(bz[1:]) - if err != nil { - // If the data cannot be unmarshaled, it is considered not found - return ccvtypes.SlashPacketData{}, false - } - - return packet, true -} - func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req *types.QueryRegisteredConsumerRewardDenomsRequest) (*types.QueryRegisteredConsumerRewardDenomsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/ccv/provider/keeper/migration.go b/x/ccv/provider/keeper/migration.go new file mode 100644 index 0000000000..5d739c8bef --- /dev/null +++ b/x/ccv/provider/keeper/migration.go @@ -0,0 +1,138 @@ +package keeper + +import ( + "fmt" + + sdktypes "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + providerKeeper Keeper + paramSpace paramtypes.Subspace +} + +// NewMigrator returns a new Migrator. +func NewMigrator(providerKeeper Keeper, paramSpace paramtypes.Subspace) Migrator { + return Migrator{providerKeeper: providerKeeper, paramSpace: paramSpace} +} + +// Migrate2to3 migrates x/ccvprovider state from consensus version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdktypes.Context) error { + return m.providerKeeper.MigrateQueuedPackets(ctx) +} + +func (k Keeper) MigrateQueuedPackets(ctx sdktypes.Context) error { + for _, consumer := range k.GetAllConsumerChains(ctx) { + slashData, vscmData := k.GetAllThrottledPacketData(ctx, consumer.ChainId) + if len(slashData) > 0 { + k.Logger(ctx).Error(fmt.Sprintf("slash data being dropped: %v", slashData)) + } + for _, data := range vscmData { + k.HandleVSCMaturedPacket(ctx, consumer.ChainId, data) + } + k.DeleteThrottledPacketDataForConsumer(ctx, consumer.ChainId) + } + return nil +} + +// Pending packet data type enum, used to encode the type of packet data stored at each entry in the mutual queue. +// Note this type is copy/pasted from throttle v1 code. +const ( + slashPacketData byte = iota + vscMaturedPacketData +) + +// GetAllThrottledPacketData returns all throttled packet data for a given consumer chain, only used for 2 -> 3 migration. +// Note this method is adapted from throttle v1 code. +func (k Keeper) GetAllThrottledPacketData(ctx sdktypes.Context, consumerChainID string) ( + slashData []ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, +) { + slashData = []ccvtypes.SlashPacketData{} + vscMaturedData = []ccvtypes.VSCMaturedPacketData{} + + store := ctx.KVStore(k.storeKey) + iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) + iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + bz := iterator.Value() + switch bz[0] { + case slashPacketData: + d := ccvtypes.SlashPacketData{} + if err := d.Unmarshal(bz[1:]); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) + continue + } + slashData = append(slashData, d) + case vscMaturedPacketData: + d := ccvtypes.VSCMaturedPacketData{} + if err := d.Unmarshal(bz[1:]); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) + continue + } + vscMaturedData = append(vscMaturedData, d) + default: + k.Logger(ctx).Error(fmt.Sprintf("invalid packet data type: %v", bz[0])) + continue + } + } + + return slashData, vscMaturedData +} + +// Note this method is copy/pasted from throttle v1 code. +func (k Keeper) DeleteThrottledPacketDataForConsumer(ctx sdktypes.Context, consumerChainID string) { + store := ctx.KVStore(k.storeKey) + iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) + iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + defer iterator.Close() + + keysToDel := [][]byte{} + for ; iterator.Valid(); iterator.Next() { + keysToDel = append(keysToDel, iterator.Key()) + } + // Delete data for this consumer + for _, key := range keysToDel { + store.Delete(key) + } + + // Delete size of data queue for this consumer + store.Delete(providertypes.ThrottledPacketDataSizeKey(consumerChainID)) +} + +// Note this method is adapted from throttle v1 code. +func (k Keeper) QueueThrottledPacketDataOnlyForTesting( + ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, packetData interface{}, +) error { + store := ctx.KVStore(k.storeKey) + + var bz []byte + var err error + switch data := packetData.(type) { + case ccvtypes.SlashPacketData: + bz, err = data.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal slash packet data: %v", err) + } + bz = append([]byte{slashPacketData}, bz...) + case ccvtypes.VSCMaturedPacketData: + bz, err = data.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal vsc matured packet data: %v", err) + } + bz = append([]byte{vscMaturedPacketData}, bz...) + default: + // Indicates a developer error, this method should only be called + // by tests, QueueThrottledSlashPacketData, or QueueThrottledVSCMaturedPacketData. + panic(fmt.Sprintf("unexpected packet data type: %T", data)) + } + + store.Set(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum), bz) + return nil +} diff --git a/x/ccv/provider/keeper/migration_test.go b/x/ccv/provider/keeper/migration_test.go new file mode 100644 index 0000000000..a710e3979c --- /dev/null +++ b/x/ccv/provider/keeper/migration_test.go @@ -0,0 +1,117 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + + testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" +) + +func TestMigrate2To3(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Set consumer client ids to mock consumers being connected to provider + providerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") + providerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") + providerKeeper.SetConsumerClientId(ctx, "chain-3", "client-3") + + // Queue some data for chain-1 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 66, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 67, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 68, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 69, testutil.GetNewVSCMaturedPacketData()) + + // Queue some data for chain-2 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 789, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 790, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 791, testutil.GetNewVSCMaturedPacketData()) + + // Queue some data for chain-3 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 123, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 124, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 125, testutil.GetNewVSCMaturedPacketData()) + + // Confirm getter methods return expected values + slash1, vscm1 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + require.Len(t, slash1, 2) + require.Len(t, vscm1, 2) + + slash2, vscm2 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + require.Len(t, slash2, 1) + require.Len(t, vscm2, 2) + + slash3, vscm3 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + require.Len(t, slash3, 1) + require.Len(t, vscm3, 2) + + // Set vsc send timestamp for every queued vsc matured packet, + // as a way to assert that the vsc matured packets are handled in the migration. + // + // That is, timestamp should exist before a vsc matured packet is handled, + // and deleted after handling. + for _, data := range vscm1 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId, time.Now()) + } + for _, data := range vscm2 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId, time.Now()) + } + for _, data := range vscm3 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId, time.Now()) + } + + // Confirm timestamps are set + for _, data := range vscm1 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + require.True(t, found) + } + for _, data := range vscm2 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + require.True(t, found) + } + for _, data := range vscm3 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + require.True(t, found) + } + + // Run migration + err := providerKeeper.MigrateQueuedPackets(ctx) + require.NoError(t, err) + + // Confirm throttled data is now deleted + slash1, vscm1 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + require.Empty(t, slash1) + require.Empty(t, vscm1) + slash2, vscm2 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + require.Empty(t, slash2) + require.Empty(t, vscm2) + slash3, vscm3 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + require.Empty(t, slash3) + require.Empty(t, vscm3) + + // Confirm timestamps are deleted, meaning vsc matured packets were handled + for _, data := range vscm1 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + require.False(t, found) + } + for _, data := range vscm2 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + require.False(t, found) + } + for _, data := range vscm3 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + require.False(t, found) + } +} diff --git a/x/ccv/provider/keeper/params.go b/x/ccv/provider/keeper/params.go index b7b53b245b..2dbe8ca40d 100644 --- a/x/ccv/provider/keeper/params.go +++ b/x/ccv/provider/keeper/params.go @@ -69,14 +69,6 @@ func (k Keeper) GetSlashMeterReplenishFraction(ctx sdk.Context) string { return f } -// GetMaxThrottledPackets returns the maximum amount of throttled slash or vsc matured packets -// that can be queued for a single consumer before the provider chain halts. -func (k Keeper) GetMaxThrottledPackets(ctx sdk.Context) int64 { - var p int64 - k.paramSpace.Get(ctx, types.KeyMaxThrottledPackets, &p) - return p -} - func (k Keeper) GetConsumerRewardDenomRegistrationFee(ctx sdk.Context) sdk.Coin { // Due to difficulties doing migrations in coordinated upgrades, this param is hardcoded to 10 ATOM in v1.1.0-multiden. // The below code is the proper way to store the param. A future scheduled upgrade will @@ -96,7 +88,6 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.GetVscTimeoutPeriod(ctx), k.GetSlashMeterReplenishPeriod(ctx), k.GetSlashMeterReplenishFraction(ctx), - k.GetMaxThrottledPackets(ctx), k.GetConsumerRewardDenomRegistrationFee(ctx), ) } diff --git a/x/ccv/provider/keeper/params_test.go b/x/ccv/provider/keeper/params_test.go index 05b3964bb7..c057079e59 100644 --- a/x/ccv/provider/keeper/params_test.go +++ b/x/ccv/provider/keeper/params_test.go @@ -44,7 +44,6 @@ func TestParams(t *testing.T) { 10*time.Minute, time.Hour, "0.4", - 100, sdk.Coin{ Denom: "stake", Amount: sdk.NewInt(10000000), diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 7e4eb557f7..a2bc358cb9 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -214,21 +214,6 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo k.DeleteUnbondingOpIndex(ctx, chainID, unbondingOpsIndex.VscId) } - // Remove any existing throttling related entries from the global queue, - // only for this consumer. - // Note: this call panics if the throttling state is invalid - k.DeleteGlobalSlashEntriesForConsumer(ctx, chainID) - - if k.GetThrottledPacketDataSize(ctx, chainID) > 0 { - k.Logger(ctx).Info("There are throttled slash and/or vsc matured packet data instances queued,"+ - " from a consumer that is being removed. This packet data will be thrown out!", "chainID", chainID) - } - - // Remove all throttled slash packets and vsc matured packets queued for this consumer. - // Note: queued VSC matured packets can be safely removed from the per-chain queue, - // since all unbonding operations for this consumer are release above. - k.DeleteThrottledPacketDataForConsumer(ctx, chainID) - k.Logger(ctx).Info("consumer chain removed from provider", "chainID", chainID) return nil @@ -314,6 +299,7 @@ func (k Keeper) MakeConsumerGenesis( "0.05", []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, ) gen = *ccv.NewInitialGenesisState( diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index e6b8573e24..39dd7a3a25 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -18,7 +18,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - cryptoutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" @@ -525,28 +524,6 @@ func TestStopConsumerChain(t *testing.T) { }, expErr: true, }, - { - description: "valid stop of consumer chain, throttle related queues are cleaned", - setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks) - - // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel - gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) - - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - ctx.BlockTime(), "chainID", 1, cryptoutil.NewCryptoIdentityFromIntSeed(90).ProviderConsAddress())) - - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chainID", 1, testkeeper.GetNewSlashPacketData()) - if err != nil { - t.Fatal(err) - } - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chainID", 2, testkeeper.GetNewVSCMaturedPacketData()) - if err != nil { - t.Fatal(err) - } - }, - expErr: false, - }, { description: "valid stop of consumer chain, all mock calls hit", setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { @@ -793,7 +770,6 @@ func TestMakeConsumerGenesis(t *testing.T) { VscTimeoutPeriod: providertypes.DefaultVscTimeoutPeriod, SlashMeterReplenishPeriod: providertypes.DefaultSlashMeterReplenishPeriod, SlashMeterReplenishFraction: providertypes.DefaultSlashMeterReplenishFraction, - MaxThrottledPackets: providertypes.DefaultMaxThrottledPackets, ConsumerRewardDenomRegistrationFee: sdk.Coin{ Denom: "stake", Amount: sdk.NewInt(1000000), @@ -836,7 +812,8 @@ func TestMakeConsumerGenesis(t *testing.T) { "unbonding_period": 1728000000000000, "soft_opt_out_threshold": "0.05", "reward_denoms": [], - "provider_reward_denoms": [] + "provider_reward_denoms": [], + "retry_delay_period": 3600000000000 }, "new_chain": true, "provider_client_state": { diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index d63594dad1..63ea8dd9d5 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -17,7 +17,7 @@ import ( ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// OnRecvVSCMaturedPacket handles a VSCMatured packet +// OnRecvVSCMaturedPacket handles a VSCMatured packet and returns a no-op result ack. func (k Keeper) OnRecvVSCMaturedPacket( ctx sdk.Context, packet channeltypes.Packet, @@ -34,12 +34,9 @@ func (k Keeper) OnRecvVSCMaturedPacket( panic(fmt.Errorf("VSCMaturedPacket received on unknown channel %s", packet.DestinationChannel)) } - if err := k.QueueThrottledVSCMaturedPacketData(ctx, chainID, packet.Sequence, data); err != nil { - return ccv.NewErrorAcknowledgementWithLog(ctx, fmt.Errorf( - "failed to queue VSCMatured packet data: %s", err.Error())) - } + k.HandleVSCMaturedPacket(ctx, chainID, data) - k.Logger(ctx).Info("VSCMaturedPacket received and enqueued", + k.Logger(ctx).Info("VSCMaturedPacket handled", "chainID", chainID, "vscID", data.ValsetUpdateId, ) @@ -48,35 +45,6 @@ func (k Keeper) OnRecvVSCMaturedPacket( return ack } -// HandleLeadingVSCMaturedPackets handles all VSCMatured packet data that has been queued this block, -// but does not need to be throttled. The handled data is then removed from the queue. -// -// Note: VSC matured packet data which is queued behind slash packet data CANNOT be -// handled until the leading slash packet data has been handled. This is to maintain -// the "VSC Maturity and Slashing Order" CCV property. If VSC matured packet data DOES NOT -// trail slash packet data for that consumer, it will be handled in this method, -// bypassing HandleThrottleQueues. -func (k Keeper) HandleLeadingVSCMaturedPackets(ctx sdk.Context) (vscMaturedHandledThisBlock int) { - vscMaturedHandledThisBlock = 0 - for _, chain := range k.GetAllConsumerChains(ctx) { - // Note: it's assumed the order of the vsc matured slice matches the order of the ibc seq nums slice, - // in that a vsc matured packet data at index i is associated with the ibc seq num at index i. - leadingVscMatured, ibcSeqNums := k.GetLeadingVSCMaturedData(ctx, chain.ChainId) - ibcSeqNumsHandled := []uint64{} - for idx, data := range leadingVscMatured { - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - // Break from inner for-loop, DeleteThrottledPacketData will still be called for this consumer - break - } - k.HandleVSCMaturedPacket(ctx, chain.ChainId, data) - vscMaturedHandledThisBlock++ - ibcSeqNumsHandled = append(ibcSeqNumsHandled, ibcSeqNums[idx]) - } - k.DeleteThrottledPacketData(ctx, chain.ChainId, ibcSeqNumsHandled...) - } - return vscMaturedHandledThisBlock -} - // HandleVSCMaturedPacket handles a VSCMatured packet. // // Note: This method should only panic for a system critical error like a @@ -270,18 +238,10 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { k.IncrementValidatorSetUpdateId(ctx) } -// EndBlockCIS contains the EndBlock logic needed for -// the Consumer Initiated Slashing sub-protocol -func (k Keeper) EndBlockCIS(ctx sdk.Context) { - // set the ValsetUpdateBlockHeight - blockHeight := uint64(ctx.BlockHeight()) + 1 - valUpdateID := k.GetValidatorSetUpdateId(ctx) - k.SetValsetUpdateBlockHeight(ctx, valUpdateID, blockHeight) - k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) - - // Replenish slash meter if necessary, BEFORE executing slash packet throttling logic. - // This ensures the meter value is replenished, and not greater than the allowance (max value) - // for the block, before the throttling logic is executed. +// BeginBlockCIS contains the BeginBlock logic needed for the Consumer Initiated Slashing sub-protocol. +func (k Keeper) BeginBlockCIS(ctx sdk.Context) { + // Replenish slash meter if necessary. This ensures the meter value is replenished before handling any slash packets, + // and ensures the meter value is not greater than the allowance (max value) for the block. // // Note: CheckForSlashMeterReplenishment contains panics for the following scenarios, any of which should never occur // if the protocol is correct and external data is properly validated: @@ -291,23 +251,16 @@ func (k Keeper) EndBlockCIS(ctx sdk.Context) { // - Marshaling and/or store corruption errors. // - Setting invalid slash meter values (see SetSlashMeter). k.CheckForSlashMeterReplenishment(ctx) +} - // Handle leading vsc matured packets before throttling logic. - // - // Note: HandleLeadingVSCMaturedPackets contains panics for the following scenarios, any of which should never occur - // if the protocol is correct and external data is properly validated: - // - // - Marshaling and/or store corruption errors. - vscMaturedHandledThisBlock := k.HandleLeadingVSCMaturedPackets(ctx) - // Handle queue entries considering throttling logic. - // - // Note: HandleThrottleQueues contains panics for the following scenarios, any of which should never occur - // if the protocol is correct and external data is properly validated: - // - // - SlashMeter has not been set (which should be set in InitGenesis, see InitializeSlashMeter). - // - Marshaling and/or store corruption errors. - // - Setting invalid slash meter values (see SetSlashMeter). - k.HandleThrottleQueues(ctx, vscMaturedHandledThisBlock) +// EndBlockCIS contains the EndBlock logic needed for +// the Consumer Initiated Slashing sub-protocol +func (k Keeper) EndBlockCIS(ctx sdk.Context) { + // set the ValsetUpdateBlockHeight + blockHeight := uint64(ctx.BlockHeight()) + 1 + valUpdateID := k.GetValidatorSetUpdateId(ctx) + k.SetValsetUpdateBlockHeight(ctx, valUpdateID, blockHeight) + k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) } // OnRecvSlashPacket delivers a received slash packet, validates it and @@ -358,20 +311,27 @@ func (k Keeper) OnRecvSlashPacket(ctx sdk.Context, packet channeltypes.Packet, d return channeltypes.NewResultAcknowledgement(ccv.V1Result) } - // Queue a slash entry to the global queue, which will be seen by the throttling logic - k.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - ctx.BlockTime(), // recv time - chainID, // consumer chain id that sent the packet - packet.Sequence, // IBC sequence number of the packet - providerConsAddr)) // Provider consensus address of val to be slashed - - // Queue slash packet data in the same (consumer chain specific) queue as vsc matured packet data, - // to enforce order of handling between the two packet data types. - if err := k.QueueThrottledSlashPacketData(ctx, chainID, packet.Sequence, data); err != nil { - return ccv.NewErrorAcknowledgementWithLog(ctx, fmt.Errorf("failed to queue slash packet data: %s", err.Error())) + meter := k.GetSlashMeter(ctx) + // Return bounce ack if meter is negative in value + if meter.IsNegative() { + k.Logger(ctx).Info("SlashPacket received, but meter is negative. Packet will be bounced", + "chainID", chainID, + "consumer cons addr", consumerConsAddr.String(), + "provider cons addr", providerConsAddr.String(), + "vscID", data.ValsetUpdateId, + "infractionType", data.Infraction, + ) + return channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult) } - k.Logger(ctx).Info("slash packet received and enqueued", + // Subtract voting power that will be jailed/tombstoned from the slash meter, + // BEFORE handling slash packet. + meter = meter.Sub(k.GetEffectiveValPower(ctx, providerConsAddr)) + k.SetSlashMeter(ctx, meter) + + k.HandleSlashPacket(ctx, chainID, data) + + k.Logger(ctx).Info("slash packet received and handled", "chainID", chainID, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), @@ -379,7 +339,8 @@ func (k Keeper) OnRecvSlashPacket(ctx sdk.Context, packet channeltypes.Packet, d "infractionType", data.Infraction, ) - return channeltypes.NewResultAcknowledgement(ccv.V1Result) + // Return result ack that the packet was handled successfully + return channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult) } // ValidateSlashPacket validates a recv slash packet before it is diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 590286261c..71e9528d64 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "strings" "testing" - "time" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -11,6 +10,8 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/math" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -93,10 +94,8 @@ func TestQueueVSCPackets(t *testing.T) { } // TestOnRecvVSCMaturedPacket tests the OnRecvVSCMaturedPacket method of the keeper. -// Particularly the behavior that VSC matured packet data should be handled immediately -// if the pending packet data queue is empty, and should be queued otherwise. // -// Note: Handling logic itself is not testing in here, just queueing behavior. +// Note: Handling logic itself is not tested here. func TestOnRecvVSCMaturedPacket(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -106,131 +105,69 @@ func TestOnRecvVSCMaturedPacket(t *testing.T) { providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - // Execute on recv for chain-1 + // Execute on recv for chain-1, confirm v1 result ack is returned ack := executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-1", 1) require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - // Assert that the packet data was queued for chain-1 - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // chain-2 queue empty - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Now queue a slash packet data instance for chain-2, then confirm the on recv method - // queues the vsc matured behind the slash packet data - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 1, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) + // Now queue a slash packet data instance for chain-2, confirm v1 result ack is returned ack = executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-2", 2) require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - require.Equal(t, uint64(2), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Chain-1 still has 1 packet data queued - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // Receive 5 more vsc matured packets for chain-2, then confirm chain-2 queue size is 7, chain-1 still size 1 - for i := 0; i < 5; i++ { - ack = executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-2", uint64(i+3)) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - } - require.Equal(t, uint64(7), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // Delete chain-2's data from its queue, then confirm the queue size is 0 - providerKeeper.DeleteThrottledPacketData(ctx, "chain-2", []uint64{1, 2, 3, 4, 5, 6, 7}...) - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) } -func TestHandleLeadingVSCMaturedPackets(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) +// TestOnRecvDowntimeSlashPacket tests the OnRecvSlashPacket method specifically for downtime slash packets. +func TestOnRecvDowntimeSlashPacket(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - vscData := getTenSampleVSCMaturedPacketData() - - // Set channel to chain, and chain to client mappings - // (faking multiple established consumer channels) + // Set channel to chain (faking multiple established channels) providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") - providerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - providerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") - // Queue some leading vsc matured packet data for chain-1 - err := providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 1, vscData[0]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 2, vscData[1]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 3, vscData[2]) - require.NoError(t, err) + // Generate a new slash packet data instance with double sign infraction type + packetData := testkeeper.GetNewSlashPacketData() + packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - // Queue some trailing slash packet data (and a couple more vsc matured) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-1", 4, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-1", 5, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 6, vscData[3]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 7, vscData[4]) - require.NoError(t, err) + // Set a block height for the valset update id in the generated packet data + providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - // Queue some leading vsc matured packet data for chain-2 - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 1, vscData[5]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 2, vscData[6]) - require.NoError(t, err) + // Set slash meter to negative value and assert a bounce ack is returned + providerKeeper.SetSlashMeter(ctx, math.NewInt(-5)) + ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult), ack) - // And trailing slash packet data for chain-2 - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 3, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 4, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) + // Also bounced for chain-2 + ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-2", 2, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult), ack) + + // Now set slash meter to positive value and assert slash packet handled result is returned + providerKeeper.SetSlashMeter(ctx, math.NewInt(5)) + + // Mock call to GetEffectiveValPower, so that it returns 2. + providerAddr := providertypes.NewProviderConsAddress(packetData.Validator.Address) + calls := []*gomock.Call{ + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()). + Return(stakingtypes.Validator{}, true).Times(1), + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(ctx, gomock.Any()). + Return(int64(2)).Times(1), + } - // And one more trailing vsc matured packet for chain-2 - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 5, vscData[7]) - require.NoError(t, err) + // Add mocks for slash packet handling + calls = append(calls, + testkeeper.GetMocksForHandleSlashPacket( + ctx, mocks, providerAddr, stakingtypes.Validator{Jailed: false}, true)..., + ) + gomock.InOrder(calls...) - // Set VSC Send timestamps for each recv vsc matured packet - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[0].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[1].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[2].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[3].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[4].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[5].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[6].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[7].ValsetUpdateId, time.Now()) - - // Confirm each chain-specific queue has the expected number of packet data instances - require.Equal(t, uint64(7), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(5), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Handle leading vsc matured packets and confirm queue sizes change for both chains - providerKeeper.HandleLeadingVSCMaturedPackets(ctx) - require.Equal(t, uint64(4), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(3), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Confirm the leading vsc matured packet data was handled for both chains, - // but not the vsc matured packet data that trails slash data in the queue. - // This assertion is made by checking that VSC Send timestamps were deleted for - // handled vsc matured packet data. - _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[0].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[1].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[2].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[3].ValsetUpdateId) - require.True(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[4].ValsetUpdateId) - require.True(t, found) + // Execute on recv and confirm slash packet handled result is returned + ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult), ack) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[5].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[6].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[7].ValsetUpdateId) - require.True(t, found) + // Require slash meter was decremented appropriately, 5-2=3 + require.Equal(t, int64(3), providerKeeper.GetSlashMeter(ctx).Int64()) } -// TestOnRecvSlashPacket tests the OnRecvSlashPacket method specifically for double-sign slash packets. +// TestOnRecvDoubleSignSlashPacket tests the OnRecvSlashPacket method specifically for double-sign slash packets. func TestOnRecvDoubleSignSlashPacket(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -249,12 +186,8 @@ func TestOnRecvDoubleSignSlashPacket(t *testing.T) { // Receive the double-sign slash packet for chain-1 and confirm the expected acknowledgement ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.V1Result), ack) - // Nothing should be queued - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - require.Equal(t, 0, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) require.True(t, providerKeeper.GetSlashLog(ctx, providertypes.NewProviderConsAddress(packetData.Validator.Address))) @@ -263,56 +196,6 @@ func TestOnRecvDoubleSignSlashPacket(t *testing.T) { require.False(t, providerKeeper.GetSlashLog(ctx, randomAddress)) } -// TestOnRecvSlashPacket tests the OnRecvSlashPacket method specifically for downtime slash packets, -// and how the method interacts with the parent and per-chain slash packet queues. -func TestOnRecvDowntimeSlashPacket(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Set channel to chain (faking multiple established channels) - providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") - providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - - // Generate a new slash packet data instance with downtime infraction type - packetData := testkeeper.GetNewSlashPacketData() - packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - - // Set a block height for the valset update id in the generated packet data - providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - - // Receive the downtime slash packet for chain-1 at time.Now() - ctx = ctx.WithBlockTime(time.Now()) - ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - - // Confirm an entry was added to the global queue, and pending packet data was added to the per-chain queue - globalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) // parent queue - require.Equal(t, 1, len(globalEntries)) - require.Equal(t, "chain-1", globalEntries[0].ConsumerChainID) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) // per chain queue - - // Generate a new downtime packet data instance with downtime infraction type - packetData = testkeeper.GetNewSlashPacketData() - packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - - // Set a block height for the valset update id in the generated packet data - providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - - // Receive a downtime slash packet for chain-2 at time.Now(Add(1 *time.Hour)) - ctx = ctx.WithBlockTime(time.Now().Add(1 * time.Hour)) - ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-2", 2, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - - // Confirm sizes of parent queue and both per-chain queues - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 2, len(globalEntries)) - require.Equal(t, "chain-1", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[1].ConsumerChainID) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) // per chain queue - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) // per chain queue -} - func executeOnRecvVSCMaturedPacket(t *testing.T, providerKeeper *keeper.Keeper, ctx sdk.Context, channelID string, ibcSeqNum uint64, ) exported.Acknowledgement { diff --git a/x/ccv/provider/keeper/throttle.go b/x/ccv/provider/keeper/throttle.go index d8be629ee7..8232e37a25 100644 --- a/x/ccv/provider/keeper/throttle.go +++ b/x/ccv/provider/keeper/throttle.go @@ -11,64 +11,8 @@ import ( tmtypes "github.com/cometbft/cometbft/types" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// This file contains functionality relevant to the throttling of slash and vsc matured packets, aka circuit breaker logic. - -const vscMaturedHandledPerBlockLimit = 100 - -// HandleThrottleQueues iterates over the global slash entry queue, and -// handles all or some portion of throttled (slash and/or VSC matured) packet data received from -// consumer chains. The slash meter is decremented appropriately in this method. -func (k Keeper) HandleThrottleQueues(ctx sdktypes.Context, vscMaturedHandledThisBlock int) { - meter := k.GetSlashMeter(ctx) - // Return if meter is negative in value - if meter.IsNegative() { - return - } - - // Return if vsc matured handle limit was already reached this block, during HandleLeadingVSCMaturedPackets. - // It makes no practical difference for throttling logic to execute next block. - // By doing this, we assure that all leading vsc matured packets were handled before any slash packets. - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - return - } - - // Obtain all global slash entries, where only some of them may be handled in this method, - // depending on the value of the slash meter. - allEntries := k.GetAllGlobalSlashEntries(ctx) - handledEntries := []providertypes.GlobalSlashEntry{} - - for _, globalEntry := range allEntries { - // Subtract voting power that will be jailed/tombstoned from the slash meter - providerAddr := providertypes.NewProviderConsAddress(globalEntry.ProviderValConsAddr) - meter = meter.Sub(k.GetEffectiveValPower(ctx, providerAddr)) - - // Handle one slash and any trailing vsc matured packet data instances by passing in - // chainID and appropriate callbacks, relevant packet data is deleted in this method. - - k.HandlePacketDataForChain(ctx, globalEntry.ConsumerChainID, k.HandleSlashPacket, k.HandleVSCMaturedPacket, vscMaturedHandledThisBlock) - handledEntries = append(handledEntries, globalEntry) - - // don't handle any more global entries if meter becomes negative in value - if meter.IsNegative() { - k.Logger(ctx).Info("negative slash meter value, no more slash packets will be handled", "meter", meter.Int64()) - break - } - } - - // Handled global entries are deleted after iteration is completed - k.DeleteGlobalSlashEntries(ctx, handledEntries...) - - // Persist current value for slash meter - k.SetSlashMeter(ctx, meter) - - if len(handledEntries) > 0 { - k.Logger(ctx).Info("handled global slash entries", "count", len(handledEntries), "meter", meter.Int64()) - } -} - // Obtains the effective validator power relevant to a validator consensus address. func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context, valConsAddr providertypes.ProviderConsAddress, @@ -87,41 +31,6 @@ func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context, } } -// HandlePacketDataForChain handles only the first queued slash packet relevant to the passed consumer chainID, -// and then handles any trailing vsc matured packets in that (consumer chain specific) throttled packet data queue. -// The handled data is then deleted from the queue. -// -// Note: Any packet data which is handled in this method is also deleted from the (consumer chain specific) queue. -func (k Keeper) HandlePacketDataForChain(ctx sdktypes.Context, consumerChainID string, - slashPacketHandler func(sdktypes.Context, string, ccvtypes.SlashPacketData), - vscMaturedPacketHandler func(sdktypes.Context, string, ccvtypes.VSCMaturedPacketData), - vscMaturedHandledThisBlock int, -) { - // Get slash packet data and trailing vsc matured packet data, handle it all. - slashFound, slashData, vscMaturedData, seqNums := k.GetSlashAndTrailingData(ctx, consumerChainID) - seqNumsHandled := []uint64{} - if slashFound { - slashPacketHandler(ctx, consumerChainID, slashData) - // Due to HandleLeadingVSCMaturedPackets() running before HandleThrottleQueues(), and the fact that - // HandleThrottleQueues() will return until all leading vsc matured have been handled, a slash packet - // should always be the first packet in the queue. So we can safely append the first seqNum here. - seqNumsHandled = append(seqNumsHandled, seqNums[0]) - } - for idx, vscMData := range vscMaturedData { - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - // Break from for-loop, DeleteThrottledPacketData will still be called for this consumer - break - } - vscMaturedPacketHandler(ctx, consumerChainID, vscMData) - vscMaturedHandledThisBlock++ - // Append seq num for this vsc matured packet - seqNumsHandled = append(seqNumsHandled, seqNums[idx+1]) // Note idx+1, since slash packet is at index 0 - } - - // Delete handled data after it has all been handled. - k.DeleteThrottledPacketData(ctx, consumerChainID, seqNumsHandled...) -} - // InitializeSlashMeter initializes the slash meter to it's max value (also its allowance), // and sets the replenish time candidate to one replenish period from current block time. func (k Keeper) InitializeSlashMeter(ctx sdktypes.Context) { @@ -206,353 +115,6 @@ func (k Keeper) GetSlashMeterAllowance(ctx sdktypes.Context) math.Int { return roundedInt } -// -// CRUD section -// - -// QueueGlobalSlashEntry queues an entry to the "global" slash packet queue, used for throttling val power changes -// related to jailing/tombstoning over time. This "global" queue is used to coordinate the order of slash packet handling -// between chains, whereas the chain-specific queue is used to coordinate the order of slash and vsc matured packets -// relevant to each chain. -func (k Keeper) QueueGlobalSlashEntry(ctx sdktypes.Context, entry providertypes.GlobalSlashEntry) { - store := ctx.KVStore(k.storeKey) - key := providertypes.GlobalSlashEntryKey(entry) - bz := entry.ProviderValConsAddr - store.Set(key, bz) -} - -// DeleteGlobalSlashEntriesForConsumer deletes all pending slash packet entries in the global queue, -// only relevant to a single consumer. -func (k Keeper) DeleteGlobalSlashEntriesForConsumer(ctx sdktypes.Context, consumerChainID string) { - allEntries := k.GetAllGlobalSlashEntries(ctx) - entriesToDel := []providertypes.GlobalSlashEntry{} - - for _, entry := range allEntries { - if entry.ConsumerChainID == consumerChainID { - entriesToDel = append(entriesToDel, entry) - } - } - k.DeleteGlobalSlashEntries(ctx, entriesToDel...) -} - -// GetAllGlobalSlashEntries returns all global slash entries from the queue. -// -// Note global slash entries are stored under keys with the following format: -// GlobalSlashEntryBytePrefix | uint64 recv time | ibc seq num | consumer chain id -// Thus, the returned array is ordered by recv time, then ibc seq num. -func (k Keeper) GetAllGlobalSlashEntries(ctx sdktypes.Context) []providertypes.GlobalSlashEntry { - store := ctx.KVStore(k.storeKey) - iterator := sdktypes.KVStorePrefixIterator(store, []byte{providertypes.GlobalSlashEntryBytePrefix}) - defer iterator.Close() - - entries := []providertypes.GlobalSlashEntry{} - - for ; iterator.Valid(); iterator.Next() { - // MustParseGlobalSlashEntryKey should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueGlobalSlashEntry. - recvTime, chainID, ibcSeqNum := providertypes.MustParseGlobalSlashEntryKey(iterator.Key()) - valAddr := providertypes.NewProviderConsAddress(iterator.Value()) - entry := providertypes.NewGlobalSlashEntry(recvTime, chainID, ibcSeqNum, valAddr) - entries = append(entries, entry) - } - return entries -} - -// DeleteGlobalSlashEntries deletes the given global entries from the global slash queue -func (k Keeper) DeleteGlobalSlashEntries(ctx sdktypes.Context, entries ...providertypes.GlobalSlashEntry) { - store := ctx.KVStore(k.storeKey) - for _, entry := range entries { - store.Delete(providertypes.GlobalSlashEntryKey(entry)) - } -} - -// Pending packet data type enum, used to encode the type of packet data stored at each entry in the mutual queue. -const ( - slashPacketData byte = iota - vscMaturedPacketData -) - -// GetThrottledPacketDataSize returns the size of the throttled packet data queue for the given consumer chain -func (k Keeper) GetThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string) uint64 { - store := ctx.KVStore(k.storeKey) - key := providertypes.ThrottledPacketDataSizeKey(consumerChainID) - var size uint64 - bz := store.Get(key) - if bz == nil { - size = 0 - } else { - size = sdktypes.BigEndianToUint64(bz) - } - return size -} - -// SetThrottledPacketDataSize sets the size of the throttled packet data queue for the given consumer chain -func (k Keeper) SetThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string, size uint64) { - // Sanity check to ensure that the chain-specific throttled packet data queue does not grow too - // large for a single consumer chain. This check ensures that binaries would panic deterministically - // if the queue does grow too large. MaxThrottledPackets should be set accordingly (quite large). - if size >= uint64(k.GetMaxThrottledPackets(ctx)) { - panic(fmt.Sprintf("throttled packet data queue for chain %s is too large: %d", consumerChainID, size)) - } - - store := ctx.KVStore(k.storeKey) - key := providertypes.ThrottledPacketDataSizeKey(consumerChainID) - bz := sdktypes.Uint64ToBigEndian(size) - store.Set(key, bz) -} - -// IncrementThrottledPacketDataSize increments the size of the throttled packet data -// queue for the given consumer chain. -func (k Keeper) IncrementThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string) { - size := k.GetThrottledPacketDataSize(ctx, consumerChainID) - k.SetThrottledPacketDataSize(ctx, consumerChainID, size+1) - k.Logger(ctx).Debug("incremented throttled packets size", - "chainID", consumerChainID, - "size", size+1, - ) -} - -// QueueThrottledSlashPacketData queues the slash packet data for a chain-specific throttled packet data queue. -// -// Note: This queue is shared between pending slash packet data and pending vsc matured packet data. -func (k Keeper) QueueThrottledSlashPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, data ccvtypes.SlashPacketData, -) error { - return k.QueueThrottledPacketData(ctx, consumerChainID, ibcSeqNum, data) -} - -// QueueThrottledVSCMaturedPacketData queues the vsc matured packet data for a chain-specific throttled packet data queue. -// -// Note: This queue is shared between pending slash packet data and pending vsc matured packet data. -func (k Keeper) QueueThrottledVSCMaturedPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, data ccvtypes.VSCMaturedPacketData, -) error { - return k.QueueThrottledPacketData(ctx, consumerChainID, ibcSeqNum, data) -} - -// QueueThrottledPacketData queues a slash packet data or vsc matured packet data instance -// for the given consumer chain's queue. -// -// Note: This method returns an error because it is called from -// OnRecvSlashPacket and OnRecvVSCMaturedPacket, meaning we can return an ibc err ack to the -// counter party chain on error, instead of panicking this chain. -func (k Keeper) QueueThrottledPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, packetData interface{}, -) error { - store := ctx.KVStore(k.storeKey) - - var bz []byte - var err error - switch data := packetData.(type) { - case ccvtypes.SlashPacketData: - bz, err = data.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal slash packet data: %v", err) - } - bz = append([]byte{slashPacketData}, bz...) - case ccvtypes.VSCMaturedPacketData: - bz, err = data.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal vsc matured packet data: %v", err) - } - bz = append([]byte{vscMaturedPacketData}, bz...) - default: - // Indicates a developer error, this method should only be called - // by tests, QueueThrottledSlashPacketData, or QueueThrottledVSCMaturedPacketData. - panic(fmt.Sprintf("unexpected packet data type: %T", data)) - } - - store.Set(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum), bz) - k.IncrementThrottledPacketDataSize(ctx, consumerChainID) - return nil -} - -// GetLeadingVSCMaturedData returns the leading vsc matured packet data instances -// for a chain-specific throttled packet data queue. Ie the vsc matured packet data instances -// that do not have any slash packet data instances preceding them in the queue for consumerChainID. -func (k Keeper) GetLeadingVSCMaturedData(ctx sdktypes.Context, consumerChainID string) ( - vscMaturedData []ccvtypes.VSCMaturedPacketData, ibcSeqNums []uint64, -) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - // Iterate over the throttled packet data queue, - // and return vsc matured packet data instances until we encounter a slash packet data instance. - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - ibcSeqNums = []uint64{} - for ; iterator.Valid(); iterator.Next() { - - bz := iterator.Value() - if bz[0] == slashPacketData { - break - } else if bz[0] != vscMaturedPacketData { - // This case would indicate a developer error or store corruption, - // since QueueThrottledPacketData should only queue slash packet data or vsc matured packet data. - panic(fmt.Sprintf("unexpected packet data type: %d", bz[0])) - } - - var data ccvtypes.VSCMaturedPacketData - err := data.Unmarshal(bz[1:]) - if err != nil { - // An error here would indicate something is very wrong, - // vsc matured packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - } - - vscMaturedData = append(vscMaturedData, data) - // The below func should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueThrottledPacketData. - _, ibcSeqNum := providertypes.MustParseThrottledPacketDataKey(iterator.Key()) - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - return vscMaturedData, ibcSeqNums -} - -// GetSlashAndTrailingData returns the first slash packet data instance and any -// trailing vsc matured packet data instances in the chain-specific throttled packet data queue. -// -// Note that throttled packet data is stored under keys with the following format: -// ThrottledPacketDataBytePrefix | len(chainID) | chainID | ibcSeqNum -// Thus, the returned array is in ascending order of ibc seq numbers. -func (k Keeper) GetSlashAndTrailingData(ctx sdktypes.Context, consumerChainID string) ( - slashFound bool, slashData ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, - // Note: this slice contains the IBC sequence numbers of the slash packet data - // and trailing vsc matured packet data instances. This is used by caller to delete the - // data after it has been handled. - ibcSeqNums []uint64, -) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - slashFound = false - slashData = ccvtypes.SlashPacketData{} - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - ibcSeqNums = []uint64{} - - for ; iterator.Valid(); iterator.Next() { - - bz := iterator.Value() - if bz[0] == slashPacketData { - if slashFound { - // Break for-loop, we've already found first slash packet data instance. - break - } else { - if err := slashData.Unmarshal(bz[1:]); err != nil { - // An error here would indicate something is very wrong, - // slash packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) - } - slashFound = true - } - } else if bz[0] == vscMaturedPacketData { - vscMData := ccvtypes.VSCMaturedPacketData{} - if err := vscMData.Unmarshal(bz[1:]); err != nil { - // An error here would indicate something is very wrong, - // vsc matured packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - } - vscMaturedData = append(vscMaturedData, vscMData) - } else { - // This case would indicate a developer error or store corruption, - // since QueueThrottledPacketData should only queue slash packet data or vsc matured packet data. - panic("invalid packet data type") - } - // The below func should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueThrottledPacketData. - _, ibcSeqNum := providertypes.MustParseThrottledPacketDataKey(iterator.Key()) - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - return slashFound, slashData, vscMaturedData, ibcSeqNums -} - -// GetAllThrottledPacketData returns all throttled packet data for a specific consumer chain. -// -// Note: This method is only used by tests and queries, hence why it returns redundant data as different types. -// Since this method executes on query, no panics are explicitly included. -func (k Keeper) GetAllThrottledPacketData(ctx sdktypes.Context, consumerChainID string) ( - slashData []ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, - rawOrderedData []interface{}, ibcSeqNums []uint64, -) { - slashData = []ccvtypes.SlashPacketData{} - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - rawOrderedData = []interface{}{} - ibcSeqNums = []uint64{} - - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - bz := iterator.Value() - switch bz[0] { - case slashPacketData: - d := ccvtypes.SlashPacketData{} - if err := d.Unmarshal(bz[1:]); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) - continue - } - slashData = append(slashData, d) - rawOrderedData = append(rawOrderedData, d) - case vscMaturedPacketData: - d := ccvtypes.VSCMaturedPacketData{} - if err := d.Unmarshal(bz[1:]); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - continue - } - vscMaturedData = append(vscMaturedData, d) - rawOrderedData = append(rawOrderedData, d) - default: - k.Logger(ctx).Error(fmt.Sprintf("invalid packet data type: %v", bz[0])) - continue - } - _, ibcSeqNum, err := providertypes.ParseThrottledPacketDataKey(iterator.Key()) - if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to parse throttled packet data key: %v", err)) - continue - } - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - - return slashData, vscMaturedData, rawOrderedData, ibcSeqNums -} - -// DeleteAllPacketDataForConsumer deletes all queued packet data for the given consumer chain. -func (k Keeper) DeleteThrottledPacketDataForConsumer(ctx sdktypes.Context, consumerChainID string) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - keysToDel := [][]byte{} - for ; iterator.Valid(); iterator.Next() { - keysToDel = append(keysToDel, iterator.Key()) - } - // Delete data for this consumer - for _, key := range keysToDel { - store.Delete(key) - } - - // Delete size of data queue for this consumer - store.Delete(providertypes.ThrottledPacketDataSizeKey(consumerChainID)) -} - -// DeleteThrottledPacketData deletes the given throttled packet data instances -// (specified by their ibc seq number) from the chain-specific throttled packet data queue. -func (k Keeper) DeleteThrottledPacketData(ctx sdktypes.Context, consumerChainID string, ibcSeqNumbers ...uint64) { - store := ctx.KVStore(k.storeKey) - for _, ibcSeqNum := range ibcSeqNumbers { - store.Delete(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) - } - // Decrement the size of the pending packet data queue - sizeBeforeDeletion := k.GetThrottledPacketDataSize(ctx, consumerChainID) - k.SetThrottledPacketDataSize(ctx, consumerChainID, sizeBeforeDeletion-uint64(len(ibcSeqNumbers))) -} - // GetSlashMeter returns a meter (persisted as a signed int) which stores an amount of voting power, corresponding // to an allowance of validators that can be jailed/tombstoned over time. // diff --git a/x/ccv/provider/keeper/throttle_test.go b/x/ccv/provider/keeper/throttle_test.go index a5356b0dc0..24e8c0ddde 100644 --- a/x/ccv/provider/keeper/throttle_test.go +++ b/x/ccv/provider/keeper/throttle_test.go @@ -1,13 +1,11 @@ package keeper_test import ( - "math/rand" "testing" "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" "cosmossdk.io/math" @@ -15,168 +13,10 @@ import ( tmtypes "github.com/cometbft/cometbft/types" - cryptoutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// TestHandlePacketDataForChain tests the HandlePacketDataForChain function. Note: Only one consumer is tested here, -// but multiple consumers are tested in TestPendingPacketData. -func TestHandlePacketDataForChain(t *testing.T) { - testCases := []struct { - name string - chainID string - // Pending packet data that will be queued in the order specified by the slice - dataToQueue []interface{} - // Indexes of packet data from dataToQueue that are expected to be handled and deleted from store - expectedHandledIndexes []int - }{ - { - "no packets", - "my-cool-chain", - []interface{}{}, - []int{}, - }, - { - "one slash packet should be handled", - "chain-37", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - }, - []int{0}, - }, - { - "one slash packet followed by one vsc matured packet should all be handled", - "chain-222", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1}, - }, - { - "one slash packet followed by multiple vsc matured packets should all be handled", - "chain-2223", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1, 2, 3, 4, 5}, - }, - { - "multiple slash packets followed by multiple vsc matured packets should only handle first slash packet", - "chain-9", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0}, - }, - { - "vsc matured packets sandwiched between slash packets should handle everything but the last slash packet", - "chain-000", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), // 10th index not included in expectedHandledIndexes - }, - []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, - }, - { - "alternating slash and vsc matured packets should handle only the first slash, and trailing vsc matured packets", - "chain-00000", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1, 2}, - }, - } - - for _, tc := range testCases { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue throttled packet data, where chainID is arbitrary, and ibc seq number is index of the data instance - for i, data := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, tc.chainID, uint64(i), data) - require.NoError(t, err) - } - - // Define our handler callbacks to simply store the data instances that are handled - handledData := []interface{}{} - slashHandleCounter := func(ctx sdktypes.Context, chainID string, data ccvtypes.SlashPacketData) { - handledData = append(handledData, data) - } - vscMaturedHandleCounter := func(ctx sdktypes.Context, chainID string, data ccvtypes.VSCMaturedPacketData) { - handledData = append(handledData, data) - } - - providerKeeper.HandlePacketDataForChain(ctx, tc.chainID, slashHandleCounter, vscMaturedHandleCounter, 0) - - // Assert number of handled data instances matches expected number - require.Equal(t, len(tc.expectedHandledIndexes), len(handledData)) - - // Assert handled data instances match expected value - for i, expectedIndex := range tc.expectedHandledIndexes { - require.Equal(t, tc.dataToQueue[expectedIndex], handledData[i]) - } - - // Sanity check, Assert that only the first handled packet is a slash packet, and the rest are vsc matured packets - for idx, instance := range handledData { - switch instance.(type) { - case ccvtypes.SlashPacketData: - require.Equal(t, 0, idx) - case ccvtypes.VSCMaturedPacketData: - default: - require.Fail(t, "unexpected data instance type") - } - } - - // Assert that the unhandled queued data instances are as expected (i.e no unexpected deletions) - expectedDataThatsLeft := []interface{}{} - for idx, data := range tc.dataToQueue { - if !slices.Contains(tc.expectedHandledIndexes, idx) { - expectedDataThatsLeft = append(expectedDataThatsLeft, data) - } - } - - _, _, dataThatsLeft, _ := providerKeeper.GetAllThrottledPacketData(ctx, tc.chainID) - require.Equal(t, expectedDataThatsLeft, dataThatsLeft) - - // Assert that each instance of handled data is deleted from the persisted queue (i.e deletions where expected) - for _, dataInstance := range handledData { - require.NotContains(t, dataThatsLeft, dataInstance) - } - } -} - // TestSlashMeterReplenishment tests the CheckForSlashMeterReplenishment, ReplenishSlashMeter, // and InitializeSlashMeter methods. func TestSlashMeterReplenishment(t *testing.T) { @@ -627,628 +467,6 @@ func TestGetSlashMeterAllowance(t *testing.T) { } } -// TestGlobalSlashEntries tests the queue and iteration functions for global slash entries, -// with assertion of FIFO ordering -func TestGlobalSlashEntries(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Consistent time for "now" - now := time.Now().UTC() - - globalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 0, len(globalEntries)) - - // Queue 3 entries for chainIDs 0, 1, 2, note their respective ibc seq nums are - // ordered differently than the chainIDs would be iterated. - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-0", 15, cryptoutil.NewCryptoIdentityFromIntSeed(10).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-1", 10, cryptoutil.NewCryptoIdentityFromIntSeed(11).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-2", 5, cryptoutil.NewCryptoIdentityFromIntSeed(12).ProviderConsAddress())) - - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 3, len(globalEntries)) - - // Queue 3 entries for chainIDs 0, 1, 2 an hour later, with incremented ibc seq nums - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-0", 16, // should appear last for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(20).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-1", 11, // should appear middle for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(21).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-2", 6, // should appear first for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(22).ProviderConsAddress())) - - // Retrieve entries from store - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 6, len(globalEntries)) - - // Assert that entries are obtained in FIFO order according to block time, then ibc seq num - require.Equal(t, "chain-2", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[1].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[2].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[3].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[4].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[5].ConsumerChainID) - - // Queue 3 entries for chainIDs 5, 6, 7 another hour later - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-5", 50, // should appear middle for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(96).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-6", 60, // should appear last for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(97).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-7", 40, // should appear first for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(98).ProviderConsAddress())) - // Retrieve entries from store - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 9, len(globalEntries)) - - // Assert that entries are obtained in FIFO order according to block time, then ibc seq num - require.Equal(t, "chain-2", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[1].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[2].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[3].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[4].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[5].ConsumerChainID) - require.Equal(t, "chain-7", globalEntries[6].ConsumerChainID) - require.Equal(t, "chain-5", globalEntries[7].ConsumerChainID) - require.Equal(t, "chain-6", globalEntries[8].ConsumerChainID) - - // Assert each field is as expected for all 9 entries - require.Equal(t, uint64(5), globalEntries[0].IbcSeqNum) - require.Equal(t, uint64(10), globalEntries[1].IbcSeqNum) - require.Equal(t, uint64(15), globalEntries[2].IbcSeqNum) - require.Equal(t, uint64(6), globalEntries[3].IbcSeqNum) - require.Equal(t, uint64(11), globalEntries[4].IbcSeqNum) - require.Equal(t, uint64(16), globalEntries[5].IbcSeqNum) - require.Equal(t, uint64(40), globalEntries[6].IbcSeqNum) - require.Equal(t, uint64(50), globalEntries[7].IbcSeqNum) - require.Equal(t, uint64(60), globalEntries[8].IbcSeqNum) - - require.Equal(t, now, globalEntries[0].RecvTime) - require.Equal(t, now, globalEntries[1].RecvTime) - require.Equal(t, now, globalEntries[2].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[3].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[4].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[5].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[6].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[7].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[8].RecvTime) -} - -// Tests DeleteGlobalSlashEntriesForConsumer. -func TestDeleteGlobalSlashEntriesForConsumer(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx( - t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Queue 2 global entries for a consumer chain ID - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(time.Hour), "chain-78", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(78).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(time.Hour), "chain-78", 2, - cryptoutil.NewCryptoIdentityFromIntSeed(79).ProviderConsAddress())) - - // Queue 1 global entry for two other consumer chain IDs - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(2*time.Hour), "chain-79", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(80).ProviderConsAddress())) - - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(3*time.Hour), "chain-80", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(81).ProviderConsAddress())) - - // Delete entries for chain-78, confirm those are deleted, and the other two remain - providerKeeper.DeleteGlobalSlashEntriesForConsumer(ctx, "chain-78") - allEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 2, len(allEntries)) - require.Equal(t, "chain-79", allEntries[0].ConsumerChainID) - require.Equal(t, "chain-80", allEntries[1].ConsumerChainID) -} - -// TestGlobalSlashEntryDeletion tests the deletion function for -// global slash entries with assertion of FIFO ordering. -func TestGlobalSlashEntryDeletion(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - now := time.Now() - - entries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 0, len(entries)) - - providerConsAddrs := []providertypes.ProviderConsAddress{ - cryptoutil.NewCryptoIdentityFromIntSeed(1).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(2).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(3).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(4).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(5).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(6).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(7).ProviderConsAddress(), - } - - // Instantiate entries in the expected order we wish to get them back as (ordered by recv time) - entries = []providertypes.GlobalSlashEntry{} - entries = append(entries, providertypes.NewGlobalSlashEntry(now, "chain-0", 1, providerConsAddrs[0])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(time.Hour).UTC(), "chain-1", 178, providerConsAddrs[1])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-2", 89, providerConsAddrs[2])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(3*time.Hour).In(time.FixedZone("UTC-8", -8*60*60)), "chain-3", 23423, providerConsAddrs[3])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(4*time.Hour).Local(), "chain-4", 323, providerConsAddrs[4])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(5*time.Hour).UTC(), "chain-5", 18, providerConsAddrs[5])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(6*time.Hour).Local(), "chain-6", 2, providerConsAddrs[6])) - - // Instantiate shuffled copy of above slice - shuffledEntries := append([]providertypes.GlobalSlashEntry{}, entries...) - seed := time.Now().UnixNano() - rng := rand.New(rand.NewSource(seed)) - rng.Shuffle(len(shuffledEntries), func(i, j int) { - shuffledEntries[i], shuffledEntries[j] = shuffledEntries[j], shuffledEntries[i] - }) - - // Queue 7 slash packets with various block times in random order - for _, entry := range shuffledEntries { - providerKeeper.QueueGlobalSlashEntry(ctx, entry) - } - - gotEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 7, len(gotEntries)) - - // Assert obtained order is decided upon via packet recvTime, not insertion order - for i, gotEntry := range gotEntries { - expectedEntry := entries[i] - require.Equal(t, expectedEntry, gotEntry) - } - - // Confirm no mutations have occurred from test helper - gotEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 7, len(gotEntries)) - - // Delete packets 1, 3, 5 (0-indexed) - providerKeeper.DeleteGlobalSlashEntries(ctx, gotEntries[1], gotEntries[3], gotEntries[5]) - - // Assert deletion and ordering - gotEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 4, len(gotEntries)) - require.Equal(t, "chain-0", gotEntries[0].ConsumerChainID) - // entry 1 was deleted - require.Equal(t, "chain-2", gotEntries[1].ConsumerChainID) - // entry 3 was deleted - require.Equal(t, "chain-4", gotEntries[2].ConsumerChainID) - // entry 5 was deleted - require.Equal(t, "chain-6", gotEntries[3].ConsumerChainID) -} - -// TestThrottledPacketData tests chain-specific throttled packet data queuing, -// iteration and deletion functionality. -func TestThrottledPacketData(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - packetDataForMultipleConsumers := []struct { - chainID string - instances []throttledPacketDataInstance - - // Expected order of data instances after retrieval from store, before deletion (specified by instance index) - expectedOrder []int - // Data instances to delete (specified by instance index) - toDelete []int - // Expected order of data instances after deletion (specified by instance index) - expectedOrderAfterDeletion []int - }{ - // Note, duplicate ibc sequence numbers are not tested, as we assume ibc behaves correctly - { - chainID: "chain-0", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 0, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 2, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 3, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 4, Data: testkeeper.GetNewSlashPacketData()}, - }, - expectedOrder: []int{0, 1, 2, 3, 4}, - toDelete: []int{0, 2, 4}, - expectedOrderAfterDeletion: []int{1, 3}, - }, - { - chainID: "chain-7", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 96, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 78, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 12, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 0, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 78972, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 9999999999999999999, Data: testkeeper.GetNewSlashPacketData()}, - }, - expectedOrder: []int{3, 4, 2, 1, 0, 5, 6}, - toDelete: []int{0, 1, 2, 3, 4, 5}, - expectedOrderAfterDeletion: []int{6}, - }, - { - chainID: "chain-thats-not-0-or-7", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 9, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 8, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 7, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 6, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 5, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewVSCMaturedPacketData()}, - }, - expectedOrder: []int{5, 4, 3, 2, 1, 0}, - toDelete: []int{1, 2, 3, 4, 5}, - expectedOrderAfterDeletion: []int{0}, - }, - } - - // Queue all packet data at once - for _, chainData := range packetDataForMultipleConsumers { - for _, dataInstance := range chainData.instances { - err := providerKeeper.QueueThrottledPacketData(ctx, chainData.chainID, dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - } - - // Assert retrieval ordering for each chain - for _, chainData := range packetDataForMultipleConsumers { - expectedInstances := getOrderedInstances(chainData.instances, chainData.expectedOrder) - assertPendingPacketDataOrdering(t, &providerKeeper, ctx, chainData.chainID, expectedInstances) - } - - // Delete specified data all at once - for _, chainData := range packetDataForMultipleConsumers { - for _, i := range chainData.toDelete { - providerKeeper.DeleteThrottledPacketData(ctx, chainData.chainID, chainData.instances[i].IbcSeqNum) - } - } - - // Assert retrieval ordering after deletion for each chain - for _, chainData := range packetDataForMultipleConsumers { - expectedInstances := getOrderedInstances(chainData.instances, chainData.expectedOrderAfterDeletion) - assertPendingPacketDataOrdering(t, &providerKeeper, ctx, chainData.chainID, expectedInstances) - } -} - -func TestGetLeadingVSCMaturedData(t *testing.T) { - // Instantiate some sample data - slashData := getTenSampleSlashPacketData() - vscMaturedData := getTenSampleVSCMaturedPacketData() - - testCases := []struct { - name string - dataToQueue []throttledPacketDataInstance - expectedReturnData []ccvtypes.VSCMaturedPacketData - expectedReturnSeqs []uint64 - }{ - { - name: "no data", - dataToQueue: []throttledPacketDataInstance{}, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, - expectedReturnSeqs: []uint64{}, - }, - { - name: "one slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 889, Data: slashData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, - expectedReturnSeqs: []uint64{}, - }, - { - name: "one vsc matured", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 54, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0]}, - expectedReturnSeqs: []uint64{54}, - }, - { - name: "one vsc matured trailing one slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: slashData[0]}, - {IbcSeqNum: 88, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, // Nothing returned - expectedReturnSeqs: []uint64{}, // Nothing returned - }, - { - name: "one vsc matured trailing multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: slashData[0]}, - {IbcSeqNum: 88, Data: slashData[1]}, - {IbcSeqNum: 89, Data: slashData[2]}, - {IbcSeqNum: 90, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, // Nothing returned - expectedReturnSeqs: []uint64{}, // Nothing returned - }, - { - name: "one vsc matured leading multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: vscMaturedData[0]}, - {IbcSeqNum: 88, Data: slashData[0]}, - {IbcSeqNum: 89, Data: slashData[1]}, - {IbcSeqNum: 90, Data: slashData[2]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0]}, - expectedReturnSeqs: []uint64{87}, - }, - { - name: "multiple vsc matured leading multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 102, Data: vscMaturedData[0]}, - {IbcSeqNum: 103, Data: vscMaturedData[1]}, - {IbcSeqNum: 104, Data: vscMaturedData[2]}, - {IbcSeqNum: 105, Data: slashData[0]}, - {IbcSeqNum: 106, Data: slashData[1]}, - {IbcSeqNum: 107, Data: slashData[2]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0], vscMaturedData[1], vscMaturedData[2]}, - expectedReturnSeqs: []uint64{102, 103, 104}, - }, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue a slash and vsc matured packet data for some random chain. - // These values should never be returned. - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "some-rando-chain", 77, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "some-rando-chain", 97, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue the data to test against - for _, dataInstance := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-99", dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - - // Obtain data from iterator - returnedData, ibcSeqNums := providerKeeper.GetLeadingVSCMaturedData(ctx, "chain-99") - - // Assert the returned data is as expected - require.Equal(t, tc.expectedReturnData, returnedData) - require.Equal(t, tc.expectedReturnSeqs, ibcSeqNums) - } -} - -func TestGetSlashAndTrailingData(t *testing.T) { - // Instantiate some data to test against - someSlashData := getTenSampleSlashPacketData() - someVSCMaturedData := getTenSampleVSCMaturedPacketData() - - testCases := []struct { - name string - dataToQueue []throttledPacketDataInstance - expectedSlashFound bool - expectedSlashData ccvtypes.SlashPacketData - expectedVSCMaturedData []ccvtypes.VSCMaturedPacketData - expectedIBCSeqNums []uint64 - }{ - { - name: "Empty queue", - dataToQueue: []throttledPacketDataInstance{}, - expectedSlashFound: false, - expectedSlashData: ccvtypes.SlashPacketData{}, // single zero value returned. - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{}, - }, - { - name: "Queue only one slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 1, Data: someSlashData[0]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[0], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{1}, - }, - { - name: "Queue two vsc matured behind slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 80, Data: someSlashData[3]}, - {IbcSeqNum: 82, Data: someVSCMaturedData[0]}, - {IbcSeqNum: 83, Data: someVSCMaturedData[1]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[3], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{someVSCMaturedData[0], someVSCMaturedData[1]}, - expectedIBCSeqNums: []uint64{80, 82, 83}, - }, - { - name: "Queue two vsc matured behind 4 slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 80, Data: someSlashData[1]}, // Only returned value - {IbcSeqNum: 82, Data: someSlashData[2]}, - {IbcSeqNum: 83, Data: someSlashData[3]}, - {IbcSeqNum: 84, Data: someSlashData[4]}, - {IbcSeqNum: 85, Data: someVSCMaturedData[1]}, - {IbcSeqNum: 86, Data: someVSCMaturedData[2]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[1], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{80}, - }, - { - name: "Queue vsc matured data behind slash data, ending with another slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 47238, Data: someSlashData[1]}, - {IbcSeqNum: 47239, Data: someVSCMaturedData[0]}, - {IbcSeqNum: 47240, Data: someVSCMaturedData[1]}, - {IbcSeqNum: 47241, Data: someVSCMaturedData[2]}, - {IbcSeqNum: 47242, Data: someVSCMaturedData[3]}, - {IbcSeqNum: 47243, Data: someSlashData[2]}, // Not returned - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[1], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{ - someVSCMaturedData[0], someVSCMaturedData[1], someVSCMaturedData[2], someVSCMaturedData[3], - }, - expectedIBCSeqNums: []uint64{47238, 47239, 47240, 47241, 47242}, - }, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue a slash and vsc matured packet data for some random chain. - // These values should never be returned. - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "some-rando-chain", 77, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "some-rando-chain", 97, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue the data to test - for _, dataInstance := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-49", dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - - // Retrieve the data, and assert that it is correct - slashFound, slashData, vscMaturedData, ibcSeqNums := providerKeeper.GetSlashAndTrailingData(ctx, "chain-49") - require.Equal(t, tc.expectedSlashFound, slashFound, tc.name) - require.Equal(t, tc.expectedSlashData, slashData, tc.name) - require.Equal(t, tc.expectedVSCMaturedData, vscMaturedData, tc.name) - require.Equal(t, tc.expectedIBCSeqNums, ibcSeqNums, tc.name) - } -} - -// TestDeleteThrottledPacketDataForConsumer tests the DeleteThrottledPacketDataForConsumer method. -func TestDeleteThrottledPacketDataForConsumer(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue slash and a VSC matured packet data for chain-48 - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-48", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-48", 1, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue 3 slash, and 4 vsc matured packet data instances for chain-49 - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 1, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 2, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 3, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 4, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 5, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 6, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Delete all packet data for chain-49, confirm they are deleted - providerKeeper.DeleteThrottledPacketDataForConsumer(ctx, "chain-49") - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData(ctx, "chain-49") - require.Empty(t, slashData) - require.Empty(t, vscMaturedData) - - // Confirm size of queue is now 0 - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-49")) - - // Confirm packet data for chain-48 is not deleted - slashData, vscMaturedData, _, _ = providerKeeper.GetAllThrottledPacketData(ctx, "chain-48") - require.Len(t, slashData, 1) - require.Len(t, vscMaturedData, 1) -} - -// TestPanicIfTooMuchThrottledPacketData tests that the provider panics -// when the number of throttled (queued) packets exceeds the max allowed by params. -func TestPanicIfTooMuchThrottledPacketData(t *testing.T) { - testCases := []struct { - max int64 - }{ - {max: 3}, // Max must be greater than 2 since we queue 2 packets for another chain in the test - {max: 5}, - {max: 10}, - {max: 15}, - {max: 25}, - {max: 100}, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Set max throttled packets param - defaultParams := providertypes.DefaultParams() - defaultParams.MaxThrottledPackets = tc.max - providerKeeper.SetParams(ctx, defaultParams) - - seed := time.Now().UnixNano() - rng := rand.New(rand.NewSource(seed)) - - // Queuing up a couple data instances for another chain shouldn't matter - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 1, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue packet data instances until we reach the max (some slash packets, some VSC matured packets) - reachedMax := false - for i := 0; i < int(tc.max); i++ { - randBool := rng.Intn(2) == 0 - var data interface{} - if randBool { - data = testkeeper.GetNewSlashPacketData() - } else { - data = testkeeper.GetNewVSCMaturedPacketData() - } - // Panic only if we've reached the max - if i == int(tc.max-1) { - require.Panics(t, func() { - _ = providerKeeper.QueueThrottledPacketData(ctx, "chain-88", uint64(i), data) - }) - reachedMax = true - } else { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-88", uint64(i), data) - require.NoError(t, err) - } - } - require.True(t, reachedMax) - } -} - -// TestThrottledPacketDataSize tests the getter, setter and incrementer for throttled packet data size. -func TestThrottledPacketDataSize(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Set params so we can use the default max throttled packet data size - params := providertypes.DefaultParams() - providerKeeper.SetParams(ctx, params) - - // Confirm initial size is 0 - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) - - // Set throttled packet data size and confirm it was set - providerKeeper.SetThrottledPacketDataSize(ctx, "chain-0", 10) - require.Equal(t, uint64(10), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) - - // Increment throttled packet data size and confirm it was incremented - providerKeeper.IncrementThrottledPacketDataSize(ctx, "chain-0") - require.Equal(t, uint64(11), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) -} - // TestSlashMeter tests the getter and setter for the slash gas meter func TestSlashMeter(t *testing.T) { testCases := []struct { @@ -1320,65 +538,3 @@ func TestSlashMeterReplenishTimeCandidate(t *testing.T) { require.Equal(t, tc.blockTime.Add(tc.replenishPeriod).UTC(), gotTime) } } - -// Struct used for TestPendingPacketData and helpers -type throttledPacketDataInstance struct { - IbcSeqNum uint64 - Data interface{} -} - -// getAllThrottledPacketDataInstances returns all throttled packet data instances in order -// from the chain-specific packet data queue. -func getAllThrottledPacketDataInstances(ctx sdktypes.Context, k *keeper.Keeper, consumerChainId string) (instances []throttledPacketDataInstance) { - _, _, allData, ibcSeqNums := k.GetAllThrottledPacketData(ctx, consumerChainId) - instances = []throttledPacketDataInstance{} - for idx, data := range allData { - instances = append(instances, throttledPacketDataInstance{ - IbcSeqNum: ibcSeqNums[idx], - Data: data, - }) - } - return instances -} - -// getOrderedInstances returns the given instances in order, specified by the given indexes -func getOrderedInstances(instances []throttledPacketDataInstance, orderbyIdx []int) (orderedInstances []throttledPacketDataInstance) { - toReturn := []throttledPacketDataInstance{} - for _, idx := range orderbyIdx { - toReturn = append(toReturn, instances[idx]) - } - return toReturn -} - -// Asserts that the throttled packet data retrieved for this consumer chain matches what's expected -func assertPendingPacketDataOrdering(t *testing.T, k *keeper.Keeper, ctx sdktypes.Context, - consumerChainId string, expectedInstances []throttledPacketDataInstance, -) { - t.Helper() - // Get all packet data for this chain - obtainedInstances := getAllThrottledPacketDataInstances(ctx, k, consumerChainId) - // No extra data should be present - require.Equal(t, len(expectedInstances), len(obtainedInstances)) - // Assert order and correct serialization/deserialization for each data instance - for i, obtainedInstance := range obtainedInstances { - require.Equal(t, expectedInstances[i], obtainedInstance) - } -} - -// getTenSampleSlashPacketData returns 10 randomized slash packet data instances for testing -func getTenSampleSlashPacketData() []ccvtypes.SlashPacketData { - sampleData := []ccvtypes.SlashPacketData{} - for i := 0; i < 10; i++ { - sampleData = append(sampleData, testkeeper.GetNewSlashPacketData()) - } - return sampleData -} - -// getTenSampleVSCMaturedPacketData returns 10 randomized VSC matured packet data instances for testing -func getTenSampleVSCMaturedPacketData() []ccvtypes.VSCMaturedPacketData { - sampleData := []ccvtypes.VSCMaturedPacketData{} - for i := 0; i < 10; i++ { - sampleData = append(sampleData, testkeeper.GetNewVSCMaturedPacketData()) - } - return sampleData -} diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index 82891c27c7..c70fdeafa7 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -107,6 +107,10 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { func (am AppModule) RegisterServices(cfg module.Configurator) { providertypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) providertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) + m := keeper.NewMigrator(*am.keeper, am.paramSpace) + if err := cfg.RegisterMigration(providertypes.ModuleName, 2, m.Migrate2to3); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s", providertypes.ModuleName, err)) + } } // InitGenesis performs genesis initialization for the provider module. It returns no validator updates. @@ -129,7 +133,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock implements the AppModule interface func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { @@ -137,6 +141,8 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { am.keeper.BeginBlockInit(ctx) // Stop and remove state for any consumer chains that are due to be stopped via pending consumer removal proposals am.keeper.BeginBlockCCR(ctx) + // Check for replenishing slash meter before any slash packets are processed for this block + am.keeper.BeginBlockCIS(ctx) } // EndBlock implements the AppModule interface diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index aba1a72e0e..eb5d878097 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -81,7 +81,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -102,7 +102,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -123,7 +123,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -144,7 +144,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -171,7 +171,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -198,7 +198,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -225,7 +225,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}), nil, nil, nil, @@ -252,7 +252,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -279,7 +279,7 @@ func TestValidateGenesisState(t *testing.T) { 0, // 0 vsc timeout here types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -306,7 +306,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, 0, // 0 slash meter replenish period here types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -333,34 +333,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, "1.15", - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), - nil, - nil, - nil, - nil, - nil, - ), - false, - }, - { - "invalid params, invalid max pending slash packets", - types.NewGenesisState( - types.DefaultValsetUpdateID, - nil, - []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, - nil, - nil, - types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, - time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, - ccv.DefaultCCVTimeoutPeriod, - types.DefaultInitTimeoutPeriod, - types.DefaultVscTimeoutPeriod, - types.DefaultSlashMeterReplenishPeriod, - "1.15", - -1, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -712,7 +685,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -733,7 +706,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}), nil, nil, nil, diff --git a/x/ccv/provider/types/params.go b/x/ccv/provider/types/params.go index afb46694a3..fb6b0c267e 100644 --- a/x/ccv/provider/types/params.go +++ b/x/ccv/provider/types/params.go @@ -36,10 +36,6 @@ const ( // that is replenished to the slash meter every replenish period. This param also serves as a maximum // fraction of total voting power that the slash meter can hold. DefaultSlashMeterReplenishFraction = "0.05" - - // DefaultMaxThrottledPackets defines the default amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - DefaultMaxThrottledPackets = 100000 ) // Reflection based keys for params subspace @@ -50,7 +46,6 @@ var ( KeyVscTimeoutPeriod = []byte("VscTimeoutPeriod") KeySlashMeterReplenishPeriod = []byte("SlashMeterReplenishPeriod") KeySlashMeterReplenishFraction = []byte("SlashMeterReplenishFraction") - KeyMaxThrottledPackets = []byte("MaxThrottledPackets") KeyConsumerRewardDenomRegistrationFee = []byte("ConsumerRewardDenomRegistrationFee") ) @@ -68,7 +63,6 @@ func NewParams( vscTimeoutPeriod time.Duration, slashMeterReplenishPeriod time.Duration, slashMeterReplenishFraction string, - maxThrottledPackets int64, consumerRewardDenomRegistrationFee sdk.Coin, ) Params { return Params{ @@ -79,7 +73,6 @@ func NewParams( VscTimeoutPeriod: vscTimeoutPeriod, SlashMeterReplenishPeriod: slashMeterReplenishPeriod, SlashMeterReplenishFraction: slashMeterReplenishFraction, - MaxThrottledPackets: maxThrottledPackets, ConsumerRewardDenomRegistrationFee: consumerRewardDenomRegistrationFee, } } @@ -105,7 +98,6 @@ func DefaultParams() Params { DefaultVscTimeoutPeriod, DefaultSlashMeterReplenishPeriod, DefaultSlashMeterReplenishFraction, - DefaultMaxThrottledPackets, // Defining this inline because it's not possible to define a constant of type sdk.Coin. // Following the pattern from cosmos-sdk/staking/types/params.go sdk.Coin{ @@ -141,9 +133,6 @@ func (p Params) Validate() error { if err := ccvtypes.ValidateStringFraction(p.SlashMeterReplenishFraction); err != nil { return fmt.Errorf("slash meter replenish fraction is invalid: %s", err) } - if err := ccvtypes.ValidatePositiveInt64(p.MaxThrottledPackets); err != nil { - return fmt.Errorf("max throttled packets is invalid: %s", err) - } if err := ValidateCoin(p.ConsumerRewardDenomRegistrationFee); err != nil { return fmt.Errorf("consumer reward denom registration fee is invalid: %s", err) } @@ -160,7 +149,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyVscTimeoutPeriod, p.VscTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeySlashMeterReplenishPeriod, p.SlashMeterReplenishPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeySlashMeterReplenishFraction, p.SlashMeterReplenishFraction, ccvtypes.ValidateStringFraction), - paramtypes.NewParamSetPair(KeyMaxThrottledPackets, p.MaxThrottledPackets, ccvtypes.ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyConsumerRewardDenomRegistrationFee, p.ConsumerRewardDenomRegistrationFee, ValidateCoin), } } diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index 0676a15986..6e8bd780bf 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -24,42 +24,39 @@ func TestValidateParams(t *testing.T) { {"custom valid params", types.NewParams( ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, {"custom invalid params", types.NewParams( ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"blank client", types.NewParams(&ibctmtypes.ClientState{}, - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, - {"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + {"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, // Check if "0.00" is valid or if a zero dec TrustFraction needs to return an error {"0 trusting period fraction", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, + "0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, {"0 ccv timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 init timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 vsc timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 slash meter replenish period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"slash meter replenish fraction over 1", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, - {"negative max pending slash packets", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, - time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"invalid consumer reward denom registration fee denom", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), false}, {"invalid consumer reward denom registration fee amount", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}), false}, } for _, tc := range testCases { diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 398010307c..e138ae53cd 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -371,9 +371,6 @@ type Params struct { // every replenish period. This param also serves as a maximum fraction of // total voting power that the slash meter can hold. SlashMeterReplenishFraction string `protobuf:"bytes,7,opt,name=slash_meter_replenish_fraction,json=slashMeterReplenishFraction,proto3" json:"slash_meter_replenish_fraction,omitempty"` - // The maximum amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - MaxThrottledPackets int64 `protobuf:"varint,8,opt,name=max_throttled_packets,json=maxThrottledPackets,proto3" json:"max_throttled_packets,omitempty"` // The fee required to be paid to add a reward denom ConsumerRewardDenomRegistrationFee types2.Coin `protobuf:"bytes,9,opt,name=consumer_reward_denom_registration_fee,json=consumerRewardDenomRegistrationFee,proto3" json:"consumer_reward_denom_registration_fee"` } @@ -460,13 +457,6 @@ func (m *Params) GetSlashMeterReplenishFraction() string { return "" } -func (m *Params) GetMaxThrottledPackets() int64 { - if m != nil { - return m.MaxThrottledPackets - } - return 0 -} - func (m *Params) GetConsumerRewardDenomRegistrationFee() types2.Coin { if m != nil { return m.ConsumerRewardDenomRegistrationFee @@ -1345,6 +1335,7 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ +<<<<<<< HEAD // 1674 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x4f, 0x6f, 0x1b, 0xc7, 0x15, 0xd7, 0x8a, 0x94, 0x2c, 0x3e, 0xea, 0x9f, 0x57, 0x72, 0x4c, 0xb9, 0x2a, 0x45, 0x6f, 0x9a, @@ -1451,6 +1442,116 @@ var fileDescriptor_f22ec409a72b7b72 = []byte{ 0xcc, 0x82, 0x6e, 0xf6, 0xfb, 0xba, 0xd4, 0xf5, 0x7e, 0xf1, 0xe7, 0x43, 0xf2, 0xa0, 0xfb, 0x72, 0xfc, 0xcf, 0x10, 0x39, 0x8a, 0x88, 0xe8, 0x2f, 0xea, 0xa9, 0xf0, 0xe0, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x43, 0xd2, 0x10, 0x3d, 0x11, 0x00, 0x00, +======= + // 1702 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x73, 0xdb, 0xc6, + 0x15, 0x17, 0x44, 0x4a, 0x16, 0x1f, 0xf5, 0x65, 0x48, 0x89, 0x29, 0x57, 0xa5, 0x64, 0xa4, 0x49, + 0xd5, 0xc9, 0x04, 0x8c, 0xe4, 0xe9, 0x4c, 0xc6, 0xd3, 0x4c, 0x46, 0xa2, 0x9c, 0x58, 0x56, 0x13, + 0x2b, 0x90, 0x2a, 0x4f, 0xdb, 0x03, 0x66, 0xb9, 0x58, 0x93, 0x3b, 0x02, 0xb1, 0xf0, 0xee, 0x02, + 0x0e, 0x2f, 0x3d, 0xf7, 0x98, 0xde, 0x32, 0xed, 0x25, 0xed, 0x3f, 0xd0, 0x73, 0xff, 0x83, 0x1c, + 0x73, 0xec, 0x29, 0xe9, 0xd8, 0xc7, 0xfe, 0x13, 0x9d, 0x5d, 0x2c, 0x3e, 0x48, 0x7d, 0x94, 0x1e, + 0xb7, 0x37, 0xe0, 0xed, 0x7b, 0xbf, 0xf7, 0xf6, 0x7d, 0xfc, 0x1e, 0x48, 0xd8, 0xa3, 0x91, 0x24, + 0x1c, 0x0f, 0x10, 0x8d, 0x7c, 0x41, 0x70, 0xc2, 0xa9, 0x1c, 0x75, 0x30, 0x4e, 0x3b, 0x31, 0x67, + 0x29, 0x0d, 0x08, 0xef, 0xa4, 0xbb, 0xc5, 0xb3, 0x1b, 0x73, 0x26, 0x99, 0xfd, 0xce, 0x15, 0x36, + 0x2e, 0xc6, 0xa9, 0x5b, 0xe8, 0xa5, 0xbb, 0x77, 0x3f, 0xbc, 0x0e, 0x38, 0xdd, 0xed, 0x88, 0x01, + 0xe2, 0x24, 0xf0, 0x31, 0x8b, 0x44, 0x32, 0xcc, 0x61, 0xef, 0xbe, 0x7b, 0x83, 0xc5, 0x0b, 0xca, + 0x89, 0x51, 0x5b, 0xef, 0xb3, 0x3e, 0xd3, 0x8f, 0x1d, 0xf5, 0x64, 0xa4, 0x5b, 0x7d, 0xc6, 0xfa, + 0x21, 0xe9, 0xe8, 0xb7, 0x5e, 0xf2, 0xac, 0x23, 0xe9, 0x90, 0x08, 0x89, 0x86, 0xb1, 0x51, 0x68, + 0x4f, 0x2a, 0x04, 0x09, 0x47, 0x92, 0xb2, 0x28, 0x07, 0xa0, 0x3d, 0xdc, 0xc1, 0x8c, 0x93, 0x0e, + 0x0e, 0x29, 0x89, 0xa4, 0xf2, 0x9a, 0x3d, 0x19, 0x85, 0x8e, 0x52, 0x08, 0x69, 0x7f, 0x20, 0x33, + 0xb1, 0xe8, 0x48, 0x12, 0x05, 0x84, 0x0f, 0x69, 0xa6, 0x5c, 0xbe, 0x19, 0x83, 0xcd, 0xca, 0x39, + 0xe6, 0xa3, 0x58, 0xb2, 0xce, 0x05, 0x19, 0x09, 0x73, 0xfa, 0x1e, 0x66, 0x62, 0xc8, 0x44, 0x87, + 0xa8, 0x8c, 0x45, 0x98, 0x74, 0xd2, 0xdd, 0x1e, 0x91, 0x68, 0xb7, 0x10, 0xe4, 0x71, 0x1b, 0xbd, + 0x1e, 0x12, 0xa5, 0x0e, 0x66, 0xd4, 0xc4, 0xed, 0xfc, 0x38, 0x0f, 0xad, 0xae, 0x49, 0xe4, 0x7e, + 0x10, 0x50, 0x75, 0xa5, 0x13, 0xce, 0x62, 0x26, 0x50, 0x68, 0xaf, 0xc3, 0x9c, 0xa4, 0x32, 0x24, + 0x2d, 0x6b, 0xdb, 0xda, 0x69, 0x78, 0xd9, 0x8b, 0xbd, 0x0d, 0xcd, 0x80, 0x08, 0xcc, 0x69, 0xac, + 0x94, 0x5b, 0xb3, 0xfa, 0xac, 0x2a, 0xb2, 0x37, 0x60, 0x21, 0xab, 0x03, 0x0d, 0x5a, 0x35, 0x7d, + 0x7c, 0x4b, 0xbf, 0x1f, 0x05, 0xf6, 0x67, 0xb0, 0x4c, 0x23, 0x2a, 0x29, 0x0a, 0xfd, 0x01, 0x51, + 0xd9, 0x68, 0xd5, 0xb7, 0xad, 0x9d, 0xe6, 0xde, 0x5d, 0x97, 0xf6, 0xb0, 0xab, 0x12, 0xe8, 0x9a, + 0xb4, 0xa5, 0xbb, 0xee, 0x23, 0xad, 0x71, 0x50, 0xff, 0xee, 0x87, 0xad, 0x19, 0x6f, 0xc9, 0xd8, + 0x65, 0x42, 0xfb, 0x1e, 0x2c, 0xf6, 0x49, 0x44, 0x04, 0x15, 0xfe, 0x00, 0x89, 0x41, 0x6b, 0x6e, + 0xdb, 0xda, 0x59, 0xf4, 0x9a, 0x46, 0xf6, 0x08, 0x89, 0x81, 0xbd, 0x05, 0xcd, 0x1e, 0x8d, 0x10, + 0x1f, 0x65, 0x1a, 0xf3, 0x5a, 0x03, 0x32, 0x91, 0x56, 0xe8, 0x02, 0x88, 0x18, 0xbd, 0x88, 0x7c, + 0x55, 0xed, 0xd6, 0x2d, 0x13, 0x48, 0x56, 0x69, 0x37, 0xaf, 0xb4, 0x7b, 0x96, 0xb7, 0xc2, 0xc1, + 0x82, 0x0a, 0xe4, 0xeb, 0x1f, 0xb7, 0x2c, 0xaf, 0xa1, 0xed, 0xd4, 0x89, 0xfd, 0x05, 0xac, 0x26, + 0x51, 0x8f, 0x45, 0x01, 0x8d, 0xfa, 0x7e, 0x4c, 0x38, 0x65, 0x41, 0x6b, 0x41, 0x43, 0x6d, 0x5c, + 0x82, 0x3a, 0x34, 0x4d, 0x93, 0x21, 0x7d, 0xa3, 0x90, 0x56, 0x0a, 0xe3, 0x13, 0x6d, 0x6b, 0x7f, + 0x09, 0x36, 0xc6, 0xa9, 0x0e, 0x89, 0x25, 0x32, 0x47, 0x6c, 0x4c, 0x8f, 0xb8, 0x8a, 0x71, 0x7a, + 0x96, 0x59, 0x1b, 0xc8, 0xdf, 0xc3, 0x1d, 0xc9, 0x51, 0x24, 0x9e, 0x11, 0x3e, 0x89, 0x0b, 0xd3, + 0xe3, 0xbe, 0x95, 0x63, 0x8c, 0x83, 0x3f, 0x82, 0xed, 0x7c, 0x12, 0x7d, 0x4e, 0x02, 0x2a, 0x24, + 0xa7, 0xbd, 0x44, 0xd9, 0xfa, 0xcf, 0x38, 0xc2, 0xba, 0x47, 0x9a, 0xba, 0x09, 0xda, 0xb9, 0x9e, + 0x37, 0xa6, 0xf6, 0xa9, 0xd1, 0xb2, 0x9f, 0xc0, 0xcf, 0x7a, 0x21, 0xc3, 0x17, 0x42, 0x05, 0xe7, + 0x8f, 0x21, 0x69, 0xd7, 0x43, 0x2a, 0x84, 0x42, 0x5b, 0xdc, 0xb6, 0x76, 0x6a, 0xde, 0xbd, 0x4c, + 0xf7, 0x84, 0xf0, 0xc3, 0x8a, 0xe6, 0x59, 0x45, 0xd1, 0xfe, 0x00, 0xec, 0x01, 0x15, 0x92, 0x71, + 0x8a, 0x51, 0xe8, 0x93, 0x48, 0x72, 0x4a, 0x44, 0x6b, 0x49, 0x9b, 0xdf, 0x2e, 0x4f, 0x1e, 0x66, + 0x07, 0xf6, 0x63, 0xb8, 0x77, 0xad, 0x53, 0x1f, 0x0f, 0x50, 0x14, 0x91, 0xb0, 0xb5, 0xac, 0xaf, + 0xb2, 0x15, 0x5c, 0xe3, 0xb3, 0x9b, 0xa9, 0x3d, 0x58, 0xf8, 0xe3, 0xb7, 0x5b, 0x33, 0xdf, 0x7c, + 0xbb, 0x35, 0xe3, 0xfc, 0xdd, 0x82, 0x3b, 0xdd, 0xe2, 0xe2, 0x43, 0x96, 0xa2, 0xf0, 0xff, 0x39, + 0x60, 0xfb, 0xd0, 0x10, 0x92, 0xc5, 0x59, 0x4b, 0xd7, 0x5f, 0xa3, 0xa5, 0x17, 0x94, 0x99, 0x3a, + 0x70, 0xfe, 0x62, 0xc1, 0xfa, 0xc3, 0xe7, 0x09, 0x4d, 0x19, 0x46, 0xff, 0x13, 0x3e, 0x38, 0x86, + 0x25, 0x52, 0xc1, 0x13, 0xad, 0xda, 0x76, 0x6d, 0xa7, 0xb9, 0xf7, 0xae, 0x9b, 0x91, 0x93, 0x5b, + 0x70, 0x96, 0x21, 0x28, 0xb7, 0xea, 0xdd, 0x1b, 0xb7, 0x75, 0xfe, 0x66, 0xc1, 0x5d, 0x95, 0xe5, + 0x3e, 0xf1, 0xc8, 0x0b, 0xc4, 0x83, 0x43, 0x12, 0xb1, 0xa1, 0x78, 0xe3, 0x18, 0x1d, 0x58, 0x0a, + 0x34, 0x92, 0x2f, 0x99, 0x8f, 0x82, 0x40, 0xc7, 0xa8, 0x75, 0x94, 0xf0, 0x8c, 0xed, 0x07, 0x81, + 0xbd, 0x03, 0xab, 0xa5, 0x0e, 0x57, 0xb5, 0x54, 0x29, 0x56, 0x6a, 0xcb, 0xb9, 0x9a, 0xae, 0x30, + 0x71, 0xfe, 0x6d, 0xc1, 0xea, 0x67, 0x21, 0xeb, 0xa1, 0xf0, 0x34, 0x44, 0x62, 0xa0, 0x3a, 0x6c, + 0xa4, 0x4a, 0xc3, 0x89, 0x19, 0x6d, 0x1d, 0xde, 0xd4, 0xa5, 0x51, 0x66, 0x9a, 0x6c, 0x3e, 0x81, + 0xdb, 0xc5, 0xb0, 0x15, 0x1d, 0xa0, 0x6f, 0x73, 0xb0, 0xf6, 0xf2, 0x87, 0xad, 0x95, 0xbc, 0xd1, + 0xba, 0xba, 0x1b, 0x0e, 0xbd, 0x15, 0x3c, 0x26, 0x08, 0xec, 0x36, 0x34, 0x69, 0x0f, 0xfb, 0x82, + 0x3c, 0xf7, 0xa3, 0x64, 0xa8, 0x9b, 0xa7, 0xee, 0x35, 0x68, 0x0f, 0x9f, 0x92, 0xe7, 0x5f, 0x24, + 0x43, 0xfb, 0x3e, 0xbc, 0x9d, 0xaf, 0x61, 0x3f, 0x45, 0xa1, 0x5e, 0xb2, 0x2a, 0x1d, 0x5c, 0xf7, + 0xd2, 0xa2, 0xb7, 0x96, 0x9f, 0x9e, 0xa3, 0x50, 0x39, 0xdb, 0x0f, 0x02, 0xee, 0xfc, 0x63, 0x0e, + 0xe6, 0x4f, 0x10, 0x47, 0x43, 0x61, 0x9f, 0xc1, 0x8a, 0x24, 0xc3, 0x38, 0x44, 0x92, 0xf8, 0x19, + 0x91, 0x9b, 0x9b, 0xbe, 0xaf, 0x09, 0xbe, 0xba, 0x00, 0xdd, 0xca, 0xca, 0x4b, 0x77, 0xdd, 0xae, + 0x96, 0x9e, 0x4a, 0x24, 0x89, 0xb7, 0x9c, 0x63, 0x64, 0x42, 0xfb, 0x23, 0x68, 0x49, 0x9e, 0x08, + 0x59, 0x52, 0x6c, 0xc9, 0x2d, 0x59, 0x2d, 0xdf, 0xce, 0xcf, 0x33, 0x56, 0x2a, 0x38, 0xe5, 0x6a, + 0x36, 0xad, 0xbd, 0x09, 0x9b, 0x9e, 0xc2, 0x9a, 0x5a, 0x45, 0x93, 0x98, 0xf5, 0xe9, 0x31, 0x6f, + 0x2b, 0xfb, 0x71, 0xd0, 0x2f, 0xc1, 0x4e, 0x05, 0x9e, 0xc4, 0x9c, 0x7b, 0x8d, 0x38, 0x53, 0x81, + 0xc7, 0x21, 0x03, 0xd8, 0x14, 0xaa, 0xf9, 0xfc, 0x21, 0x91, 0x9a, 0x9b, 0xe3, 0x90, 0x44, 0x54, + 0x0c, 0x72, 0xf0, 0xf9, 0xe9, 0xc1, 0x37, 0x34, 0xd0, 0xe7, 0x0a, 0xc7, 0xcb, 0x61, 0x8c, 0x97, + 0x2e, 0xb4, 0xaf, 0xf6, 0x52, 0x14, 0xe8, 0x96, 0x2e, 0xd0, 0x4f, 0xae, 0x80, 0x28, 0xaa, 0x24, + 0xe0, 0xbd, 0xca, 0x0e, 0x51, 0x53, 0xed, 0xeb, 0x81, 0xf2, 0x39, 0xe9, 0x2b, 0xa2, 0x45, 0xd9, + 0x3a, 0x21, 0xa4, 0xd8, 0x83, 0x86, 0x39, 0xd4, 0x67, 0x4d, 0xc1, 0x1a, 0x5d, 0x46, 0x23, 0xf3, + 0xb1, 0xe0, 0x94, 0xab, 0xa6, 0xe0, 0x08, 0xaf, 0x82, 0xf5, 0x29, 0x21, 0x8f, 0xeb, 0x0b, 0x0b, + 0xab, 0x0d, 0xe7, 0x17, 0xd0, 0xd0, 0x23, 0xba, 0x8f, 0x2f, 0x84, 0xbd, 0x09, 0x0d, 0xd5, 0xeb, + 0x44, 0x08, 0x22, 0x5a, 0x96, 0x9e, 0xec, 0x52, 0xe0, 0x48, 0xd8, 0xb8, 0xee, 0x53, 0x49, 0xd8, + 0x4f, 0xe1, 0x56, 0x4c, 0xf4, 0x1e, 0xd7, 0x86, 0xcd, 0xbd, 0x8f, 0xdd, 0x29, 0xbe, 0x73, 0xdd, + 0xeb, 0x00, 0xbd, 0x1c, 0xcd, 0xe1, 0xe5, 0x07, 0xda, 0xc4, 0xfa, 0x10, 0xf6, 0xf9, 0xa4, 0xd3, + 0x5f, 0xbd, 0x96, 0xd3, 0x09, 0xbc, 0xd2, 0xe7, 0xfb, 0xd0, 0xdc, 0xcf, 0xae, 0xfd, 0x6b, 0x2a, + 0xe4, 0xe5, 0xb4, 0x2c, 0x56, 0xd3, 0xf2, 0x18, 0x96, 0xcd, 0xd6, 0x3b, 0x63, 0x9a, 0x66, 0xec, + 0x9f, 0x02, 0x98, 0x75, 0xa9, 0xe8, 0x29, 0x23, 0xe2, 0x86, 0x91, 0x1c, 0x05, 0x63, 0xdb, 0x6b, + 0x76, 0x6c, 0x7b, 0x39, 0x1e, 0xac, 0x9c, 0x0b, 0xfc, 0x9b, 0xfc, 0x93, 0xe8, 0x49, 0x2c, 0xec, + 0xb7, 0x60, 0x5e, 0x4d, 0x86, 0x01, 0xaa, 0x7b, 0x73, 0xa9, 0xc0, 0x47, 0x9a, 0x8b, 0xcb, 0xcf, + 0x2e, 0x16, 0xfb, 0x34, 0x10, 0xad, 0xd9, 0xed, 0xda, 0x4e, 0xdd, 0x5b, 0x4e, 0x4a, 0xf3, 0xa3, + 0x40, 0x38, 0xbf, 0x85, 0x66, 0x05, 0xd0, 0x5e, 0x86, 0xd9, 0x02, 0x6b, 0x96, 0x06, 0xf6, 0x03, + 0xd8, 0x28, 0x81, 0xc6, 0xc9, 0x35, 0x43, 0x6c, 0x78, 0x77, 0x0a, 0x85, 0x31, 0x7e, 0x15, 0xce, + 0x13, 0x58, 0x3f, 0x2a, 0x47, 0xb9, 0xa0, 0xee, 0xb1, 0x1b, 0x5a, 0xe3, 0xfb, 0x79, 0x13, 0x1a, + 0xc5, 0x6f, 0x0b, 0x7d, 0xfb, 0xba, 0x57, 0x0a, 0x9c, 0x21, 0xac, 0x9e, 0x0b, 0x7c, 0x4a, 0xa2, + 0xa0, 0x04, 0xbb, 0x26, 0x01, 0x07, 0x93, 0x40, 0x53, 0x7f, 0xbb, 0x96, 0xee, 0x18, 0x6c, 0x9c, + 0xa3, 0x90, 0x06, 0x48, 0x32, 0x7e, 0x4a, 0x64, 0xb6, 0x56, 0x4f, 0x10, 0xbe, 0x20, 0x52, 0xd8, + 0x1e, 0xd4, 0x43, 0x2a, 0xa4, 0xe9, 0xac, 0x8f, 0xae, 0xed, 0xac, 0x74, 0xd7, 0xbd, 0x0e, 0xe4, + 0x10, 0x49, 0x64, 0x26, 0x52, 0x63, 0x39, 0x3f, 0x87, 0xb5, 0xcf, 0x91, 0x4c, 0x38, 0x09, 0xc6, + 0x6a, 0xbc, 0x0a, 0x35, 0x55, 0x3f, 0x4b, 0xd7, 0x4f, 0x3d, 0xaa, 0x2d, 0xdf, 0x7a, 0xf8, 0x55, + 0xcc, 0xb8, 0x24, 0xc1, 0xa5, 0x8c, 0xdc, 0x90, 0xde, 0x0b, 0x58, 0x53, 0xc9, 0x12, 0x24, 0x0a, + 0xfc, 0xe2, 0x9e, 0x59, 0x1d, 0x9b, 0x7b, 0xbf, 0x9c, 0x6a, 0x3a, 0x26, 0xdd, 0x99, 0x0b, 0xdc, + 0x4e, 0x27, 0xe4, 0xc2, 0xf9, 0x93, 0x05, 0xad, 0x63, 0x32, 0xda, 0x17, 0x82, 0xf6, 0xa3, 0x21, + 0x89, 0xa4, 0x62, 0x36, 0x84, 0x89, 0x7a, 0xb4, 0xdf, 0x81, 0xa5, 0x62, 0x93, 0xea, 0x05, 0x6a, + 0xe9, 0x05, 0xba, 0x98, 0x0b, 0xd5, 0x80, 0xd9, 0x0f, 0x00, 0x62, 0x4e, 0x52, 0x1f, 0xfb, 0x17, + 0x64, 0x64, 0xaa, 0xb8, 0x59, 0x5d, 0x8c, 0xd9, 0x2f, 0x3f, 0xf7, 0x24, 0xe9, 0x85, 0x14, 0x1f, + 0x93, 0x91, 0xb7, 0xa0, 0xf4, 0xbb, 0xc7, 0x64, 0xa4, 0xbe, 0x74, 0x62, 0xf6, 0x82, 0x70, 0xbd, + 0xcd, 0x6a, 0x5e, 0xf6, 0xe2, 0xfc, 0xd9, 0x82, 0x3b, 0x45, 0x39, 0xf2, 0x76, 0x3d, 0x49, 0x7a, + 0xca, 0xe2, 0x86, 0xbc, 0x5d, 0x8a, 0x76, 0xf6, 0x8a, 0x68, 0x3f, 0x81, 0xc5, 0x62, 0x40, 0x54, + 0xbc, 0xb5, 0x29, 0xe2, 0x6d, 0xe6, 0x16, 0xc7, 0x64, 0xe4, 0xfc, 0xa1, 0x12, 0xdb, 0xc1, 0xa8, + 0xc2, 0x7d, 0xfc, 0xbf, 0xc4, 0x56, 0xb8, 0xad, 0xc6, 0x86, 0xab, 0xf6, 0x97, 0x2e, 0x50, 0xbb, + 0x7c, 0x01, 0xe7, 0xaf, 0x16, 0xac, 0x57, 0xbd, 0x8a, 0x33, 0x76, 0xc2, 0x93, 0x88, 0xdc, 0xe4, + 0xbd, 0x1c, 0xbf, 0xd9, 0xea, 0xf8, 0x3d, 0x85, 0xe5, 0xb1, 0xa0, 0x84, 0xc9, 0xc6, 0x87, 0x53, + 0xf5, 0x58, 0x85, 0x5d, 0xbd, 0xa5, 0xea, 0x3d, 0xc4, 0xc1, 0xd3, 0xef, 0x5e, 0xb6, 0xad, 0xef, + 0x5f, 0xb6, 0xad, 0x7f, 0xbd, 0x6c, 0x5b, 0x5f, 0xbf, 0x6a, 0xcf, 0x7c, 0xff, 0xaa, 0x3d, 0xf3, + 0xcf, 0x57, 0xed, 0x99, 0xdf, 0x7d, 0xdc, 0xa7, 0x72, 0x90, 0xf4, 0x5c, 0xcc, 0x86, 0x1d, 0xf3, + 0xb3, 0xbe, 0xf4, 0xf5, 0x41, 0xf1, 0x9f, 0x47, 0x7a, 0xbf, 0xf3, 0xd5, 0xf8, 0x7f, 0x30, 0x72, + 0x14, 0x13, 0xd1, 0x9b, 0xd7, 0xac, 0x70, 0xff, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x13, + 0xf6, 0x7a, 0xb4, 0x11, 0x00, 0x00, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -1760,11 +1861,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x4a - if m.MaxThrottledPackets != 0 { - i = encodeVarintProvider(dAtA, i, uint64(m.MaxThrottledPackets)) - i-- - dAtA[i] = 0x40 - } if len(m.SlashMeterReplenishFraction) > 0 { i -= len(m.SlashMeterReplenishFraction) copy(dAtA[i:], m.SlashMeterReplenishFraction) @@ -2622,9 +2718,6 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovProvider(uint64(l)) } - if m.MaxThrottledPackets != 0 { - n += 1 + sovProvider(uint64(m.MaxThrottledPackets)) - } l = m.ConsumerRewardDenomRegistrationFee.Size() n += 1 + l + sovProvider(uint64(l)) return n @@ -4149,25 +4242,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.SlashMeterReplenishFraction = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxThrottledPackets", wireType) - } - m.MaxThrottledPackets = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProvider - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxThrottledPackets |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRewardDenomRegistrationFee", wireType) diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 9fc9178e09..ea54d382ae 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -637,8 +637,6 @@ type QueryThrottleStateResponse struct { // next time the slash meter could potentially be replenished, iff it's not // full NextReplenishCandidate time.Time `protobuf:"bytes,3,opt,name=next_replenish_candidate,json=nextReplenishCandidate,proto3,stdtime" json:"next_replenish_candidate"` - // data relevant to currently throttled slash packets - Packets []*ThrottledSlashPacket `protobuf:"bytes,4,rep,name=packets,proto3" json:"packets,omitempty"` } func (m *QueryThrottleStateResponse) Reset() { *m = QueryThrottleStateResponse{} } @@ -695,262 +693,6 @@ func (m *QueryThrottleStateResponse) GetNextReplenishCandidate() time.Time { return time.Time{} } -func (m *QueryThrottleStateResponse) GetPackets() []*ThrottledSlashPacket { - if m != nil { - return m.Packets - } - return nil -} - -type QueryThrottledConsumerPacketDataRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *QueryThrottledConsumerPacketDataRequest) Reset() { - *m = QueryThrottledConsumerPacketDataRequest{} -} -func (m *QueryThrottledConsumerPacketDataRequest) String() string { return proto.CompactTextString(m) } -func (*QueryThrottledConsumerPacketDataRequest) ProtoMessage() {} -func (*QueryThrottledConsumerPacketDataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{15} -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.Merge(m, src) -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryThrottledConsumerPacketDataRequest proto.InternalMessageInfo - -func (m *QueryThrottledConsumerPacketDataRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -type QueryThrottledConsumerPacketDataResponse struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - Size_ uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` - PacketDataInstances []ThrottledPacketDataWrapper `protobuf:"bytes,3,rep,name=packetDataInstances,proto3" json:"packetDataInstances"` -} - -func (m *QueryThrottledConsumerPacketDataResponse) Reset() { - *m = QueryThrottledConsumerPacketDataResponse{} -} -func (m *QueryThrottledConsumerPacketDataResponse) String() string { return proto.CompactTextString(m) } -func (*QueryThrottledConsumerPacketDataResponse) ProtoMessage() {} -func (*QueryThrottledConsumerPacketDataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{16} -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.Merge(m, src) -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryThrottledConsumerPacketDataResponse proto.InternalMessageInfo - -func (m *QueryThrottledConsumerPacketDataResponse) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -func (m *QueryThrottledConsumerPacketDataResponse) GetSize_() uint64 { - if m != nil { - return m.Size_ - } - return 0 -} - -func (m *QueryThrottledConsumerPacketDataResponse) GetPacketDataInstances() []ThrottledPacketDataWrapper { - if m != nil { - return m.PacketDataInstances - } - return nil -} - -// A query wrapper type for the global entry and data relevant to a throttled -// slash packet. -type ThrottledSlashPacket struct { - GlobalEntry GlobalSlashEntry `protobuf:"bytes,1,opt,name=global_entry,json=globalEntry,proto3" json:"global_entry"` - Data types.SlashPacketData `protobuf:"bytes,2,opt,name=data,proto3" json:"data"` -} - -func (m *ThrottledSlashPacket) Reset() { *m = ThrottledSlashPacket{} } -func (m *ThrottledSlashPacket) String() string { return proto.CompactTextString(m) } -func (*ThrottledSlashPacket) ProtoMessage() {} -func (*ThrottledSlashPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{17} -} -func (m *ThrottledSlashPacket) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ThrottledSlashPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ThrottledSlashPacket.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ThrottledSlashPacket) XXX_Merge(src proto.Message) { - xxx_messageInfo_ThrottledSlashPacket.Merge(m, src) -} -func (m *ThrottledSlashPacket) XXX_Size() int { - return m.Size() -} -func (m *ThrottledSlashPacket) XXX_DiscardUnknown() { - xxx_messageInfo_ThrottledSlashPacket.DiscardUnknown(m) -} - -var xxx_messageInfo_ThrottledSlashPacket proto.InternalMessageInfo - -func (m *ThrottledSlashPacket) GetGlobalEntry() GlobalSlashEntry { - if m != nil { - return m.GlobalEntry - } - return GlobalSlashEntry{} -} - -func (m *ThrottledSlashPacket) GetData() types.SlashPacketData { - if m != nil { - return m.Data - } - return types.SlashPacketData{} -} - -// ThrottledPacketDataWrapper contains either SlashPacketData or -// VSCMaturedPacketData -type ThrottledPacketDataWrapper struct { - // Types that are valid to be assigned to Data: - // *ThrottledPacketDataWrapper_SlashPacket - // *ThrottledPacketDataWrapper_VscMaturedPacket - Data isThrottledPacketDataWrapper_Data `protobuf_oneof:"data"` -} - -func (m *ThrottledPacketDataWrapper) Reset() { *m = ThrottledPacketDataWrapper{} } -func (m *ThrottledPacketDataWrapper) String() string { return proto.CompactTextString(m) } -func (*ThrottledPacketDataWrapper) ProtoMessage() {} -func (*ThrottledPacketDataWrapper) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{18} -} -func (m *ThrottledPacketDataWrapper) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ThrottledPacketDataWrapper) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ThrottledPacketDataWrapper.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ThrottledPacketDataWrapper) XXX_Merge(src proto.Message) { - xxx_messageInfo_ThrottledPacketDataWrapper.Merge(m, src) -} -func (m *ThrottledPacketDataWrapper) XXX_Size() int { - return m.Size() -} -func (m *ThrottledPacketDataWrapper) XXX_DiscardUnknown() { - xxx_messageInfo_ThrottledPacketDataWrapper.DiscardUnknown(m) -} - -var xxx_messageInfo_ThrottledPacketDataWrapper proto.InternalMessageInfo - -type isThrottledPacketDataWrapper_Data interface { - isThrottledPacketDataWrapper_Data() - MarshalTo([]byte) (int, error) - Size() int -} - -type ThrottledPacketDataWrapper_SlashPacket struct { - SlashPacket *types.SlashPacketData `protobuf:"bytes,1,opt,name=slash_packet,json=slashPacket,proto3,oneof" json:"slash_packet,omitempty"` -} -type ThrottledPacketDataWrapper_VscMaturedPacket struct { - VscMaturedPacket *types.VSCMaturedPacketData `protobuf:"bytes,2,opt,name=vsc_matured_packet,json=vscMaturedPacket,proto3,oneof" json:"vsc_matured_packet,omitempty"` -} - -func (*ThrottledPacketDataWrapper_SlashPacket) isThrottledPacketDataWrapper_Data() {} -func (*ThrottledPacketDataWrapper_VscMaturedPacket) isThrottledPacketDataWrapper_Data() {} - -func (m *ThrottledPacketDataWrapper) GetData() isThrottledPacketDataWrapper_Data { - if m != nil { - return m.Data - } - return nil -} - -func (m *ThrottledPacketDataWrapper) GetSlashPacket() *types.SlashPacketData { - if x, ok := m.GetData().(*ThrottledPacketDataWrapper_SlashPacket); ok { - return x.SlashPacket - } - return nil -} - -func (m *ThrottledPacketDataWrapper) GetVscMaturedPacket() *types.VSCMaturedPacketData { - if x, ok := m.GetData().(*ThrottledPacketDataWrapper_VscMaturedPacket); ok { - return x.VscMaturedPacket - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*ThrottledPacketDataWrapper) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*ThrottledPacketDataWrapper_SlashPacket)(nil), - (*ThrottledPacketDataWrapper_VscMaturedPacket)(nil), - } -} - type QueryRegisteredConsumerRewardDenomsRequest struct { } @@ -962,7 +704,7 @@ func (m *QueryRegisteredConsumerRewardDenomsRequest) String() string { } func (*QueryRegisteredConsumerRewardDenomsRequest) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{19} + return fileDescriptor_422512d7b7586cd7, []int{15} } func (m *QueryRegisteredConsumerRewardDenomsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1003,7 +745,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) String() string { } func (*QueryRegisteredConsumerRewardDenomsResponse) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{20} + return fileDescriptor_422512d7b7586cd7, []int{16} } func (m *QueryRegisteredConsumerRewardDenomsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1055,10 +797,6 @@ func init() { proto.RegisterType((*QueryValidatorProviderAddrResponse)(nil), "interchain_security.ccv.provider.v1.QueryValidatorProviderAddrResponse") proto.RegisterType((*QueryThrottleStateRequest)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateRequest") proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateResponse") - proto.RegisterType((*QueryThrottledConsumerPacketDataRequest)(nil), "interchain_security.ccv.provider.v1.QueryThrottledConsumerPacketDataRequest") - proto.RegisterType((*QueryThrottledConsumerPacketDataResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottledConsumerPacketDataResponse") - proto.RegisterType((*ThrottledSlashPacket)(nil), "interchain_security.ccv.provider.v1.ThrottledSlashPacket") - proto.RegisterType((*ThrottledPacketDataWrapper)(nil), "interchain_security.ccv.provider.v1.ThrottledPacketDataWrapper") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsRequest)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsRequest") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsResponse") } @@ -1068,6 +806,7 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ +<<<<<<< HEAD // 1323 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, 0x1f, 0xf5, 0x3a, 0x69, 0x9a, 0x4c, 0xfa, 0xfd, 0xb6, 0x4c, 0x4b, 0x71, 0xb7, 0x95, 0x5d, 0xb6, @@ -1152,6 +891,76 @@ var fileDescriptor_422512d7b7586cd7 = []byte{ 0x86, 0x6e, 0x93, 0x86, 0x61, 0x13, 0xd6, 0x20, 0xac, 0xab, 0xdf, 0x3b, 0xed, 0x7e, 0xad, 0x8b, 0xc6, 0x83, 0x5d, 0xf3, 0xb7, 0x15, 0x60, 0xb6, 0x31, 0x25, 0xbe, 0x56, 0x2e, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x84, 0xab, 0xda, 0x7b, 0x39, 0x13, 0x00, 0x00, +======= + // 1060 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0x5e, 0x27, 0x34, 0x24, 0x13, 0x20, 0xd5, 0xb4, 0x94, 0xad, 0x13, 0xed, 0x16, 0x57, 0x40, + 0x5a, 0xc0, 0xce, 0x6e, 0x2e, 0x6d, 0x51, 0xba, 0xd9, 0x0d, 0x21, 0x54, 0x6d, 0xd5, 0xe0, 0x56, + 0x20, 0x01, 0xc2, 0x9a, 0xd8, 0xc3, 0xae, 0x25, 0xaf, 0xc7, 0x9d, 0x99, 0x75, 0x1a, 0x55, 0x1c, + 0xe0, 0x00, 0x3d, 0x56, 0x42, 0x70, 0xee, 0x9f, 0xd3, 0x1b, 0x45, 0xbd, 0x70, 0x2a, 0x28, 0xe1, + 0xc0, 0x11, 0x71, 0x47, 0xaa, 0x3c, 0x1e, 0x7b, 0x7f, 0x39, 0xbb, 0xce, 0x26, 0x37, 0x7b, 0xe6, + 0xbd, 0xef, 0x7d, 0xdf, 0xdb, 0x37, 0xf3, 0x79, 0x81, 0xe1, 0xfa, 0x1c, 0x53, 0xbb, 0x85, 0x5c, + 0xdf, 0x62, 0xd8, 0xee, 0x50, 0x97, 0xef, 0x19, 0xb6, 0x1d, 0x1a, 0x01, 0x25, 0xa1, 0xeb, 0x60, + 0x6a, 0x84, 0x15, 0xe3, 0x7e, 0x07, 0xd3, 0x3d, 0x3d, 0xa0, 0x84, 0x13, 0x78, 0x31, 0x23, 0x41, + 0xb7, 0xed, 0x50, 0x4f, 0x12, 0xf4, 0xb0, 0xa2, 0x2e, 0x35, 0x09, 0x69, 0x7a, 0xd8, 0x40, 0x81, + 0x6b, 0x20, 0xdf, 0x27, 0x1c, 0x71, 0x97, 0xf8, 0x2c, 0x86, 0x50, 0xcf, 0x36, 0x49, 0x93, 0x88, + 0x47, 0x23, 0x7a, 0x92, 0xab, 0x65, 0x99, 0x23, 0xde, 0x76, 0x3a, 0xdf, 0x1a, 0xdc, 0x6d, 0x63, + 0xc6, 0x51, 0x3b, 0x90, 0x01, 0xd5, 0x3c, 0x54, 0x53, 0x16, 0x71, 0xce, 0xca, 0x61, 0x39, 0x61, + 0xc5, 0x60, 0x2d, 0x44, 0xb1, 0x63, 0xd9, 0xc4, 0x67, 0x9d, 0x76, 0x9a, 0xf1, 0xce, 0x88, 0x8c, + 0x5d, 0x97, 0xe2, 0x38, 0x4c, 0xbb, 0x02, 0x16, 0x3f, 0x8b, 0xba, 0xb2, 0x21, 0xb3, 0xb7, 0xb0, + 0x8f, 0x99, 0xcb, 0x4c, 0x7c, 0xbf, 0x83, 0x19, 0x87, 0xe7, 0xc1, 0x6c, 0x0c, 0xe1, 0x3a, 0x45, + 0xe5, 0x82, 0xb2, 0x3c, 0x67, 0xbe, 0x2a, 0xde, 0x6f, 0x38, 0xda, 0x43, 0xb0, 0x94, 0x9d, 0xc9, + 0x02, 0xe2, 0x33, 0x0c, 0xbf, 0x02, 0xaf, 0x37, 0xe3, 0x25, 0x8b, 0x71, 0xc4, 0xb1, 0xc8, 0x9f, + 0xaf, 0xae, 0xe8, 0x87, 0x35, 0x3e, 0xac, 0xe8, 0x03, 0x58, 0x77, 0xa3, 0xbc, 0xc6, 0x2b, 0x4f, + 0x5f, 0x94, 0x0b, 0xe6, 0x6b, 0xcd, 0x9e, 0x35, 0x6d, 0x09, 0xa8, 0x7d, 0xc5, 0x37, 0x22, 0xb8, + 0x84, 0xb5, 0x86, 0x06, 0x44, 0x25, 0xbb, 0x92, 0x59, 0x03, 0xcc, 0x88, 0xf2, 0xac, 0xa8, 0x5c, + 0x98, 0x5e, 0x9e, 0xaf, 0x5e, 0xd6, 0x73, 0xcc, 0x82, 0x2e, 0x40, 0x4c, 0x99, 0xa9, 0x5d, 0x02, + 0xef, 0x0d, 0x97, 0xb8, 0xcb, 0x11, 0xe5, 0xdb, 0x94, 0x04, 0x84, 0x21, 0x2f, 0x65, 0xf3, 0x48, + 0x01, 0xcb, 0xe3, 0x63, 0x25, 0xb7, 0xaf, 0xc1, 0x5c, 0x90, 0x2c, 0xca, 0x8e, 0x5d, 0xcf, 0x47, + 0x4f, 0x82, 0xd7, 0x1d, 0xc7, 0x8d, 0x86, 0xb4, 0x0b, 0xdd, 0x05, 0xd4, 0x96, 0xc1, 0xbb, 0x59, + 0x4c, 0x48, 0x30, 0x44, 0xfa, 0x47, 0x25, 0x5b, 0x60, 0x5f, 0x68, 0xfa, 0x4b, 0x0f, 0x71, 0x5e, + 0x3b, 0x12, 0x67, 0x13, 0xb7, 0x49, 0x88, 0xbc, 0x4c, 0xca, 0x35, 0x70, 0x4a, 0x94, 0x1e, 0x31, + 0x8a, 0x70, 0x11, 0xcc, 0xd9, 0x9e, 0x8b, 0x7d, 0x1e, 0xed, 0x4d, 0x89, 0xbd, 0xd9, 0x78, 0xe1, + 0x86, 0xa3, 0xfd, 0xa4, 0x80, 0xb7, 0x85, 0x92, 0xcf, 0x91, 0xe7, 0x3a, 0x88, 0x13, 0xda, 0xd3, + 0x2a, 0x3a, 0x7e, 0xd0, 0xe1, 0x1a, 0x38, 0x9d, 0x90, 0xb6, 0x90, 0xe3, 0x50, 0xcc, 0x58, 0x5c, + 0xa4, 0x01, 0xff, 0x7b, 0x51, 0x7e, 0x63, 0x0f, 0xb5, 0xbd, 0x6b, 0x9a, 0xdc, 0xd0, 0xcc, 0x85, + 0x24, 0xb6, 0x1e, 0xaf, 0x5c, 0x9b, 0x7d, 0xf4, 0xa4, 0x5c, 0xf8, 0xe7, 0x49, 0xb9, 0xa0, 0xdd, + 0x01, 0xda, 0x28, 0x22, 0xb2, 0x9b, 0x97, 0xc0, 0xe9, 0xe4, 0x28, 0xa7, 0xe5, 0x62, 0x46, 0x0b, + 0x76, 0x4f, 0x7c, 0x54, 0x6c, 0x58, 0xda, 0x76, 0x4f, 0xf1, 0x7c, 0xd2, 0x86, 0x6a, 0x8d, 0x90, + 0x36, 0x50, 0x7f, 0x94, 0xb4, 0x7e, 0x22, 0x5d, 0x69, 0x43, 0x9d, 0x94, 0xd2, 0x06, 0xba, 0xa6, + 0x2d, 0x82, 0xf3, 0x02, 0xf0, 0x5e, 0x8b, 0x12, 0xce, 0x3d, 0x2c, 0x8e, 0x7d, 0x32, 0x9c, 0xbf, + 0x2b, 0xf2, 0xf8, 0x0f, 0xec, 0xca, 0x32, 0x65, 0x30, 0xcf, 0x3c, 0xc4, 0x5a, 0x56, 0x1b, 0x73, + 0x4c, 0x45, 0x85, 0x69, 0x13, 0x88, 0xa5, 0xdb, 0xd1, 0x0a, 0xac, 0x82, 0x37, 0x7b, 0x02, 0x2c, + 0xe4, 0x79, 0x64, 0x17, 0xf9, 0x36, 0x16, 0xda, 0xa7, 0xcd, 0x33, 0xdd, 0xd0, 0x7a, 0xb2, 0x05, + 0xbf, 0x01, 0x45, 0x1f, 0x3f, 0xe0, 0x16, 0xc5, 0x81, 0x87, 0x7d, 0x97, 0xb5, 0x2c, 0x1b, 0xf9, + 0x4e, 0x24, 0x16, 0x17, 0xa7, 0xc5, 0xcc, 0xab, 0x7a, 0x7c, 0xf3, 0xeb, 0xc9, 0xcd, 0xaf, 0xdf, + 0x4b, 0x6e, 0xfe, 0xc6, 0x6c, 0x74, 0x87, 0x3d, 0xfe, 0xb3, 0xac, 0x98, 0xe7, 0x22, 0x14, 0x33, + 0x01, 0xd9, 0x48, 0x30, 0xb4, 0x0f, 0xc0, 0x65, 0x21, 0xc9, 0xc4, 0x4d, 0x97, 0x71, 0x4c, 0xb1, + 0xd3, 0x3d, 0x1d, 0xbb, 0x88, 0x3a, 0x1f, 0x63, 0x9f, 0xb4, 0xd3, 0xe3, 0xb9, 0x09, 0xde, 0xcf, + 0x15, 0x2d, 0x3b, 0x72, 0x0e, 0xcc, 0x38, 0x62, 0x45, 0xdc, 0x78, 0x73, 0xa6, 0x7c, 0xab, 0xfe, + 0xba, 0x00, 0x4e, 0x09, 0x1c, 0xb8, 0xaf, 0x80, 0xb3, 0x59, 0xd7, 0x39, 0x5c, 0xcf, 0x75, 0x92, + 0x47, 0x78, 0x88, 0x5a, 0x3f, 0x06, 0x42, 0xcc, 0x5f, 0xdb, 0xfc, 0xe1, 0xf9, 0xdf, 0x3f, 0x4f, + 0xd5, 0xe0, 0xda, 0x78, 0x9b, 0x4f, 0xe7, 0x59, 0xfa, 0x85, 0xf1, 0x30, 0x19, 0xfe, 0xef, 0xe0, + 0x73, 0x05, 0x9c, 0xc9, 0x30, 0x06, 0x58, 0x3b, 0x3a, 0xc3, 0x3e, 0xc3, 0x51, 0xd7, 0x27, 0x07, + 0x90, 0x0a, 0xaf, 0x0a, 0x85, 0xab, 0xb0, 0x72, 0x04, 0x85, 0xb1, 0x15, 0xc1, 0xef, 0xa7, 0x40, + 0xf1, 0x10, 0x7f, 0x61, 0xf0, 0xd6, 0x84, 0xcc, 0x32, 0xad, 0x4c, 0xbd, 0x7d, 0x42, 0x68, 0x52, + 0xf4, 0xa7, 0x42, 0x74, 0x03, 0xae, 0x1f, 0x55, 0x74, 0xf4, 0x45, 0x41, 0xb9, 0x95, 0xba, 0x04, + 0xfc, 0x5f, 0x01, 0x6f, 0x65, 0xdb, 0x15, 0x83, 0x37, 0x27, 0x26, 0x3d, 0xec, 0x8b, 0xea, 0xad, + 0x93, 0x01, 0x93, 0x0d, 0xd8, 0x12, 0x0d, 0xa8, 0xc3, 0xda, 0x04, 0x0d, 0x20, 0x41, 0x8f, 0xfe, + 0x7f, 0x93, 0x1b, 0x31, 0xd3, 0x5b, 0xe0, 0x27, 0xf9, 0x59, 0x8f, 0x72, 0x49, 0x75, 0xeb, 0xd8, + 0x38, 0x52, 0x78, 0x5d, 0x08, 0xff, 0x08, 0x5e, 0xcd, 0xf1, 0xdd, 0x9e, 0x00, 0x59, 0x7d, 0x56, + 0x95, 0x21, 0xb9, 0xd7, 0x73, 0x26, 0x92, 0x9c, 0xe1, 0x9e, 0x13, 0x49, 0xce, 0x32, 0xbf, 0xc9, + 0x24, 0xf7, 0xd9, 0x25, 0xfc, 0x4d, 0x01, 0x70, 0xd8, 0xf7, 0xe0, 0xf5, 0xfc, 0x14, 0xb3, 0xec, + 0x54, 0xad, 0x4d, 0x9c, 0x2f, 0xa5, 0x5d, 0x11, 0xd2, 0xaa, 0x70, 0x65, 0xbc, 0x34, 0x2e, 0x01, + 0xe2, 0xff, 0x04, 0xf0, 0x97, 0x29, 0x70, 0x31, 0x87, 0x91, 0xc1, 0x3b, 0xf9, 0x29, 0xe6, 0x32, + 0x50, 0x75, 0xfb, 0xe4, 0x00, 0x65, 0x13, 0x6e, 0x8a, 0x26, 0x6c, 0xc2, 0x8d, 0xf1, 0x4d, 0xa0, + 0x29, 0x62, 0x77, 0xa6, 0xa9, 0xc0, 0xb4, 0x62, 0x63, 0x6e, 0x7c, 0xf1, 0x74, 0xbf, 0xa4, 0x3c, + 0xdb, 0x2f, 0x29, 0x7f, 0xed, 0x97, 0x94, 0xc7, 0x07, 0xa5, 0xc2, 0xb3, 0x83, 0x52, 0xe1, 0x8f, + 0x83, 0x52, 0xe1, 0xcb, 0xb5, 0xa6, 0xcb, 0x5b, 0x9d, 0x1d, 0xdd, 0x26, 0x6d, 0xc3, 0x26, 0xac, + 0x4d, 0x58, 0x4f, 0xbd, 0x0f, 0xd3, 0x7a, 0xe1, 0xaa, 0xf1, 0x60, 0xa0, 0xf3, 0x7b, 0x01, 0x66, + 0x3b, 0x33, 0xe2, 0xe3, 0x64, 0xf5, 0x65, 0x00, 0x00, 0x00, 0xff, 0xff, 0xad, 0x57, 0x98, 0xb7, + 0x30, 0x0f, 0x00, 0x00, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } // Reference imports to suppress errors if they are not otherwise used. @@ -1185,9 +994,6 @@ type QueryClient interface { // QueryThrottleState returns the main on-chain state relevant to currently // throttled slash packets QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - QueryThrottledConsumerPacketData(ctx context.Context, in *QueryThrottledConsumerPacketDataRequest, opts ...grpc.CallOption) (*QueryThrottledConsumerPacketDataResponse, error) // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) @@ -1264,15 +1070,6 @@ func (c *queryClient) QueryThrottleState(ctx context.Context, in *QueryThrottleS return out, nil } -func (c *queryClient) QueryThrottledConsumerPacketData(ctx context.Context, in *QueryThrottledConsumerPacketDataRequest, opts ...grpc.CallOption) (*QueryThrottledConsumerPacketDataResponse, error) { - out := new(QueryThrottledConsumerPacketDataResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryThrottledConsumerPacketData", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) { out := new(QueryRegisteredConsumerRewardDenomsResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryRegisteredConsumerRewardDenoms", in, out, opts...) @@ -1303,9 +1100,6 @@ type QueryServer interface { // QueryThrottleState returns the main on-chain state relevant to currently // throttled slash packets QueryThrottleState(context.Context, *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - QueryThrottledConsumerPacketData(context.Context, *QueryThrottledConsumerPacketDataRequest) (*QueryThrottledConsumerPacketDataResponse, error) // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(context.Context, *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) @@ -1336,9 +1130,6 @@ func (*UnimplementedQueryServer) QueryValidatorProviderAddr(ctx context.Context, func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryThrottleState not implemented") } -func (*UnimplementedQueryServer) QueryThrottledConsumerPacketData(ctx context.Context, req *QueryThrottledConsumerPacketDataRequest) (*QueryThrottledConsumerPacketDataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryThrottledConsumerPacketData not implemented") -} func (*UnimplementedQueryServer) QueryRegisteredConsumerRewardDenoms(ctx context.Context, req *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryRegisteredConsumerRewardDenoms not implemented") } @@ -1473,24 +1264,6 @@ func _Query_QueryThrottleState_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Query_QueryThrottledConsumerPacketData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryThrottledConsumerPacketDataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryThrottledConsumerPacketData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryThrottledConsumerPacketData", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryThrottledConsumerPacketData(ctx, req.(*QueryThrottledConsumerPacketDataRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_QueryRegisteredConsumerRewardDenoms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryRegisteredConsumerRewardDenomsRequest) if err := dec(in); err != nil { @@ -1541,10 +1314,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryThrottleState", Handler: _Query_QueryThrottleState_Handler, }, - { - MethodName: "QueryThrottledConsumerPacketData", - Handler: _Query_QueryThrottledConsumerPacketData_Handler, - }, { MethodName: "QueryRegisteredConsumerRewardDenoms", Handler: _Query_QueryRegisteredConsumerRewardDenoms_Handler, @@ -2007,20 +1776,6 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if len(m.Packets) > 0 { - for iNdEx := len(m.Packets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Packets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.NextReplenishCandidate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate):]) if err4 != nil { return 0, err4 @@ -2042,7 +1797,7 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryThrottledConsumerPacketDataRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2052,27 +1807,20 @@ func (m *QueryThrottledConsumerPacketDataRequest) Marshal() (dAtA []byte, err er return dAtA[:n], nil } -func (m *QueryThrottledConsumerPacketDataRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryThrottledConsumerPacketDataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *QueryThrottledConsumerPacketDataResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2082,245 +1830,56 @@ func (m *QueryThrottledConsumerPacketDataResponse) Marshal() (dAtA []byte, err e return dAtA[:n], nil } -func (m *QueryThrottledConsumerPacketDataResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryThrottledConsumerPacketDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PacketDataInstances) > 0 { - for iNdEx := len(m.PacketDataInstances) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PacketDataInstances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.Denoms) > 0 { + for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denoms[iNdEx]) + copy(dAtA[i:], m.Denoms[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0xa } } - if m.Size_ != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x10 - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *ThrottledSlashPacket) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil + dAtA[offset] = uint8(v) + return base } - -func (m *ThrottledSlashPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryConsumerGenesisRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *ThrottledSlashPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.GlobalEntry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ThrottledPacketDataWrapper) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ThrottledPacketDataWrapper) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Data != nil { - { - size := m.Data.Size() - i -= size - if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *ThrottledPacketDataWrapper_SlashPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper_SlashPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SlashPacket != nil { - { - size, err := m.SlashPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.VscMaturedPacket != nil { - { - size, err := m.VscMaturedPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *QueryRegisteredConsumerRewardDenomsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryRegisteredConsumerRewardDenomsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denoms) > 0 { - for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Denoms[iNdEx]) - copy(dAtA[i:], m.Denoms[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryConsumerGenesisRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryConsumerGenesisResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryConsumerGenesisResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = m.GenesisState.Size() @@ -2496,99 +2055,9 @@ func (m *QueryThrottleStateResponse) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate) n += 1 + l + sovQuery(uint64(l)) - if len(m.Packets) > 0 { - for _, e := range m.Packets { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryThrottledConsumerPacketDataRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryThrottledConsumerPacketDataResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Size_ != 0 { - n += 1 + sovQuery(uint64(m.Size_)) - } - if len(m.PacketDataInstances) > 0 { - for _, e := range m.PacketDataInstances { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *ThrottledSlashPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.GlobalEntry.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.Data.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *ThrottledPacketDataWrapper) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Data != nil { - n += m.Data.Size() - } return n } -func (m *ThrottledPacketDataWrapper_SlashPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SlashPacket != nil { - l = m.SlashPacket.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VscMaturedPacket != nil { - l = m.VscMaturedPacket.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} func (m *QueryRegisteredConsumerRewardDenomsRequest) Size() (n int) { if m == nil { return 0 @@ -3846,493 +3315,6 @@ func (m *QueryThrottleStateResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Packets = append(m.Packets, &ThrottledSlashPacket{}) - if err := m.Packets[len(m.Packets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryThrottledConsumerPacketDataRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryThrottledConsumerPacketDataResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketDataInstances", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PacketDataInstances = append(m.PacketDataInstances, ThrottledPacketDataWrapper{}) - if err := m.PacketDataInstances[len(m.PacketDataInstances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ThrottledSlashPacket) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ThrottledSlashPacket: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ThrottledSlashPacket: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GlobalEntry", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GlobalEntry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ThrottledPacketDataWrapper) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ThrottledPacketDataWrapper: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ThrottledPacketDataWrapper: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashPacket", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types.SlashPacketData{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &ThrottledPacketDataWrapper_SlashPacket{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VscMaturedPacket", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &types.VSCMaturedPacketData{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &ThrottledPacketDataWrapper_VscMaturedPacket{v} - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 6a249ca2a2..1a4b418158 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -231,42 +231,6 @@ func local_request_Query_QueryThrottleState_0(ctx context.Context, marshaler run } -var ( - filter_Query_QueryThrottledConsumerPacketData_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryThrottledConsumerPacketData_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryThrottledConsumerPacketDataRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryThrottledConsumerPacketData_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryThrottledConsumerPacketData(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryThrottledConsumerPacketData_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryThrottledConsumerPacketDataRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryThrottledConsumerPacketData_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryThrottledConsumerPacketData(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_QueryRegisteredConsumerRewardDenoms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRegisteredConsumerRewardDenomsRequest var metadata runtime.ServerMetadata @@ -452,29 +416,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryThrottledConsumerPacketData_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_QueryThrottledConsumerPacketData_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryThrottledConsumerPacketData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryRegisteredConsumerRewardDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -679,26 +620,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryThrottledConsumerPacketData_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QueryThrottledConsumerPacketData_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryThrottledConsumerPacketData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryRegisteredConsumerRewardDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -737,8 +658,6 @@ var ( pattern_Query_QueryThrottleState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "throttle_state"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryThrottledConsumerPacketData_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "pending_consumer_packets"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "registered_consumer_reward_denoms"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -757,7 +676,5 @@ var ( forward_Query_QueryThrottleState_0 = runtime.ForwardResponseMessage - forward_Query_QueryThrottledConsumerPacketData_0 = runtime.ForwardResponseMessage - forward_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.ForwardResponseMessage ) diff --git a/x/ccv/types/params.go b/x/ccv/types/params.go index 6a903c0d8f..070bb9875d 100644 --- a/x/ccv/types/params.go +++ b/x/ccv/types/params.go @@ -39,6 +39,9 @@ const ( // By default, the bottom 5% of the validator set can opt out of validating consumer chains DefaultSoftOptOutThreshold = "0.05" + + // Default retry delay period is 1 hour. + DefaultRetryDelayPeriod = time.Hour ) // Reflection based keys for params subspace @@ -54,6 +57,7 @@ var ( KeySoftOptOutThreshold = []byte("SoftOptOutThreshold") KeyRewardDenoms = []byte("RewardDenoms") KeyProviderRewardDenoms = []byte("ProviderRewardDenoms") + KeyRetryDelayPeriod = []byte("RetryDelayPeriod") ) // ParamKeyTable type declaration for parameters @@ -66,9 +70,16 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, distributionTransmissionChannel, providerFeePoolAddrStr string, ccvTimeoutPeriod, transferTimeoutPeriod time.Duration, consumerRedistributionFraction string, historicalEntries int64, +<<<<<<< HEAD consumerUnbondingPeriod time.Duration, softOptOutThreshold string, rewardDenoms, providerRewardDenoms []string, ) Params { return Params{ +======= + consumerUnbondingPeriod time.Duration, softOptOutThreshold string, + rewardDenoms, providerRewardDenoms []string, retryDelayPeriod time.Duration, +) ConsumerParams { + return ConsumerParams{ +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) Enabled: enabled, BlocksPerDistributionTransmission: blocksPerDistributionTransmission, DistributionTransmissionChannel: distributionTransmissionChannel, @@ -81,6 +92,7 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, SoftOptOutThreshold: softOptOutThreshold, RewardDenoms: rewardDenoms, ProviderRewardDenoms: providerRewardDenoms, + RetryDelayPeriod: retryDelayPeriod, } } @@ -101,6 +113,7 @@ func DefaultParams() Params { DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, + DefaultRetryDelayPeriod, ) } @@ -142,6 +155,9 @@ func (p Params) Validate() error { if err := ValidateDenoms(p.ProviderRewardDenoms); err != nil { return err } + if err := ValidateDuration(p.RetryDelayPeriod); err != nil { + return err + } return nil } @@ -171,6 +187,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { p.RewardDenoms, ValidateDenoms), paramtypes.NewParamSetPair(KeyProviderRewardDenoms, p.ProviderRewardDenoms, ValidateDenoms), + paramtypes.NewParamSetPair(KeyRetryDelayPeriod, + p.RetryDelayPeriod, ValidateDuration), } } diff --git a/x/ccv/types/shared_consumer.pb.go b/x/ccv/types/shared_consumer.pb.go index 4cf8860269..4c0973d962 100644 --- a/x/ccv/types/shared_consumer.pb.go +++ b/x/ccv/types/shared_consumer.pb.go @@ -79,6 +79,8 @@ type Params struct { // Provider-originated reward denoms. These are denoms coming from the // provider which are allowed to be used as rewards. e.g. "uatom" ProviderRewardDenoms []string `protobuf:"bytes,12,rep,name=provider_reward_denoms,json=providerRewardDenoms,proto3" json:"provider_reward_denoms,omitempty"` + // The period after which a consumer can retry sending a throttled packet. + RetryDelayPeriod time.Duration `protobuf:"bytes,13,opt,name=retry_delay_period,json=retryDelayPeriod,proto3,stdduration" json:"retry_delay_period"` } func (m *Params) Reset() { *m = Params{} } @@ -198,7 +200,18 @@ func (m *Params) GetProviderRewardDenoms() []string { return nil } +<<<<<<< HEAD // GenesisState defines the CCV consumer chain genesis state. +======= +func (m *ConsumerParams) GetRetryDelayPeriod() time.Duration { + if m != nil { + return m.RetryDelayPeriod + } + return 0 +} + +// ConsumerGenesisState defines the CCV consumer chain genesis state. +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) // // Note this type is referenced in both the consumer and provider CCV modules, // and persisted on the provider, see MakeConsumerGenesis and SetConsumerGenesis. @@ -621,6 +634,7 @@ func init() { } var fileDescriptor_d0a8be0efc64dfbc = []byte{ +<<<<<<< HEAD // 1178 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4d, 0x6f, 0x1b, 0x45, 0x18, 0x8e, 0x9b, 0x34, 0xb5, 0x27, 0x09, 0x4d, 0x27, 0xad, 0xd9, 0x26, 0xc2, 0x71, 0x0d, 0x48, @@ -696,6 +710,85 @@ var fileDescriptor_d0a8be0efc64dfbc = []byte{ 0x13, 0x39, 0x4c, 0x88, 0xd4, 0x43, 0xa9, 0x93, 0x33, 0x33, 0xf7, 0xc7, 0x7f, 0x62, 0xc5, 0x83, 0xe4, 0x57, 0xf7, 0x3b, 0xe6, 0xfe, 0x1e, 0x7b, 0x8b, 0x2e, 0xbe, 0x07, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x28, 0xd8, 0xb6, 0xab, 0x0a, 0x00, 0x00, +======= + // 1203 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x4d, 0x73, 0x13, 0x37, + 0x18, 0x8e, 0x49, 0x08, 0xb6, 0x92, 0x40, 0x50, 0x82, 0xbb, 0x24, 0x53, 0xc7, 0xb8, 0xed, 0x8c, + 0xa7, 0x2d, 0xbb, 0x25, 0xd0, 0xe9, 0x4c, 0x0f, 0x9d, 0x21, 0x76, 0x69, 0xd2, 0xa1, 0x24, 0x6c, + 0x42, 0x0e, 0x74, 0xa6, 0x1a, 0x59, 0x52, 0x6c, 0x0d, 0x6b, 0xc9, 0x23, 0x69, 0x37, 0xcd, 0xb5, + 0xbf, 0x80, 0x63, 0x7f, 0x12, 0x47, 0x8e, 0x9c, 0x4a, 0x07, 0xfe, 0x48, 0x47, 0x1f, 0xeb, 0xd8, + 0xe4, 0xa3, 0x70, 0x5b, 0xe9, 0x7d, 0x9e, 0xf7, 0xfb, 0x7d, 0xb5, 0xe0, 0x3b, 0x2e, 0x0c, 0x53, + 0x64, 0x80, 0xb9, 0x40, 0x9a, 0x91, 0x5c, 0x71, 0x73, 0x92, 0x10, 0x52, 0x24, 0xc5, 0xbd, 0x44, + 0x0f, 0xb0, 0x62, 0x14, 0x11, 0x29, 0x74, 0x3e, 0x64, 0x2a, 0x1e, 0x29, 0x69, 0x24, 0x5c, 0x3b, + 0x87, 0x11, 0x13, 0x52, 0xc4, 0xc5, 0xbd, 0xb5, 0x75, 0xc3, 0x04, 0x65, 0x6a, 0xc8, 0x85, 0x49, + 0x70, 0x8f, 0xf0, 0xc4, 0x9c, 0x8c, 0x98, 0xf6, 0xc4, 0xb5, 0x84, 0xf7, 0x48, 0x92, 0xf1, 0xfe, + 0xc0, 0x90, 0x8c, 0x33, 0x61, 0x74, 0x32, 0x81, 0x2e, 0xee, 0x4d, 0x9c, 0x02, 0xe1, 0x8e, 0x25, + 0x10, 0xa9, 0x58, 0x42, 0x06, 0x58, 0x08, 0x96, 0x59, 0x54, 0xf8, 0x0c, 0x90, 0x46, 0x5f, 0xca, + 0x7e, 0xc6, 0x12, 0x77, 0xea, 0xe5, 0x47, 0x09, 0xcd, 0x15, 0x36, 0x5c, 0x8a, 0x20, 0x5f, 0xed, + 0xcb, 0xbe, 0x74, 0x9f, 0x89, 0xfd, 0x0a, 0xb7, 0x5f, 0x5d, 0x12, 0xf4, 0x31, 0x57, 0x2c, 0xc0, + 0x36, 0x3e, 0x54, 0x6e, 0xf8, 0x90, 0x69, 0x83, 0x87, 0x23, 0x0f, 0x68, 0xbd, 0x9d, 0x07, 0xd7, + 0x3b, 0x21, 0x3b, 0x7b, 0x58, 0xe1, 0xa1, 0x86, 0x11, 0xb8, 0xc6, 0x04, 0xee, 0x65, 0x8c, 0x46, + 0x95, 0x66, 0xa5, 0x5d, 0x4d, 0xcb, 0x23, 0xdc, 0x05, 0x5f, 0xf6, 0x32, 0x49, 0x5e, 0x68, 0x34, + 0x62, 0x0a, 0x51, 0xae, 0x8d, 0xe2, 0xbd, 0xdc, 0xfa, 0x8a, 0x8c, 0xc2, 0x42, 0x0f, 0xb9, 0xd6, + 0x5c, 0x8a, 0xe8, 0x4a, 0xb3, 0xd2, 0x9e, 0x4d, 0xef, 0x78, 0xec, 0x1e, 0x53, 0xdd, 0x09, 0xe4, + 0xc1, 0x04, 0x10, 0xfe, 0x0a, 0xee, 0x5c, 0xa8, 0x05, 0x85, 0x34, 0x45, 0xb3, 0xcd, 0x4a, 0xbb, + 0x96, 0x6e, 0xd0, 0x0b, 0x94, 0x74, 0x3c, 0x0c, 0xfe, 0x08, 0xd6, 0x46, 0x4a, 0x16, 0x9c, 0x32, + 0x85, 0x8e, 0x18, 0x43, 0x23, 0x29, 0x33, 0x84, 0x29, 0x55, 0x48, 0x1b, 0x15, 0xcd, 0x39, 0x25, + 0xf5, 0x12, 0xf1, 0x88, 0xb1, 0x3d, 0x29, 0xb3, 0x87, 0x94, 0xaa, 0x7d, 0xa3, 0xe0, 0x53, 0x00, + 0x09, 0x29, 0x90, 0x4d, 0x8e, 0xcc, 0x8d, 0x8d, 0x8e, 0x4b, 0x1a, 0x5d, 0x6d, 0x56, 0xda, 0x0b, + 0x9b, 0xb7, 0x63, 0x9f, 0xc3, 0xb8, 0xcc, 0x61, 0xdc, 0x0d, 0x05, 0xda, 0xaa, 0xbe, 0xfa, 0x67, + 0x63, 0xe6, 0xef, 0xb7, 0x1b, 0x95, 0x74, 0x99, 0x90, 0xe2, 0xc0, 0xb3, 0xf7, 0x1c, 0x19, 0xfe, + 0x0e, 0x3e, 0x73, 0xd1, 0x1c, 0x31, 0xf5, 0xa1, 0xde, 0xf9, 0x8f, 0xd7, 0x7b, 0xab, 0xd4, 0x31, + 0xad, 0x7c, 0x1b, 0x34, 0xcb, 0x96, 0x46, 0x8a, 0x4d, 0xa5, 0xf0, 0x48, 0x61, 0x62, 0x3f, 0xa2, + 0x6b, 0x2e, 0xe2, 0x46, 0x89, 0x4b, 0xa7, 0x60, 0x8f, 0x02, 0x0a, 0xde, 0x05, 0x70, 0xc0, 0xb5, + 0x91, 0x8a, 0x13, 0x9c, 0x21, 0x26, 0x8c, 0xe2, 0x4c, 0x47, 0x55, 0x57, 0xc0, 0x9b, 0xa7, 0x92, + 0x9f, 0xbd, 0x00, 0x3e, 0x01, 0xcb, 0xb9, 0xe8, 0x49, 0x41, 0xb9, 0xe8, 0x97, 0xe1, 0xd4, 0x3e, + 0x3e, 0x9c, 0x1b, 0x63, 0x72, 0x08, 0xe4, 0x3e, 0xa8, 0x6b, 0x79, 0x64, 0x90, 0x1c, 0x19, 0x64, + 0x33, 0x64, 0x06, 0x8a, 0xe9, 0x81, 0xcc, 0x68, 0x04, 0x9c, 0xfb, 0x2b, 0x56, 0xba, 0x3b, 0x32, + 0xbb, 0xb9, 0x39, 0x28, 0x45, 0xf0, 0x0b, 0xb0, 0xa4, 0xd8, 0x31, 0x56, 0x14, 0x51, 0x26, 0xe4, + 0x50, 0x47, 0x0b, 0xcd, 0xd9, 0x76, 0x2d, 0x5d, 0xf4, 0x97, 0x5d, 0x77, 0x07, 0x1f, 0x80, 0x71, + 0xb1, 0xd1, 0x34, 0x7a, 0xd1, 0xa1, 0x57, 0x4b, 0x69, 0x3a, 0xc9, 0x7a, 0x0a, 0xa0, 0x62, 0x46, + 0x9d, 0x20, 0xca, 0x32, 0x7c, 0x52, 0x46, 0xb8, 0xf4, 0x09, 0x8d, 0xe0, 0xe8, 0x5d, 0xcb, 0xf6, + 0x21, 0xb6, 0xde, 0x54, 0xc1, 0x6a, 0x39, 0x61, 0xbf, 0x30, 0xc1, 0x34, 0xd7, 0xfb, 0x06, 0x1b, + 0x06, 0xb7, 0xc1, 0xfc, 0xc8, 0x4d, 0x9c, 0x1b, 0xb3, 0x85, 0xcd, 0xaf, 0xe3, 0x8b, 0xd7, 0x52, + 0x3c, 0x3d, 0xa3, 0x5b, 0x73, 0xd6, 0x60, 0x1a, 0xf8, 0xf0, 0x5b, 0x00, 0xc7, 0xb1, 0xfa, 0xc5, + 0x84, 0x38, 0x75, 0x53, 0x58, 0x4b, 0x97, 0x4b, 0x49, 0xc7, 0x09, 0x76, 0x28, 0x8c, 0xc1, 0xca, + 0x29, 0xda, 0x0f, 0x8f, 0x85, 0xfb, 0x31, 0xbb, 0x39, 0x86, 0x7b, 0xc9, 0x0e, 0x85, 0xeb, 0xa0, + 0x26, 0xd8, 0x31, 0x72, 0x7e, 0xb9, 0x39, 0xaa, 0xa6, 0x55, 0xc1, 0x8e, 0x3b, 0xf6, 0x0c, 0x11, + 0xb8, 0xf5, 0xa1, 0x69, 0x6d, 0xa3, 0x0b, 0xc3, 0xf3, 0x4d, 0xcc, 0x7b, 0x24, 0x9e, 0xdc, 0x98, + 0xf1, 0xc4, 0x8e, 0xb4, 0x71, 0xb9, 0x5b, 0x97, 0x90, 0x74, 0x65, 0xda, 0x55, 0x9f, 0xa5, 0x01, + 0x88, 0x4e, 0x0d, 0x48, 0xa1, 0x99, 0xd0, 0xb9, 0x0e, 0x36, 0xfc, 0x20, 0xc5, 0xff, 0x6b, 0xa3, + 0xa4, 0x79, 0x33, 0xe3, 0xbe, 0x98, 0xbe, 0x87, 0x7f, 0x80, 0xe5, 0x21, 0x36, 0xb9, 0x72, 0xad, + 0x8d, 0xc9, 0x0b, 0x66, 0x74, 0x74, 0xad, 0x39, 0xdb, 0x5e, 0xd8, 0xbc, 0x7b, 0x59, 0x65, 0x7e, + 0x0b, 0x9c, 0xc3, 0xfd, 0xce, 0x9e, 0x63, 0x85, 0xe2, 0xdc, 0x28, 0x95, 0xf9, 0x5b, 0x3b, 0x3b, + 0x37, 0xb8, 0xe0, 0x86, 0xe3, 0x0c, 0x15, 0x38, 0x43, 0x9a, 0x99, 0xa8, 0xea, 0xd4, 0x37, 0x27, + 0xfd, 0xb5, 0x6f, 0x4e, 0x7c, 0x88, 0x33, 0x4e, 0xb1, 0x91, 0xea, 0xd9, 0x88, 0x62, 0xc3, 0x82, + 0xc6, 0xa5, 0x40, 0x3f, 0xc4, 0xd9, 0x3e, 0x33, 0xd0, 0x80, 0xb5, 0x01, 0xb3, 0x51, 0x23, 0x23, + 0xad, 0x46, 0xcd, 0x0c, 0xca, 0x1d, 0xde, 0x96, 0xb3, 0xe6, 0x54, 0x6f, 0x5e, 0xe6, 0xf9, 0xb6, + 0x63, 0x1f, 0xc8, 0x43, 0xc7, 0xf5, 0xa6, 0x76, 0xba, 0xc1, 0x58, 0x7d, 0x70, 0x9e, 0x94, 0xc2, + 0x13, 0xf0, 0xb9, 0xcc, 0x8d, 0x36, 0xd8, 0xef, 0x00, 0x2a, 0x8f, 0x85, 0x5d, 0x6f, 0x48, 0x67, + 0x58, 0x0f, 0xb8, 0xe8, 0x47, 0xc0, 0x19, 0x4e, 0x2e, 0x33, 0xbc, 0x7b, 0xaa, 0xa0, 0x1b, 0xf8, + 0xc1, 0xea, 0xba, 0x3c, 0x2b, 0xda, 0x0f, 0x9a, 0xa1, 0x02, 0xd1, 0x88, 0x79, 0xb3, 0xe3, 0xed, + 0x57, 0x16, 0x6a, 0xc1, 0xb5, 0xc2, 0xe6, 0xc7, 0x8d, 0x90, 0xa5, 0x74, 0xb1, 0xc1, 0x8f, 0xb9, + 0x2e, 0xab, 0x55, 0x0f, 0x9a, 0xa7, 0x41, 0x1a, 0xfe, 0x55, 0x01, 0x8d, 0x0c, 0x6b, 0x33, 0xfd, + 0x34, 0xb9, 0x97, 0x0d, 0xf9, 0x0c, 0x45, 0x8b, 0xce, 0xf4, 0x0f, 0x97, 0x99, 0x7e, 0x8c, 0xb5, + 0x99, 0x7c, 0xb3, 0xb6, 0x2c, 0xdf, 0xa7, 0xbf, 0x0c, 0x3c, 0xbb, 0x18, 0x02, 0xeb, 0x60, 0x7e, + 0xa4, 0x58, 0xa7, 0x73, 0xe8, 0x36, 0x51, 0x35, 0x0d, 0xa7, 0xd6, 0x73, 0x50, 0x3f, 0xbf, 0x86, + 0x96, 0x11, 0xbc, 0xb3, 0xbb, 0x65, 0x2e, 0x0d, 0x27, 0xd8, 0x06, 0xcb, 0x67, 0x3a, 0xe5, 0x8a, + 0x43, 0x5c, 0x2f, 0xa6, 0xea, 0xdc, 0x7a, 0x06, 0x56, 0xce, 0x29, 0x13, 0xfc, 0x09, 0xac, 0x17, + 0x65, 0x73, 0x4e, 0xcc, 0xa3, 0x7d, 0x67, 0x99, 0xf6, 0x9b, 0xac, 0x96, 0xde, 0x1e, 0x43, 0xc6, + 0x23, 0xf6, 0xd0, 0x03, 0x5a, 0xdf, 0x83, 0xf5, 0xc7, 0x97, 0x47, 0x3a, 0xe1, 0xf7, 0x6c, 0xe9, + 0x77, 0xcb, 0x80, 0x9b, 0x67, 0xe6, 0x0c, 0xae, 0x82, 0xab, 0x85, 0x26, 0x3b, 0x34, 0xc4, 0xe8, + 0x0f, 0x70, 0x07, 0x2c, 0xf9, 0xc9, 0x33, 0x27, 0xee, 0xe1, 0x75, 0xf1, 0x2d, 0x6c, 0xae, 0x9d, + 0xd9, 0xde, 0x07, 0xe5, 0xaf, 0x90, 0x5f, 0xdf, 0x2f, 0xed, 0xfa, 0x5e, 0x2c, 0xa9, 0x56, 0xd8, + 0xea, 0x81, 0xfa, 0xf9, 0x4d, 0x03, 0xb7, 0xc1, 0x5c, 0xc6, 0xb5, 0xf5, 0x72, 0xd6, 0x6f, 0xa0, + 0x4f, 0x69, 0xbb, 0x50, 0x72, 0xa7, 0x61, 0xeb, 0xc9, 0xab, 0x77, 0x8d, 0xca, 0xeb, 0x77, 0x8d, + 0xca, 0xbf, 0xef, 0x1a, 0x95, 0x97, 0xef, 0x1b, 0x33, 0xaf, 0xdf, 0x37, 0x66, 0xde, 0xbc, 0x6f, + 0xcc, 0x3c, 0x7f, 0xd0, 0xe7, 0x66, 0x90, 0xf7, 0x62, 0x22, 0x87, 0x09, 0x91, 0x7a, 0x28, 0x75, + 0x72, 0x6a, 0xe6, 0xee, 0xf8, 0xa7, 0xaf, 0xb8, 0x9f, 0xfc, 0xe9, 0xfe, 0xfc, 0xdc, 0x8f, 0x6a, + 0x6f, 0xde, 0xc5, 0x77, 0xff, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x49, 0x54, 0x31, 0x16, + 0x0b, 0x00, 0x00, +>>>>>>> 88499b7 (feat!: completed throttle v2 (provider changes + migration + testing) (#1321)) } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -718,6 +811,14 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.RetryDelayPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RetryDelayPeriod):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x6a if len(m.ProviderRewardDenoms) > 0 { for iNdEx := len(m.ProviderRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.ProviderRewardDenoms[iNdEx]) @@ -743,12 +844,12 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } - n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err1 != nil { - return 0, err1 + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err2 != nil { + return 0, err2 } - i -= n1 - i = encodeVarintSharedConsumer(dAtA, i, uint64(n1)) + i -= n2 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x4a if m.HistoricalEntries != 0 { @@ -763,21 +864,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintSharedConsumer(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x32 - n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) if err3 != nil { return 0, err3 } i -= n3 i = encodeVarintSharedConsumer(dAtA, i, uint64(n3)) i-- + dAtA[i] = 0x32 + n4, err4 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n4)) + i-- dAtA[i] = 0x2a if len(m.ProviderFeePoolAddrStr) > 0 { i -= len(m.ProviderFeePoolAddrStr) @@ -1089,12 +1190,12 @@ func (m *MaturingVSCPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n9, err9 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.MaturityTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime):]) - if err9 != nil { - return 0, err9 + n10, err10 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.MaturityTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime):]) + if err10 != nil { + return 0, err10 } - i -= n9 - i = encodeVarintSharedConsumer(dAtA, i, uint64(n9)) + i -= n10 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n10)) i-- dAtA[i] = 0x12 if m.VscId != 0 { @@ -1202,6 +1303,8 @@ func (m *Params) Size() (n int) { n += 1 + l + sovSharedConsumer(uint64(l)) } } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RetryDelayPeriod) + n += 1 + l + sovSharedConsumer(uint64(l)) return n } @@ -1719,6 +1822,39 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.ProviderRewardDenoms = append(m.ProviderRewardDenoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RetryDelayPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.RetryDelayPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSharedConsumer(dAtA[iNdEx:])