From c32da7f9e89942311781fe2e3ef1b970367220ca Mon Sep 17 00:00:00 2001 From: insumity Date: Mon, 26 Aug 2024 11:02:15 +0200 Subject: [PATCH 01/43] feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> --- Makefile | 6 +- docs/docs/adrs/adr-019-permissionless-ics.md | 12 +- .../ccv/provider/v1/provider.proto | 102 + .../ccv/provider/v1/query.proto | 140 +- .../ccv/provider/v1/tx.proto | 139 +- tests/integration/common.go | 2 +- tests/integration/distribution.go | 50 +- tests/integration/double_vote.go | 55 +- tests/integration/expired_client.go | 10 +- tests/integration/key_assignment.go | 32 +- tests/integration/misbehaviour.go | 44 +- .../integration/partial_set_security_test.go | 5 +- tests/integration/provider_gov_hooks.go | 44 +- tests/integration/setup.go | 45 +- tests/integration/slashing.go | 10 +- tests/integration/stop_consumer.go | 26 +- tests/mbt/driver/core.go | 6 +- tests/mbt/driver/setup.go | 5 +- testutil/ibc_testing/generic_setup.go | 48 +- testutil/keeper/mocks.go | 14 + testutil/keeper/unit_test_helpers.go | 86 +- x/ccv/provider/client/cli/query.go | 42 +- x/ccv/provider/client/cli/tx.go | 207 ++ x/ccv/provider/handler.go | 9 + x/ccv/provider/handler_test.go | 62 +- x/ccv/provider/ibc_middleware.go | 6 +- x/ccv/provider/ibc_module_test.go | 27 +- .../provider/keeper/consumer_equivocation.go | 82 +- x/ccv/provider/keeper/distribution.go | 63 +- x/ccv/provider/keeper/distribution_test.go | 4 +- x/ccv/provider/keeper/genesis.go | 32 +- x/ccv/provider/keeper/genesis_test.go | 4 +- x/ccv/provider/keeper/grpc_query.go | 190 +- x/ccv/provider/keeper/grpc_query_test.go | 158 +- x/ccv/provider/keeper/hooks.go | 74 +- x/ccv/provider/keeper/hooks_test.go | 23 +- x/ccv/provider/keeper/keeper.go | 575 ++-- x/ccv/provider/keeper/keeper_test.go | 257 +- x/ccv/provider/keeper/key_assignment.go | 175 +- x/ccv/provider/keeper/key_assignment_test.go | 92 +- x/ccv/provider/keeper/legacy_proposal.go | 87 +- x/ccv/provider/keeper/legacy_proposal_test.go | 206 +- x/ccv/provider/keeper/msg_server.go | 220 +- x/ccv/provider/keeper/msg_server_test.go | 55 + x/ccv/provider/keeper/partial_set_security.go | 122 +- .../keeper/partial_set_security_test.go | 219 +- x/ccv/provider/keeper/permissionless.go | 747 +++++ x/ccv/provider/keeper/permissionless_test.go | 384 +++ x/ccv/provider/keeper/proposal.go | 423 ++- x/ccv/provider/keeper/proposal_test.go | 802 ++--- x/ccv/provider/keeper/relay.go | 104 +- x/ccv/provider/keeper/relay_test.go | 61 +- x/ccv/provider/keeper/validator_set_update.go | 56 +- .../keeper/validator_set_update_test.go | 29 +- .../provider/migrations/v5/migration_test.go | 6 +- x/ccv/provider/migrations/v5/migrations.go | 9 +- x/ccv/provider/migrations/v6/migrations.go | 9 +- x/ccv/provider/module.go | 5 +- x/ccv/provider/module_test.go | 4 +- x/ccv/provider/proposal_handler.go | 6 +- x/ccv/provider/proposal_handler_test.go | 52 +- x/ccv/provider/types/codec.go | 9 +- x/ccv/provider/types/errors.go | 67 +- x/ccv/provider/types/events.go | 2 +- x/ccv/provider/types/keys.go | 472 +-- x/ccv/provider/types/keys_test.go | 105 +- x/ccv/provider/types/legacy_proposal.go | 54 +- x/ccv/provider/types/legacy_proposal_test.go | 96 +- x/ccv/provider/types/msg.go | 459 ++- x/ccv/provider/types/msg_test.go | 21 + x/ccv/provider/types/provider.pb.go | 1906 +++++++++++- x/ccv/provider/types/query.pb.go | 1883 ++++++++++-- x/ccv/provider/types/query.pb.gw.go | 852 +++++- x/ccv/provider/types/throttle.go | 17 - x/ccv/provider/types/tx.pb.go | 2641 ++++++++++++++--- x/ccv/types/expected_keepers.go | 1 + 76 files changed, 11357 insertions(+), 3797 deletions(-) create mode 100644 x/ccv/provider/keeper/msg_server_test.go create mode 100644 x/ccv/provider/keeper/permissionless.go create mode 100644 x/ccv/provider/keeper/permissionless_test.go create mode 100644 x/ccv/provider/types/msg_test.go delete mode 100644 x/ccv/provider/types/throttle.go diff --git a/Makefile b/Makefile index 1e8eb8e5bc..ec2493c9b4 100644 --- a/Makefile +++ b/Makefile @@ -33,8 +33,8 @@ install: go.sum go install -ldflags "$(democracyFlags)" ./cmd/interchain-security-cdd go install -ldflags "$(standaloneFlags)" ./cmd/interchain-security-sd -# run all tests: unit, integration, diff, and E2E -test: test-unit test-integration test-mbt test-e2e +# run all tests: unit, integration, and E2E +test: test-unit test-integration test-e2e # shortcut for local development test-dev: test-unit test-integration test-mbt @@ -271,4 +271,4 @@ build-docs-local: ############################################################################### e2e-traces: - cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v \ No newline at end of file + cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v diff --git a/docs/docs/adrs/adr-019-permissionless-ics.md b/docs/docs/adrs/adr-019-permissionless-ics.md index 59b13659a4..70273ee2f3 100644 --- a/docs/docs/adrs/adr-019-permissionless-ics.md +++ b/docs/docs/adrs/adr-019-permissionless-ics.md @@ -95,8 +95,7 @@ consumer chains with the exact same `chainId`, and it is the responsibility of t to interact with by providing the right `consumerId`. Note that with Permissionless ICS, all interactions on a consumer chain have to use the `consumerId` instead of the `chainId`. -For example, if a validator opts in on a chain using `MsgOptIn`, the validator has to provide the `consumerId`. To also -provide the `consumerId` for Top N consumers chains, we store a mapping between `proposalID` to `consumerId`. This storing +For example, if a validator opts in on a chain using `MsgOptIn`, the validator has to provide the `consumerId`. To also provide the `consumerId` for Top N consumers chains, we store a mapping between `proposalID` to `consumerId`. This storing takes place in the [`AfterProposalSubmission`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.8/x/gov/types/hooks.go#L19) hook. Specifically, for the equivocation evidence, we update the `MsgSubmitConsumerMisbehaviour` and `MsgSubmitConsumerDoubleVoting` messages to include the `consumerId`, and change [Hermes](https://github.com/informalsystems/hermes) to include `consumerId` in those constructed messages as well. @@ -161,9 +160,9 @@ where `ConsumerRegistrationRecord` contains information about the to-be-launched ```protobuf message ConsumerRegistrationRecord { - // the title of the chain to-be-launched + // the title of the chain to-be-registered string title; - // the description of the chain to-be-launched + // the description of the chain to-be-registered string description; // the chain id of the new consumer chain string chain_id; @@ -183,7 +182,7 @@ To move an Opt In consumer chain to its initialized phase, we issue a `MsgInitia ```protobuf message MsgInitializeConsumer { - // consumer id of the to-be-updated consumer chain + // consumer id of the to-be-initialized consumer chain string consumer_id; // the initialization record that contains initialization parameters for the upcoming chain ConsumerInitializationRecord initialization_record; @@ -332,6 +331,9 @@ Because we only have two consumer chains at the moment, this is not going to be consumer chains that are being voted upon. Similarly, all the messages, queries, etc. would need to be changed to operate on a `consumerId` instead of a `chainId`. +To prevent a validator from accidentally opting in to a wrong chain, we disallow a validator from opting in to two or more +different chains (different `consumerId`) with the same `chainId`. + It is **important** to migrate any ongoing `ConsumerAdditionProposal`s when we upgrade before we actually deprecate `ConsumerAdditionProposal`s. ## Consequences diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 7e1836cf38..7204d5754b 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -21,6 +21,7 @@ import "amino/amino.proto"; // These schemas can change with proper consideration of compatibility or migration. // +// WARNING: This message is deprecated in favor of `MsgCreateConsumer`. // ConsumerAdditionProposal is a governance proposal on the provider chain to // spawn a new consumer chain. If it passes, then all validators on the provider // chain are expected to validate the consumer chain at spawn time or get @@ -112,6 +113,7 @@ message ConsumerAdditionProposal { bool allow_inactive_vals = 21; } +// WARNING: This message is deprecated in favor of `MsgRemoveConsumer`. // ConsumerRemovalProposal is a governance proposal on the provider chain to // remove (and stop) a consumer chain. If it passes, all the consumer chain's // state is removed from the provider chain. The outstanding unbonding operation @@ -132,6 +134,7 @@ message ConsumerRemovalProposal { [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; } +// WARNING: This message is deprecated in favor of `MsgUpdateConsumer`. // ConsumerModificationProposal is a governance proposal on the provider chain to modify parameters of a running // consumer chain. If it passes, the consumer chain's state is updated to take into account the newest params. message ConsumerModificationProposal { @@ -285,6 +288,7 @@ message ConsumerRemovalProposals { // AddressList contains a list of consensus addresses message AddressList { repeated bytes addresses = 1; } +// WARNING: This message is deprecated and is not used. // ChannelToChain is used to map a CCV channel ID to the consumer chainID message ChannelToChain { string channel_id = 1; @@ -362,3 +366,101 @@ message ConsumerRewardsAllocation { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; } + +// ConsumerMetadata contains general information about the registered chain +message ConsumerMetadata { + // the name of the chain + string name = 1; + // the description of the chain + string description = 2; + // the metadata (e.g., GitHub repository URL) of the chain + string metadata = 3; +} + +// ConsumerInitializationParameters are the parameters needed to launch a chain +message ConsumerInitializationParameters { + // ---------- ---------- ---------- + // Following fields are used when the consumer chain launches and are not needed by the provider afterwards. + // ---------- ---------- ---------- + + // the proposed initial height of new consumer chain. + // For a completely new chain, this will be {0,1}. However, it may be + // different if this is a chain that is converting to a consumer chain. + ibc.core.client.v1.Height initial_height = 1 [ (gogoproto.nullable) = false ]; + // The hash of the consumer chain genesis state without the consumer CCV + // module genesis params. It is used for off-chain confirmation of + // genesis.json validity by validators and other parties. + bytes genesis_hash = 2; + // The hash of the consumer chain binary that should be run by validators on + // chain initialization. It is used for off-chain confirmation of binary + // validity by validators and other parties. + bytes binary_hash = 3; + // spawn time is the time on the provider chain at which the consumer chain + // genesis is finalized and all validators will be responsible for starting + // their consumer chain validator node. + google.protobuf.Timestamp spawn_time = 4 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + google.protobuf.Duration unbonding_period = 5 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + + + // ---------- ---------- ---------- + // Following fields are used to construct the consumer genesis of the to-be-launched consumer chain + // and are set up as params on the consumer chain. Those params can then be directly modified by the consumer chain. + // ---------- ---------- ---------- + + // Sent CCV related IBC packets will timeout after this duration + google.protobuf.Duration ccv_timeout_period = 6 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + // Sent transfer related IBC packets will timeout after this duration + google.protobuf.Duration transfer_timeout_period = 7 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + string consumer_redistribution_fraction = 8; + // BlocksPerDistributionTransmission is the number of blocks between + // ibc-token-transfers from the consumer chain to the provider chain. On + // sending transmission event, `consumer_redistribution_fraction` of the + // accumulated tokens are sent to the consumer redistribution address. + int64 blocks_per_distribution_transmission = 9; + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + int64 historical_entries = 10; + // The ID of a token transfer channel used for the Reward Distribution + // sub-protocol. If DistributionTransmissionChannel == "", a new transfer + // channel is created on top of the same connection as the CCV channel. + // Note that transfer_channel_id is the ID of the channel end on the consumer + // chain. it is most relevant for chains performing a sovereign to consumer + // changeover in order to maintain the existing ibc transfer channel + string distribution_transmission_channel = 11; +} + +// PowerShapingParameters contains parameters that shape the validator set that we send to the consumer chain +message PowerShapingParameters { + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + uint32 top_N = 1; + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + uint32 validators_power_cap = 2; + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + uint32 validator_set_cap = 3; + // corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate the consumer chain + repeated string allowlist = 4; + // corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain + repeated string denylist = 5; + // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. + uint64 min_stake = 6; + // Corresponds to whether inactive validators are allowed to validate the consumer chain. + bool allow_inactive_vals = 7; +} + +// ConsumerIds contains consumer ids of chains +// Used so we can easily (de)serialize slices of strings +message ConsumerIds { repeated string ids = 1; } diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 9a8fbf7f42..c9536b8e16 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -11,14 +11,20 @@ import "interchain_security/ccv/v1/shared_consumer.proto"; import "interchain_security/ccv/v1/wire.proto"; import "tendermint/crypto/keys.proto"; import "cosmos_proto/cosmos.proto"; +import "cosmos/staking/v1beta1/staking.proto"; service Query { // ConsumerGenesis queries the genesis state needed to start a consumer chain // whose proposal has been accepted rpc QueryConsumerGenesis(QueryConsumerGenesisRequest) returns (QueryConsumerGenesisResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_genesis/{chain_id}"; + option (google.api.http) = { + // [DEPRECATED] use the {consumer_id} endpoint instead. + get: "/interchain_security/ccv/provider/consumer_genesis/{chain_id}"; + additional_bindings { + get: "/interchain_security/ccv/provider/consumer_genesis/{consumer_id}"; + } + }; } // ConsumerChains queries active consumer chains supported by the provider @@ -90,8 +96,13 @@ service Query { rpc QueryAllPairsValConAddrByConsumerChainID ( QueryAllPairsValConAddrByConsumerChainIDRequest) returns (QueryAllPairsValConAddrByConsumerChainIDResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_chain_id"; + option (google.api.http) = { + // [DEPRECATED] use the {consumer_id} endpoint instead. + get: "/interchain_security/ccv/provider/{chain_id}"; + additional_bindings { + get: "/interchain_security/ccv/provider/{consumer_id}"; + } + }; } // QueryParams returns all current values of provider parameters @@ -106,8 +117,13 @@ service Query { rpc QueryConsumerChainOptedInValidators( QueryConsumerChainOptedInValidatorsRequest) returns (QueryConsumerChainOptedInValidatorsResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/opted_in_validators/{chain_id}"; + option (google.api.http) = { + // [DEPRECATED] use the {consumer_id} endpoint instead. + get: "/interchain_security/ccv/provider/opted_in_validators/{chain_id}"; + additional_bindings { + get: "/interchain_security/ccv/provider/opted_in_validators/{consumer_id}"; + } + }; } // QueryConsumerChainsValidatorHasToValidate returns a list of consumer chains @@ -124,8 +140,13 @@ service Query { rpc QueryValidatorConsumerCommissionRate( QueryValidatorConsumerCommissionRateRequest) returns (QueryValidatorConsumerCommissionRateResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_commission_rate/{chain_id}/{provider_address}"; + option (google.api.http) = { + // [DEPRECATED] use the {consumer_id} endpoint instead. + get: "/interchain_security/ccv/provider/consumer_commission_rate/{chain_id}/{provider_address}"; + additional_bindings { + get: "/interchain_security/ccv/provider/consumer_commission_rate/{consumer_id}/{provider_address}"; + } + }; } // QueryConsumerValidators returns the latest set consumer-validator set for a given chainID @@ -133,8 +154,13 @@ service Query { // because a VSCPacket could be delayed to be delivered on the consumer chain. rpc QueryConsumerValidators(QueryConsumerValidatorsRequest) returns (QueryConsumerValidatorsResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_validators/{chain_id}"; + option (google.api.http) = { + // [DEPRECATED] use the {consumer_id} endpoint instead. + get: "/interchain_security/ccv/provider/consumer_validators/{chain_id}"; + additional_bindings { + get: "/interchain_security/ccv/provider/consumer_validators/{consumer_id}"; + } + }; } // QueryBlocksUntilNextEpoch returns the number of blocks until the next epoch @@ -144,9 +170,21 @@ service Query { option (google.api.http).get = "/interchain_security/ccv/provider/blocks_until_next_epoch"; } + + // QueryConsumerIdFromClientId returns the consumer id of the chain + // associated with the provided client id + rpc QueryConsumerIdFromClientId(QueryConsumerIdFromClientIdRequest) + returns (QueryConsumerIdFromClientIdResponse) { + option (google.api.http).get = + "/interchain_security/ccv/provider/consumer_id/{client_id}"; + } } -message QueryConsumerGenesisRequest { string chain_id = 1; } +message QueryConsumerGenesisRequest { + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; + string consumer_id = 2; +} message QueryConsumerGenesisResponse { interchain_security.ccv.v1.ConsumerGenesisState genesis_state = 1 @@ -192,10 +230,12 @@ message Chain { message QueryValidatorConsumerAddrRequest { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // The id of the consumer chain - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // The consensus address of the validator on the provider chain string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + // The id of the consumer chain + string consumer_id = 3; } message QueryValidatorConsumerAddrResponse { @@ -206,10 +246,12 @@ message QueryValidatorConsumerAddrResponse { message QueryValidatorProviderAddrRequest { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // The id of the provider chain - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // The consensus address of the validator on the consumer chain string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + // The id of the consumer chain + string consumer_id = 3; } message QueryValidatorProviderAddrResponse { @@ -245,13 +287,17 @@ message QueryProposedChainIDsResponse { } message ProposedChain { - string chainID = 1; + // [DEPRECATED] use `consumer_id` instead + string chainID = 1 [deprecated = true]; uint64 proposalID = 2; + string consumer_id = 3; } message QueryAllPairsValConAddrByConsumerChainIDRequest { + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // The id of the consumer chain - string chain_id = 1; + string consumer_id = 2; } message QueryAllPairsValConAddrByConsumerChainIDResponse { @@ -273,7 +319,9 @@ message QueryParamsResponse { } message QueryConsumerChainOptedInValidatorsRequest { - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; + string consumer_id = 2; } message QueryConsumerChainOptedInValidatorsResponse { @@ -282,7 +330,9 @@ message QueryConsumerChainOptedInValidatorsResponse { } message QueryConsumerValidatorsRequest { - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; + string consumer_id = 2; } message QueryConsumerValidatorsValidator { @@ -290,13 +340,44 @@ message QueryConsumerValidatorsValidator { string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The consumer public key of the validator used on the consumer chain tendermint.crypto.PublicKey consumer_key = 2; + // [DEPRECATED] use `consumer_power` instead + int64 power = 3 [deprecated = true]; + + // [DEPRECATED] use `consumer_commission_rate` instead + string rate = 4 [ deprecated = true, + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; // The power of the validator used on the consumer chain - int64 power = 3; + int64 consumer_power = 5; // The rate to charge delegators on the consumer chain, as a fraction - string rate = 4 [ + string consumer_commission_rate = 6 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // The rate to charge delegators on the provider chain, as a fraction + string provider_commission_rate = 7 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + // description defines the description terms for the validator + cosmos.staking.v1beta1.Description description = 8 [(gogoproto.nullable) = false]; + // provider_operator_address defines the address of the validator's operator + string provider_operator_address = 9 [(cosmos_proto.scalar) = "cosmos.ValidatorAddressString"]; + // jailed defined whether the validator has been jailed from bonded status or not. + bool jailed = 10; + // status is the validator status (bonded/unbonding/unbonded). + cosmos.staking.v1beta1.BondStatus status = 11; + // provider_tokens defines the delegated tokens (incl. self-delegation). + string provider_tokens = 12 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + // The power of the validator used on the provider chain + int64 provider_power = 13; + // validates_current_epoch defines whether the validator has to validate for the current epoch or not + bool validates_current_epoch = 14; } message QueryConsumerValidatorsResponse { @@ -313,9 +394,11 @@ message QueryConsumerChainsValidatorHasToValidateResponse { } message QueryValidatorConsumerCommissionRateRequest { - string chain_id = 1; - // The consensus address of the validator on the provider chain + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; + // The consensus address of the validator on the provider chain string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + string consumer_id = 3; } message QueryValidatorConsumerCommissionRateResponse { @@ -332,3 +415,14 @@ message QueryBlocksUntilNextEpochResponse { // The number of blocks until the next epoch starts uint64 blocks_until_next_epoch = 1; } + +message QueryConsumerIdFromClientIdRequest { + // the client id (on the provider) that is tracking the consumer chain + // the client id can be found from the consumer chain by querying (i.e., `query ccvconsumer provider-info`) + string client_id = 1; +} + +message QueryConsumerIdFromClientIdResponse { + // the consumer id of the chain associated with this client id + string consumer_id = 1; +} diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 113923b11c..80b4885603 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -23,13 +23,22 @@ service Msg { rpc AssignConsumerKey(MsgAssignConsumerKey) returns (MsgAssignConsumerKeyResponse); rpc SubmitConsumerMisbehaviour(MsgSubmitConsumerMisbehaviour) returns (MsgSubmitConsumerMisbehaviourResponse); rpc SubmitConsumerDoubleVoting(MsgSubmitConsumerDoubleVoting) returns (MsgSubmitConsumerDoubleVotingResponse); - rpc ConsumerAddition(MsgConsumerAddition) returns (MsgConsumerAdditionResponse); - rpc ConsumerRemoval(MsgConsumerRemoval) returns (MsgConsumerRemovalResponse); + rpc ConsumerAddition(MsgConsumerAddition) returns (MsgConsumerAdditionResponse) { + option deprecated = true; + }; + rpc ConsumerRemoval(MsgConsumerRemoval) returns (MsgConsumerRemovalResponse) { + option deprecated = true; + }; + rpc CreateConsumer(MsgCreateConsumer) returns (MsgCreateConsumerResponse); + rpc UpdateConsumer(MsgUpdateConsumer) returns (MsgUpdateConsumerResponse); + rpc RemoveConsumer(MsgRemoveConsumer) returns (MsgRemoveConsumerResponse); rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc OptIn(MsgOptIn) returns (MsgOptInResponse); rpc OptOut(MsgOptOut) returns (MsgOptOutResponse); rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); - rpc ConsumerModification(MsgConsumerModification) returns (MsgConsumerModificationResponse); + rpc ConsumerModification(MsgConsumerModification) returns (MsgConsumerModificationResponse) { + option deprecated = true; + } rpc ChangeRewardDenoms(MsgChangeRewardDenoms) returns (MsgChangeRewardDenomsResponse); } @@ -40,8 +49,8 @@ message MsgAssignConsumerKey { option (gogoproto.goproto_getters) = false; - // The chain id of the consumer chain to assign a consensus public key to - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // The validator address on the provider string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The consensus public key to use on the consumer. @@ -51,6 +60,9 @@ message MsgAssignConsumerKey { // Tx signer address string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // the consumer id of the consumer chain to assign a consensus public key to + string consumer_id = 5; } message MsgAssignConsumerKeyResponse {} @@ -67,6 +79,8 @@ message MsgSubmitConsumerMisbehaviour { // The Misbehaviour of the consumer chain wrapping // two conflicting IBC headers ibc.lightclients.tendermint.v1.Misbehaviour misbehaviour = 2; + // the consumer id of the consumer chain where the misbehaviour occurred + string consumer_id = 3; } message MsgSubmitConsumerMisbehaviourResponse {} @@ -85,6 +99,8 @@ message MsgSubmitConsumerDoubleVoting { tendermint.types.DuplicateVoteEvidence duplicate_vote_evidence = 2; // The light client header of the infraction block ibc.lightclients.tendermint.v1.Header infraction_block_header = 3; + // the consumer id of the consumer chain where the double-voting took place + string consumer_id = 4; } message MsgSubmitConsumerDoubleVotingResponse {} @@ -102,13 +118,7 @@ message MsgUpdateParams { message MsgUpdateParamsResponse {} - -// MsgConsumerAddition defines the message used to spawn a new consumer chain using a v1 governance proposal. -// If it passes, then all validators on the provider chain are expected to validate -// the consumer chain at spawn time or get slashed. -// It is recommended that spawn time occurs after the proposal end time. -// -// Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgCreateConsumer` instead message MsgConsumerAddition { option (cosmos.msg.v1.signer) = "authority"; @@ -193,13 +203,7 @@ message MsgConsumerAddition { // MsgConsumerAdditionResponse defines response type for MsgConsumerAddition messages message MsgConsumerAdditionResponse {} - -// MsgConsumerRemoval message contains a governance proposal on the provider chain to -// remove (and stop) a consumer chain. If it passes, all the consumer chain's -// state is removed from the provider chain. The outstanding unbonding operation -// funds are released. -// -// Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgRemoveConsumer` instead message MsgConsumerRemoval { option (cosmos.msg.v1.signer) = "authority"; @@ -216,6 +220,25 @@ message MsgConsumerRemoval { // MsgConsumerRemovalResponse defines response type for MsgConsumerRemoval messages message MsgConsumerRemovalResponse {} + +// MsgRemoveConsumer defines the message used to remove (and stop) a consumer chain. +// If it passes, all the consumer chain's state is eventually removed from the provider chain. +message MsgRemoveConsumer { + option (cosmos.msg.v1.signer) = "authority"; + + // the consumer id of the consumer chain to be stopped + string consumer_id = 1; + // the time on the provider chain at which all validators are responsible to + // stop their consumer chain validator node + google.protobuf.Timestamp stop_time = 2 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + // signer address + string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgRemoveConsumerResponse defines response type for MsgRemoveConsumer messages +message MsgRemoveConsumerResponse {} + // ChangeRewardDenomsProposal is a governance proposal on the provider chain to // mutate the set of denoms accepted by the provider as rewards. // @@ -239,8 +262,8 @@ message MsgOptIn { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; option (cosmos.msg.v1.signer) = "signer"; - // the chain id of the consumer chain to opt in to - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // the validator address on the provider string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // (optional) The consensus public key to use on the consumer in json string format corresponding to proto-any, @@ -250,7 +273,8 @@ message MsgOptIn { string consumer_key = 3; // signer address string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - + // the consumer id of the consumer chain to opt in to + string consumer_id = 5; } message MsgOptInResponse {} @@ -259,13 +283,14 @@ message MsgOptOut { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; option (cosmos.msg.v1.signer) = "signer"; - // the chain id of the consumer chain to opt out from - string chain_id = 1; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 1 [deprecated = true]; // the validator address on the provider string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // signer address string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - + // the consumer id of the consumer chain to opt out from + string consumer_id = 4; } message MsgOptOutResponse {} @@ -277,10 +302,10 @@ message MsgSetConsumerCommissionRate { option (gogoproto.goproto_getters) = false; option (cosmos.msg.v1.signer) = "signer"; - // The validator address on the provider - string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; - // The chain id of the consumer chain to set a commission rate - string chain_id = 2; + // The validator address on the provider + string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + // [DEPRECATED] use `consumer_id` instead + string chain_id = 2 [deprecated = true]; // The rate to charge delegators on the consumer chain, as a fraction // TODO: migrate rate from sdk.Dec to math.LegacyDec string rate = 3 [ @@ -290,16 +315,14 @@ message MsgSetConsumerCommissionRate { ]; // signer address string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // the consumer id of the consumer chain to set the commission rate + string consumer_id = 5; } message MsgSetConsumerCommissionRateResponse {} -// MsgConsumerModification message contains a governance proposal on the provider chain to -// modify a running consumer chain. If it passes, the consumer chain's -// parameters are updated. -// -// Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgUpdateConsumer` instead message MsgConsumerModification { option (cosmos.msg.v1.signer) = "authority"; @@ -337,3 +360,51 @@ message MsgConsumerModification { } message MsgConsumerModificationResponse {} + +// MsgCreateConsumer defines the message that creates a consumer chain +message MsgCreateConsumer { + option (cosmos.msg.v1.signer) = "signer"; + + // signer address + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // the chain id of the new consumer chain + string chain_id = 2; + + ConsumerMetadata metadata = 3 [ (gogoproto.nullable) = false ]; + + ConsumerInitializationParameters initialization_parameters = 4; + + PowerShapingParameters power_shaping_parameters = 5; +} + +// MsgCreateConsumerResponse defines response type for MsgCreateConsumer +message MsgCreateConsumerResponse { + string consumer_id = 1; +} + +// MsgUpdateConsumer defines the message used to modify a consumer chain. +message MsgUpdateConsumer { + option (cosmos.msg.v1.signer) = "signer"; + + // signer address + string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // the consumer id of the consumer chain to be updated + string consumer_id = 2; + + // the new owner of the consumer when updated + string new_owner_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // the metadata of the consumer when updated + ConsumerMetadata metadata = 4; + + // initialization parameters can only be updated before a chain has launched + ConsumerInitializationParameters initialization_parameters = 5; + + // the power-shaping parameters of the consumer when updated + PowerShapingParameters power_shaping_parameters = 6; +} + +// MsgUpdateConsumerResponse defines response type for MsgUpdateConsumer messages +message MsgUpdateConsumerResponse {} \ No newline at end of file diff --git a/tests/integration/common.go b/tests/integration/common.go index 46ef499d01..a2c5cd8d46 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -42,7 +42,7 @@ func (s *CCVTestSuite) getFirstBundle() icstestingutils.ConsumerBundle { } func (s *CCVTestSuite) getBundleByIdx(index int) icstestingutils.ConsumerBundle { - return *s.consumerBundles[ibctesting.GetChainID(2+index)] + return *s.consumerBundles[fmt.Sprintf("%d", 2+index)] } func (s *CCVTestSuite) providerCtx() sdk.Context { diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go index 8fecaccfc8..316b343f0a 100644 --- a/tests/integration/distribution.go +++ b/tests/integration/distribution.go @@ -125,7 +125,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // Save the consumer validators total outstanding rewards on the provider consumerValsOutstandingRewardsFunc := func(ctx sdk.Context) sdk.DecCoins { totalRewards := sdk.DecCoins{} - vals, err := providerKeeper.GetConsumerValSet(ctx, s.consumerChain.ChainID) + vals, err := providerKeeper.GetConsumerValSet(ctx, s.getFirstBundle().ConsumerId) s.Require().NoError(err) for _, v := range vals { @@ -160,7 +160,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // Consumer allocations are distributed between the validators and the community pool. // The decimals resulting from the distribution are expected to remain in the consumer allocations. - rewardsAlloc := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.consumerChain.ChainID) + rewardsAlloc := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.getFirstBundle().ConsumerId) remainingAlloc := rewardsAlloc.Rewards.AmountOf(rewardsIBCdenom) s.Require().True(remainingAlloc.LTE(math.LegacyOneDec())) @@ -601,7 +601,7 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() { // update consumer allocation keeper.SetConsumerRewardsAllocation( ctx, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, providertypes.ConsumerRewardsAllocation{ Rewards: sdk.NewDecCoins(sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(100_000))), }, @@ -668,7 +668,7 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() { rewardsPoolBalance := bankKeeper.GetAllBalances(s.providerCtx(), sdk.MustAccAddressFromBech32(data.Receiver)) // save the consumer's rewards allocated - consumerRewardsAllocations := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.consumerChain.ChainID) + consumerRewardsAllocations := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.getFirstBundle().ConsumerId) // execute middleware OnRecvPacket logic ack := cbs.OnRecvPacket(s.providerCtx(), packet, sdk.AccAddress{}) @@ -682,7 +682,7 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() { // compute the balance and allocation difference rewardsTransferred := bankKeeper.GetAllBalances(s.providerCtx(), sdk.MustAccAddressFromBech32(data.Receiver)). Sub(rewardsPoolBalance...) - rewardsAllocated := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.consumerChain.ChainID). + rewardsAllocated := providerKeeper.GetConsumerRewardsAllocation(s.providerCtx(), s.getFirstBundle().ConsumerId). Rewards.Sub(consumerRewardsAllocations.Rewards) if !tc.expErr { @@ -739,11 +739,11 @@ func (s *CCVTestSuite) TestAllocateTokens() { // Allocate rewards evenly between consumers rewardsPerChain := totalRewards.QuoInt(math.NewInt(int64(len(s.consumerBundles)))) - for chainID := range s.consumerBundles { + for consumerId := range s.consumerBundles { // update consumer allocation providerKeeper.SetConsumerRewardsAllocation( providerCtx, - chainID, + consumerId, providertypes.ConsumerRewardsAllocation{ Rewards: sdk.NewDecCoinsFromCoins(rewardsPerChain...), }, @@ -797,7 +797,7 @@ func (s *CCVTestSuite) TestAllocateTokens() { // check that the total expected rewards are transferred to the distribution module account // store the decimal remainders in the consumer reward allocations - allocRemainderPerChain := providerKeeper.GetConsumerRewardsAllocation(providerCtx, s.consumerChain.ChainID).Rewards + allocRemainderPerChain := providerKeeper.GetConsumerRewardsAllocation(providerCtx, s.getFirstBundle().ConsumerId).Rewards // compute the total rewards distributed to the distribution module balance (validator outstanding rewards + community pool tax), totalRewardsDistributed := sdk.NewDecCoinsFromCoins(totalRewards...).Sub(allocRemainderPerChain.MulDec(math.LegacyNewDec(int64(consNum)))) @@ -843,7 +843,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { distributionKeeper := s.providerApp.GetTestDistributionKeeper() bankKeeper := s.providerApp.GetTestBankKeeper() - chainID := s.consumerChain.ChainID + consumerId := s.getFirstBundle().ConsumerId testCases := []struct { name string @@ -889,11 +889,11 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { ctx.BlockHeight()) // change the consumer valset - consuVals, err := providerKeeper.GetConsumerValSet(ctx, chainID) + consuVals, err := providerKeeper.GetConsumerValSet(ctx, consumerId) s.Require().NoError(err) - providerKeeper.DeleteConsumerValSet(ctx, chainID) - providerKeeper.SetConsumerValSet(ctx, chainID, consuVals[0:tc.consuValLen]) - consuVals, err = providerKeeper.GetConsumerValSet(ctx, chainID) + providerKeeper.DeleteConsumerValSet(ctx, consumerId) + providerKeeper.SetConsumerValSet(ctx, consumerId, consuVals[0:tc.consuValLen]) + consuVals, err = providerKeeper.GetConsumerValSet(ctx, consumerId) s.Require().NoError(err) // set the same consumer commission rate for all consumer validators @@ -901,7 +901,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { provAddr := providertypes.NewProviderConsAddress(sdk.ConsAddress(v.ProviderConsAddr)) err := providerKeeper.SetConsumerCommissionRate( ctx, - chainID, + consumerId, provAddr, tc.rate, ) @@ -911,7 +911,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidators() { // allocate tokens res := providerKeeper.AllocateTokensToConsumerValidators( ctx, - chainID, + consumerId, tc.tokens, ) @@ -981,7 +981,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida distributionKeeper := s.providerApp.GetTestDistributionKeeper() bankKeeper := s.providerApp.GetTestBankKeeper() - chainID := s.consumerChain.ChainID + consumerId := s.getFirstBundle().ConsumerId tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))} rate := math.LegacyOneDec() @@ -994,7 +994,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida ctx = ctx.WithBlockHeight(providerKeeper.GetNumberOfEpochsToStartReceivingRewards(ctx)*providerKeeper.GetBlocksPerEpoch(ctx) + 1) // update the consumer validators - consuVals, err := providerKeeper.GetConsumerValSet(ctx, chainID) + consuVals, err := providerKeeper.GetConsumerValSet(ctx, consumerId) s.Require().NoError(err) // first 2 validators were consumer validators since block height 1 and hence get rewards consuVals[0].JoinHeight = 1 @@ -1003,11 +1003,11 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida // have not been consumer validators for `GetNumberOfEpochsToStartReceivingRewards * GetBlocksPerEpoch` blocks consuVals[2].JoinHeight = 2 consuVals[3].JoinHeight = 2 - providerKeeper.SetConsumerValSet(ctx, chainID, consuVals) + providerKeeper.SetConsumerValSet(ctx, consumerId, consuVals) - providerKeeper.DeleteConsumerValSet(ctx, chainID) - providerKeeper.SetConsumerValSet(ctx, chainID, consuVals) - consuVals, err = providerKeeper.GetConsumerValSet(ctx, chainID) + providerKeeper.DeleteConsumerValSet(ctx, consumerId) + providerKeeper.SetConsumerValSet(ctx, consumerId, consuVals) + consuVals, err = providerKeeper.GetConsumerValSet(ctx, consumerId) s.Require().NoError(err) // set the same consumer commission rate for all consumer validators @@ -1015,7 +1015,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida provAddr := providertypes.NewProviderConsAddress(sdk.ConsAddress(v.ProviderConsAddr)) err := providerKeeper.SetConsumerCommissionRate( ctx, - chainID, + consumerId, provAddr, rate, ) @@ -1025,7 +1025,7 @@ func (s *CCVTestSuite) TestAllocateTokensToConsumerValidatorsWithDifferentValida // allocate tokens res := providerKeeper.AllocateTokensToConsumerValidators( ctx, - chainID, + consumerId, tokens, ) @@ -1101,8 +1101,8 @@ func (s *CCVTestSuite) TestMultiConsumerRewardsDistribution() { // Iterate over the consumers and perform the reward distribution // to the provider - for chainID := range s.consumerBundles { - bundle := s.consumerBundles[chainID] + for consumerId := range s.consumerBundles { + bundle := s.consumerBundles[consumerId] consumerKeeper := bundle.App.GetConsumerKeeper() bankKeeper := bundle.App.GetTestBankKeeper() accountKeeper := bundle.App.GetTestAccountKeeper() diff --git a/tests/integration/double_vote.go b/tests/integration/double_vote.go index 2f275fd95c..b4c9f82c10 100644 --- a/tests/integration/double_vote.go +++ b/tests/integration/double_vote.go @@ -42,7 +42,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { equivocationEvidenceMinHeight := uint64(s.consumerCtx().BlockHeight() - 1) s.providerApp.GetProviderKeeper().SetEquivocationEvidenceMinHeight( s.providerCtx(), - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, equivocationEvidenceMinHeight, ) @@ -56,7 +56,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) consuBadVote := testutil.MakeAndSignVote( @@ -65,7 +65,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) // create two votes using the provider validator key @@ -75,7 +75,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), provValSet, provSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) provBadVote := testutil.MakeAndSignVote( @@ -84,7 +84,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), provValSet, provSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) // create two votes using the consumer validator key that both have @@ -95,7 +95,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) consuVoteOld2 := testutil.MakeAndSignVote( @@ -104,15 +104,15 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) testCases := []struct { - name string - ev *tmtypes.DuplicateVoteEvidence - chainID string - pubkey tmcrypto.PubKey - expPass bool + name string + ev *tmtypes.DuplicateVoteEvidence + consumerId string + pubkey tmcrypto.PubKey + expPass bool }{ { "cannot find consumer chain for the given chain ID - shouldn't pass", @@ -123,7 +123,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - "chainID", + "consumerId", consuVal.PubKey, false, }, @@ -136,7 +136,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consuVal.PubKey, false, }, @@ -149,7 +149,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consuVal.PubKey, false, }, @@ -162,7 +162,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, provVal.PubKey, false, }, @@ -176,7 +176,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consuVal.PubKey, false, }, @@ -193,7 +193,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consuVal.PubKey, true, }, @@ -207,7 +207,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { TotalVotingPower: consuVal.VotingPower, Timestamp: s.consumerCtx().BlockTime(), }, - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, provVal.PubKey, true, }, @@ -216,7 +216,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { for _, tc := range testCases { s.Run(tc.name, func() { consuAddr := types.NewConsumerConsAddress(sdk.ConsAddress(tc.ev.VoteA.ValidatorAddress.Bytes())) - provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, consuAddr) + provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.getFirstBundle().ConsumerId, consuAddr) validator, _ := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) initialTokens := math.LegacyNewDecFromInt(validator.GetTokens()) @@ -228,7 +228,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { // we remove the consumer key assigned to the validator otherwise // HandleConsumerDoubleVoting uses the consumer key to verify the signature if tc.ev.VoteA.ValidatorAddress.String() != consuVal.Address.String() { - s.providerApp.GetProviderKeeper().DeleteKeyAssignments(provCtx, s.consumerChain.ChainID) + s.providerApp.GetProviderKeeper().DeleteKeyAssignments(provCtx, s.getFirstBundle().ConsumerId) } // convert validator public key @@ -237,8 +237,8 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVoting() { err = s.providerApp.GetProviderKeeper().HandleConsumerDoubleVoting( provCtx, + tc.consumerId, tc.ev, - tc.chainID, pk, ) @@ -296,7 +296,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) consuBadVote := testutil.MakeAndSignVote( @@ -305,7 +305,7 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele s.consumerCtx().BlockTime(), consuValSet, consuSigner, - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, ) // In order to create an evidence for a consumer chain, @@ -320,14 +320,13 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele Timestamp: s.consumerCtx().BlockTime(), } - chainID := s.consumerChain.ChainID pubKey := consuVal.PubKey consuAddr := types.NewConsumerConsAddress(sdk.ConsAddress(consuVal.Address.Bytes())) - provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, consuAddr) + provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.getFirstBundle().ConsumerId, consuAddr) consuAddr2 := types.NewConsumerConsAddress(sdk.ConsAddress(consuVal2.Address.Bytes())) - provAddr2 := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, consuAddr2) + provAddr2 := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.getFirstBundle().ConsumerId, consuAddr2) validator, err := s.providerApp.GetTestStakingKeeper().GetValidator(s.providerCtx(), provAddr.ToSdkConsAddr().Bytes()) s.Require().NoError(err) @@ -392,8 +391,8 @@ func (s *CCVTestSuite) TestHandleConsumerDoubleVotingSlashesUndelegationsAndRele // cause double voting err = s.providerApp.GetProviderKeeper().HandleConsumerDoubleVoting( s.providerCtx(), + s.getFirstBundle().ConsumerId, evidence, - chainID, pk, ) s.Require().NoError(err) diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go index 5a55c75079..259979e351 100644 --- a/tests/integration/expired_client.go +++ b/tests/integration/expired_client.go @@ -36,7 +36,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() { s.nextEpoch() // check that the packet was added to the list of pending VSC packets - packets := providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + packets := providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().NotEmpty(packets, "no pending VSC packets found") s.Require().Equal(1, len(packets), "unexpected number of pending VSC packets") @@ -44,7 +44,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() { s.nextEpoch() // check that the packet is still in the list of pending VSC packets - packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().NotEmpty(packets, "no pending VSC packets found") s.Require().Equal(1, len(packets), "unexpected number of pending VSC packets") @@ -55,7 +55,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() { s.nextEpoch() // check that the packets are still in the list of pending VSC packets - packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().NotEmpty(packets, "no pending VSC packets found") s.Require().Equal(2, len(packets), "unexpected number of pending VSC packets") @@ -66,7 +66,7 @@ func (s *CCVTestSuite) TestVSCPacketSendExpiredClient() { s.nextEpoch() // check that the packets are not in the list of pending VSC packets - packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + packets = providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().Empty(packets, "unexpected pending VSC packets found") // check that validator updates work @@ -105,7 +105,7 @@ func (s *CCVTestSuite) TestConsumerPacketSendExpiredClient() { s.nextEpoch() // check that the packets are not in the list of pending VSC packets - providerPackets := providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + providerPackets := providerKeeper.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().Empty(providerPackets, "pending VSC packets found") // relay all VSC packet from provider to consumer diff --git a/tests/integration/key_assignment.go b/tests/integration/key_assignment.go index c6478d98ba..73defc1b57 100644 --- a/tests/integration/key_assignment.go +++ b/tests/integration/key_assignment.go @@ -24,14 +24,14 @@ func (s *CCVTestSuite) TestKeyAssignment() { "assignment during channel init", func(pk *providerkeeper.Keeper) error { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } // check that a VSCPacket is queued s.nextEpoch() - pendingPackets := pk.GetPendingVSCPackets(s.providerCtx(), s.consumerChain.ChainID) + pendingPackets := pk.GetPendingVSCPackets(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().Len(pendingPackets, 1) // establish CCV channel @@ -47,7 +47,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -63,7 +63,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -85,14 +85,14 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } // same key assignment, but different validator validator2, _ := generateNewConsumerKey(s, 1) - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator2, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator2, consumerKey) if err != nil { return err } @@ -108,13 +108,13 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } // same key assignment, but different validator - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -130,14 +130,14 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } // same key assignment validator, consumerKey = generateNewConsumerKey(s, 0) - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -153,7 +153,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -161,7 +161,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // same key assignment validator2, _ := generateNewConsumerKey(s, 1) - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator2, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator2, consumerKey) if err != nil { return err } @@ -177,14 +177,14 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } s.nextEpoch() // same key assignment - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -200,7 +200,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // key assignment validator, consumerKey := generateNewConsumerKey(s, 0) - err := pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err := pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } @@ -208,7 +208,7 @@ func (s *CCVTestSuite) TestKeyAssignment() { // same key assignment validator, consumerKey = generateNewConsumerKey(s, 0) - err = pk.AssignConsumerKey(s.providerCtx(), s.consumerChain.ChainID, validator, consumerKey) + err = pk.AssignConsumerKey(s.providerCtx(), s.getFirstBundle().ConsumerId, validator, consumerKey) if err != nil { return err } diff --git a/tests/integration/misbehaviour.go b/tests/integration/misbehaviour.go index 5924c90df1..127b3a23a3 100644 --- a/tests/integration/misbehaviour.go +++ b/tests/integration/misbehaviour.go @@ -34,7 +34,7 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() { misb := &ibctmtypes.Misbehaviour{ ClientId: s.path.EndpointA.ClientID, Header1: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime, @@ -46,7 +46,7 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() { // create a different header by changing the header timestamp only // in order to create an equivocation, i.e. both headers have the same deterministic states Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(10*time.Second), @@ -61,13 +61,13 @@ func (s *CCVTestSuite) TestHandleConsumerMisbehaviour() { validator, _ := s.getValByIdx(0) initialTokens := math.LegacyNewDecFromInt(validator.GetTokens()) - err := s.providerApp.GetProviderKeeper().HandleConsumerMisbehaviour(s.providerCtx(), *misb) + err := s.providerApp.GetProviderKeeper().HandleConsumerMisbehaviour(s.providerCtx(), s.getFirstBundle().ConsumerId, *misb) s.NoError(err) // verify that validators are jailed, tombstoned, and slashed for _, v := range clientTMValset.Validators { consuAddr := sdk.ConsAddress(v.Address.Bytes()) - provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.consumerChain.ChainID, types.NewConsumerConsAddress(consuAddr)) + provAddr := s.providerApp.GetProviderKeeper().GetProviderAddrFromConsumerAddr(s.providerCtx(), s.getFirstBundle().ConsumerId, types.NewConsumerConsAddress(consuAddr)) val, err := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), provAddr.Address) s.Require().NoError(err) s.Require().True(val.Jailed) @@ -102,7 +102,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { // create a consumer client header clientHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime, @@ -144,7 +144,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { "incorrect valset - shouldn't pass", func() *ibctmtypes.Misbehaviour { clientHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Minute), @@ -155,7 +155,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { ) clientHeaderWithCorruptedValset := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Hour), @@ -181,7 +181,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { "incorrect valset 2 - shouldn't pass", func() *ibctmtypes.Misbehaviour { clientHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Minute), @@ -192,7 +192,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { ) clientHeaderWithCorruptedSigs := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Hour), @@ -220,7 +220,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { "incorrect signatures - shouldn't pass", func() *ibctmtypes.Misbehaviour { clientHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Minute), @@ -231,7 +231,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { ) clientHeaderWithCorruptedSigs := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Hour), @@ -262,7 +262,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { // the resulting header contains invalid fields // i.e. ValidatorsHash, NextValidatorsHash. Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime, @@ -286,7 +286,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { Header1: clientHeader, // the resulting header contains a different BlockID Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Minute), @@ -308,7 +308,7 @@ func (s *CCVTestSuite) TestGetByzantineValidators() { // create a valid header with a different hash // and commit round amnesiaHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, altTime.Add(time.Minute), @@ -383,7 +383,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { // create a valid client header clientHeader := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, headerTs, @@ -402,7 +402,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { // create a conflicting client with different block ID using // to alternative validator set clientHeaderWithDiffBlockID := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, headerTs, @@ -419,7 +419,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { // create a conflicting client header with insufficient voting power clientHeaderWithInsufficientVotingPower := s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+1), clientHeight, // use a different block time to change the header BlockID @@ -434,7 +434,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { equivocationEvidenceMinHeight := clientHeight.RevisionHeight + 1 s.providerApp.GetProviderKeeper().SetEquivocationEvidenceMinHeight( s.providerCtx(), - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, equivocationEvidenceMinHeight, ) @@ -485,7 +485,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { ClientId: s.path.EndpointA.ClientID, Header1: clientHeader, Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(clientHeight.RevisionHeight+2), clientHeight, headerTs, @@ -502,7 +502,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { &ibctmtypes.Misbehaviour{ ClientId: s.path.EndpointA.ClientID, Header1: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(equivocationEvidenceMinHeight-1), clientHeight, headerTs, @@ -512,7 +512,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { altSigners, ), Header2: s.consumerChain.CreateTMClientHeader( - s.consumerChain.ChainID, + s.getFirstBundle().Chain.ChainID, int64(equivocationEvidenceMinHeight-1), clientHeight, headerTs, @@ -547,7 +547,7 @@ func (s *CCVTestSuite) TestCheckMisbehaviour() { for _, tc := range testCases { s.Run(tc.name, func() { - err := s.providerApp.GetProviderKeeper().CheckMisbehaviour(s.providerCtx(), *tc.misbehaviour) + err := s.providerApp.GetProviderKeeper().CheckMisbehaviour(s.providerCtx(), s.getFirstBundle().ConsumerId, *tc.misbehaviour) cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), s.path.EndpointA.ClientID) s.Require().True(ok) // verify that the client wasn't frozen diff --git a/tests/integration/partial_set_security_test.go b/tests/integration/partial_set_security_test.go index ebc6336fee..e99ce6f44a 100644 --- a/tests/integration/partial_set_security_test.go +++ b/tests/integration/partial_set_security_test.go @@ -1,6 +1,7 @@ package integration import ( + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "slices" "sort" "testing" @@ -151,7 +152,9 @@ func TestMinStake(t *testing.T) { // adjust parameters // set the minStake according to the test case - providerKeeper.SetMinStake(s.providerChain.GetContext(), s.consumerChain.ChainID, tc.minStake) + providerKeeper.SetConsumerPowerShapingParameters(s.providerChain.GetContext(), s.getFirstBundle().ConsumerId, types.PowerShapingParameters{ + MinStake: tc.minStake, + }) // delegate and undelegate to trigger a vscupdate diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go index 813a62a671..0890436781 100644 --- a/tests/integration/provider_gov_hooks.go +++ b/tests/integration/provider_gov_hooks.go @@ -13,33 +13,55 @@ import ( testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" ) -// tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks -// hooks require adding a proposal in the gov module and registering a consumer chain with the provider module +// TestAfterPropSubmissionAndVotingPeriodEnded tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks +// require adding a proposal in the gov module and registering a consumer chain with the provider module func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() { ctx := s.providerChain.GetContext() providerKeeper := s.providerApp.GetProviderKeeper() govKeeper := s.providerApp.GetTestGovKeeper() proposer := s.providerChain.SenderAccount - addConsumerProp := testkeeper.GetTestMsgConsumerAddition() + msgUpdateConsumer := testkeeper.GetTestMsgUpdateConsumer() - proposal, err := v1.NewProposal([]sdk.Msg{&addConsumerProp}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + proposal, err := v1.NewProposal([]sdk.Msg{&msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) s.Require().NoError(err) err = govKeeper.SetProposal(ctx, proposal) s.Require().NoError(err) - providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) + // the proposal can only be submitted if the owner of the chain is the gov module + providerKeeper.SetConsumerOwnerAddress(ctx, msgUpdateConsumer.ConsumerId, "some bogus address") - // verify that the proposal ID is created - proposalIdOnProvider, ok := providerKeeper.GetProposedConsumerChain(ctx, proposal.Id) + err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) + s.Require().Error(err) + + // the proposal can only be submitted if the owner of the chain is the gov module + govModuleAddress := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" + providerKeeper.SetConsumerOwnerAddress(ctx, msgUpdateConsumer.ConsumerId, govModuleAddress) + + err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) + s.Require().NoError(err) + + // verify that the proposal id is created + consumerIdOnProvider, ok := providerKeeper.GetProposalIdToConsumerId(ctx, proposal.Id) s.Require().True(ok) - s.Require().NotEmpty(proposalIdOnProvider) - s.Require().Equal(addConsumerProp.ChainId, proposalIdOnProvider) + s.Require().NotEmpty(consumerIdOnProvider) + s.Require().Equal(msgUpdateConsumer.ConsumerId, consumerIdOnProvider) providerKeeper.Hooks().AfterProposalVotingPeriodEnded(ctx, proposal.Id) - // verify that the proposal ID is deleted - s.Require().Empty(providerKeeper.GetProposedConsumerChain(ctx, proposal.Id)) + // verify that the proposal id is deleted + s.Require().Empty(providerKeeper.GetProposalIdToConsumerId(ctx, proposal.Id)) + + // assert that a proposal with more than one `MsgUpdateConsumer` messages fails + proposal, err = v1.NewProposal([]sdk.Msg{&msgUpdateConsumer, &msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) + s.Require().NoError(err) + + err = govKeeper.SetProposal(ctx, proposal) + s.Require().NoError(err) + + err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) + s.Require().Error(err) + } func (s *CCVTestSuite) TestGetConsumerAdditionFromProp() { diff --git a/tests/integration/setup.go b/tests/integration/setup.go index eeb980200f..20924e9b2e 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -3,6 +3,7 @@ package integration import ( "context" "fmt" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "testing" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -21,7 +22,6 @@ import ( icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" testutil "github.com/cosmos/interchain-security/v5/testutil/integration" consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -60,7 +60,7 @@ type CCVTestSuite struct { // The transfer path to the first consumer among multiple. transferPath *ibctesting.Path - // A map from consumer chain ID to its consumer bundle. + // A map from consumer id to its consumer bundle. // The preferred way to access chains, apps, and paths when designing tests around multiple consumers. consumerBundles map[string]*icstestingutils.ConsumerBundle skippedTests map[string]bool @@ -149,35 +149,28 @@ func (suite *CCVTestSuite) SetupTest() { // 1. the consumer chain is added to the coordinator // 2. MakeGenesis is called on the provider chain // 3. ibc/testing sets the tendermint header for the consumer chain app - providerKeeper.SetPendingConsumerAdditionProp(suite.providerCtx(), &types.ConsumerAdditionProposal{ - ChainId: icstestingutils.FirstConsumerChainID, - }) - ps := providerKeeper.GetAllPendingConsumerAdditionProps(suite.providerCtx()) - preProposalKeyAssignment(suite, icstestingutils.FirstConsumerChainID) - // remove props so they don't interfere with the rest of the setup - // if not removed here, setupConsumerCallback will have 2 proposals for adding the first consumer chain - providerKeeper.DeletePendingConsumerAdditionProps(suite.providerCtx(), ps...) + providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, keeper.Initialized) + preProposalKeyAssignment(suite, icstestingutils.FirstConsumerId) // start consumer chains suite.consumerBundles = make(map[string]*icstestingutils.ConsumerBundle) for i := 0; i < icstestingutils.NumConsumers; i++ { bundle := suite.setupConsumerCallback(&suite.Suite, suite.coordinator, i) - suite.consumerBundles[bundle.Chain.ChainID] = bundle + suite.consumerBundles[bundle.ConsumerId] = bundle suite.registerPacketSniffer(bundle.Chain) // check that TopN is correctly set for the consumer - topN, found := providerKeeper.GetTopN(suite.providerCtx(), bundle.Chain.ChainID) - suite.Require().True(found) + topN := providerKeeper.GetTopN(suite.providerCtx(), bundle.ConsumerId) suite.Require().Equal(bundle.TopN, topN) } // initialize each consumer chain with it's corresponding genesis state // stored on the provider. - for chainID := range suite.consumerBundles { + for consumerId := range suite.consumerBundles { consumerGenesisState, found := providerKeeper.GetConsumerGenesis( suite.providerCtx(), - chainID, + consumerId, ) suite.Require().True(found, "consumer genesis not found") @@ -186,7 +179,7 @@ func (suite *CCVTestSuite) SetupTest() { Provider: consumerGenesisState.Provider, NewChain: consumerGenesisState.NewChain, } - initConsumerChain(suite, chainID, &genesisState) + initConsumerChain(suite, consumerId, &genesisState) } // try updating all clients @@ -221,11 +214,11 @@ func (s *CCVTestSuite) getSentPacket(chain *ibctesting.TestChain, sequence uint6 // initConsumerChain initializes a consumer chain given a genesis state func initConsumerChain( s *CCVTestSuite, - chainID string, + consumerId string, genesisState *consumertypes.GenesisState, ) { providerKeeper := s.providerApp.GetProviderKeeper() - bundle := s.consumerBundles[chainID] + bundle := s.consumerBundles[consumerId] // run CCV module init genesis s.NotPanics(func() { @@ -249,7 +242,7 @@ func initConsumerChain( // Set provider endpoint's clientID for each consumer providerEndpointClientID, found := providerKeeper.GetConsumerClientId( s.providerCtx(), - chainID, + consumerId, ) s.Require().True(found, "provider endpoint clientID not found") bundle.Path.EndpointB.ClientID = providerEndpointClientID @@ -291,7 +284,7 @@ func initConsumerChain( err = bundle.Path.EndpointA.UpdateClient() s.Require().NoError(err) - if chainID == icstestingutils.FirstConsumerChainID { + if consumerId == "2" { // Support tests that were written before multiple consumers were supported. firstBundle := s.getFirstBundle() s.consumerApp = firstBundle.App @@ -379,14 +372,14 @@ func (suite *CCVTestSuite) SetupAllTransferChannels() { suite.SetupTransferChannel() // setup all the remaining consumers transfer channels - for chainID := range suite.consumerBundles { + for consumerId := range suite.consumerBundles { // skip fist consumer - if chainID == suite.consumerChain.ChainID { + if consumerId == suite.getFirstBundle().ConsumerId { continue } // get the bundle for the chain ID - bundle := suite.consumerBundles[chainID] + bundle := suite.consumerBundles[consumerId] // setup the transfer channel suite.setupTransferChannel( bundle.TransferPath, @@ -423,9 +416,9 @@ func (s CCVTestSuite) validateEndpointsClientConfig(consumerBundle icstestinguti } // preProposalKeyAssignment assigns keys to all provider validators for -// the consumer with chainID before the chain is registered, i.e., +// the consumer with consumerId before the chain is registered, i.e., // before a client to the consumer is created -func preProposalKeyAssignment(s *CCVTestSuite, chainID string) { +func preProposalKeyAssignment(s *CCVTestSuite, consumerId string) { providerKeeper := s.providerApp.GetProviderKeeper() for _, val := range s.providerChain.Vals.Validators { @@ -445,7 +438,7 @@ func preProposalKeyAssignment(s *CCVTestSuite, chainID string) { // as a result, NewTestChainWithValSet in AddConsumer uses providerChain.Signers s.providerChain.Signers[tmPubKey.Address().String()] = privVal - err = providerKeeper.AssignConsumerKey(s.providerCtx(), chainID, validator, consumerKey) + err = providerKeeper.AssignConsumerKey(s.providerCtx(), consumerId, validator, consumerKey) s.Require().NoError(err) } } diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go index eab288deb3..8156672a0d 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -57,7 +57,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { // map consumer consensus address to provider consensus address providerConsAddr, found := providerKeeper.GetValidatorByConsumerAddr( s.providerCtx(), - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consumerConsAddr, ) s.Require().True(found) @@ -188,7 +188,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { // map consumer consensus address to provider consensus address providerConsAddr, found := providerKeeper.GetValidatorByConsumerAddr( s.providerCtx(), - s.consumerChain.ChainID, + s.getFirstBundle().ConsumerId, consumerConsAddr) s.Require().True(found) @@ -307,7 +307,7 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() { suite.Require().Equal(stakingtypes.Bonded, validator.GetStatus()) // set init VSC id for chain0 - providerKeeper.SetInitChainHeight(suite.providerCtx(), suite.consumerChain.ChainID, uint64(suite.providerCtx().BlockHeight())) + providerKeeper.SetInitChainHeight(suite.providerCtx(), suite.getFirstBundle().ConsumerId, uint64(suite.providerCtx().BlockHeight())) // set validator signing-info providerSlashingKeeper.SetValidatorSigningInfo( @@ -316,7 +316,7 @@ func (suite *CCVTestSuite) TestHandleSlashPacketDowntime() { slashingtypes.ValidatorSigningInfo{Address: consAddr.String()}, ) - providerKeeper.HandleSlashPacket(suite.providerCtx(), suite.consumerChain.ChainID, + providerKeeper.HandleSlashPacket(suite.providerCtx(), suite.getFirstBundle().ConsumerId, *ccv.NewSlashPacketData( abci.Validator{Address: tmVal.Address, Power: 0}, uint64(0), @@ -413,7 +413,7 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() { suite.Require().NoError(err, "no error expected") suite.Require().Equal(ccv.SlashPacketHandledResult, ackResult, "expected successful ack") - providerKeeper.SetConsumerValidator(ctx, firstBundle.Chain.ChainID, providertypes.ConsensusValidator{ + providerKeeper.SetConsumerValidator(ctx, firstBundle.ConsumerId, providertypes.ConsensusValidator{ ProviderConsAddr: validAddress, }) diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index 839bd10771..c296026e0a 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -75,8 +75,8 @@ func (s *CCVTestSuite) TestStopConsumerChain() { }, { func(suite *CCVTestSuite) error { - providerKeeper.SetSlashAcks(s.providerCtx(), firstBundle.Chain.ChainID, []string{"validator-1", "validator-2", "validator-3"}) - providerKeeper.AppendPendingVSCPackets(s.providerCtx(), firstBundle.Chain.ChainID, ccv.ValidatorSetChangePacketData{ValsetUpdateId: 1}) + providerKeeper.SetSlashAcks(s.providerCtx(), firstBundle.ConsumerId, []string{"validator-1", "validator-2", "validator-3"}) + providerKeeper.AppendPendingVSCPackets(s.providerCtx(), firstBundle.ConsumerId, ccv.ValidatorSetChangePacketData{ValsetUpdateId: 1}) return nil }, }, @@ -88,11 +88,11 @@ func (s *CCVTestSuite) TestStopConsumerChain() { } // stop the consumer chain - err = providerKeeper.StopConsumerChain(s.providerCtx(), firstBundle.Chain.ChainID, true) + err = providerKeeper.StopConsumerChain(s.providerCtx(), firstBundle.ConsumerId, true) s.Require().NoError(err) // check all states are removed and the unbonding operation released - s.checkConsumerChainIsRemoved(firstBundle.Chain.ChainID, true) + s.checkConsumerChainIsRemoved(firstBundle.ConsumerId, true) } // TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end @@ -105,7 +105,7 @@ func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() { providerKeeper := s.providerApp.GetProviderKeeper() // stop the consumer chain - err := providerKeeper.StopConsumerChain(s.providerCtx(), s.consumerChain.ChainID, true) + err := providerKeeper.StopConsumerChain(s.providerCtx(), s.getFirstBundle().ConsumerId, true) s.Require().NoError(err) err = s.path.EndpointA.UpdateClient() @@ -126,7 +126,7 @@ func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() { // s.Require().False(found) } -func (s *CCVTestSuite) checkConsumerChainIsRemoved(chainID string, checkChannel bool) { +func (s *CCVTestSuite) checkConsumerChainIsRemoved(consumerId string, checkChannel bool) { channelID := s.path.EndpointB.ChannelID providerKeeper := s.providerApp.GetProviderKeeper() @@ -136,18 +136,18 @@ func (s *CCVTestSuite) checkConsumerChainIsRemoved(chainID string, checkChannel } // verify consumer chain's states are removed - _, found := providerKeeper.GetConsumerGenesis(s.providerCtx(), chainID) + _, found := providerKeeper.GetConsumerGenesis(s.providerCtx(), consumerId) s.Require().False(found) - _, found = providerKeeper.GetConsumerClientId(s.providerCtx(), chainID) + _, found = providerKeeper.GetConsumerClientId(s.providerCtx(), consumerId) s.Require().False(found) - _, found = providerKeeper.GetChainToChannel(s.providerCtx(), chainID) + _, found = providerKeeper.GetConsumerIdToChannelId(s.providerCtx(), consumerId) s.Require().False(found) - _, found = providerKeeper.GetChannelToChain(s.providerCtx(), channelID) + _, found = providerKeeper.GetChannelIdToConsumerId(s.providerCtx(), channelID) s.Require().False(found) - s.Require().Nil(providerKeeper.GetSlashAcks(s.providerCtx(), chainID)) - s.Require().Zero(providerKeeper.GetInitChainHeight(s.providerCtx(), chainID)) - s.Require().Empty(providerKeeper.GetPendingVSCPackets(s.providerCtx(), chainID)) + s.Require().Nil(providerKeeper.GetSlashAcks(s.providerCtx(), consumerId)) + s.Require().Zero(providerKeeper.GetInitChainHeight(s.providerCtx(), consumerId)) + s.Require().Empty(providerKeeper.GetPendingVSCPackets(s.providerCtx(), consumerId)) } diff --git a/tests/mbt/driver/core.go b/tests/mbt/driver/core.go index 2cd618096f..8d0332f504 100644 --- a/tests/mbt/driver/core.go +++ b/tests/mbt/driver/core.go @@ -220,7 +220,7 @@ func (s *Driver) getStateString() string { state.WriteString("\n") state.WriteString("Consumers Chains:\n") - chainIds := s.providerKeeper().GetAllRegisteredConsumerChainIDs(s.providerCtx()) + chainIds := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) state.WriteString(strings.Join(chainIds, ", ")) state.WriteString("\n\n") @@ -258,7 +258,7 @@ func (s *Driver) getChainStateString(chain ChainId) string { if !s.isProviderChain(chain) { // Check whether the chain is in the consumer chains on the provider - consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerChainIDs(s.providerCtx()) + consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) found := false for _, consumerChainID := range consumerChainIDs { @@ -366,7 +366,7 @@ func (s *Driver) endAndBeginBlock(chain ChainId, timeAdvancement time.Duration) } func (s *Driver) runningConsumerChainIDs() []ChainId { - consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerChainIDs(s.providerCtx()) + consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) consumersWithIntactChannel := make([]ChainId, 0) for _, consumerChainID := range consumerIDsOnProvider { diff --git a/tests/mbt/driver/setup.go b/tests/mbt/driver/setup.go index d9e658c030..adaa444167 100644 --- a/tests/mbt/driver/setup.go +++ b/tests/mbt/driver/setup.go @@ -12,6 +12,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v8/testing" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/stretchr/testify/require" @@ -388,7 +389,9 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC require.NoError(s.t, err, "Error setting consumer genesis on provider for chain %v", consumerChain.ChainID) // set the top N percentage to 100 to simulate a full consumer - s.providerKeeper().SetTopN(providerChain.GetContext(), consumerChain.ChainID, 100) + s.providerKeeper().SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerChain.ChainID, types.PowerShapingParameters{ + Top_N: 100, + }) // Client ID is set in InitGenesis and we treat it as a black box. So // must query it to use it with the endpoint. diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 3aaae5702f..d9aa02d732 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -3,9 +3,10 @@ package ibc_testing import ( "encoding/json" "fmt" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "testing" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" "github.com/stretchr/testify/require" @@ -37,7 +38,7 @@ const ( ) var ( - FirstConsumerChainID string + FirstConsumerId string provChainID string democConsumerChainID string consumerTopNParams [NumConsumers]uint32 @@ -46,7 +47,7 @@ var ( func init() { // Disable revision format ibctesting.ChainIDSuffix = "" - FirstConsumerChainID = ibctesting.GetChainID(2) + FirstConsumerId = "2" provChainID = ibctesting.GetChainID(1) democConsumerChainID = ibctesting.GetChainID(5000) // TopN parameter values per consumer chain initiated @@ -57,6 +58,7 @@ func init() { // ConsumerBundle serves as a way to store useful in-mem consumer app chain state // and relevant IBC paths in the context of CCV integration testing. type ConsumerBundle struct { + ConsumerId string Chain *ibctesting.TestChain App testutil.ConsumerApp Path *ibctesting.Path @@ -138,20 +140,26 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerApp := providerChain.App.(Tp) providerKeeper := providerApp.GetProviderKeeper() - prop := testkeeper.GetTestConsumerAdditionProp() - prop.ChainId = chainID - prop.Top_N = consumerTopNParams[index] // isn't used in CreateConsumerClient + consumerMetadata := testkeeper.GetTestConsumerMetadata() + initializationParameters := testkeeper.GetTestInitializationParameters() // NOTE: we cannot use the time.Now() because the coordinator chooses a hardcoded start time // using time.Now() could set the spawn time to be too far in the past or too far in the future - prop.SpawnTime = coordinator.CurrentTime + initializationParameters.SpawnTime = coordinator.CurrentTime // NOTE: the initial height passed to CreateConsumerClient // must be the height on the consumer when InitGenesis is called - prop.InitialHeight = clienttypes.Height{RevisionNumber: 0, RevisionHeight: 2} + initializationParameters.InitialHeight = clienttypes.Height{RevisionNumber: 0, RevisionHeight: 2} + + powerShapingParameters := testkeeper.GetTestPowerShapingParameters() + powerShapingParameters.Top_N = consumerTopNParams[index] // isn't used in CreateConsumerClient - providerKeeper.SetPendingConsumerAdditionProp(providerChain.GetContext(), prop) - props := providerKeeper.GetAllPendingConsumerAdditionProps(providerChain.GetContext()) - s.Require().Len(props, 1, "unexpected len consumer addition proposals in AddConsumer") + consumerId := fmt.Sprintf("%d", index+2) + providerKeeper.SetConsumerChainId(providerChain.GetContext(), consumerId, chainID) + providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata) + providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) + providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) + providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, keeper.Initialized) + providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) // opt-in all validators lastVals, err := providerApp.GetProviderKeeper().GetLastBondedValidators(providerChain.GetContext()) @@ -159,7 +167,8 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( for _, v := range lastVals { consAddr, _ := v.GetConsAddr() - providerKeeper.SetOptedIn(providerChain.GetContext(), chainID, providertypes.NewProviderConsAddress(consAddr)) + providerKeeper.SetOptedIn(providerChain.GetContext(), consumerId, providertypes.NewProviderConsAddress(consAddr)) + providerKeeper.AppendOptedInConsumerId(providerChain.GetContext(), providertypes.NewProviderConsAddress(consAddr), consumerId) } // commit the state on the provider chain @@ -169,8 +178,14 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( // get genesis state created by the provider consumerGenesisState, found := providerKeeper.GetConsumerGenesis( providerChain.GetContext(), - chainID, + consumerId, + ) + + foo, found := providerKeeper.GetConsumerClientId( + providerChain.GetContext(), + consumerId, ) + _ = foo s.Require().True(found, "consumer genesis not found in AddConsumer") @@ -201,8 +216,9 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( } return &ConsumerBundle{ - Chain: testChain, - App: consumerToReturn, - TopN: prop.Top_N, + ConsumerId: consumerId, + Chain: testChain, + App: consumerToReturn, + TopN: powerShapingParameters.Top_N, } } diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index 1a1cd971d5..94ef8e1f98 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -1234,6 +1234,20 @@ func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { return m.recorder } +// AddressCodec mocks base method. +func (m *MockAccountKeeper) AddressCodec() address.Codec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddressCodec") + ret0, _ := ret[0].(address.Codec) + return ret0 +} + +// AddressCodec indicates an expected call of AddressCodec. +func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressCodec", reflect.TypeOf((*MockAccountKeeper)(nil).AddressCodec)) +} + // GetModuleAccount mocks base method. func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types1.ModuleAccountI { m.ctrl.T.Helper() diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index f458ac4c3b..ef8d3a747f 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -219,6 +219,7 @@ func GetNewSlashPacketData() types.SlashPacketData { // Also see `TestProviderStateIsCleanedAfterConsumerChainIsStopped`. func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks MockedKeepers, + consumerId string, ) { t.Helper() @@ -230,9 +231,15 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, gomock.InOrder(expectations...) - prop := GetTestConsumerAdditionProp() - err := providerKeeper.CreateConsumerClient(ctx, prop) + providerKeeper.SetConsumerChainId(ctx, consumerId, "chainID") + providerKeeper.SetConsumerMetadata(ctx, consumerId, GetTestConsumerMetadata()) + providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, GetTestInitializationParameters()) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters()) + providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + + err := providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) + providerKeeper.SetClientIdToConsumerId(ctx, "clientID", consumerId) err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) } @@ -240,30 +247,69 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, // TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned // after a stopped consumer chain. func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, - expectedChainID, expectedChannelID string, + consumerId, expectedChannelID string, ) { t.Helper() - _, found := providerKeeper.GetConsumerClientId(ctx, expectedChainID) + _, found := providerKeeper.GetConsumerClientId(ctx, consumerId) require.False(t, found) - _, found = providerKeeper.GetChainToChannel(ctx, expectedChainID) + _, found = providerKeeper.GetConsumerIdToChannelId(ctx, consumerId) require.False(t, found) - _, found = providerKeeper.GetChannelToChain(ctx, expectedChannelID) + _, found = providerKeeper.GetChannelIdToConsumerId(ctx, expectedChannelID) require.False(t, found) - _, found = providerKeeper.GetInitChainHeight(ctx, expectedChainID) + _, found = providerKeeper.GetInitChainHeight(ctx, consumerId) require.False(t, found) - acks := providerKeeper.GetSlashAcks(ctx, expectedChainID) + acks := providerKeeper.GetSlashAcks(ctx, consumerId) require.Empty(t, acks) // in case the chain was successfully stopped, it should not contain a Top N associated to it - _, found = providerKeeper.GetTopN(ctx, expectedChainID) - require.False(t, found) + topN := providerKeeper.GetTopN(ctx, consumerId) + require.Zero(t, topN) // test key assignment state is cleaned - require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &expectedChainID)) - require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) - require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) - require.Empty(t, providerKeeper.GetAllCommissionRateValidators(ctx, expectedChainID)) - require.Zero(t, providerKeeper.GetEquivocationEvidenceMinHeight(ctx, expectedChainID)) + require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId)) + require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &consumerId)) + require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, consumerId)) + require.Empty(t, providerKeeper.GetAllCommissionRateValidators(ctx, consumerId)) + require.Zero(t, providerKeeper.GetEquivocationEvidenceMinHeight(ctx, consumerId)) +} + +func GetTestConsumerMetadata() providertypes.ConsumerMetadata { + return providertypes.ConsumerMetadata{ + Name: "chain name", + Description: "description", + Metadata: "metadata", + } +} + +func GetTestInitializationParameters() providertypes.ConsumerInitializationParameters { + initialHeight := clienttypes.NewHeight(4, 5) + spawnTime := time.Now() + ccvTimeoutPeriod := types.DefaultCCVTimeoutPeriod + transferTimeoutPeriod := types.DefaultTransferTimeoutPeriod + unbondingPeriod := types.DefaultConsumerUnbondingPeriod + return providertypes.ConsumerInitializationParameters{ + InitialHeight: initialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + ConsumerRedistributionFraction: types.DefaultConsumerRedistributeFrac, + BlocksPerDistributionTransmission: types.DefaultBlocksPerDistributionTransmission, + DistributionTransmissionChannel: "", + HistoricalEntries: types.DefaultHistoricalEntries, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, + UnbondingPeriod: unbondingPeriod, + } +} + +func GetTestPowerShapingParameters() providertypes.PowerShapingParameters { + return providertypes.PowerShapingParameters{ + Top_N: 0, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + } } func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { @@ -294,9 +340,17 @@ func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { return prop } +func GetTestMsgUpdateConsumer() providertypes.MsgUpdateConsumer { + return providertypes.MsgUpdateConsumer{ + Signer: "signer", + ConsumerId: "consumerId", + NewOwnerAddress: "newOwnerAddress", + } +} + func GetTestMsgConsumerAddition() providertypes.MsgConsumerAddition { return providertypes.MsgConsumerAddition{ - ChainId: "a ChainID", + ChainId: "a ChainId", InitialHeight: clienttypes.NewHeight(4, 5), GenesisHash: []byte(base64.StdEncoding.EncodeToString([]byte("gen_hash"))), BinaryHash: []byte(base64.StdEncoding.EncodeToString([]byte("bin_hash"))), diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 84fbff3fd0..34d715583c 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -40,6 +40,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdConsumerChainsValidatorHasToValidate()) cmd.AddCommand(CmdValidatorConsumerCommissionRate()) cmd.AddCommand(CmdBlocksUntilNextEpoch()) + cmd.AddCommand(CmdConsumerIdFromClientId()) return cmd } @@ -57,7 +58,7 @@ func CmdConsumerGenesis() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := types.QueryConsumerGenesisRequest{ChainId: args[0]} + req := types.QueryConsumerGenesisRequest{ConsumerId: args[0]} res, err := queryClient.QueryConsumerGenesis(cmd.Context(), &req) if err != nil { return err @@ -211,7 +212,7 @@ $ %s query provider validator-consumer-key foochain %s1gghjut3ccd8ay0zduzj64hwre } queryClient := types.NewQueryClient(clientCtx) - consumerChainID := args[0] + consumerId := args[0] addr, err := sdk.ConsAddressFromBech32(args[1]) if err != nil { @@ -219,7 +220,7 @@ $ %s query provider validator-consumer-key foochain %s1gghjut3ccd8ay0zduzj64hwre } req := &types.QueryValidatorConsumerAddrRequest{ - ChainId: consumerChainID, + ConsumerId: consumerId, ProviderAddress: addr.String(), } res, err := queryClient.QueryValidatorConsumerAddr(cmd.Context(), req) @@ -366,7 +367,7 @@ func CmdAllPairsValConAddrByConsumerChainID() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := types.QueryAllPairsValConAddrByConsumerChainIDRequest{ChainId: args[0]} + req := types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: args[0]} res, err := queryClient.QueryAllPairsValConAddrByConsumerChainID(cmd.Context(), &req) if err != nil { return err @@ -435,7 +436,7 @@ $ %s consumer-opted-in-validators foochain queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.QueryConsumerChainOptedInValidators(cmd.Context(), - &types.QueryConsumerChainOptedInValidatorsRequest{ChainId: args[0]}) + &types.QueryConsumerChainOptedInValidatorsRequest{ConsumerId: args[0]}) if err != nil { return err } @@ -470,7 +471,7 @@ $ %s consumer-validators foochain queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.QueryConsumerValidators(cmd.Context(), - &types.QueryConsumerValidatorsRequest{ChainId: args[0]}) + &types.QueryConsumerValidatorsRequest{ConsumerId: args[0]}) if err != nil { return err } @@ -554,7 +555,7 @@ $ %s validator-consumer-commission-rate foochain %s1gghjut3ccd8ay0zduzj64hwre2fx res, err := queryClient.QueryValidatorConsumerCommissionRate(cmd.Context(), &types.QueryValidatorConsumerCommissionRateRequest{ - ChainId: args[0], + ConsumerId: args[0], ProviderAddress: addr.String(), }) if err != nil { @@ -596,3 +597,30 @@ func CmdBlocksUntilNextEpoch() *cobra.Command { return cmd } + +func CmdConsumerIdFromClientId() *cobra.Command { + cmd := &cobra.Command{ + Use: "consumer-id-from-client-id [client-id]", + Short: "Query the consumer id of the chain associated with the provided client id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryConsumerIdFromClientIdRequest{ClientId: args[0]} + res, err := queryClient.QueryConsumerIdFromClientId(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 4011a36a79..4a7cef864f 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "strings" + "time" "cosmossdk.io/math" @@ -36,6 +37,9 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(NewAssignConsumerKeyCmd()) cmd.AddCommand(NewSubmitConsumerMisbehaviourCmd()) cmd.AddCommand(NewSubmitConsumerDoubleVotingCmd()) + cmd.AddCommand(NewCreateConsumerCmd()) + cmd.AddCommand(NewUpdateConsumerCmd()) + cmd.AddCommand(NewRemoveConsumerCmd()) cmd.AddCommand(NewOptInCmd()) cmd.AddCommand(NewOptOutCmd()) cmd.AddCommand(NewSetConsumerCommissionRateCmd()) @@ -209,6 +213,209 @@ Example: return cmd } +func NewCreateConsumerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-consumer [chain-id] [metadata] [initialization-parameters] [power-shaping-parameters]", + Short: "create a consumer chain", + Long: strings.TrimSpace( + fmt.Sprintf(`Create a consumer chain and get the assigned consumer id of this chain. +Note that the one that signs this message is the owner of this consumer chain. The owner can be later +changed by updating the consumer chain. + +Example: +%s tx provider create-consumer [chain-id] [path/to/metadata.json] [path/to/initialization-parameters.json] [path/to/power-shaping-parameters.json] --from node0 --home ../node0 --chain-id $CID +`, version.AppName)), + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + signer := clientCtx.GetFromAddress().String() + + chainId := args[0] + + metadata := types.ConsumerMetadata{} + metadataJson, err := os.ReadFile(args[1]) + if err != nil { + return err + } + if err = json.Unmarshal(metadataJson, &metadata); err != nil { + return fmt.Errorf("metadata unmarshalling failed: %w", err) + } + + initializationParameters := types.ConsumerInitializationParameters{} + initializationParametersJson, err := os.ReadFile(args[2]) + if err != nil { + return err + } + if err = json.Unmarshal(initializationParametersJson, &initializationParameters); err != nil { + return fmt.Errorf("initialization parameters unmarshalling failed: %w", err) + } + + powerShapingParameters := types.PowerShapingParameters{} + + powerShapingParametersJson, err := os.ReadFile(args[3]) + if err != nil { + return err + } + if err = json.Unmarshal(powerShapingParametersJson, &powerShapingParameters); err != nil { + return fmt.Errorf("power-shaping parameters unmarshalling failed: %w", err) + } + + msg, err := types.NewMsgCreateConsumer(signer, chainId, metadata, &initializationParameters, &powerShapingParameters) + if err != nil { + return err + } + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +func NewUpdateConsumerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-consumer [consumer-id] [owner-address] [metadata] [initialization-parameters] [power-shaping-parameters]", + Short: "update a consumer chain", + Long: strings.TrimSpace( + fmt.Sprintf(`Update a consumer chain to change its parameters (e.g., spawn time, allow list, etc.). +Note that only the owner of the chain can initialize it. + +Example: +%s tx provider update-consumer [consumer-id] [owner-address] [path/to/metadata.json] [path/to/initialization-parameters.json] [path/to/power-shaping-parameters.json] --from node0 --home ../node0 --chain-id $CID +`, version.AppName)), + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + signer := clientCtx.GetFromAddress().String() + consumerId := args[0] + ownerAddress := args[1] + + metadata := types.ConsumerMetadata{} + metadataJson, err := os.ReadFile(args[2]) + if err != nil { + return err + } + if err = json.Unmarshal(metadataJson, &metadata); err != nil { + return fmt.Errorf("metadata unmarshalling failed: %w", err) + } + + initializationParameters := types.ConsumerInitializationParameters{} + initializationParametersJson, err := os.ReadFile(args[3]) + if err != nil { + return err + } + if err = json.Unmarshal(initializationParametersJson, &initializationParameters); err != nil { + return fmt.Errorf("initialization parameters unmarshalling failed: %w", err) + } + + powerShapingParameters := types.PowerShapingParameters{} + powerShapingParametersJson, err := os.ReadFile(args[4]) + if err != nil { + return err + } + if err = json.Unmarshal(powerShapingParametersJson, &powerShapingParameters); err != nil { + return fmt.Errorf("power-shaping parameters unmarshalling failed: %w", err) + } + + msg, err := types.NewMsgUpdateConsumer(signer, consumerId, ownerAddress, &metadata, &initializationParameters, &powerShapingParameters) + if err != nil { + return err + } + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +func NewRemoveConsumerCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove-consumer [consumer-id] [stop-time-layout] [stop-time-value]", + Short: "remove a consumer chain", + Long: strings.TrimSpace( + fmt.Sprintf(`Removes (and stops) a consumer chain. Note that only the owner of the chain can remove it. +Stop time is parsed by using the layout and the value (see https://pkg.go.dev/time#Parse). + +Example: +%s tx provider remove-consumer [consumer-id] [stop-time-layout] [stop-time-value] --from node0 --home ../node0 --chain-id $CID +`, version.AppName)), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + signer := clientCtx.GetFromAddress().String() + consumerId := args[0] + stopTimeLayout := args[1] + stopTimeValue := args[2] + + stopTime, err := time.Parse(stopTimeLayout, stopTimeValue) + if err != nil { + return err + } + + msg, err := types.NewMsgRemoveConsumer(signer, consumerId, stopTime) + if err != nil { + return err + } + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + func NewOptInCmd() *cobra.Command { cmd := &cobra.Command{ Use: "opt-in [consumer-chain-id] [consumer-pubkey]", diff --git a/x/ccv/provider/handler.go b/x/ccv/provider/handler.go index 78e17257de..937fcb1805 100644 --- a/x/ccv/provider/handler.go +++ b/x/ccv/provider/handler.go @@ -36,6 +36,15 @@ func NewHandler(k *keeper.Keeper) baseapp.MsgServiceHandler { case *types.MsgSetConsumerCommissionRate: res, err := msgServer.SetConsumerCommissionRate(ctx, msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgCreateConsumer: + res, err := msgServer.CreateConsumer(ctx, msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUpdateConsumer: + res, err := msgServer.UpdateConsumer(ctx, msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRemoveConsumer: + res, err := msgServer.RemoveConsumer(ctx, msg) + return sdk.WrapServiceResult(ctx, res, err) default: return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } diff --git a/x/ccv/provider/handler_test.go b/x/ccv/provider/handler_test.go index 9c14efe91b..7ea306f47e 100644 --- a/x/ccv/provider/handler_test.go +++ b/x/ccv/provider/handler_test.go @@ -46,18 +46,16 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { testCases := []struct { name string // State-mutating setup specific to this test case - setup func(sdk.Context, keeper.Keeper, testkeeper.MockedKeepers) - expError bool - chainID string + setup func(sdk.Context, keeper.Keeper, testkeeper.MockedKeepers) + expError bool + consumerId string }{ { name: "success", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{ - ChainId: "chainid", - }) + k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), @@ -67,11 +65,11 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, - expError: false, - chainID: "chainid", + expError: false, + consumerId: "consumerId", }, { - name: "fail: chain ID not registered", + name: "fail: consumer id does not correspond to a registered chain", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { @@ -82,36 +80,33 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { ).Return(providerCryptoId.SDKStakingValidator(), nil).Times(1), ) }, - expError: true, - chainID: "chainid", + expError: true, + consumerId: "consumerId", }, { name: "fail: missing validator", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{ - ChainId: "chainid", - }) + k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound).Times(1), ) }, - expError: true, - chainID: "chainid", + expError: true, + consumerId: "consumerId", }, { name: "fail: consumer key in use by other validator", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{ - ChainId: "chainid", - }) + k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + // Use the consumer key already used by some other validator - k.SetValidatorByConsumerAddr(ctx, "chainid", consumerConsAddr, providerConsAddr2) + k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( @@ -124,19 +119,18 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { ).Return(stakingtypes.Validator{}, nil), ) }, - expError: true, - chainID: "chainid", + expError: true, + consumerId: "consumerId", }, { name: "fail: consumer key in use by the same validator", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{ - ChainId: "chainid", - }) + k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + // Use the consumer key already - k.SetValidatorByConsumerAddr(ctx, "chainid", consumerConsAddr, providerConsAddr) + k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( @@ -147,20 +141,18 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, - expError: true, - chainID: "chainid", + expError: true, + consumerId: "consumerId", }, { name: "fail: consumer key in use by other validator", setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetPendingConsumerAdditionProp(ctx, &providertypes.ConsumerAdditionProposal{ - ChainId: "chainid", - }) + k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) // Use the consumer key already used by some other validator - k.SetValidatorByConsumerAddr(ctx, "chainid", consumerConsAddr, providerConsAddr2) + k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( @@ -173,8 +165,8 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { ).Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound), ) }, - expError: true, - chainID: "chainid", + expError: true, + consumerId: "consumerId", }, } @@ -184,7 +176,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { tc.setup(ctx, k, mocks) - msg, err := providertypes.NewMsgAssignConsumerKey(tc.chainID, + msg, err := providertypes.NewMsgAssignConsumerKey(tc.consumerId, providerCryptoId.SDKValOpAddress(), consumerKey, providerCryptoId.SDKStakingValidator().OperatorAddress, ) diff --git a/x/ccv/provider/ibc_middleware.go b/x/ccv/provider/ibc_middleware.go index d9d816ab93..3872fd5fbe 100644 --- a/x/ccv/provider/ibc_middleware.go +++ b/x/ccv/provider/ibc_middleware.go @@ -122,7 +122,7 @@ func (im IBCMiddleware) OnRecvPacket( // deserialized without checking errors. if ack.Success() { // execute the middleware logic only if the sender is a consumer chain - consumerID, err := im.keeper.IdentifyConsumerChainIDFromIBCPacket(ctx, packet) + consumerId, err := im.keeper.IdentifyConsumerIdFromIBCPacket(ctx, packet) if err != nil { return ack } @@ -144,13 +144,13 @@ func (im IBCMiddleware) OnRecvPacket( // and if so, adds it to the consumer chain rewards allocation, // otherwise the prohibited coin just stays in the pool forever. if im.keeper.ConsumerRewardDenomExists(ctx, coinDenom) { - alloc := im.keeper.GetConsumerRewardsAllocation(ctx, consumerID) + alloc := im.keeper.GetConsumerRewardsAllocation(ctx, consumerId) alloc.Rewards = alloc.Rewards.Add( sdk.NewDecCoinsFromCoins(sdk.Coin{ Denom: coinDenom, Amount: coinAmt, })...) - im.keeper.SetConsumerRewardsAllocation(ctx, consumerID, alloc) + im.keeper.SetConsumerRewardsAllocation(ctx, consumerId, alloc) } } diff --git a/x/ccv/provider/ibc_module_test.go b/x/ccv/provider/ibc_module_test.go index 58573d3e3b..2d778daf00 100644 --- a/x/ccv/provider/ibc_module_test.go +++ b/x/ccv/provider/ibc_module_test.go @@ -96,17 +96,17 @@ func TestOnChanOpenTry(t *testing.T) { "unexpected client ID mapped to chain ID", func(params *params, keeper *providerkeeper.Keeper) { keeper.SetConsumerClientId( params.ctx, - "consumerChainID", - "invalidClientID", + "consumerId", + "invalidClientId", ) }, false, }, { "other CCV channel exists for this consumer chain", func(params *params, keeper *providerkeeper.Keeper) { - keeper.SetChainToChannel( + keeper.SetConsumerIdToChannelId( params.ctx, - "consumerChainID", + "consumerId", "some existing channel ID", ) }, false, @@ -122,7 +122,8 @@ func TestOnChanOpenTry(t *testing.T) { providerModule := provider.NewAppModule(&providerKeeper, *keeperParams.ParamsSubspace, keeperParams.StoreKey) providerKeeper.SetPort(ctx, ccv.ProviderPortID) - providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientIDToConsumer") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientIdToConsumer") + providerKeeper.SetClientIdToConsumerId(ctx, "clientIdToConsumer", "consumerId") // Instantiate valid params as default. Individual test cases mutate these as needed. params := params{ @@ -145,9 +146,9 @@ func TestOnChanOpenTry(t *testing.T) { mocks.MockScopedKeeper.EXPECT().ClaimCapability( params.ctx, params.chanCap, host.ChannelCapabilityPath(params.portID, params.channelID)).AnyTimes(), mocks.MockConnectionKeeper.EXPECT().GetConnection(ctx, "connectionIDToConsumer").Return( - conntypes.ConnectionEnd{ClientId: "clientIDToConsumer"}, true, + conntypes.ConnectionEnd{ClientId: "clientIdToConsumer"}, true, ).AnyTimes(), - mocks.MockClientKeeper.EXPECT().GetClientState(ctx, "clientIDToConsumer").Return( + mocks.MockClientKeeper.EXPECT().GetClientState(ctx, "clientIdToConsumer").Return( &ibctmtypes.ClientState{ChainId: "consumerChainID"}, true, ).AnyTimes(), mocks.MockAccountKeeper.EXPECT().GetModuleAccount(ctx, providertypes.ConsumerRewardsPool).Return(&moduleAcct).AnyTimes(), @@ -170,13 +171,13 @@ func TestOnChanOpenTry(t *testing.T) { require.NoError(t, err) md := &ccv.HandshakeMetadata{} err = md.Unmarshal([]byte(metadata)) - require.NoError(t, err) + require.NoError(t, err, tc.name) require.Equal(t, moduleAcct.BaseAccount.Address, md.ProviderFeePoolAddr, "returned dist account metadata must match expected") require.Equal(t, ccv.Version, md.Version, "returned ccv version metadata must match expected") ctrl.Finish() } else { - require.Error(t, err) + require.Error(t, err, tc.name) } } } @@ -309,9 +310,11 @@ func TestOnChanOpenConfirm(t *testing.T) { gomock.InOrder(tc.mockExpectations(ctx, mocks)...) if tc.setDuplicateChannel { - providerKeeper.SetChainToChannel(ctx, "consumerChainID", "existingChannelID") + providerKeeper.SetConsumerIdToChannelId(ctx, "consumerChainID", "existingChannelID") } + providerKeeper.SetClientIdToConsumerId(ctx, "clientID", "consumerChainID") + providerModule := provider.NewAppModule(&providerKeeper, *keeperParams.ParamsSubspace, keeperParams.StoreKey) err := providerModule.OnChanOpenConfirm(ctx, "providerPortID", "channelID") @@ -320,11 +323,11 @@ func TestOnChanOpenConfirm(t *testing.T) { require.NoError(t, err) // Validate channel mappings - channelID, found := providerKeeper.GetChainToChannel(ctx, "consumerChainID") + channelID, found := providerKeeper.GetConsumerIdToChannelId(ctx, "consumerChainID") require.True(t, found) require.Equal(t, "channelID", channelID) - chainID, found := providerKeeper.GetChannelToChain(ctx, "channelID") + chainID, found := providerKeeper.GetChannelIdToConsumerId(ctx, "channelID") require.True(t, found) require.Equal(t, "consumerChainID", chainID) diff --git a/x/ccv/provider/keeper/consumer_equivocation.go b/x/ccv/provider/keeper/consumer_equivocation.go index 8f4f59732a..c4c307b167 100644 --- a/x/ccv/provider/keeper/consumer_equivocation.go +++ b/x/ccv/provider/keeper/consumer_equivocation.go @@ -28,51 +28,57 @@ import ( // Double Voting section // -// HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer chain ID +// HandleConsumerDoubleVoting verifies a double voting evidence for a given a consumer id // and a public key and, if successful, executes the slashing, jailing, and tombstoning of the malicious validator. func (k Keeper) HandleConsumerDoubleVoting( ctx sdk.Context, + consumerId string, evidence *tmtypes.DuplicateVoteEvidence, - chainID string, pubkey cryptotypes.PubKey, ) error { // check that the evidence is for an ICS consumer chain - if _, found := k.GetConsumerClientId(ctx, chainID); !found { + if _, found := k.GetConsumerClientId(ctx, consumerId); !found { return errorsmod.Wrapf( ccvtypes.ErrInvalidDoubleVotingEvidence, "cannot find consumer chain %s", - chainID, + consumerId, ) } // check that the evidence is not too old - minHeight := k.GetEquivocationEvidenceMinHeight(ctx, chainID) + minHeight := k.GetEquivocationEvidenceMinHeight(ctx, consumerId) if uint64(evidence.VoteA.Height) < minHeight { return errorsmod.Wrapf( ccvtypes.ErrInvalidDoubleVotingEvidence, "evidence for consumer chain %s is too old - evidence height (%d), min (%d)", - chainID, + consumerId, evidence.VoteA.Height, minHeight, ) } + // get the chainId of this consumer chain to verify the double-voting evidence + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return err + } + // verifies the double voting evidence using the consumer chain public key - if err := k.VerifyDoubleVotingEvidence(*evidence, chainID, pubkey); err != nil { + if err = k.VerifyDoubleVotingEvidence(*evidence, chainId, pubkey); err != nil { return err } // get the validator's consensus address on the provider providerAddr := k.GetProviderAddrFromConsumerAddr( ctx, - chainID, + consumerId, types.NewConsumerConsAddress(sdk.ConsAddress(evidence.VoteA.ValidatorAddress.Bytes())), ) - if err := k.SlashValidator(ctx, providerAddr); err != nil { + if err = k.SlashValidator(ctx, providerAddr); err != nil { return err } - if err := k.JailAndTombstoneValidator(ctx, providerAddr); err != nil { + if err = k.JailAndTombstoneValidator(ctx, providerAddr); err != nil { return err } @@ -88,7 +94,7 @@ func (k Keeper) HandleConsumerDoubleVoting( // for a given chain id and a validator public key func (k Keeper) VerifyDoubleVotingEvidence( evidence tmtypes.DuplicateVoteEvidence, - chainID string, + chainId string, pubkey cryptotypes.PubKey, ) error { if pubkey == nil { @@ -140,10 +146,10 @@ func (k Keeper) VerifyDoubleVotingEvidence( vb := evidence.VoteB.ToProto() // signatures must be valid - if !pubkey.VerifySignature(tmtypes.VoteSignBytes(chainID, va), evidence.VoteA.Signature) { + if !pubkey.VerifySignature(tmtypes.VoteSignBytes(chainId, va), evidence.VoteA.Signature) { return fmt.Errorf("verifying VoteA: %w", tmtypes.ErrVoteInvalidSignature) } - if !pubkey.VerifySignature(tmtypes.VoteSignBytes(chainID, vb), evidence.VoteB.Signature) { + if !pubkey.VerifySignature(tmtypes.VoteSignBytes(chainId, vb), evidence.VoteB.Signature) { return fmt.Errorf("verifying VoteB: %w", tmtypes.ErrVoteInvalidSignature) } @@ -156,11 +162,11 @@ func (k Keeper) VerifyDoubleVotingEvidence( // HandleConsumerMisbehaviour checks if the given IBC misbehaviour corresponds to an equivocation light client attack, // and in this case, slashes, jails, and tombstones -func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error { +func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error { logger := k.Logger(ctx) // Check that the misbehaviour is valid and that the client consensus states at trusted heights are within trusting period - if err := k.CheckMisbehaviour(ctx, misbehaviour); err != nil { + if err := k.CheckMisbehaviour(ctx, consumerId, misbehaviour); err != nil { logger.Info("Misbehaviour rejected", err.Error()) return err @@ -182,7 +188,7 @@ func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, misbehaviour ibctmty for _, v := range byzantineValidators { providerAddr := k.GetProviderAddrFromConsumerAddr( ctx, - misbehaviour.Header1.Header.ChainID, + consumerId, types.NewConsumerConsAddress(sdk.ConsAddress(v.Address.Bytes())), ) err := k.SlashValidator(ctx, providerAddr) @@ -292,16 +298,26 @@ func headerToLightBlock(h ibctmtypes.Header) (*tmtypes.LightBlock, error) { // CheckMisbehaviour checks that headers in the given misbehaviour forms // a valid light client attack from an ICS consumer chain and that the light client isn't expired -func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour) error { - consumerChainID := misbehaviour.Header1.Header.ChainID +func (k Keeper) CheckMisbehaviour(ctx sdk.Context, consumerId string, misbehaviour ibctmtypes.Misbehaviour) error { + chainId := misbehaviour.Header1.Header.ChainID + + consumerChainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return err + } else if consumerChainId != chainId { + return fmt.Errorf("incorrect misbehaviour for a different chain id (%s) than that of the consumer chain %s (consumerId: %s)", + chainId, + consumerChainId, + consumerId) + } // check that the misbehaviour is for an ICS consumer chain - clientId, found := k.GetConsumerClientId(ctx, consumerChainID) + clientId, found := k.GetConsumerClientId(ctx, consumerId) if !found { - return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain: %s", consumerChainID) + return fmt.Errorf("incorrect misbehaviour with conflicting headers from a non-existent consumer chain (consumerId: %s)", consumerId) } else if misbehaviour.ClientId != clientId { - return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain %s is %s got %s", - consumerChainID, + return fmt.Errorf("incorrect misbehaviour: expected client ID for consumer chain with id %s is %s got %s", + consumerId, clientId, misbehaviour.ClientId, ) @@ -315,7 +331,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe } // Check that the evidence is not too old - minHeight := k.GetEquivocationEvidenceMinHeight(ctx, consumerChainID) + minHeight := k.GetEquivocationEvidenceMinHeight(ctx, consumerId) evidenceHeight := misbehaviour.Header1.GetHeight().GetRevisionHeight() // Note that the revision number is not relevant for checking the age of evidence // as it's already part of the chain ID and the minimum height is mapped to chain IDs @@ -323,7 +339,7 @@ func (k Keeper) CheckMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbe return errorsmod.Wrapf( ccvtypes.ErrInvalidDoubleVotingEvidence, "evidence for consumer chain %s is too old - evidence height (%d), min (%d)", - consumerChainID, + consumerId, evidenceHeight, minHeight, ) @@ -517,20 +533,20 @@ func (k Keeper) SlashValidator(ctx sdk.Context, providerAddr types.ProviderConsA // // SetEquivocationEvidenceMinHeight sets the minimum height -// of a valid consumer equivocation evidence for a given consumer chain ID -func (k Keeper) SetEquivocationEvidenceMinHeight(ctx sdk.Context, chainID string, height uint64) { +// of a valid consumer equivocation evidence for a given consumer id +func (k Keeper) SetEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string, height uint64) { store := ctx.KVStore(k.storeKey) heightBytes := make([]byte, 8) binary.BigEndian.PutUint64(heightBytes, height) - store.Set(types.EquivocationEvidenceMinHeightKey(chainID), heightBytes) + store.Set(types.EquivocationEvidenceMinHeightKey(consumerId), heightBytes) } // GetEquivocationEvidenceMinHeight returns the minimum height -// of a valid consumer equivocation evidence for a given consumer chain ID -func (k Keeper) GetEquivocationEvidenceMinHeight(ctx sdk.Context, chainID string) uint64 { +// of a valid consumer equivocation evidence for a given consumer id +func (k Keeper) GetEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string) uint64 { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.EquivocationEvidenceMinHeightKey(chainID)) + bz := store.Get(types.EquivocationEvidenceMinHeightKey(consumerId)) if bz == nil { return 0 } @@ -539,8 +555,8 @@ func (k Keeper) GetEquivocationEvidenceMinHeight(ctx sdk.Context, chainID string } // DeleteEquivocationEvidenceMinHeight deletes the minimum height -// of a valid consumer equivocation evidence for a given consumer chain ID -func (k Keeper) DeleteEquivocationEvidenceMinHeight(ctx sdk.Context, chainID string) { +// of a valid consumer equivocation evidence for a given consumer id +func (k Keeper) DeleteEquivocationEvidenceMinHeight(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.EquivocationEvidenceMinHeightKey(chainID)) + store.Delete(types.EquivocationEvidenceMinHeightKey(consumerId)) } diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 7970a8c682..13698cde32 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -75,7 +75,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { } // Iterate over all registered consumer chains - for _, consumerChainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { + for _, consumerChainID := range k.GetAllRegisteredConsumerIds(ctx) { // note that it's possible that no rewards are collected even though the // reward pool isn't empty. This can happen if the reward pool holds some tokens @@ -176,7 +176,7 @@ func (k Keeper) IsEligibleForConsumerRewards(ctx sdk.Context, consumerValidatorH // to the given consumer chain's validator set func (k Keeper) AllocateTokensToConsumerValidators( ctx sdk.Context, - chainID string, + consumerId string, tokens sdk.DecCoins, ) (allocated sdk.DecCoins) { // return early if the tokens are empty @@ -185,17 +185,17 @@ func (k Keeper) AllocateTokensToConsumerValidators( } // get the total voting power of the consumer valset - totalPower := math.LegacyNewDec(k.ComputeConsumerTotalVotingPower(ctx, chainID)) + totalPower := math.LegacyNewDec(k.ComputeConsumerTotalVotingPower(ctx, consumerId)) if totalPower.IsZero() { return allocated } // Allocate tokens by iterating over the consumer validators - consumerVals, err := k.GetConsumerValSet(ctx, chainID) + consumerVals, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { k.Logger(ctx).Error( "cannot get consumer validator set while allocating rewards from consumer chain", - chainID, + consumerId, "error", err, ) @@ -220,7 +220,7 @@ func (k Keeper) AllocateTokensToConsumerValidators( "cannot find validator by consensus address", consAddr, "while allocating rewards from consumer chain", - chainID, + consumerId, "error", err, ) @@ -228,7 +228,7 @@ func (k Keeper) AllocateTokensToConsumerValidators( } // check if the validator set a custom commission rate for the consumer chain - if cr, found := k.GetConsumerCommissionRate(ctx, chainID, types.NewProviderConsAddress(consAddr)); found { + if cr, found := k.GetConsumerCommissionRate(ctx, consumerId, types.NewProviderConsAddress(consAddr)); found { // set the validator commission rate val.Commission.CommissionRates.Rate = cr } @@ -241,7 +241,7 @@ func (k Keeper) AllocateTokensToConsumerValidators( ) if err != nil { k.Logger(ctx).Error("fail to allocate tokens to validator :%s while allocating rewards from consumer chain: %s", - consAddr, chainID) + consAddr, consumerId) continue } @@ -254,19 +254,19 @@ func (k Keeper) AllocateTokensToConsumerValidators( // consumer reward pools getter and setter -// GetConsumerRewardsAllocation returns the consumer rewards allocation for the given chain ID -func (k Keeper) GetConsumerRewardsAllocation(ctx sdk.Context, chainID string) (pool types.ConsumerRewardsAllocation) { +// GetConsumerRewardsAllocation returns the consumer rewards allocation for the given consumer id +func (k Keeper) GetConsumerRewardsAllocation(ctx sdk.Context, consumerId string) (pool types.ConsumerRewardsAllocation) { store := ctx.KVStore(k.storeKey) - b := store.Get(types.ConsumerRewardsAllocationKey(chainID)) + b := store.Get(types.ConsumerRewardsAllocationKey(consumerId)) k.cdc.MustUnmarshal(b, &pool) return } -// SetConsumerRewardsAllocation sets the consumer rewards allocation for the given chain ID -func (k Keeper) SetConsumerRewardsAllocation(ctx sdk.Context, chainID string, pool types.ConsumerRewardsAllocation) { +// SetConsumerRewardsAllocation sets the consumer rewards allocation for the given consumer id +func (k Keeper) SetConsumerRewardsAllocation(ctx sdk.Context, consumerId string, pool types.ConsumerRewardsAllocation) { store := ctx.KVStore(k.storeKey) b := k.cdc.MustMarshal(&pool) - store.Set(types.ConsumerRewardsAllocationKey(chainID), b) + store.Set(types.ConsumerRewardsAllocationKey(consumerId), b) } // GetConsumerRewardsPool returns the balance @@ -280,20 +280,19 @@ func (k Keeper) GetConsumerRewardsPool(ctx sdk.Context) sdk.Coins { // ComputeConsumerTotalVotingPower returns the validator set total voting power // for the given consumer chain -func (k Keeper) ComputeConsumerTotalVotingPower(ctx sdk.Context, chainID string) (totalPower int64) { +func (k Keeper) ComputeConsumerTotalVotingPower(ctx sdk.Context, consumerId string) (totalPower int64) { // sum the consumer validators set voting powers - vals, err := k.GetConsumerValSet(ctx, chainID) + vals, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { k.Logger(ctx).Error( "cannot get consumer validator set while computing total voting power for consumer chain", - chainID, + consumerId, "error", err, ) return } for _, v := range vals { - // only consider the voting power of a validator that would receive rewards (i.e., validator has been validating for a number of blocks) if !k.IsEligibleForConsumerRewards(ctx, v.JoinHeight) { continue @@ -305,9 +304,9 @@ func (k Keeper) ComputeConsumerTotalVotingPower(ctx sdk.Context, chainID string) return } -// IdentifyConsumerChainIDFromIBCPacket checks if the packet destination matches a registered consumer chain. +// IdentifyConsumerIdFromIBCPacket checks if the packet destination matches a registered consumer chain. // If so, it returns the consumer chain ID, otherwise an error. -func (k Keeper) IdentifyConsumerChainIDFromIBCPacket(ctx sdk.Context, packet channeltypes.Packet) (string, error) { +func (k Keeper) IdentifyConsumerIdFromIBCPacket(ctx sdk.Context, packet channeltypes.Packet) (string, error) { channel, ok := k.channelKeeper.GetChannel(ctx, packet.DestinationPort, packet.DestinationChannel) if !ok { return "", errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for channel ID: %s", packet.DestinationChannel) @@ -316,27 +315,31 @@ func (k Keeper) IdentifyConsumerChainIDFromIBCPacket(ctx sdk.Context, packet cha return "", errorsmod.Wrap(channeltypes.ErrTooManyConnectionHops, "must have direct connection to consumer chain") } connectionID := channel.ConnectionHops[0] - _, tmClient, err := k.getUnderlyingClient(ctx, connectionID) + clientId, _, err := k.getUnderlyingClient(ctx, connectionID) if err != nil { return "", err } - chainID := tmClient.ChainId - if _, ok := k.GetChainToChannel(ctx, chainID); !ok { - return "", errorsmod.Wrapf(types.ErrUnknownConsumerChannelId, "no CCV channel found for chain with ID: %s", chainID) + consumerId, found := k.GetClientIdToConsumerId(ctx, clientId) + if !found { + return "", errorsmod.Wrapf(types.ErrUnknownConsumerId, "no consumer id for client with id: %s", clientId) + } + + if _, ok := k.GetConsumerIdToChannelId(ctx, consumerId); !ok { + return "", errorsmod.Wrapf(types.ErrUnknownConsumerChannelId, "no CCV channel found for chain with ID: %s", consumerId) } - return chainID, nil + return consumerId, nil } // HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address // on the condition that the given consumer chain exists. -func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec) error { +func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec) error { // check that the consumer chain exists - if !k.IsConsumerProposedOrRegistered(ctx, chainID) { + if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { return errorsmod.Wrapf( - types.ErrUnknownConsumerChainId, - "unknown consumer chain, with id: %s", chainID) + types.ErrUnknownConsumerId, + "unknown consumer chain, with id: %s", consumerId) } // validate against the minimum commission rate @@ -353,7 +356,7 @@ func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, // set per-consumer chain commission rate for the validator address return k.SetConsumerCommissionRate( ctx, - chainID, + consumerId, providerAddr, commissionRate, ) diff --git a/x/ccv/provider/keeper/distribution_test.go b/x/ccv/provider/keeper/distribution_test.go index e8caeb7c36..57ff82bc95 100644 --- a/x/ccv/provider/keeper/distribution_test.go +++ b/x/ccv/provider/keeper/distribution_test.go @@ -225,13 +225,13 @@ func TestIdentifyConsumerChainIDFromIBCPacket(t *testing.T) { defer ctrl.Finish() tc.expectedCalls(ctx, mocks, tc.packet) - _, err := keeper.IdentifyConsumerChainIDFromIBCPacket( + _, err := keeper.IdentifyConsumerIdFromIBCPacket( ctx, tc.packet, ) if tc.expCCVChannel { - keeper.SetChainToChannel(ctx, chainID, ccvChannel) + keeper.SetConsumerIdToChannelId(ctx, chainID, ccvChannel) } if !tc.expErr { diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index 5b44227f90..0c01cef1e9 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -53,8 +53,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) []abc } // check if the CCV channel was established if cs.ChannelId != "" { - k.SetChannelToChain(ctx, cs.ChannelId, chainID) - k.SetChainToChannel(ctx, chainID, cs.ChannelId) + k.SetChannelToConsumerId(ctx, cs.ChannelId, chainID) + k.SetConsumerIdToChannelId(ctx, chainID, cs.ChannelId) k.SetInitChainHeight(ctx, chainID, cs.InitialHeight) k.SetSlashAcks(ctx, cs.ChainId, cs.SlashDowntimeAck) } else { @@ -129,45 +129,45 @@ func (k Keeper) InitGenesisValUpdates(ctx sdk.Context) []abci.ValidatorUpdate { // ExportGenesis returns the CCV provider module's exported genesis func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { // get a list of all registered consumer chains - registeredChainIDs := k.GetAllRegisteredConsumerChainIDs(ctx) + registeredConsumerIds := k.GetAllRegisteredConsumerIds(ctx) // export states for each consumer chains var consumerStates []types.ConsumerState - for _, chainID := range registeredChainIDs { + for _, consumerId := range registeredConsumerIds { // no need for the second return value of GetConsumerClientId - // as GetAllRegisteredConsumerChainIDs already iterated through + // as GetAllRegisteredConsumerIds already iterated through // the entire prefix range - clientID, _ := k.GetConsumerClientId(ctx, chainID) - gen, found := k.GetConsumerGenesis(ctx, chainID) + clientId, _ := k.GetConsumerClientId(ctx, consumerId) + gen, found := k.GetConsumerGenesis(ctx, consumerId) if !found { - panic(fmt.Errorf("cannot find genesis for consumer chain %s with client %s", chainID, clientID)) + panic(fmt.Errorf("cannot find genesis for consumer chain %s with client %s", consumerId, clientId)) } // initial consumer chain states cs := types.ConsumerState{ - ChainId: chainID, - ClientId: clientID, + ChainId: consumerId, + ClientId: clientId, ConsumerGenesis: gen, } // try to find channel id for the current consumer chain - channelId, found := k.GetChainToChannel(ctx, chainID) + channelId, found := k.GetConsumerIdToChannelId(ctx, consumerId) if found { cs.ChannelId = channelId - cs.InitialHeight, found = k.GetInitChainHeight(ctx, chainID) + cs.InitialHeight, found = k.GetInitChainHeight(ctx, consumerId) if !found { - panic(fmt.Errorf("cannot find init height for consumer chain %s", chainID)) + panic(fmt.Errorf("cannot find init height for consumer chain %s", consumerId)) } - cs.SlashDowntimeAck = k.GetSlashAcks(ctx, chainID) + cs.SlashDowntimeAck = k.GetSlashAcks(ctx, consumerId) } - cs.PendingValsetChanges = k.GetPendingVSCPackets(ctx, chainID) + cs.PendingValsetChanges = k.GetPendingVSCPackets(ctx, consumerId) consumerStates = append(consumerStates, cs) } // ConsumerAddrsToPrune are added only for registered consumer chains consumerAddrsToPrune := []types.ConsumerAddrsToPruneV2{} - for _, chainID := range registeredChainIDs { + for _, chainID := range registeredConsumerIds { consumerAddrsToPrune = append(consumerAddrsToPrune, k.GetAllConsumerAddrsToPrune(ctx, chainID)...) } diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index 82069b4b8d..8f305f1197 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -132,7 +132,7 @@ func TestInitAndExportGenesis(t *testing.T) { require.Equal(t, expectedCandidate, pk.GetSlashMeterReplenishTimeCandidate(ctx)) // check local provider chain states - chainID, found := pk.GetChannelToChain(ctx, provGenesis.ConsumerStates[0].ChannelId) + chainID, found := pk.GetChannelIdToConsumerId(ctx, provGenesis.ConsumerStates[0].ChannelId) require.True(t, found) require.Equal(t, cChainIDs[0], chainID) require.Equal(t, vscID, pk.GetValidatorSetUpdateId(ctx)) @@ -189,7 +189,7 @@ func assertConsumerChainStates(t *testing.T, ctx sdk.Context, pk keeper.Keeper, require.Equal(t, cs.ClientId, clientID) if expChan := cs.ChannelId; expChan != "" { - gotChan, found := pk.GetChainToChannel(ctx, chainID) + gotChan, found := pk.GetConsumerIdToChannelId(ctx, chainID) require.True(t, found) require.Equal(t, expChan, gotChan) } diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 415a181096..5408cc606a 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -8,7 +8,6 @@ import ( "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -23,17 +22,20 @@ func (k Keeper) QueryConsumerGenesis(c context.Context, req *types.QueryConsumer if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } - if req.ChainId == "" { - return nil, status.Errorf(codes.InvalidArgument, "invalid request: chain id cannot be empty") + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) } - gen, ok := k.GetConsumerGenesis(ctx, req.ChainId) + gen, ok := k.GetConsumerGenesis(ctx, consumerId) if !ok { return nil, status.Error( codes.NotFound, - errorsmod.Wrap(types.ErrUnknownConsumerChainId, req.ChainId).Error(), + errorsmod.Wrap(types.ErrUnknownConsumerId, consumerId).Error(), ) } @@ -48,7 +50,7 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu ctx := sdk.UnwrapSDKContext(goCtx) chains := []*types.Chain{} - for _, chainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { + for _, chainID := range k.GetAllRegisteredConsumerIds(ctx) { c, err := k.GetConsumerChain(ctx, chainID) if err != nil { return nil, status.Error(codes.Internal, err.Error()) @@ -60,43 +62,39 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu } // GetConsumerChain returns a Chain data structure with all the necessary fields -func (k Keeper) GetConsumerChain(ctx sdk.Context, chainID string) (types.Chain, error) { - clientID, found := k.GetConsumerClientId(ctx, chainID) +func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chain, error) { + clientID, found := k.GetConsumerClientId(ctx, consumerId) if !found { - return types.Chain{}, fmt.Errorf("cannot find clientID for consumer (%s)", chainID) + return types.Chain{}, fmt.Errorf("cannot find clientID for consumer (%s)", consumerId) } - topN, found := k.GetTopN(ctx, chainID) - if !found { - k.Logger(ctx).Error("failed to get top N, treating as 0", "chain", chainID) - topN = 0 - } + topN := k.GetTopN(ctx, consumerId) // Get the minimal power in the top N for the consumer chain - minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, chainID) + minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, consumerId) if !found { - k.Logger(ctx).Error("failed to get minimum power in top N, treating as -1", "chain", chainID) + k.Logger(ctx).Error("failed to get minimum power in top N, treating as -1", "chain", consumerId) minPowerInTopN = -1 } - validatorSetCap, _ := k.GetValidatorSetCap(ctx, chainID) + validatorSetCap := k.GetValidatorSetCap(ctx, consumerId) - validatorsPowerCap, _ := k.GetValidatorsPowerCap(ctx, chainID) + validatorsPowerCap := k.GetValidatorsPowerCap(ctx, consumerId) - allowlist := k.GetAllowList(ctx, chainID) + allowlist := k.GetAllowList(ctx, consumerId) strAllowlist := make([]string, len(allowlist)) for i, addr := range allowlist { strAllowlist[i] = addr.String() } - denylist := k.GetDenyList(ctx, chainID) + denylist := k.GetDenyList(ctx, consumerId) strDenylist := make([]string, len(denylist)) for i, addr := range denylist { strDenylist[i] = addr.String() } return types.Chain{ - ChainId: chainID, + ChainId: consumerId, ClientId: clientID, Top_N: topN, MinPowerInTop_N: minPowerInTopN, @@ -142,18 +140,25 @@ func (k Keeper) QueryConsumerChainStops(goCtx context.Context, req *types.QueryC func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.QueryValidatorConsumerAddrRequest) (*types.QueryValidatorConsumerAddrResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } ctx := sdk.UnwrapSDKContext(goCtx) + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) + } + providerAddrTmp, err := sdk.ConsAddressFromBech32(req.ProviderAddress) if err != nil { return nil, err } providerAddr := types.NewProviderConsAddress(providerAddrTmp) - consumerKey, found := k.GetValidatorConsumerPubKey(ctx, req.ChainId, providerAddr) + consumerKey, found := k.GetValidatorConsumerPubKey(ctx, consumerId, providerAddr) if !found { return &types.QueryValidatorConsumerAddrResponse{}, nil } @@ -170,7 +175,9 @@ func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.Que func (k Keeper) QueryValidatorProviderAddr(goCtx context.Context, req *types.QueryValidatorProviderAddrRequest) (*types.QueryValidatorProviderAddrResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -239,18 +246,21 @@ func (k Keeper) QueryProposedConsumerChainIDs(goCtx context.Context, req *types. func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, req *types.QueryAllPairsValConAddrByConsumerChainIDRequest) (*types.QueryAllPairsValConAddrByConsumerChainIDResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } - if req.ChainId == "" { - return nil, status.Error(codes.InvalidArgument, "empty chainId") + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) } // list of pairs valconsensus addr pairValConAddrs := []*types.PairValConAddrProviderAndConsumer{} ctx := sdk.UnwrapSDKContext(goCtx) - validatorConsumerPubKeys := k.GetAllValidatorConsumerPubKeys(ctx, &req.ChainId) + validatorConsumerPubKeys := k.GetAllValidatorConsumerPubKeys(ctx, &consumerId) for _, data := range validatorConsumerPubKeys { consumerAddr, err := ccvtypes.TMCryptoPublicKeyToConsAddr(*data.ConsumerKey) if err != nil { @@ -283,22 +293,24 @@ func (k Keeper) QueryParams(goCtx context.Context, req *types.QueryParamsRequest // QueryConsumerChainOptedInValidators returns all validators that opted-in to a given consumer chain func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req *types.QueryConsumerChainOptedInValidatorsRequest) (*types.QueryConsumerChainOptedInValidatorsResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } - consumerChainID := req.ChainId - if consumerChainID == "" { - return nil, status.Error(codes.InvalidArgument, "empty chainId") + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) } optedInVals := []string{} ctx := sdk.UnwrapSDKContext(goCtx) - if !k.IsConsumerProposedOrRegistered(ctx, consumerChainID) { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerChainID)) + if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerId)) } - for _, v := range k.GetAllOptedIn(ctx, consumerChainID) { + for _, v := range k.GetAllOptedIn(ctx, consumerId) { optedInVals = append(optedInVals, v.ToSdkConsAddr().String()) } @@ -310,52 +322,64 @@ func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req * // QueryConsumerValidators returns all validators that are consumer validators in a given consumer chain func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryConsumerValidatorsRequest) (*types.QueryConsumerValidatorsResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } - - consumerChainID := req.ChainId - if consumerChainID == "" { - return nil, status.Error(codes.InvalidArgument, "empty chainId") + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) } ctx := sdk.UnwrapSDKContext(goCtx) - if _, found := k.GetConsumerClientId(ctx, consumerChainID); !found { + if _, found := k.GetConsumerClientId(ctx, consumerId); !found { // chain has to have started; consumer client id is set for a chain during the chain's spawn time - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("no started consumer chain: %s", consumerChainID)) + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("no started consumer chain: %s", consumerId)) } var validators []*types.QueryConsumerValidatorsValidator - consumerValSet, err := k.GetConsumerValSet(ctx, consumerChainID) + consumerValSet, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - for _, v := range consumerValSet { + for _, consumerVal := range consumerValSet { + provAddr := types.ProviderConsAddress{Address: consumerVal.ProviderConsAddr} + consAddr := provAddr.ToSdkConsAddr() - consAddr, err := sdk.ConsAddressFromBech32(sdk.ConsAddress(v.ProviderConsAddr).String()) + providerVal, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) if err != nil { - return nil, status.Error(codes.InvalidArgument, "invalid provider address") + k.Logger(ctx).Error("cannot find consensus address for provider address:%s", provAddr.String()) + continue } - var rate math.LegacyDec - consumerRate, found := k.GetConsumerCommissionRate(ctx, consumerChainID, types.NewProviderConsAddress(consAddr)) - if found { - rate = consumerRate - } else { - v, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, consAddr) - if err != nil { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown validator: %s", consAddr.String())) - } - rate = v.Commission.Rate + hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerId) + if err != nil { + k.Logger(ctx).Error("cannot define if validator %s has to validate for consumer %s for current epoch", + provAddr.String(), consumerId) + continue + } + + consumerRate, found := k.GetConsumerCommissionRate(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + if !found { + consumerRate = providerVal.Commission.Rate } validators = append(validators, &types.QueryConsumerValidatorsValidator{ - ProviderAddress: sdk.ConsAddress(v.ProviderConsAddr).String(), - ConsumerKey: v.PublicKey, - Power: v.Power, - Rate: rate, + ProviderAddress: sdk.ConsAddress(consumerVal.ProviderConsAddr).String(), + ConsumerKey: consumerVal.PublicKey, + ConsumerPower: consumerVal.Power, + ConsumerCommissionRate: consumerRate, + Description: providerVal.Description, + ProviderOperatorAddress: providerVal.OperatorAddress, + Jailed: providerVal.Jailed, + Status: providerVal.Status, + ProviderTokens: providerVal.Tokens, + ProviderCommissionRate: providerVal.Commission.Rate, + ProviderPower: providerVal.GetConsensusPower(k.stakingKeeper.PowerReduction(ctx)), + ValidatesCurrentEpoch: hasToValidate, }) } return &types.QueryConsumerValidatorsResponse{ @@ -386,7 +410,7 @@ func (k Keeper) QueryConsumerChainsValidatorHasToValidate(goCtx context.Context, // get all the consumer chains for which the validator is either already // opted-in, currently a consumer validator or if its voting power is within the TopN validators consumersToValidate := []string{} - for _, consumerChainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { + for _, consumerChainID := range k.GetAllRegisteredConsumerIds(ctx) { if hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerChainID); err == nil && hasToValidate { consumersToValidate = append(consumersToValidate, consumerChainID) } @@ -401,10 +425,10 @@ func (k Keeper) QueryConsumerChainsValidatorHasToValidate(goCtx context.Context, func (k Keeper) hasToValidate( ctx sdk.Context, provAddr types.ProviderConsAddress, - chainID string, + consumerId string, ) (bool, error) { // if the validator was sent as part of the packet in the last epoch, it has to validate - if k.IsConsumerValidator(ctx, chainID, provAddr) { + if k.IsConsumerValidator(ctx, consumerId, provAddr) { return true, nil } @@ -413,24 +437,24 @@ func (k Keeper) hasToValidate( if err != nil { return false, nil } - if topN, found := k.GetTopN(ctx, chainID); found && topN > 0 { + if topN := k.GetTopN(ctx, consumerId); topN > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N - minPower, found := k.GetMinimumPowerInTopN(ctx, chainID) + minPower, found := k.GetMinimumPowerInTopN(ctx, consumerId) if found { - k.OptInTopNValidators(ctx, chainID, activeValidators, minPower) + k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) } else { - k.Logger(ctx).Error("did not find min power in top N for chain", "chain", chainID) + k.Logger(ctx).Error("did not find min power in top N for chain", "chain", consumerId) } } // if the validator is opted in and belongs to the validators of the next epoch, then if nothing changes // the validator would have to validate in the next epoch - if k.IsOptedIn(ctx, chainID, provAddr) { + if k.IsOptedIn(ctx, consumerId, provAddr) { lastVals, err := k.GetLastBondedValidators(ctx) if err != nil { return false, err } - nextValidators := k.ComputeNextValidators(ctx, chainID, lastVals) + nextValidators := k.ComputeNextValidators(ctx, consumerId, lastVals) for _, v := range nextValidators { consAddr := sdk.ConsAddress(v.ProviderConsAddr) if provAddr.ToSdkConsAddr().Equals(consAddr) { @@ -446,12 +470,14 @@ func (k Keeper) hasToValidate( // validator charges on a given consumer chain func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req *types.QueryValidatorConsumerCommissionRateRequest) (*types.QueryValidatorConsumerCommissionRateResponse, error) { if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } else if req.ChainId != "" { + return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } - consumerChainID := req.ChainId - if consumerChainID == "" { - return nil, status.Error(codes.InvalidArgument, "empty chainId") + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) } consAddr, err := sdk.ConsAddressFromBech32(req.ProviderAddress) @@ -461,15 +487,15 @@ func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req ctx := sdk.UnwrapSDKContext(goCtx) - if !k.IsConsumerProposedOrRegistered(ctx, consumerChainID) { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerChainID)) + if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerId)) } res := &types.QueryValidatorConsumerCommissionRateResponse{} // Check if the validator has a commission rate set for the consumer chain, // otherwise use the commission rate from the validator staking module struct - consumerRate, found := k.GetConsumerCommissionRate(ctx, consumerChainID, types.NewProviderConsAddress(consAddr)) + consumerRate, found := k.GetConsumerCommissionRate(ctx, consumerId, types.NewProviderConsAddress(consAddr)) if found { res.Rate = consumerRate } else { @@ -492,3 +518,15 @@ func (k Keeper) QueryBlocksUntilNextEpoch(goCtx context.Context, req *types.Quer return &types.QueryBlocksUntilNextEpochResponse{BlocksUntilNextEpoch: uint64(blocksUntilNextEpoch)}, nil } + +// QueryConsumerIdFromClientId returns the consumer id of the chain associated with this client id +func (k Keeper) QueryConsumerIdFromClientId(goCtx context.Context, req *types.QueryConsumerIdFromClientIdRequest) (*types.QueryConsumerIdFromClientIdResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + consumerId, found := k.GetClientIdToConsumerId(ctx, req.ClientId) + if !found { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("no known consumer chain for this client id: %s", req.ClientId)) + } + + return &types.QueryConsumerIdFromClientIdResponse{ConsumerId: consumerId}, nil +} diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 27e6d00155..bbc61794d8 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -4,6 +4,8 @@ import ( "fmt" "testing" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -21,7 +23,7 @@ import ( ) func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { - chainID := consumer + consumerId := "0" providerConsAddress, err := sdk.ConsAddressFromBech32("cosmosvalcons1wpex7anfv3jhystyv3eq20r35a") require.NoError(t, err) @@ -34,9 +36,9 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - pk.SetValidatorConsumerPubKey(ctx, chainID, providerAddr, consumerKey) + pk.SetValidatorConsumerPubKey(ctx, consumerId, providerAddr, consumerKey) - consumerPubKey, found := pk.GetValidatorConsumerPubKey(ctx, chainID, providerAddr) + consumerPubKey, found := pk.GetValidatorConsumerPubKey(ctx, consumerId, providerAddr) require.True(t, found, "consumer pubkey not found") require.NotEmpty(t, consumerPubKey, "consumer pubkey is empty") require.Equal(t, consumerPubKey, consumerKey) @@ -45,17 +47,16 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, nil) require.Error(t, err) - // Request with chainId is empty + // Request with empty consumer id _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{}) require.Error(t, err) - // Request with chainId is invalid - response, err := pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ChainId: "invalidChainId"}) - require.NoError(t, err) - require.Equal(t, []*types.PairValConAddrProviderAndConsumer{}, response.PairValConAddr) + // Request with invalid consumer id + response, err := pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: "invalidConsumerId"}) + require.Error(t, err) // Request is valid - response, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ChainId: chainID}) + response, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: consumerId}) require.NoError(t, err) expectedResult := types.PairValConAddrProviderAndConsumer{ @@ -68,20 +69,21 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { } func TestQueryConsumerChainOptedInValidators(t *testing.T) { - chainID := "chainID" - pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerId := "0" + req := types.QueryConsumerChainOptedInValidatorsRequest{ - ChainId: chainID, + ConsumerId: consumerId, } // error returned from not yet proposed or not yet registered chain _, err := pk.QueryConsumerChainOptedInValidators(ctx, &req) require.Error(t, err) - pk.SetProposedConsumerChain(ctx, chainID, 1) + pk.FetchAndIncrementConsumerId(ctx) + pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized) providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) @@ -89,63 +91,101 @@ func TestQueryConsumerChainOptedInValidators(t *testing.T) { ValidatorsProviderAddresses: []string{providerAddr1.String(), providerAddr2.String()}, } - pk.SetOptedIn(ctx, chainID, providerAddr1) - pk.SetOptedIn(ctx, chainID, providerAddr2) + pk.SetOptedIn(ctx, consumerId, providerAddr1) + pk.SetOptedIn(ctx, consumerId, providerAddr2) res, err := pk.QueryConsumerChainOptedInValidators(ctx, &req) require.NoError(t, err) require.Equal(t, &expectedResponse, res) } func TestQueryConsumerValidators(t *testing.T) { - chainID := "chainID" - pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerId := "0" + req := types.QueryConsumerValidatorsRequest{ - ChainId: chainID, + ConsumerId: consumerId, } // error returned from not-started chain _, err := pk.QueryConsumerValidators(ctx, &req) require.Error(t, err) - providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) - consumerKey1 := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() - consumerValidator1 := types.ConsensusValidator{ProviderConsAddr: providerAddr1.ToSdkConsAddr(), Power: 1, PublicKey: &consumerKey1} - expectedCommissionRate1 := math.LegacyMustNewDecFromStr("0.123") - pk.SetConsumerCommissionRate(ctx, chainID, providerAddr1, expectedCommissionRate1) + val1 := createStakingValidator(ctx, mocks, 1, 1, 1) + valConsAddr1, _ := val1.GetConsAddr() + providerAddr1 := types.NewProviderConsAddress(valConsAddr1) + pk1, _ := val1.CmtConsPublicKey() + consumerValidator1 := types.ConsensusValidator{ProviderConsAddr: providerAddr1.ToSdkConsAddr(), Power: 1, PublicKey: &pk1} + val1.Tokens = sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction) + val1.Description = stakingtypes.Description{Moniker: "ConsumerValidator1"} + val1.Commission.Rate = math.LegacyMustNewDecFromStr("0.123") + + val2 := createStakingValidator(ctx, mocks, 1, 2, 2) + valConsAddr2, _ := val2.GetConsAddr() + providerAddr2 := types.NewProviderConsAddress(valConsAddr2) + pk2, _ := val2.CmtConsPublicKey() + consumerValidator2 := types.ConsensusValidator{ProviderConsAddr: providerAddr2.ToSdkConsAddr(), Power: 2, PublicKey: &pk2} + val2.Tokens = sdk.TokensFromConsensusPower(2, sdk.DefaultPowerReduction) + val2.Description = stakingtypes.Description{Moniker: "ConsumerValidator2"} + val2.Commission.Rate = math.LegacyMustNewDecFromStr("0.123") - providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) - consumerKey2 := cryptotestutil.NewCryptoIdentityFromIntSeed(2).TMProtoCryptoPublicKey() - consumerValidator2 := types.ConsensusValidator{ProviderConsAddr: providerAddr2.ToSdkConsAddr(), Power: 2, PublicKey: &consumerKey2} - expectedCommissionRate2 := math.LegacyMustNewDecFromStr("0.123") - pk.SetConsumerCommissionRate(ctx, chainID, providerAddr2, expectedCommissionRate2) + // set up the client id so the chain looks like it "started" + pk.SetConsumerClientId(ctx, consumerId, "clientID") + pk.SetConsumerValSet(ctx, consumerId, []types.ConsensusValidator{consumerValidator1, consumerValidator2}) + // set a consumer commission rate for val1 + val1ConsComRate := math.LegacyMustNewDecFromStr("0.456") + pk.SetConsumerCommissionRate(ctx, consumerId, providerAddr1, val1ConsComRate) expectedResponse := types.QueryConsumerValidatorsResponse{ Validators: []*types.QueryConsumerValidatorsValidator{ - {ProviderAddress: providerAddr1.String(), ConsumerKey: &consumerKey1, Power: 1, Rate: expectedCommissionRate1}, - {ProviderAddress: providerAddr2.String(), ConsumerKey: &consumerKey2, Power: 2, Rate: expectedCommissionRate2}, + { + ProviderAddress: providerAddr1.String(), + ConsumerKey: &pk1, + ConsumerPower: 1, + ConsumerCommissionRate: val1ConsComRate, + Description: val1.Description, + ProviderOperatorAddress: val1.OperatorAddress, + Jailed: val1.Jailed, + Status: val1.Status, + ProviderTokens: val1.Tokens, + ProviderCommissionRate: val1.Commission.Rate, + ProviderPower: 1, + ValidatesCurrentEpoch: true, + }, + { + ProviderAddress: providerAddr2.String(), + ConsumerKey: &pk2, + ConsumerPower: 2, + ConsumerCommissionRate: val2.Commission.Rate, + Description: val2.Description, + ProviderOperatorAddress: val2.OperatorAddress, + Jailed: val2.Jailed, + Status: val2.Status, + ProviderTokens: val2.Tokens, + ProviderCommissionRate: val2.Commission.Rate, + ProviderPower: 2, + ValidatesCurrentEpoch: true, + }, }, } - // set up the client id so the chain looks like it "started" - pk.SetConsumerClientId(ctx, chainID, "clientID") - pk.SetConsumerValSet(ctx, chainID, []types.ConsensusValidator{consumerValidator1, consumerValidator2}) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr1).Return(val1, nil).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr2).Return(val2, nil).AnyTimes() + mocks.MockStakingKeeper.EXPECT().PowerReduction(ctx).Return(sdk.DefaultPowerReduction).AnyTimes() + + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{val1, val2}, -1) // -1 to allow the calls "AnyTimes" res, err := pk.QueryConsumerValidators(ctx, &req) require.NoError(t, err) require.Equal(t, &expectedResponse, res) // validator with no set consumer commission rate - pk.DeleteConsumerCommissionRate(ctx, chainID, providerAddr1) - expectedCommissionRate := math.LegacyMustNewDecFromStr("0.456") + pk.DeleteConsumerCommissionRate(ctx, consumerId, providerAddr1) // because no consumer commission rate is set, the validator's set commission rate on the provider is used - val := stakingtypes.Validator{Commission: stakingtypes.Commission{CommissionRates: stakingtypes.CommissionRates{Rate: expectedCommissionRate}}} - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr( - ctx, providerAddr1.ToSdkConsAddr()).Return(val, nil).Times(1) - res, _ = pk.QueryConsumerValidators(ctx, &req) - require.Equal(t, expectedCommissionRate, res.Validators[0].Rate) + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Equal(t, val1.Commission.Rate, res.Validators[0].ConsumerCommissionRate) } func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { @@ -197,14 +237,14 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { } func TestQueryValidatorConsumerCommissionRate(t *testing.T) { - chainID := "chainID" + consumerId := "0" pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) req := types.QueryValidatorConsumerCommissionRateRequest{ - ChainId: chainID, + ConsumerId: consumerId, ProviderAddress: providerAddr.String(), } @@ -212,15 +252,17 @@ func TestQueryValidatorConsumerCommissionRate(t *testing.T) { _, err := pk.QueryValidatorConsumerCommissionRate(ctx, &req) require.Error(t, err) - pk.SetProposedConsumerChain(ctx, chainID, 1) + pk.FetchAndIncrementConsumerId(ctx) + pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized) + // validator with set consumer commission rate expectedCommissionRate := math.LegacyMustNewDecFromStr("0.123") - pk.SetConsumerCommissionRate(ctx, chainID, providerAddr, expectedCommissionRate) + pk.SetConsumerCommissionRate(ctx, consumerId, providerAddr, expectedCommissionRate) res, _ := pk.QueryValidatorConsumerCommissionRate(ctx, &req) require.Equal(t, expectedCommissionRate, res.Rate) // validator with no set consumer commission rate - pk.DeleteConsumerCommissionRate(ctx, chainID, providerAddr) + pk.DeleteConsumerCommissionRate(ctx, consumerId, providerAddr) expectedCommissionRate = math.LegacyMustNewDecFromStr("0.456") // because no consumer commission rate is set, the validator's set commission rate on the provider is used @@ -285,9 +327,11 @@ func TestGetConsumerChain(t *testing.T) { clientID := fmt.Sprintf("client-%d", len(chainIDs)-i) topN := topNs[i] pk.SetConsumerClientId(ctx, chainID, clientID) - pk.SetTopN(ctx, chainID, topN) - pk.SetValidatorSetCap(ctx, chainID, validatorSetCaps[i]) - pk.SetValidatorsPowerCap(ctx, chainID, validatorPowerCaps[i]) + pk.SetConsumerPowerShapingParameters(ctx, chainID, types.PowerShapingParameters{ + Top_N: topN, + ValidatorSetCap: validatorSetCaps[i], + ValidatorsPowerCap: validatorPowerCaps[i], + }) pk.SetMinimumPowerInTopN(ctx, chainID, expectedMinPowerInTopNs[i]) for _, addr := range allowlists[i] { pk.SetAllowlist(ctx, chainID, addr) @@ -318,9 +362,25 @@ func TestGetConsumerChain(t *testing.T) { }) } - for i, chainID := range pk.GetAllRegisteredAndProposedChainIDs(ctx) { + for i, chainID := range pk.GetAllActiveConsumerIds(ctx) { c, err := pk.GetConsumerChain(ctx, chainID) require.NoError(t, err) require.Equal(t, expectedGetAllOrder[i], c) } } + +func TestQueryConsumerIdFromClientId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.QueryConsumerIdFromClientId(ctx, &types.QueryConsumerIdFromClientIdRequest{ClientId: "clientId"}) + require.Error(t, err) + require.ErrorContains(t, err, "no known consumer chain") + + expectedConsumerId := "consumerId" + providerKeeper.SetClientIdToConsumerId(ctx, "clientId", expectedConsumerId) + + res, err := providerKeeper.QueryConsumerIdFromClientId(ctx, &types.QueryConsumerIdFromClientIdRequest{ClientId: "clientId"}) + require.NoError(t, err) + require.Equal(t, expectedConsumerId, res.ConsumerId) +} diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index a72f60080f..841db8330e 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -2,8 +2,8 @@ package keeper import ( "context" - "cosmossdk.io/math" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -106,26 +106,76 @@ func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) err // // AfterProposalSubmission - call hook if registered -// After a consumerAddition proposal submission, a record is created -// that maps the proposal ID to the consumer chain ID. -func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalID uint64) error { +// If an update consumer message exists in the proposal, a record is created that maps the proposal id to the consumer id +func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalId uint64) error { ctx := sdk.UnwrapSDKContext(goCtx) - if p, ok := h.GetConsumerAdditionFromProp(ctx, proposalID); ok { - h.k.SetProposedConsumerChain(ctx, p.ChainId, proposalID) + + p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) + if err != nil { + return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) } + + hasUpdateConsumerMsg := false + for _, msg := range p.GetMessages() { + sdkMsg, isMsgUpdateConsumer := msg.GetCachedValue().(*providertypes.MsgUpdateConsumer) + if isMsgUpdateConsumer { + // A `MsgUpdateConsumer` can only succeed if the owner of the consumer chain is the gov module. + // If that's not the case, we immediately fail the proposal. + // Note that someone could potentially change the owner of a chain to be that of the gov module + // while a proposal is active and before the proposal is executed. Even then, we still do not allow + // `MsgUpdateConsumer` proposals if the owner of the chain is not the gov module to avoid someone forgetting + // to change the owner address while the proposal is active. + ownerAddress, err := h.k.GetConsumerOwnerAddress(ctx, sdkMsg.ConsumerId) + if err != nil { + return fmt.Errorf("cannot find owner address for consumer with consumer id (%s): %s", sdkMsg.ConsumerId, err.Error()) + } else if ownerAddress != h.k.GetAuthority() { + return fmt.Errorf("owner address (%s) is not the gov module (%s)", ownerAddress, h.k.GetAuthority()) + } + + if hasUpdateConsumerMsg { + return fmt.Errorf("proposal can contain at most one `MsgUpdateConsumer` message") + } + hasUpdateConsumerMsg = true + h.k.SetProposalIdToConsumerId(ctx, proposalId, sdkMsg.ConsumerId) + } + + // if the proposal contains a deprecated message, cancel the proposal + _, isMsgConsumerAddition := msg.GetCachedValue().(*providertypes.MsgConsumerAddition) + if isMsgConsumerAddition { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerAddition`; use `MsgCreateConsumer` instead") + } + + _, isMsgConsumerModification := msg.GetCachedValue().(*providertypes.MsgConsumerModification) + if isMsgConsumerModification { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerModification`; use `MsgUpdateConsumer` instead") + } + _, isMsgConsumerRemoval := msg.GetCachedValue().(*providertypes.MsgConsumerRemoval) + if isMsgConsumerRemoval { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerRemoval`; use `MsgRemoveConsumer` instead") + } + } + return nil } // AfterProposalVotingPeriodEnded - call hook if registered -// After proposal voting ends, the consumer chainID in store is deleted. -// When a consumerAddition proposal passes, the consumer chainID is available in providerKeeper.GetAllPendingConsumerAdditionProps -// or providerKeeper.GetAllConsumerChains(ctx). -func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalID uint64) error { +// After proposal voting ends, the consumer to proposal id record in store is deleted. +func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalId uint64) error { ctx := sdk.UnwrapSDKContext(goCtx) - if _, ok := h.GetConsumerAdditionFromProp(ctx, proposalID); ok { - h.k.DeleteProposedConsumerChainInStore(ctx, proposalID) + p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) + if err != nil { + return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) } + + for _, msg := range p.GetMessages() { + _, isUpdateConsumer := msg.GetCachedValue().(*providertypes.MsgUpdateConsumer) + if isUpdateConsumer { + h.k.DeleteProposalIdToConsumerId(ctx, proposalId) + return nil + } + } + return nil } diff --git a/x/ccv/provider/keeper/hooks_test.go b/x/ccv/provider/keeper/hooks_test.go index 2447b5edf3..8f7f90c948 100644 --- a/x/ccv/provider/keeper/hooks_test.go +++ b/x/ccv/provider/keeper/hooks_test.go @@ -1,13 +1,12 @@ package keeper_test import ( - "testing" - sdk "github.com/cosmos/cosmos-sdk/types" cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "github.com/golang/mock/gomock" + "testing" ) func TestValidatorConsensusKeyInUse(t *testing.T) { @@ -30,32 +29,40 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { { name: "in use by another validator", setup: func(ctx sdk.Context, k providerkeeper.Keeper) { + k.FetchAndIncrementConsumerId(ctx) + k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) + // We are trying to add a new validator, but its address has already been used // by another validator - k.SetValidatorByConsumerAddr(ctx, "chainid", + k.SetValidatorByConsumerAddr(ctx, "0", newValidator.ConsumerConsAddress(), anotherValidator0.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "chainid", "clientID") + k.SetConsumerClientId(ctx, "0", "clientId") }, expect: true, }, { name: "in use by one of several other validators", setup: func(ctx sdk.Context, k providerkeeper.Keeper) { + k.FetchAndIncrementConsumerId(ctx) + k.FetchAndIncrementConsumerId(ctx) + k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) + k.SetConsumerPhase(ctx, "1", providerkeeper.Initialized) + // We are trying to add a new validator, but its address has already been used // by another validator, of which there are several, across potentially several chains - k.SetValidatorByConsumerAddr(ctx, "chainid0", + k.SetValidatorByConsumerAddr(ctx, "0", newValidator.ConsumerConsAddress(), anotherValidator0.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "chainid0", "clientID0") + k.SetConsumerClientId(ctx, "0", "clientId0") - k.SetValidatorByConsumerAddr(ctx, "chainid1", + k.SetValidatorByConsumerAddr(ctx, "1", anotherValidator1.ConsumerConsAddress(), anotherValidator1.ProviderConsAddress(), ) - k.SetConsumerClientId(ctx, "chainid1", "clientID1") + k.SetConsumerClientId(ctx, "1", "clientId1") }, expect: true, }, diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 1125ae52c8..46f641f660 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -189,54 +189,53 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability return k.scopedKeeper.ClaimCapability(ctx, cap, name) } -// SetChainToChannel sets the mapping from a consumer chainID to the CCV channel ID for that consumer chain. -func (k Keeper) SetChainToChannel(ctx sdk.Context, chainID, channelID string) { +// SetConsumerIdToChannelId sets the mapping from a consumer id to the CCV channel id for that consumer chain. +func (k Keeper) SetConsumerIdToChannelId(ctx sdk.Context, consumerId, channelId string) { store := ctx.KVStore(k.storeKey) - store.Set(types.ChainToChannelKey(chainID), []byte(channelID)) + store.Set(types.ConsumerIdToChannelIdKey(consumerId), []byte(channelId)) } -// GetChainToChannel gets the CCV channelID for the given consumer chainID -func (k Keeper) GetChainToChannel(ctx sdk.Context, chainID string) (string, bool) { +// GetConsumerIdToChannelId gets the CCV channelId for the given consumer id +func (k Keeper) GetConsumerIdToChannelId(ctx sdk.Context, consumerId string) (string, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ChainToChannelKey(chainID)) + bz := store.Get(types.ConsumerIdToChannelIdKey(consumerId)) if bz == nil { return "", false } return string(bz), true } -// DeleteChainToChannel deletes the CCV channel ID for the given consumer chain ID -func (k Keeper) DeleteChainToChannel(ctx sdk.Context, chainID string) { +// DeleteConsumerIdToChannelId deletes the CCV channel id for the given consumer id +func (k Keeper) DeleteConsumerIdToChannelId(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ChainToChannelKey(chainID)) + store.Delete(types.ConsumerIdToChannelIdKey(consumerId)) } -// SetProposedConsumerChain stores a consumer chainId corresponding to a submitted consumer addition proposal -// This consumer chainId is deleted once the voting period for the proposal ends. -func (k Keeper) SetProposedConsumerChain(ctx sdk.Context, chainID string, proposalID uint64) { +// SetProposalIdToConsumerId stores a consumer id corresponding to a proposal that contains a `MsgUpdateConsumer` mesage. +// This consumer id is deleted once the voting period for the proposal ends. +func (k Keeper) SetProposalIdToConsumerId(ctx sdk.Context, proposalId uint64, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Set(types.ProposedConsumerChainKey(proposalID), []byte(chainID)) + store.Set(types.ProposedConsumerChainKey(proposalId), []byte(consumerId)) } -// GetProposedConsumerChain returns the proposed chainID for the given consumerAddition proposal ID. +// GetProposalIdToConsumerId returns the proposed consumer id for the given proposal id. // This method is only used for testing. -func (k Keeper) GetProposedConsumerChain(ctx sdk.Context, proposalID uint64) (string, bool) { +func (k Keeper) GetProposalIdToConsumerId(ctx sdk.Context, proposalId uint64) (string, bool) { store := ctx.KVStore(k.storeKey) - consumerChain := store.Get(types.ProposedConsumerChainKey(proposalID)) + consumerChain := store.Get(types.ProposedConsumerChainKey(proposalId)) if consumerChain != nil { return string(consumerChain), true } return "", false } -// DeleteProposedConsumerChainInStore deletes the consumer chainID from store -// which is in gov consumerAddition proposal -func (k Keeper) DeleteProposedConsumerChainInStore(ctx sdk.Context, proposalID uint64) { +// DeleteProposalIdToConsumerId deletes the proposal to consumer id record from store +func (k Keeper) DeleteProposalIdToConsumerId(ctx sdk.Context, proposalId uint64) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ProposedConsumerChainKey(proposalID)) + store.Delete(types.ProposedConsumerChainKey(proposalId)) } -// GetAllProposedConsumerChainIDs returns the proposed chainID of all gov consumerAddition proposals that are still in the voting period. +// GetAllProposedConsumerChainIDs returns the proposed consumer ids of all gov proposals that are still in the voting period func (k Keeper) GetAllProposedConsumerChainIDs(ctx sdk.Context) []types.ProposedChain { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, types.ProposedConsumerChainKeyPrefix()) @@ -250,7 +249,7 @@ func (k Keeper) GetAllProposedConsumerChainIDs(ctx sdk.Context) []types.Proposed } proposedChains = append(proposedChains, types.ProposedChain{ - ChainID: string(iterator.Value()), + ConsumerId: string(iterator.Value()), ProposalID: proposalID, }) @@ -270,90 +269,96 @@ func (k Keeper) GetAllPendingConsumerChainIDs(ctx sdk.Context) []string { return chainIDs } -// GetAllRegisteredConsumerChainIDs gets all of the consumer chain IDs, for which the provider module +// GetAllRegisteredConsumerIds gets all of the consumer chain IDs, for which the provider module // created IBC clients. Consumer chains with created clients are also referred to as registered. // // Note that the registered consumer chains are stored under keys with the following format: -// ChainToClientKeyPrefix | chainID +// ConsumerIdToClientIdKeyPrefix | consumerId // Thus, the returned array is in ascending order of chainIDs. -func (k Keeper) GetAllRegisteredConsumerChainIDs(ctx sdk.Context) []string { - chainIDs := []string{} +func (k Keeper) GetAllRegisteredConsumerIds(ctx sdk.Context) []string { + consumerIds := []string{} store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChainToClientKeyPrefix()) + iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdToClientIdKeyPrefix()) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - // remove 1 byte prefix from key to retrieve chainID - chainID := string(iterator.Key()[1:]) - chainIDs = append(chainIDs, chainID) + // remove 1 byte prefix from key to retrieve consumerId + consumerId := string(iterator.Key()[1:]) + consumerIds = append(consumerIds, consumerId) } - return chainIDs + return consumerIds } -// SetChannelToChain sets the mapping from the CCV channel ID to the consumer chainID. -func (k Keeper) SetChannelToChain(ctx sdk.Context, channelID, chainID string) { +// SetChannelToConsumerId sets the mapping from the CCV channel id to the consumer id. +func (k Keeper) SetChannelToConsumerId(ctx sdk.Context, channelId, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Set(types.ChannelToChainKey(channelID), []byte(chainID)) + store.Set(types.ChannelToConsumerIdKey(channelId), []byte(consumerId)) } -// GetChannelToChain gets the consumer chainID for a given CCV channelID -func (k Keeper) GetChannelToChain(ctx sdk.Context, channelID string) (string, bool) { +// GetChannelIdToConsumerId gets the consumer id for a given CCV channel id +func (k Keeper) GetChannelIdToConsumerId(ctx sdk.Context, channelID string) (string, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ChannelToChainKey(channelID)) + bz := store.Get(types.ChannelToConsumerIdKey(channelID)) if bz == nil { return "", false } return string(bz), true } -// DeleteChannelToChain deletes the consumer chain ID for a given CCV channelID -func (k Keeper) DeleteChannelToChain(ctx sdk.Context, channelID string) { +// DeleteChannelIdToConsumerId deletes the consumer id for a given CCV channel id +func (k Keeper) DeleteChannelIdToConsumerId(ctx sdk.Context, channelId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ChannelToChainKey(channelID)) + store.Delete(types.ChannelToConsumerIdKey(channelId)) } -// GetAllChannelToChains gets all channel to chain mappings. If a mapping exists, +// GetAllChannelToConsumers gets all channel to chain mappings. If a mapping exists, // then the CCV channel to that consumer chain is established. // -// Note that mapping from CCV channel IDs to consumer chainIDs +// Note that mapping from CCV channel IDs to consumer IDs // is stored under keys with the following format: -// ChannelToChainKeyPrefix | channelID +// ChannelIdToConsumerIdKeyPrefix | channelID // Thus, the returned array is in ascending order of channelIDs. -func (k Keeper) GetAllChannelToChains(ctx sdk.Context) (channels []types.ChannelToChain) { +func (k Keeper) GetAllChannelToConsumers(ctx sdk.Context) (channelsToConsumers []struct { + ChannelId string + ConsumerId string +}) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChannelToChainKeyPrefix()) + iterator := storetypes.KVStorePrefixIterator(store, types.ChannelIdToConsumerIdKeyPrefix()) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // remove prefix from key to retrieve channelID channelID := string(iterator.Key()[1:]) - chainID := string(iterator.Value()) - - channels = append(channels, types.ChannelToChain{ - ChannelId: channelID, - ChainId: chainID, + consumerId := string(iterator.Value()) + + channelsToConsumers = append(channelsToConsumers, struct { + ChannelId string + ConsumerId string + }{ + ChannelId: channelID, + ConsumerId: consumerId, }) } - return channels + return channelsToConsumers } -func (k Keeper) SetConsumerGenesis(ctx sdk.Context, chainID string, gen ccv.ConsumerGenesisState) error { +func (k Keeper) SetConsumerGenesis(ctx sdk.Context, consumerId string, gen ccv.ConsumerGenesisState) error { store := ctx.KVStore(k.storeKey) bz, err := gen.Marshal() if err != nil { return err } - store.Set(types.ConsumerGenesisKey(chainID), bz) + store.Set(types.ConsumerGenesisKey(consumerId), bz) return nil } -func (k Keeper) GetConsumerGenesis(ctx sdk.Context, chainID string) (ccv.ConsumerGenesisState, bool) { +func (k Keeper) GetConsumerGenesis(ctx sdk.Context, consumerId string) (ccv.ConsumerGenesisState, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ConsumerGenesisKey(chainID)) + bz := store.Get(types.ConsumerGenesisKey(consumerId)) if bz == nil { return ccv.ConsumerGenesisState{}, false } @@ -367,9 +372,9 @@ func (k Keeper) GetConsumerGenesis(ctx sdk.Context, chainID string) (ccv.Consume return data, true } -func (k Keeper) DeleteConsumerGenesis(ctx sdk.Context, chainID string) { +func (k Keeper) DeleteConsumerGenesis(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerGenesisKey(chainID)) + store.Delete(types.ConsumerGenesisKey(consumerId)) } // VerifyConsumerChain verifies that the chain trying to connect on the channel handshake @@ -379,21 +384,26 @@ func (k Keeper) VerifyConsumerChain(ctx sdk.Context, channelID string, connectio return errorsmod.Wrap(channeltypes.ErrTooManyConnectionHops, "must have direct connection to provider chain") } connectionID := connectionHops[0] - clientID, tmClient, err := k.getUnderlyingClient(ctx, connectionID) + clientId, _, err := k.getUnderlyingClient(ctx, connectionID) if err != nil { return err } - ccvClientId, found := k.GetConsumerClientId(ctx, tmClient.ChainId) + + consumerId, found := k.GetClientIdToConsumerId(ctx, clientId) + if !found { + return errorsmod.Wrapf(ccv.ErrConsumerChainNotFound, "cannot find consumer id associated with client id: %s", clientId) + } + ccvClientId, found := k.GetConsumerClientId(ctx, consumerId) if !found { - return errorsmod.Wrapf(ccv.ErrClientNotFound, "cannot find client for consumer chain %s", tmClient.ChainId) + return errorsmod.Wrapf(ccv.ErrClientNotFound, "cannot find client for consumer chain %s", consumerId) } - if ccvClientId != clientID { - return errorsmod.Wrapf(types.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID) + if ccvClientId != clientId { + return errorsmod.Wrapf(types.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientId) } // Verify that there isn't already a CCV channel for the consumer chain - if prevChannel, ok := k.GetChainToChannel(ctx, tmClient.ChainId); ok { - return errorsmod.Wrapf(ccv.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain %s", prevChannel, tmClient.ChainId) + if prevChannel, ok := k.GetConsumerIdToChannelId(ctx, consumerId); ok { + return errorsmod.Wrapf(ccv.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain %s", prevChannel, consumerId) } return nil } @@ -418,18 +428,22 @@ func (k Keeper) SetConsumerChain(ctx sdk.Context, channelID string) error { if err != nil { return err } + consumerId, found := k.GetClientIdToConsumerId(ctx, clientID) + if !found { + return errorsmod.Wrapf(types.ErrNoConsumerId, "cannot find a consumer chain associated for this client: %s", clientID) + } // Verify that there isn't already a CCV channel for the consumer chain chainID := tmClient.ChainId - if prevChannelID, ok := k.GetChainToChannel(ctx, chainID); ok { - return errorsmod.Wrapf(ccv.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain %s", prevChannelID, chainID) + if prevChannelID, ok := k.GetConsumerIdToChannelId(ctx, consumerId); ok { + return errorsmod.Wrapf(ccv.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain with id %s", prevChannelID, consumerId) } // the CCV channel is established: // - set channel mappings - k.SetChainToChannel(ctx, chainID, channelID) - k.SetChannelToChain(ctx, channelID, chainID) + k.SetConsumerIdToChannelId(ctx, consumerId, channelID) + k.SetChannelToConsumerId(ctx, channelID, consumerId) // - set current block height for the consumer chain initialization - k.SetInitChainHeight(ctx, chainID, uint64(ctx.BlockHeight())) + k.SetInitChainHeight(ctx, consumerId, uint64(ctx.BlockHeight())) // emit event on successful addition ctx.EventManager().EmitEvent( @@ -554,7 +568,7 @@ func (k Keeper) DeleteValsetUpdateBlockHeight(ctx sdk.Context, valsetUpdateId ui // // TODO: SlashAcks should be persisted as a list of ConsumerConsAddr types, not strings. // See https://github.com/cosmos/interchain-security/issues/728 -func (k Keeper) SetSlashAcks(ctx sdk.Context, chainID string, acks []string) { +func (k Keeper) SetSlashAcks(ctx sdk.Context, consumerId string, acks []string) { store := ctx.KVStore(k.storeKey) sa := types.SlashAcks{ @@ -566,16 +580,16 @@ func (k Keeper) SetSlashAcks(ctx sdk.Context, chainID string, acks []string) { // sa is instantiated in this method and should be able to be marshaled. panic(fmt.Errorf("failed to marshal SlashAcks: %w", err)) } - store.Set(types.SlashAcksKey(chainID), bz) + store.Set(types.SlashAcksKey(consumerId), bz) } -// GetSlashAcks returns the slash acks stored under the given chain ID +// GetSlashAcks returns the slash acks stored under the given consumer id // // TODO: SlashAcks should be persisted as a list of ConsumerConsAddr types, not strings. // See https://github.com/cosmos/interchain-security/issues/728 -func (k Keeper) GetSlashAcks(ctx sdk.Context, chainID string) []string { +func (k Keeper) GetSlashAcks(ctx sdk.Context, consumerId string) []string { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.SlashAcksKey(chainID)) + bz := store.Get(types.SlashAcksKey(consumerId)) if bz == nil { return nil } @@ -589,45 +603,45 @@ func (k Keeper) GetSlashAcks(ctx sdk.Context, chainID string) []string { return acks.GetAddresses() } -// ConsumeSlashAcks empties and returns the slash acks for a given chain ID -func (k Keeper) ConsumeSlashAcks(ctx sdk.Context, chainID string) (acks []string) { - acks = k.GetSlashAcks(ctx, chainID) +// ConsumeSlashAcks empties and returns the slash acks for a given consumer id +func (k Keeper) ConsumeSlashAcks(ctx sdk.Context, consumerId string) (acks []string) { + acks = k.GetSlashAcks(ctx, consumerId) if len(acks) < 1 { return } store := ctx.KVStore(k.storeKey) - store.Delete(types.SlashAcksKey(chainID)) + store.Delete(types.SlashAcksKey(consumerId)) return } -// DeleteSlashAcks deletes the slash acks for a given chain ID -func (k Keeper) DeleteSlashAcks(ctx sdk.Context, chainID string) { +// DeleteSlashAcks deletes the slash acks for a given consumer id +func (k Keeper) DeleteSlashAcks(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.SlashAcksKey(chainID)) + store.Delete(types.SlashAcksKey(consumerId)) } -// AppendSlashAck appends the given slash ack to the given chain ID slash acks in store -func (k Keeper) AppendSlashAck(ctx sdk.Context, chainID, +// AppendSlashAck appends the given slash ack to the given consumer id slash acks in store +func (k Keeper) AppendSlashAck(ctx sdk.Context, consumerId, ack string, // TODO: consumer cons addr should be accepted here, see https://github.com/cosmos/interchain-security/issues/728 ) { - acks := k.GetSlashAcks(ctx, chainID) + acks := k.GetSlashAcks(ctx, consumerId) acks = append(acks, ack) - k.SetSlashAcks(ctx, chainID, acks) + k.SetSlashAcks(ctx, consumerId, acks) } // SetInitChainHeight sets the provider block height when the given consumer chain was initiated -func (k Keeper) SetInitChainHeight(ctx sdk.Context, chainID string, height uint64) { +func (k Keeper) SetInitChainHeight(ctx sdk.Context, consumerId string, height uint64) { store := ctx.KVStore(k.storeKey) heightBytes := make([]byte, 8) binary.BigEndian.PutUint64(heightBytes, height) - store.Set(types.InitChainHeightKey(chainID), heightBytes) + store.Set(types.InitChainHeightKey(consumerId), heightBytes) } // GetInitChainHeight returns the provider block height when the given consumer chain was initiated -func (k Keeper) GetInitChainHeight(ctx sdk.Context, chainID string) (uint64, bool) { +func (k Keeper) GetInitChainHeight(ctx sdk.Context, consumerId string) (uint64, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.InitChainHeightKey(chainID)) + bz := store.Get(types.InitChainHeightKey(consumerId)) if bz == nil { return 0, false } @@ -636,17 +650,17 @@ func (k Keeper) GetInitChainHeight(ctx sdk.Context, chainID string) (uint64, boo } // DeleteInitChainHeight deletes the block height value for which the given consumer chain's channel was established -func (k Keeper) DeleteInitChainHeight(ctx sdk.Context, chainID string) { +func (k Keeper) DeleteInitChainHeight(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.InitChainHeightKey(chainID)) + store.Delete(types.InitChainHeightKey(consumerId)) } -// GetPendingVSCPackets returns the list of pending ValidatorSetChange packets stored under chain ID -func (k Keeper) GetPendingVSCPackets(ctx sdk.Context, chainID string) []ccv.ValidatorSetChangePacketData { +// GetPendingVSCPackets returns the list of pending ValidatorSetChange packets stored under consumer id +func (k Keeper) GetPendingVSCPackets(ctx sdk.Context, consumerId string) []ccv.ValidatorSetChangePacketData { var packets types.ValidatorSetChangePackets store := ctx.KVStore(k.storeKey) - bz := store.Get(types.PendingVSCsKey(chainID)) + bz := store.Get(types.PendingVSCsKey(consumerId)) if bz == nil { return []ccv.ValidatorSetChangePacketData{} } @@ -659,9 +673,9 @@ func (k Keeper) GetPendingVSCPackets(ctx sdk.Context, chainID string) []ccv.Vali } // AppendPendingVSCPackets adds the given ValidatorSetChange packet to the list -// of pending ValidatorSetChange packets stored under chain ID -func (k Keeper) AppendPendingVSCPackets(ctx sdk.Context, chainID string, newPackets ...ccv.ValidatorSetChangePacketData) { - pds := append(k.GetPendingVSCPackets(ctx, chainID), newPackets...) +// of pending ValidatorSetChange packets stored under consumer id +func (k Keeper) AppendPendingVSCPackets(ctx sdk.Context, consumerId string, newPackets ...ccv.ValidatorSetChangePacketData) { + pds := append(k.GetPendingVSCPackets(ctx, consumerId), newPackets...) store := ctx.KVStore(k.storeKey) packets := types.ValidatorSetChangePackets{List: pds} @@ -671,35 +685,35 @@ func (k Keeper) AppendPendingVSCPackets(ctx sdk.Context, chainID string, newPack // packets is instantiated in this method and should be able to be marshaled. panic(fmt.Errorf("cannot marshal pending validator set changes: %w", err)) } - store.Set(types.PendingVSCsKey(chainID), buf) + store.Set(types.PendingVSCsKey(consumerId), buf) } // DeletePendingVSCPackets deletes the list of pending ValidatorSetChange packets for chain ID -func (k Keeper) DeletePendingVSCPackets(ctx sdk.Context, chainID string) { +func (k Keeper) DeletePendingVSCPackets(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.PendingVSCsKey(chainID)) + store.Delete(types.PendingVSCsKey(consumerId)) } -// SetConsumerClientId sets the client ID for the given chain ID -func (k Keeper) SetConsumerClientId(ctx sdk.Context, chainID, clientID string) { +// SetConsumerClientId sets the client id for the given consumer id +func (k Keeper) SetConsumerClientId(ctx sdk.Context, consumerId, clientID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.ChainToClientKey(chainID), []byte(clientID)) + store.Set(types.ConsumerIdToClientIdKey(consumerId), []byte(clientID)) } -// GetConsumerClientId returns the client ID for the given chain ID. -func (k Keeper) GetConsumerClientId(ctx sdk.Context, chainID string) (string, bool) { +// GetConsumerClientId returns the client id for the given consumer id. +func (k Keeper) GetConsumerClientId(ctx sdk.Context, consumerId string) (string, bool) { store := ctx.KVStore(k.storeKey) - clientIdBytes := store.Get(types.ChainToClientKey(chainID)) + clientIdBytes := store.Get(types.ConsumerIdToClientIdKey(consumerId)) if clientIdBytes == nil { return "", false } return string(clientIdBytes), true } -// DeleteConsumerClientId removes from the store the clientID for the given chainID. -func (k Keeper) DeleteConsumerClientId(ctx sdk.Context, chainID string) { +// DeleteConsumerClientId removes from the store the client id for the given consumer id. +func (k Keeper) DeleteConsumerClientId(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ChainToClientKey(chainID)) + store.Delete(types.ConsumerIdToClientIdKey(consumerId)) } // SetSlashLog updates validator's slash log for a consumer chain @@ -728,101 +742,83 @@ func (k Keeper) BondDenom(ctx sdk.Context) (string, error) { return k.stakingKeeper.BondDenom(ctx) } -func (k Keeper) GetAllRegisteredAndProposedChainIDs(ctx sdk.Context) []string { - allConsumerChains := []string{} - allConsumerChains = append(allConsumerChains, k.GetAllRegisteredConsumerChainIDs(ctx)...) - proposedChains := k.GetAllProposedConsumerChainIDs(ctx) - for _, proposedChain := range proposedChains { - allConsumerChains = append(allConsumerChains, proposedChain.ChainID) +// GetAllActiveConsumerIds returns all the consumer ids of chains that are registered, initialized, or launched +func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { + latestConsumerId, found := k.GetConsumerId(ctx) + if !found { + return []string{} } - pendingChainIDs := k.GetAllPendingConsumerChainIDs(ctx) - allConsumerChains = append(allConsumerChains, pendingChainIDs...) - - return allConsumerChains -} -// SetTopN stores the N value associated to chain with `chainID` -func (k Keeper) SetTopN( - ctx sdk.Context, - chainID string, - N uint32, -) { - store := ctx.KVStore(k.storeKey) - - buf := make([]byte, 4) - binary.BigEndian.PutUint32(buf, N) - - store.Set(types.TopNKey(chainID), buf) -} + consumerIds := []string{} + for i := uint64(0); i <= latestConsumerId; i++ { + consumerId := fmt.Sprintf("%d", i) + phase, foundPhase := k.GetConsumerPhase(ctx, consumerId) + if !foundPhase || (phase != Registered && phase != Initialized && phase != Launched) { + continue + } + consumerIds = append(consumerIds, consumerId) + } -// DeleteTopN removes the N value associated to chain with `chainID` -func (k Keeper) DeleteTopN( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.TopNKey(chainID)) + return consumerIds } -// GetTopN returns (N, true) if chain `chainID` has a top N associated, and (0, false) otherwise. +// GetTopN returns N if chain `consumerId` has a top N associated, and 0 otherwise. func (k Keeper) GetTopN( ctx sdk.Context, - chainID string, -) (uint32, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.TopNKey(chainID)) - if buf == nil { - return 0, false + consumerId string, +) uint32 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) } - return binary.BigEndian.Uint32(buf), true + + return powerShapingParameters.Top_N } -// IsTopN returns true if chain with `chainID` is a Top-N chain (i.e., enforces at least one validator to validate chain `chainID`) -func (k Keeper) IsTopN(ctx sdk.Context, chainID string) bool { - topN, found := k.GetTopN(ctx, chainID) - return found && topN > 0 +// IsTopN returns true if chain with `consumerId` is a Top-N chain (i.e., enforces at least one validator to validate chain `consumerId`) +func (k Keeper) IsTopN(ctx sdk.Context, consumerId string) bool { + return k.GetTopN(ctx, consumerId) > 0 } -// IsOptIn returns true if chain with `chainID` is an Opt-In chain (i.e., no validator is forced to validate chain `chainID`) -func (k Keeper) IsOptIn(ctx sdk.Context, chainID string) bool { - topN, found := k.GetTopN(ctx, chainID) - return !found || topN == 0 +// IsOptIn returns true if chain with `consumerId` is an Opt-In chain (i.e., no validator is forced to validate chain `consumerId`) +func (k Keeper) IsOptIn(ctx sdk.Context, consumerId string) bool { + return k.GetTopN(ctx, consumerId) == 0 } func (k Keeper) SetOptedIn( ctx sdk.Context, - chainID string, + consumerId string, providerConsAddress types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Set(types.OptedInKey(chainID, providerConsAddress), []byte{}) + store.Set(types.OptedInKey(consumerId, providerConsAddress), []byte{}) } func (k Keeper) DeleteOptedIn( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.OptedInKey(chainID, providerAddr)) + store.Delete(types.OptedInKey(consumerId, providerAddr)) } func (k Keeper) IsOptedIn( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) bool { store := ctx.KVStore(k.storeKey) - return store.Get(types.OptedInKey(chainID, providerAddr)) != nil + return store.Get(types.OptedInKey(consumerId, providerAddr)) != nil } -// GetAllOptedIn returns all the opted-in validators on chain `chainID` +// GetAllOptedIn returns all the opted-in validators on chain `consumerId` func (k Keeper) GetAllOptedIn( ctx sdk.Context, - chainID string, + consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ChainIdWithLenKey(types.OptedInKeyPrefix(), chainID) + key := types.ConsumerIdWithLenKey(types.OptedInKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -833,13 +829,13 @@ func (k Keeper) GetAllOptedIn( return providerConsAddresses } -// DeleteAllOptedIn deletes all the opted-in validators for chain with `chainID` +// DeleteAllOptedIn deletes all the opted-in validators for chain with `consumerId` func (k Keeper) DeleteAllOptedIn( ctx sdk.Context, - chainID string, + consumerId string, ) { store := ctx.KVStore(k.storeKey) - key := types.ChainIdWithLenKey(types.OptedInKeyPrefix(), chainID) + key := types.ConsumerIdWithLenKey(types.OptedInKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) var keysToDel [][]byte @@ -856,7 +852,7 @@ func (k Keeper) DeleteAllOptedIn( // for the given validator address func (k Keeper) SetConsumerCommissionRate( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec, ) error { @@ -868,7 +864,7 @@ func (k Keeper) SetConsumerCommissionRate( return err } - store.Set(types.ConsumerCommissionRateKey(chainID, providerAddr), bz) + store.Set(types.ConsumerCommissionRateKey(consumerId, providerAddr), bz) return nil } @@ -876,11 +872,11 @@ func (k Keeper) SetConsumerCommissionRate( // for the given validator address func (k Keeper) GetConsumerCommissionRate( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) (math.LegacyDec, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ConsumerCommissionRateKey(chainID, providerAddr)) + bz := store.Get(types.ConsumerCommissionRateKey(consumerId, providerAddr)) if bz == nil { return math.LegacyZeroDec(), false } @@ -896,13 +892,13 @@ func (k Keeper) GetConsumerCommissionRate( } // GetAllCommissionRateValidators returns all the validator address -// that set a commission rate for the given chain ID +// that set a commission rate for the given consumer id func (k Keeper) GetAllCommissionRateValidators( ctx sdk.Context, - chainID string, + consumerId string, ) (addresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ChainIdWithLenKey(types.ConsumerCommissionRateKeyPrefix(), chainID) + key := types.ConsumerIdWithLenKey(types.ConsumerCommissionRateKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -918,102 +914,54 @@ func (k Keeper) GetAllCommissionRateValidators( // associated to the given validator address func (k Keeper) DeleteConsumerCommissionRate( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerCommissionRateKey(chainID, providerAddr)) -} - -// SetValidatorsPowerCap sets the power-cap value `p` associated to chain with `chainID` -func (k Keeper) SetValidatorsPowerCap( - ctx sdk.Context, - chainID string, - p uint32, -) { - store := ctx.KVStore(k.storeKey) - - buf := make([]byte, 4) - binary.BigEndian.PutUint32(buf, p) - - store.Set(types.ValidatorsPowerCapKey(chainID), buf) -} - -// DeleteValidatorsPowerCap removes the power-cap value associated to chain with `chainID` -func (k Keeper) DeleteValidatorsPowerCap( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ValidatorsPowerCapKey(chainID)) + store.Delete(types.ConsumerCommissionRateKey(consumerId, providerAddr)) } -// GetValidatorsPowerCap returns `(p, true)` if chain `chainID` has power cap `p` associated with it, and (0, false) otherwise +// GetValidatorsPowerCap returns the associated power cap of chain with `consumerId` and 0 if no power cap association is found func (k Keeper) GetValidatorsPowerCap( ctx sdk.Context, - chainID string, -) (uint32, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.ValidatorsPowerCapKey(chainID)) - if buf == nil { - return 0, false + consumerId string, +) uint32 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) } - return binary.BigEndian.Uint32(buf), true + return powerShapingParameters.ValidatorsPowerCap } -// SetValidatorSetCap stores the validator-set cap value `c` associated to chain with `chainID` -func (k Keeper) SetValidatorSetCap( - ctx sdk.Context, - chainID string, - c uint32, -) { - store := ctx.KVStore(k.storeKey) - - buf := make([]byte, 4) - binary.BigEndian.PutUint32(buf, c) - - store.Set(types.ValidatorSetCapKey(chainID), buf) -} - -// DeleteValidatorSetCap removes the validator-set cap value associated to chain with `chainID` -func (k Keeper) DeleteValidatorSetCap( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ValidatorSetCapKey(chainID)) -} - -// GetValidatorSetCap returns `(c, true)` if chain `chainID` has validator-set cap `c` associated with it, and (0, false) otherwise +// GetValidatorSetCap returns the associated validator set cap of chain with `consumerId` and 0 if no set cap association is found func (k Keeper) GetValidatorSetCap( ctx sdk.Context, - chainID string, -) (uint32, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.ValidatorSetCapKey(chainID)) - if buf == nil { - return 0, false + consumerId string, +) uint32 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) } - return binary.BigEndian.Uint32(buf), true + return powerShapingParameters.ValidatorSetCap } -// SetAllowlist allowlists validator with `providerAddr` address on chain `chainID` +// SetAllowlist allowlists validator with `providerAddr` address on chain `consumerId` func (k Keeper) SetAllowlist( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Set(types.AllowlistKey(chainID, providerAddr), []byte{}) + store.Set(types.AllowlistKey(consumerId, providerAddr), []byte{}) } // GetAllowList returns all allowlisted validators func (k Keeper) GetAllowList( ctx sdk.Context, - chainID string, + consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ChainIdWithLenKey(types.AllowlistKeyPrefix(), chainID) + key := types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -1024,21 +972,21 @@ func (k Keeper) GetAllowList( return providerConsAddresses } -// IsAllowlisted returns `true` if validator with `providerAddr` has been allowlisted on chain `chainID` +// IsAllowlisted returns `true` if validator with `providerAddr` has been allowlisted on chain `consumerId` func (k Keeper) IsAllowlisted( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) bool { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.AllowlistKey(chainID, providerAddr)) + bz := store.Get(types.AllowlistKey(consumerId, providerAddr)) return bz != nil } // DeleteAllowlist deletes all allowlisted validators -func (k Keeper) DeleteAllowlist(ctx sdk.Context, chainID string) { +func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistKeyPrefix(), chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) defer iterator.Close() keysToDel := [][]byte{} @@ -1051,32 +999,32 @@ func (k Keeper) DeleteAllowlist(ctx sdk.Context, chainID string) { } } -// IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `chainID` -func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, chainID string) bool { +// IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `consumerId` +func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.AllowlistKeyPrefix(), chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) defer iterator.Close() return !iterator.Valid() } -// SetDenylist denylists validator with `providerAddr` address on chain `chainID` +// SetDenylist denylists validator with `providerAddr` address on chain `consumerId` func (k Keeper) SetDenylist( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) - store.Set(types.DenylistKey(chainID, providerAddr), []byte{}) + store.Set(types.DenylistKey(consumerId, providerAddr), []byte{}) } // GetDenyList returns all denylisted validators func (k Keeper) GetDenyList( ctx sdk.Context, - chainID string, + consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ChainIdWithLenKey(types.DenylistKeyPrefix(), chainID) + key := types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -1087,21 +1035,21 @@ func (k Keeper) GetDenyList( return providerConsAddresses } -// IsDenylisted returns `true` if validator with `providerAddr` has been denylisted on chain `chainID` +// IsDenylisted returns `true` if validator with `providerAddr` has been denylisted on chain `consumerId` func (k Keeper) IsDenylisted( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) bool { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.DenylistKey(chainID, providerAddr)) + bz := store.Get(types.DenylistKey(consumerId, providerAddr)) return bz != nil } // DeleteDenylist deletes all denylisted validators -func (k Keeper) DeleteDenylist(ctx sdk.Context, chainID string) { +func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistKeyPrefix(), chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) defer iterator.Close() keysToDel := [][]byte{} @@ -1114,10 +1062,10 @@ func (k Keeper) DeleteDenylist(ctx sdk.Context, chainID string) { } } -// IsDenylistEmpty returns `true` if no validator is denylisted on chain `chainID` -func (k Keeper) IsDenylistEmpty(ctx sdk.Context, chainID string) bool { +// IsDenylistEmpty returns `true` if no validator is denylisted on chain `consumerId` +func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ChainIdWithLenKey(types.DenylistKeyPrefix(), chainID)) + iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) defer iterator.Close() return !iterator.Valid() @@ -1127,7 +1075,7 @@ func (k Keeper) IsDenylistEmpty(ctx sdk.Context, chainID string) bool { // for a given consumer chain. func (k Keeper) SetMinimumPowerInTopN( ctx sdk.Context, - chainID string, + consumerId string, power int64, ) { store := ctx.KVStore(k.storeKey) @@ -1135,17 +1083,17 @@ func (k Keeper) SetMinimumPowerInTopN( buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, uint64(power)) - store.Set(types.MinimumPowerInTopNKey(chainID), buf) + store.Set(types.MinimumPowerInTopNKey(consumerId), buf) } // GetMinimumPowerInTopN returns the minimum power required for a validator to be in the top N // for a given consumer chain. func (k Keeper) GetMinimumPowerInTopN( ctx sdk.Context, - chainID string, + consumerId string, ) (int64, bool) { store := ctx.KVStore(k.storeKey) - buf := store.Get(types.MinimumPowerInTopNKey(chainID)) + buf := store.Get(types.MinimumPowerInTopNKey(consumerId)) if buf == nil { return 0, false } @@ -1156,93 +1104,36 @@ func (k Keeper) GetMinimumPowerInTopN( // for a given consumer chain. func (k Keeper) DeleteMinimumPowerInTopN( ctx sdk.Context, - chainID string, + consumerId string, ) { store := ctx.KVStore(k.storeKey) - store.Delete(types.MinimumPowerInTopNKey(chainID)) -} - -// SetMinStake sets the minimum stake required for a validator to validate -// a given consumer chain. -func (k Keeper) SetMinStake( - ctx sdk.Context, - chainID string, - minStake uint64, -) { - store := ctx.KVStore(k.storeKey) - - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, minStake) - - store.Set(types.MinStakeKey(chainID), buf) + store.Delete(types.MinimumPowerInTopNKey(consumerId)) } // GetMinStake returns the minimum stake required for a validator to validate -// a given consumer chain. +// a given consumer chain. Returns 0 if min stake is not found for this consumer id. func (k Keeper) GetMinStake( ctx sdk.Context, - chainID string, -) (uint64, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.MinStakeKey(chainID)) - if buf == nil { - return 0, false - } - return binary.BigEndian.Uint64(buf), true -} - -// DeleteMinStake removes the minimum stake required for a validator to validate -// a given consumer chain. -func (k Keeper) DeleteMinStake( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.MinStakeKey(chainID)) -} - -// SetInactiveValidatorsAllowed sets whether inactive validators are allowed to validate -// a given consumer chain. -func (k Keeper) SetInactiveValidatorsAllowed( - ctx sdk.Context, - chainID string, - allowed bool, -) { - if allowed { - k.EnableInactiveValidators(ctx, chainID) - } else { - k.DisableInactiveValidators(ctx, chainID) + consumerId string, +) uint64 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) } -} - -// EnableInactiveValidators sets the flag to signal that inactive validators are allowed to validate -// a given consumer chain. -func (k Keeper) EnableInactiveValidators( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Set(types.AllowInactiveValidatorsKey(chainID), []byte{}) + return powerShapingParameters.MinStake } // AllowsInactiveValidators returns whether inactive validators are allowed to validate -// a given consumer chain. +// a given consumer chain. Returns false if flag on inactive validators is not found for this consumer id. func (k Keeper) AllowsInactiveValidators( ctx sdk.Context, - chainID string, + consumerId string, ) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.AllowInactiveValidatorsKey(chainID)) -} - -// DisableInactiveValidators removes the flag of whether inactive validators are allowed to validate -// a given consumer chain. -func (k Keeper) DisableInactiveValidators( - ctx sdk.Context, - chainID string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.AllowInactiveValidatorsKey(chainID)) + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) + } + return powerShapingParameters.AllowInactiveVals } func (k Keeper) UnbondingCanComplete(ctx sdk.Context, id uint64) error { diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 442e86c09d..d781164e5b 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -229,7 +229,7 @@ func TestGetAllRegisteredConsumerChainIDs(t *testing.T) { defer ctrl.Finish() chainIDs := []string{"chain-2", "chain-1", "chain-4", "chain-3"} - // GetAllRegisteredConsumerChainIDs iterates over chainID in lexicographical order + // GetAllRegisteredConsumerIds iterates over consumerId in lexicographical order expectedChainIDs := []string{"chain-1", "chain-2", "chain-3", "chain-4"} for i, chainID := range chainIDs { @@ -237,30 +237,37 @@ func TestGetAllRegisteredConsumerChainIDs(t *testing.T) { pk.SetConsumerClientId(ctx, chainID, clientID) } - result := pk.GetAllRegisteredConsumerChainIDs(ctx) + result := pk.GetAllRegisteredConsumerIds(ctx) require.Len(t, result, len(chainIDs)) require.Equal(t, expectedChainIDs, result) } -// TestGetAllChannelToChains tests GetAllChannelToChains behaviour correctness +// TestGetAllChannelToChains tests GetAllChannelToConsumers behaviour correctness func TestGetAllChannelToChains(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainIDs := []string{"chain-2", "chain-1", "chain-4", "chain-3"} - expectedGetAllOrder := []types.ChannelToChain{} - for i, chainID := range chainIDs { - channelID := fmt.Sprintf("client-%d", len(chainIDs)-i) - pk.SetChannelToChain(ctx, channelID, chainID) - expectedGetAllOrder = append(expectedGetAllOrder, types.ChannelToChain{ChainId: chainID, ChannelId: channelID}) + consumerIds := []string{"2", "1", "4", "3"} + var expectedGetAllOrder []struct { + ChannelId string + ConsumerId string + } + + for i, consumerId := range consumerIds { + channelID := fmt.Sprintf("client-%d", len(consumerIds)-i) + pk.SetChannelToConsumerId(ctx, channelID, consumerId) + expectedGetAllOrder = append(expectedGetAllOrder, struct { + ChannelId string + ConsumerId string + }{ConsumerId: consumerId, ChannelId: channelID}) } // sorting by channelID sort.Slice(expectedGetAllOrder, func(i, j int) bool { return expectedGetAllOrder[i].ChannelId < expectedGetAllOrder[j].ChannelId }) - result := pk.GetAllChannelToChains(ctx) - require.Len(t, result, len(chainIDs)) + result := pk.GetAllChannelToConsumers(ctx) + require.Len(t, result, len(consumerIds)) require.Equal(t, expectedGetAllOrder, result) } @@ -282,19 +289,19 @@ func TestSetProposedConsumerChains(t *testing.T) { defer ctrl.Finish() tests := []struct { - chainID string - proposalID uint64 + consumerId string + proposalId uint64 }{ - {chainID: "1", proposalID: 1}, - {chainID: "some other ID", proposalID: 12}, - {chainID: "some other other chain ID", proposalID: 123}, - {chainID: "", proposalID: 1234}, + {consumerId: "1", proposalId: 1}, + {consumerId: "some other ID", proposalId: 12}, + {consumerId: "some other other chain ID", proposalId: 123}, + {consumerId: "", proposalId: 1234}, } for _, test := range tests { - providerKeeper.SetProposedConsumerChain(ctx, test.chainID, test.proposalID) - cID, _ := providerKeeper.GetProposedConsumerChain(ctx, test.proposalID) - require.Equal(t, cID, test.chainID) + providerKeeper.SetProposalIdToConsumerId(ctx, test.proposalId, test.consumerId) + cID, _ := providerKeeper.GetProposalIdToConsumerId(ctx, test.proposalId) + require.Equal(t, cID, test.consumerId) } } @@ -303,23 +310,23 @@ func TestDeleteProposedConsumerChainInStore(t *testing.T) { defer ctrl.Finish() tests := []struct { - chainID string - proposalID uint64 - deleteProposalID uint64 + chainId string + proposalId uint64 + deleteProposalId uint64 ok bool }{ - {chainID: "1", proposalID: 1, deleteProposalID: 1, ok: true}, - {chainID: "", proposalID: 12, deleteProposalID: 12, ok: true}, - {chainID: "1", proposalID: 0, deleteProposalID: 1, ok: false}, + {chainId: "1", proposalId: 1, deleteProposalId: 1, ok: true}, + {chainId: "", proposalId: 12, deleteProposalId: 12, ok: true}, + {chainId: "1", proposalId: 0, deleteProposalId: 1, ok: false}, } for _, test := range tests { - providerKeeper.SetProposedConsumerChain(ctx, test.chainID, test.proposalID) - providerKeeper.DeleteProposedConsumerChainInStore(ctx, test.deleteProposalID) - cID, found := providerKeeper.GetProposedConsumerChain(ctx, test.proposalID) + providerKeeper.SetProposalIdToConsumerId(ctx, test.proposalId, test.chainId) + providerKeeper.DeleteProposalIdToConsumerId(ctx, test.deleteProposalId) + cID, found := providerKeeper.GetProposalIdToConsumerId(ctx, test.proposalId) if test.ok { require.False(t, found) } else { - require.Equal(t, cID, test.chainID) + require.Equal(t, cID, test.chainId) } } } @@ -331,21 +338,21 @@ func TestGetAllProposedConsumerChainIDs(t *testing.T) { {}, { { - ChainID: "1", + ConsumerId: "1", ProposalID: 1, }, }, { { - ChainID: "1", + ConsumerId: "1", ProposalID: 1, }, { - ChainID: "2", + ConsumerId: "2", ProposalID: 2, }, { - ChainID: "", + ConsumerId: "", ProposalID: 3, }, }, @@ -353,7 +360,7 @@ func TestGetAllProposedConsumerChainIDs(t *testing.T) { for _, test := range tests { for _, tc := range test { - providerKeeper.SetProposedConsumerChain(ctx, tc.ChainID, tc.ProposalID) + providerKeeper.SetProposalIdToConsumerId(ctx, tc.ProposalID, tc.ConsumerId) } chains := providerKeeper.GetAllProposedConsumerChainIDs(ctx) @@ -367,7 +374,7 @@ func TestGetAllProposedConsumerChainIDs(t *testing.T) { require.Equal(t, chains, test) for _, tc := range test { - providerKeeper.DeleteProposedConsumerChainInStore(ctx, tc.ProposalID) + providerKeeper.DeleteProposalIdToConsumerId(ctx, tc.ProposalID) } } } @@ -378,27 +385,28 @@ func TestTopN(t *testing.T) { defer ctrl.Finish() tests := []struct { - chainID string - N uint32 - isOptIn bool + consumerId string + N uint32 + isOptIn bool }{ - {chainID: "TopNChain1", N: 50, isOptIn: false}, - {chainID: "TopNChain2", N: 100, isOptIn: false}, - {chainID: "OptInChain", N: 0, isOptIn: true}, + {consumerId: "TopNChain1", N: 50, isOptIn: false}, + {consumerId: "TopNChain2", N: 100, isOptIn: false}, + {consumerId: "OptInChain", N: 0, isOptIn: true}, } for _, test := range tests { - providerKeeper.SetTopN(ctx, test.chainID, test.N) - topN, found := providerKeeper.GetTopN(ctx, test.chainID) + providerKeeper.SetConsumerPowerShapingParameters(ctx, test.consumerId, types.PowerShapingParameters{ + Top_N: test.N, + }) + topN := providerKeeper.GetTopN(ctx, test.consumerId) require.Equal(t, test.N, topN) - require.True(t, found) if test.isOptIn { - require.True(t, providerKeeper.IsOptIn(ctx, test.chainID)) - require.False(t, providerKeeper.IsTopN(ctx, test.chainID)) + require.True(t, providerKeeper.IsOptIn(ctx, test.consumerId)) + require.False(t, providerKeeper.IsTopN(ctx, test.consumerId)) } else { - require.False(t, providerKeeper.IsOptIn(ctx, test.chainID)) - require.True(t, providerKeeper.IsTopN(ctx, test.chainID)) + require.False(t, providerKeeper.IsOptIn(ctx, test.consumerId)) + require.True(t, providerKeeper.IsTopN(ctx, test.consumerId)) } } } @@ -414,10 +422,10 @@ func TestGetAllOptedIn(t *testing.T) { } for _, expectedOptedInValidator := range expectedOptedInValidators { - providerKeeper.SetOptedIn(ctx, "chainID", expectedOptedInValidator) + providerKeeper.SetOptedIn(ctx, "consumerId", expectedOptedInValidator) } - actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "chainID") + actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "consumerId") // sort validators first to be able to compare sortOptedInValidators := func(addresses []types.ProviderConsAddress) { @@ -438,19 +446,19 @@ func TestOptedIn(t *testing.T) { optedInValidator1 := types.NewProviderConsAddress([]byte("providerAddr1")) optedInValidator2 := types.NewProviderConsAddress([]byte("providerAddr2")) - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator1)) - providerKeeper.SetOptedIn(ctx, "chainID", optedInValidator1) - require.True(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator1)) - providerKeeper.DeleteOptedIn(ctx, "chainID", optedInValidator1) - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator1)) - - providerKeeper.SetOptedIn(ctx, "chainID", optedInValidator1) - providerKeeper.SetOptedIn(ctx, "chainID", optedInValidator2) - require.True(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator1)) - require.True(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator2)) - providerKeeper.DeleteAllOptedIn(ctx, "chainID") - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator1)) - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", optedInValidator2)) + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) + providerKeeper.SetOptedIn(ctx, "consumerId", optedInValidator1) + require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", optedInValidator1) + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) + + providerKeeper.SetOptedIn(ctx, "consumerId", optedInValidator1) + providerKeeper.SetOptedIn(ctx, "consumerId", optedInValidator2) + require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) + require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator2)) + providerKeeper.DeleteAllOptedIn(ctx, "consumerId") + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator2)) } // TestConsumerCommissionRate tests the `SetConsumerCommissionRate`, `GetConsumerCommissionRate`, and `DeleteConsumerCommissionRate` methods @@ -461,31 +469,31 @@ func TestConsumerCommissionRate(t *testing.T) { providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) - cr, found := providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + cr, found := providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr1) require.False(t, found) require.Equal(t, math.LegacyZeroDec(), cr) - providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr1, math.LegacyOneDec()) - cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + providerKeeper.SetConsumerCommissionRate(ctx, "consumerId", providerAddr1, math.LegacyOneDec()) + cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr1) require.True(t, found) require.Equal(t, math.LegacyOneDec(), cr) - providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr2, math.LegacyZeroDec()) - cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr2) + providerKeeper.SetConsumerCommissionRate(ctx, "consumerId", providerAddr2, math.LegacyZeroDec()) + cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr2) require.True(t, found) require.Equal(t, math.LegacyZeroDec(), cr) - provAddrs := providerKeeper.GetAllCommissionRateValidators(ctx, "chainID") + provAddrs := providerKeeper.GetAllCommissionRateValidators(ctx, "consumerId") require.Len(t, provAddrs, 2) for _, addr := range provAddrs { - providerKeeper.DeleteConsumerCommissionRate(ctx, "chainID", addr) + providerKeeper.DeleteConsumerCommissionRate(ctx, "consumerId", addr) } - _, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + _, found = providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr1) require.False(t, found) - _, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr2) + _, found = providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr2) require.False(t, found) } @@ -494,7 +502,7 @@ func TestAllowlist(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" // no validator was allowlisted and hence the allowlist is empty require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) @@ -522,7 +530,7 @@ func TestDenylist(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" // no validator was denylisted and hence the denylist is empty require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) @@ -549,22 +557,25 @@ func TestDenylist(t *testing.T) { func TestAllowInactiveValidators(t *testing.T) { k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - chainID := "chainID" + consumerId := "consumerId" // check that by default, AllowsInactiveValidators returns false - require.False(t, k.AllowsInactiveValidators(ctx, chainID)) + require.False(t, k.AllowsInactiveValidators(ctx, consumerId)) // set the chain to allow inactive validators - k.SetInactiveValidatorsAllowed(ctx, chainID, true) - + k.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ + AllowInactiveVals: true, + }) // check that AllowsInactiveValidators returns true - require.True(t, k.AllowsInactiveValidators(ctx, chainID)) + require.True(t, k.AllowsInactiveValidators(ctx, consumerId)) // set the chain to not allow inactive validators - k.SetInactiveValidatorsAllowed(ctx, chainID, false) + k.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ + AllowInactiveVals: false, + }) // check that AllowsInactiveValidators returns false - require.False(t, k.AllowsInactiveValidators(ctx, chainID)) + require.False(t, k.AllowsInactiveValidators(ctx, consumerId)) } // Tests setting, getting and deleting parameters that are stored per-consumer chain. @@ -579,49 +590,65 @@ func TestKeeperConsumerParams(t *testing.T) { tests := []struct { name string settingFunc func(sdk.Context, string, int64) - getFunc func(sdk.Context, string) (int64, bool) + getFunc func(sdk.Context, string) int64 deleteFunc func(sdk.Context, string) initialValue int64 updatedValue int64 }{ { - name: "Minimum Power In Top N", - settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetMinimumPowerInTopN(ctx, id, val) }, - getFunc: func(ctx sdk.Context, id string) (int64, bool) { return k.GetMinimumPowerInTopN(ctx, id) }, + name: "Minimum Power In Top N", + settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetMinimumPowerInTopN(ctx, id, val) }, + getFunc: func(ctx sdk.Context, id string) int64 { + minimumPowerInTopN, _ := k.GetMinimumPowerInTopN(ctx, id) + return minimumPowerInTopN + }, deleteFunc: func(ctx sdk.Context, id string) { k.DeleteMinimumPowerInTopN(ctx, id) }, initialValue: 1000, updatedValue: 2000, }, { - name: "Minimum Stake", - settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetMinStake(ctx, id, uint64(val)) }, - getFunc: func(ctx sdk.Context, id string) (int64, bool) { - val, found := k.GetMinStake(ctx, id) - return int64(val), found + name: "Minimum Stake", + settingFunc: func(ctx sdk.Context, id string, val int64) { + k.SetConsumerPowerShapingParameters(ctx, id, + types.PowerShapingParameters{ + MinStake: uint64(val), + }) }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteMinStake(ctx, id) }, + getFunc: func(ctx sdk.Context, id string) int64 { + return int64(k.GetMinStake(ctx, id)) + }, + deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, initialValue: 1000, updatedValue: 2000, }, { - name: "Validator Set Cap", - settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetValidatorSetCap(ctx, id, uint32(val)) }, - getFunc: func(ctx sdk.Context, id string) (int64, bool) { - val, found := k.GetValidatorSetCap(ctx, id) - return int64(val), found + name: "Validator Set Cap", + settingFunc: func(ctx sdk.Context, id string, val int64) { + k.SetConsumerPowerShapingParameters(ctx, id, + types.PowerShapingParameters{ + ValidatorSetCap: uint32(val), + }) + }, + getFunc: func(ctx sdk.Context, id string) int64 { + return int64(k.GetValidatorSetCap(ctx, id)) }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteValidatorSetCap(ctx, id) }, + deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, initialValue: 10, updatedValue: 200, }, { - name: "Validator Powers Cap", - settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetValidatorsPowerCap(ctx, id, uint32(val)) }, - getFunc: func(ctx sdk.Context, id string) (int64, bool) { - val, found := k.GetValidatorsPowerCap(ctx, id) - return int64(val), found + name: "Validator Powers Cap", + settingFunc: func(ctx sdk.Context, id string, val int64) { + k.SetConsumerPowerShapingParameters(ctx, id, + types.PowerShapingParameters{ + ValidatorsPowerCap: uint32(val), + }) }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteValidatorsPowerCap(ctx, id) }, + getFunc: func(ctx sdk.Context, id string) int64 { + val := k.GetValidatorsPowerCap(ctx, id) + return int64(val) + }, + deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, initialValue: 10, updatedValue: 11, }, @@ -629,40 +656,38 @@ func TestKeeperConsumerParams(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - chainID := "chainID" + chainID := "consumerId" // Set initial value tt.settingFunc(ctx, chainID, int64(tt.initialValue)) // Retrieve and check initial value - actualValue, found := tt.getFunc(ctx, chainID) - require.True(t, found) + actualValue := tt.getFunc(ctx, chainID) require.EqualValues(t, tt.initialValue, actualValue) // Update value tt.settingFunc(ctx, chainID, int64(tt.updatedValue)) // Retrieve and check updated value - newActualValue, found := tt.getFunc(ctx, chainID) - require.True(t, found) + newActualValue := tt.getFunc(ctx, chainID) require.EqualValues(t, tt.updatedValue, newActualValue) - // Check non-existent chain ID - _, found = tt.getFunc(ctx, "not the chainID") - require.False(t, found) + // Check non-existent consumer id + res := tt.getFunc(ctx, "not the consumerId") + require.Zero(t, res) // Delete value tt.deleteFunc(ctx, chainID) // Check that value was deleted - _, found = tt.getFunc(ctx, chainID) - require.False(t, found) + res = tt.getFunc(ctx, chainID) + require.Zero(t, res) // Try deleting again tt.deleteFunc(ctx, chainID) // Check that the value is still deleted - _, found = tt.getFunc(ctx, chainID) - require.False(t, found) + res = tt.getFunc(ctx, chainID) + require.Zero(t, res) }) } } diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index 23dd20109d..2e3846feb4 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -67,11 +67,11 @@ func (k Keeper) ParseConsumerKey(consumerKey string) (tmprotocrypto.PublicKey, e // GetValidatorConsumerPubKey returns a validator's public key assigned for a consumer chain func (k Keeper) GetValidatorConsumerPubKey( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, ) (consumerKey tmprotocrypto.PublicKey, found bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ConsumerValidatorsKey(chainID, providerAddr)) + bz := store.Get(types.ConsumerValidatorsKey(consumerId, providerAddr)) if bz == nil { return consumerKey, false } @@ -87,7 +87,7 @@ func (k Keeper) GetValidatorConsumerPubKey( // SetValidatorConsumerPubKey sets a validator's public key assigned for a consumer chain func (k Keeper) SetValidatorConsumerPubKey( ctx sdk.Context, - chainID string, + consumerId string, providerAddr types.ProviderConsAddress, consumerKey tmprotocrypto.PublicKey, ) { @@ -98,33 +98,33 @@ func (k Keeper) SetValidatorConsumerPubKey( // the consumer key is obtained from GetValidatorConsumerPubKey, called from panic(fmt.Sprintf("failed to marshal consumer key: %v", err)) } - store.Set(types.ConsumerValidatorsKey(chainID, providerAddr), bz) + store.Set(types.ConsumerValidatorsKey(consumerId, providerAddr), bz) } // GetAllValidatorConsumerPubKeys gets all the validators public keys assigned for a consumer chain -// If chainID is nil, it returns all the validators public keys assigned for all consumer chains +// If consumerId is nil, it returns all the validators public keys assigned for all consumer chains // // Note that the validators public keys assigned for a consumer chain are stored under keys -// with the following format: ConsumerValidatorsBytePrefix | len(chainID) | chainID | providerAddress +// with the following format: ConsumerValidatorsBytePrefix | len(consumerId) | consumerId | providerAddress // Thus, the returned array is -// - in ascending order of providerAddresses, if chainID is not nil; -// - in undetermined order, if chainID is nil. -func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, chainID *string) (validatorConsumerPubKeys []types.ValidatorConsumerPubKey) { +// - in ascending order of providerAddresses, if consumerId is not nil; +// - in undetermined order, if consumerId is nil. +func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, consumerId *string) (validatorConsumerPubKeys []types.ValidatorConsumerPubKey) { store := ctx.KVStore(k.storeKey) var prefix []byte consumerValidatorsKeyPrefix := types.ConsumerValidatorsKeyPrefix() - if chainID == nil { + if consumerId == nil { // iterate over the validators public keys assigned for all consumer chains prefix = []byte{consumerValidatorsKeyPrefix} } else { - // iterate over the validators public keys assigned for chainID - prefix = types.ChainIdWithLenKey(consumerValidatorsKeyPrefix, *chainID) + // iterate over the validators public keys assigned for consumerId + prefix = types.ConsumerIdWithLenKey(consumerValidatorsKeyPrefix, *consumerId) } iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - // TODO: store chainID and provider cons address in value bytes, marshaled as protobuf type - chainID, providerAddrTmp, err := types.ParseChainIdAndConsAddrKey(consumerValidatorsKeyPrefix, iterator.Key()) + // TODO: store consumerId and provider cons address in value bytes, marshaled as protobuf type + consumerId, providerAddrTmp, err := types.ParseChainIdAndConsAddrKey(consumerValidatorsKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // the store key is assumed to be correctly serialized in SetValidatorConsumerPubKey. @@ -140,7 +140,7 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, chainID *string) } validatorConsumerPubKeys = append(validatorConsumerPubKeys, types.ValidatorConsumerPubKey{ - ChainId: chainID, + ChainId: consumerId, ProviderAddr: providerAddr.ToSdkConsAddr(), ConsumerKey: &consumerKey, }) @@ -150,20 +150,20 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, chainID *string) } // DeleteValidatorConsumerPubKey deletes a validator's public key assigned for a consumer chain -func (k Keeper) DeleteValidatorConsumerPubKey(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) { +func (k Keeper) DeleteValidatorConsumerPubKey(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerValidatorsKey(chainID, providerAddr)) + store.Delete(types.ConsumerValidatorsKey(consumerId, providerAddr)) } // GetValidatorByConsumerAddr returns a validator's consensus address on the provider // given the validator's consensus address on a consumer func (k Keeper) GetValidatorByConsumerAddr( ctx sdk.Context, - chainID string, + consumerId string, consumerAddr types.ConsumerConsAddress, ) (providerAddr types.ProviderConsAddress, found bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ValidatorsByConsumerAddrKey(chainID, consumerAddr)) + bz := store.Get(types.ValidatorsByConsumerAddrKey(consumerId, consumerAddr)) if bz == nil { return providerAddr, false } @@ -175,45 +175,45 @@ func (k Keeper) GetValidatorByConsumerAddr( // to the validator's consensus address on the provider func (k Keeper) SetValidatorByConsumerAddr( ctx sdk.Context, - chainID string, + consumerId string, consumerAddr types.ConsumerConsAddress, providerAddr types.ProviderConsAddress, ) { store := ctx.KVStore(k.storeKey) // Cons address is a type alias for a byte string, no marshaling needed bz := providerAddr.ToSdkConsAddr() - store.Set(types.ValidatorsByConsumerAddrKey(chainID, consumerAddr), bz) + store.Set(types.ValidatorsByConsumerAddrKey(consumerId, consumerAddr), bz) } // GetValidatorsByConsumerAddrs gets all the mappings from consensus addresses // on a given consumer chain to consensus addresses on the provider chain. -// If chainID is nil, it returns all the mappings from consensus addresses on all consumer chains. +// If consumerId is nil, it returns all the mappings from consensus addresses on all consumer chains. // // Note that the mappings for a consumer chain are stored under keys with the following format: -// ValidatorsByConsumerAddrKeyPrefix | len(chainID) | chainID | consumerAddress +// ValidatorsByConsumerAddrKeyPrefix | len(consumerId) | consumerId | consumerAddress // Thus, the returned array is -// - in ascending order of consumerAddresses, if chainID is not nil; -// - in undetermined order, if chainID is nil. -func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, chainID *string) (validatorConsumerAddrs []types.ValidatorByConsumerAddr) { +// - in ascending order of consumerAddresses, if consumerId is not nil; +// - in undetermined order, if consumerId is nil. +func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, consumerId *string) (validatorConsumerAddrs []types.ValidatorByConsumerAddr) { store := ctx.KVStore(k.storeKey) var prefix []byte validatorsByConsumerAddrKeyPrefix := types.ValidatorsByConsumerAddrKeyPrefix() - if chainID == nil { + if consumerId == nil { // iterate over the mappings from consensus addresses on all consumer chains prefix = []byte{validatorsByConsumerAddrKeyPrefix} } else { - // iterate over the mappings from consensus addresses on chainID - prefix = types.ChainIdWithLenKey(validatorsByConsumerAddrKeyPrefix, *chainID) + // iterate over the mappings from consensus addresses on consumerId + prefix = types.ConsumerIdWithLenKey(validatorsByConsumerAddrKeyPrefix, *consumerId) } iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - // TODO: store chainID and consumer cons address in value bytes, marshaled as protobuf type - chainID, consumerAddrTmp, err := types.ParseChainIdAndConsAddrKey(validatorsByConsumerAddrKeyPrefix, iterator.Key()) + // TODO: store consumerId and consumer cons address in value bytes, marshaled as protobuf type + consumerId, consumerAddrTmp, err := types.ParseChainIdAndConsAddrKey(validatorsByConsumerAddrKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in SetValidatorByConsumerAddr. - panic(fmt.Sprintf("failed to parse chainID and consumer address: %v", err)) + panic(fmt.Sprintf("failed to parse consumerId and consumer address: %v", err)) } consumerAddr := types.NewConsumerConsAddress(consumerAddrTmp) providerAddr := types.NewProviderConsAddress(iterator.Value()) @@ -221,7 +221,7 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, chainID *string) validatorConsumerAddrs = append(validatorConsumerAddrs, types.ValidatorByConsumerAddr{ ConsumerAddr: consumerAddr.ToSdkConsAddr(), ProviderAddr: providerAddr.ToSdkConsAddr(), - ChainId: chainID, + ChainId: consumerId, }) } @@ -230,9 +230,9 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, chainID *string) // DeleteValidatorByConsumerAddr deletes the mapping from a validator's consensus address on a consumer // to the validator's consensus address on the provider -func (k Keeper) DeleteValidatorByConsumerAddr(ctx sdk.Context, chainID string, consumerAddr types.ConsumerConsAddress) { +func (k Keeper) DeleteValidatorByConsumerAddr(ctx sdk.Context, consumerId string, consumerAddr types.ConsumerConsAddress) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ValidatorsByConsumerAddrKey(chainID, consumerAddr)) + store.Delete(types.ValidatorsByConsumerAddrKey(consumerId, consumerAddr)) } // AppendConsumerAddrsToPrune appends a consumer validator address to the list of consumer addresses @@ -245,12 +245,12 @@ func (k Keeper) DeleteValidatorByConsumerAddr(ctx sdk.Context, chainID string, c // - or there exists a timestamp in ConsumerAddrsToPrune s.t. cAddr in ConsumerAddrsToPrune(timestamp) func (k Keeper) AppendConsumerAddrsToPrune( ctx sdk.Context, - chainID string, + consumerId string, pruneTs time.Time, consumerAddr types.ConsumerConsAddress, ) { store := ctx.KVStore(k.storeKey) - storeKey := types.ConsumerAddrsToPruneV2Key(chainID, pruneTs) + storeKey := types.ConsumerAddrsToPruneV2Key(consumerId, pruneTs) bz := store.Get(storeKey) var consumerAddrsToPrune types.AddressList if bz != nil { @@ -275,12 +275,12 @@ func (k Keeper) AppendConsumerAddrsToPrune( // Note that this method is only used in testing. func (k Keeper) GetConsumerAddrsToPrune( ctx sdk.Context, - chainID string, + consumerId string, ts time.Time, ) (consumerAddrsToPrune types.AddressList) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ConsumerAddrsToPruneV2Key(chainID, ts)) + bz := store.Get(types.ConsumerAddrsToPruneV2Key(consumerId, ts)) if bz == nil { return } @@ -297,28 +297,28 @@ func (k Keeper) GetConsumerAddrsToPrune( // The returned addresses are removed from the store. // // Note that the list of all consumer addresses is stored under keys with the following format: -// ConsumerAddrsToPruneV2BytePrefix | len(chainID) | chainID | timestamp +// ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | timestamp // Thus, this method returns all the consumer addresses stored under keys in the following range: -// (ConsumerAddrsToPruneV2BytePrefix | len(chainID) | chainID | ts') where ts' <= ts +// (ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | ts') where ts' <= ts func (k Keeper) ConsumeConsumerAddrsToPrune( ctx sdk.Context, - chainID string, + consumerId string, ts time.Time, ) (consumerAddrsToPrune types.AddressList) { store := ctx.KVStore(k.storeKey) consumerAddrsToPruneKeyPrefix := types.ConsumerAddrsToPruneV2KeyPrefix() - startPrefix := types.ChainIdWithLenKey(consumerAddrsToPruneKeyPrefix, chainID) + startPrefix := types.ConsumerIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) iterator := store.Iterator(startPrefix, - storetypes.InclusiveEndBytes(types.ConsumerAddrsToPruneV2Key(chainID, ts))) + storetypes.InclusiveEndBytes(types.ConsumerAddrsToPruneV2Key(consumerId, ts))) defer iterator.Close() var keysToDel [][]byte for ; iterator.Valid(); iterator.Next() { // Sanity check - if _, pruneTs, err := types.ParseChainIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()); err != nil { + if _, pruneTs, err := types.ParseConsumerIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()); err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in AppendConsumerAddrsToPrune. - k.Logger(ctx).Error("ParseChainIdAndTsKey failed", + k.Logger(ctx).Error("ParseConsumerIdAndTsKey failed", "key", string(iterator.Key()), "error", err.Error(), ) @@ -352,19 +352,19 @@ func (k Keeper) ConsumeConsumerAddrsToPrune( return } -// GetAllConsumerAddrsToPrune gets all consumer addresses that can be eventually pruned for a given chainID. +// GetAllConsumerAddrsToPrune gets all consumer addresses that can be eventually pruned for a given consumerId. // // Note that the list of all consumer addresses is stored under keys with the following format: -// ConsumerAddrsToPruneV2BytePrefix | len(chainID) | chainID | timestamp +// ConsumerAddrsToPruneV2BytePrefix | len(consumerId) | consumerId | timestamp // Thus, the returned array is in ascending order of timestamps. -func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, chainID string) (consumerAddrsToPrune []types.ConsumerAddrsToPruneV2) { +func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, consumerId string) (consumerAddrsToPrune []types.ConsumerAddrsToPruneV2) { store := ctx.KVStore(k.storeKey) consumerAddrsToPruneKeyPrefix := types.ConsumerAddrsToPruneV2KeyPrefix() - iteratorPrefix := types.ChainIdWithLenKey(consumerAddrsToPruneKeyPrefix, chainID) + iteratorPrefix := types.ConsumerIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) iterator := storetypes.KVStorePrefixIterator(store, iteratorPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - _, ts, err := types.ParseChainIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()) + _, ts, err := types.ParseConsumerIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in AppendConsumerAddrsToPrune. @@ -381,7 +381,7 @@ func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, chainID string) (con consumerAddrsToPrune = append(consumerAddrsToPrune, types.ConsumerAddrsToPruneV2{ PruneTs: ts, ConsumerAddrs: &addrs, - ChainId: chainID, + ChainId: consumerId, }) } @@ -389,25 +389,25 @@ func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, chainID string) (con } // DeleteConsumerAddrsToPruneV2 deletes the list of consumer addresses mapped to a timestamp -func (k Keeper) DeleteConsumerAddrsToPrune(ctx sdk.Context, chainID string, pruneTs time.Time) { +func (k Keeper) DeleteConsumerAddrsToPrune(ctx sdk.Context, consumerId string, pruneTs time.Time) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerAddrsToPruneV2Key(chainID, pruneTs)) + store.Delete(types.ConsumerAddrsToPruneV2Key(consumerId, pruneTs)) } // AssignConsumerKey assigns the consumerKey to the validator with providerAddr -// on the consumer chain with ID chainID, if it is either registered or currently +// on the consumer chain with the given `consumerId`, if it is either registered or currently // voted on in a ConsumerAddition governance proposal func (k Keeper) AssignConsumerKey( ctx sdk.Context, - chainID string, + consumerId string, validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey, ) error { - // check that the consumer chain is either registered or that - // a ConsumerAdditionProposal was submitted. - if !k.IsConsumerProposedOrRegistered(ctx, chainID) { + phase, found := k.GetConsumerPhase(ctx, consumerId) + if !found || phase == Stopped { + //check that the consumer chain is either registered, initialized, or launched return errorsmod.Wrapf( - types.ErrUnknownConsumerChainId, chainID, + types.ErrUnknownConsumerId, consumerId, ) } @@ -433,7 +433,7 @@ func (k Keeper) AssignConsumerKey( } // We prevent a validator from assigning the default provider key as a consumer key // if it has not already assigned a different consumer key - _, found := k.GetValidatorConsumerPubKey(ctx, chainID, providerAddr) + _, found := k.GetValidatorConsumerPubKey(ctx, consumerId, providerAddr) if !found { return errorsmod.Wrapf( types.ErrCannotAssignDefaultKeyAssignment, @@ -442,7 +442,7 @@ func (k Keeper) AssignConsumerKey( } } - if _, found := k.GetValidatorByConsumerAddr(ctx, chainID, consumerAddr); found { + if _, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerAddr); found { // This consumer key is already in use, or it is to be pruned. With this check we prevent another validator // from assigning the same consumer key as some other validator. Additionally, we prevent a validator from // reusing a consumer key that it used in the past and is now to be pruned. @@ -452,16 +452,15 @@ func (k Keeper) AssignConsumerKey( } // get the previous key assigned for this validator on this consumer chain - if oldConsumerKey, found := k.GetValidatorConsumerPubKey(ctx, chainID, providerAddr); found { + if oldConsumerKey, found := k.GetValidatorConsumerPubKey(ctx, consumerId, providerAddr); found { oldConsumerAddrTmp, err := ccvtypes.TMCryptoPublicKeyToConsAddr(oldConsumerKey) if err != nil { return err } oldConsumerAddr := types.NewConsumerConsAddress(oldConsumerAddrTmp) - // check whether the consumer chain is already registered, - // i.e., a client to the consumer was already created - if _, consumerRegistered := k.GetConsumerClientId(ctx, chainID); consumerRegistered { + // check whether the consumer chain has already launched (i.e., a client to the consumer was already created) + if phase == Launched { // mark the old consumer address as prunable once UnbondingPeriod elapses; // note: this state is removed on EndBlock unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) @@ -470,26 +469,26 @@ func (k Keeper) AssignConsumerKey( } k.AppendConsumerAddrsToPrune( ctx, - chainID, + consumerId, ctx.BlockTime().Add(unbondingPeriod), oldConsumerAddr, ) } else { // if the consumer chain is not registered, then remove the mapping // from the old consumer address to the provider address - k.DeleteValidatorByConsumerAddr(ctx, chainID, oldConsumerAddr) + k.DeleteValidatorByConsumerAddr(ctx, consumerId, oldConsumerAddr) } } // set the mapping from this validator's provider address to the new consumer key; // overwrite if already exists // note: this state is deleted when the validator is removed from the staking module - k.SetValidatorConsumerPubKey(ctx, chainID, providerAddr, consumerKey) + k.SetValidatorConsumerPubKey(ctx, consumerId, providerAddr, consumerKey) // set the mapping from this validator's new consensus address on the consumer // to its consensus address on the provider; // note: this state must be deleted through the pruning mechanism - k.SetValidatorByConsumerAddr(ctx, chainID, consumerAddr, providerAddr) + k.SetValidatorByConsumerAddr(ctx, consumerId, consumerAddr, providerAddr) return nil } @@ -498,11 +497,11 @@ func (k Keeper) AssignConsumerKey( // consAddr set as the consensus address on a consumer chain func (k Keeper) GetProviderAddrFromConsumerAddr( ctx sdk.Context, - chainID string, + consumerId string, consumerAddr types.ConsumerConsAddress, ) types.ProviderConsAddress { // check if this address is known only to the consumer chain - if providerConsAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, consumerAddr); found { + if providerConsAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerAddr); found { return providerConsAddr } // If mapping from consumer -> provider addr is not found, there is no assigned key, @@ -512,46 +511,46 @@ func (k Keeper) GetProviderAddrFromConsumerAddr( // PruneKeyAssignments prunes the consumer addresses no longer needed // as they cannot be referenced in slash requests (by a correct consumer) -func (k Keeper) PruneKeyAssignments(ctx sdk.Context, chainID string) { +func (k Keeper) PruneKeyAssignments(ctx sdk.Context, consumerId string) { now := ctx.BlockTime() - consumerAddrs := k.ConsumeConsumerAddrsToPrune(ctx, chainID, now) + consumerAddrs := k.ConsumeConsumerAddrsToPrune(ctx, consumerId, now) for _, addrBz := range consumerAddrs.Addresses { consumerAddr := types.NewConsumerConsAddress(addrBz) - k.DeleteValidatorByConsumerAddr(ctx, chainID, consumerAddr) + k.DeleteValidatorByConsumerAddr(ctx, consumerId, consumerAddr) k.Logger(ctx).Info("consumer address was pruned", - "consumer chainID", chainID, + "consumer consumerId", consumerId, "consumer consensus addr", consumerAddr.String(), ) } } // DeleteKeyAssignments deletes all the state needed for key assignments on a consumer chain -func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, chainID string) { +func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, consumerId string) { // delete ValidatorConsumerPubKey - for _, validatorConsumerAddr := range k.GetAllValidatorConsumerPubKeys(ctx, &chainID) { + for _, validatorConsumerAddr := range k.GetAllValidatorConsumerPubKeys(ctx, &consumerId) { providerAddr := types.NewProviderConsAddress(validatorConsumerAddr.ProviderAddr) - k.DeleteValidatorConsumerPubKey(ctx, chainID, providerAddr) + k.DeleteValidatorConsumerPubKey(ctx, consumerId, providerAddr) } // delete ValidatorsByConsumerAddr - for _, validatorConsumerAddr := range k.GetAllValidatorsByConsumerAddr(ctx, &chainID) { + for _, validatorConsumerAddr := range k.GetAllValidatorsByConsumerAddr(ctx, &consumerId) { consumerAddr := types.NewConsumerConsAddress(validatorConsumerAddr.ConsumerAddr) - k.DeleteValidatorByConsumerAddr(ctx, chainID, consumerAddr) + k.DeleteValidatorByConsumerAddr(ctx, consumerId, consumerAddr) } // delete ValidatorConsumerPubKey - for _, consumerAddrsToPrune := range k.GetAllConsumerAddrsToPrune(ctx, chainID) { - k.DeleteConsumerAddrsToPrune(ctx, chainID, consumerAddrsToPrune.PruneTs) + for _, consumerAddrsToPrune := range k.GetAllConsumerAddrsToPrune(ctx, consumerId) { + k.DeleteConsumerAddrsToPrune(ctx, consumerId, consumerAddrsToPrune.PruneTs) } } // IsConsumerProposedOrRegistered checks if a consumer chain is either registered, meaning either already running // or will run soon, or proposed its ConsumerAdditionProposal was submitted but the chain was not yet added to ICS yet. -func (k Keeper) IsConsumerProposedOrRegistered(ctx sdk.Context, chainID string) bool { - allConsumerChains := k.GetAllRegisteredAndProposedChainIDs(ctx) +func (k Keeper) IsConsumerProposedOrRegistered(ctx sdk.Context, consumerId string) bool { + allConsumerChains := k.GetAllActiveConsumerIds(ctx) for _, c := range allConsumerChains { - if c == chainID { + if c == consumerId { return true } } @@ -578,8 +577,8 @@ func (k Keeper) ValidatorConsensusKeyInUse(ctx sdk.Context, valAddr sdk.ValAddre panic("could not get validator cons addr ") } - allConsumerChains := k.GetAllRegisteredAndProposedChainIDs(ctx) - for _, c := range allConsumerChains { + allConsumerIds := k.GetAllActiveConsumerIds(ctx) + for _, c := range allConsumerIds { if _, exist := k.GetValidatorByConsumerAddr(ctx, c, types.NewConsumerConsAddress(consensusAddr), diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index 7dbec09f40..290b8a6048 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -24,7 +24,7 @@ import ( ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -const ChainID = "chainID" +const ChainID = "consumerId" func TestValidatorConsumerPubKeyCRUD(t *testing.T) { chainID := consumer @@ -69,7 +69,7 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { }, ) } - // select a chainID with more than two assignments + // select a consumerId with more than two assignments var chainID string for i := range chainIDs { chainID = chainIDs[i] @@ -149,7 +149,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { }, ) } - // select a chainID with more than two assignments + // select a consumerId with more than two assignments var chainID string for i := range chainIDs { chainID = chainIDs[i] @@ -261,7 +261,7 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { }, ) } - // select a chainID with more than two assignments + // select a consumerId with more than two assignments var chainID string for i := range chainIDs { chainID = chainIDs[i] @@ -342,7 +342,7 @@ func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chain } func TestAssignConsensusKeyForConsumerChain(t *testing.T) { - chainID := ChainID + consumerId := "0" providerIdentities := []*cryptotestutil.CryptoIdentity{ cryptotestutil.NewCryptoIdentityFromIntSeed(0), cryptotestutil.NewCryptoIdentityFromIntSeed(1), @@ -359,26 +359,26 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { doActions func(sdk.Context, providerkeeper.Keeper) }{ /* - 0. Consumer not registered: Assign PK0->CK0 and error - 1. Consumer registered: Assign PK0->CK0 and retrieve PK0->CK0 - 2. Consumer registered: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1 - 3. Consumer registered: Assign PK0->CK0, PK1->CK0 and error - 4. Consumer registered: Assign PK1->PK0 and error - 5. Consumer proposed: Assign Assign PK0->CK0 and retrieve PK0->CK0 - 6. Consumer proposed: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1 - 7. Consumer proposed: Assign PK0->CK0, PK1->CK0 and error - 8. Consumer proposed: Assign PK1->PK0 and error + 0. Consumer not in the right phase: Assign PK0->CK0 and error + 1. Consumer launched: Assign PK0->CK0 and retrieve PK0->CK0 + 2. Consumer launched: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1 + 3. Consumer launched: Assign PK0->CK0, PK1->CK0 and error + 4. Consumer launched: Assign PK1->PK0 and error + 5. Consumer registered: Assign PK0->CK0 and retrieve PK0->CK0 + 6. Consumer registered: Assign PK0->CK0, PK0->CK1 and retrieve PK0->CK1 + 7. Consumer registered: Assign PK0->CK0, PK1->CK0 and error + 8. Consumer registered: Assign PK1->PK0 and error */ { name: "0", mockSetup: func(ctx sdk.Context, k providerkeeper.Keeper, mocks testkeeper.MockedKeepers) {}, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - err := k.AssignConsumerKey(ctx, chainID, + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.Error(t, err) - _, found := k.GetValidatorByConsumerAddr(ctx, chainID, + _, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[0].ConsumerConsAddress()) require.False(t, found) }, @@ -393,13 +393,13 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerClientId(ctx, chainID, "") - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[0].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -420,18 +420,18 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(sdkCtx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerClientId(sdkCtx, chainID, "") - err := k.AssignConsumerKey(sdkCtx, chainID, + k.SetConsumerPhase(sdkCtx, consumerId, providerkeeper.Launched) + err := k.AssignConsumerKey(sdkCtx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - err = k.AssignConsumerKey(sdkCtx, chainID, + err = k.AssignConsumerKey(sdkCtx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[1].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(sdkCtx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(sdkCtx, consumerId, consumerIdentities[1].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -450,18 +450,18 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerClientId(ctx, chainID, "") - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - err = k.AssignConsumerKey(ctx, chainID, + err = k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.Error(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[0].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -477,8 +477,8 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerClientId(ctx, chainID, "") - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), ) @@ -495,13 +495,13 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetProposedConsumerChain(ctx, chainID, 0) - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[0].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -520,18 +520,18 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetProposedConsumerChain(ctx, chainID, 0) - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - err = k.AssignConsumerKey(ctx, chainID, + err = k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[1].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[1].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -550,18 +550,18 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetProposedConsumerChain(ctx, chainID, 0) - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.NoError(t, err) - err = k.AssignConsumerKey(ctx, chainID, + err = k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), ) require.Error(t, err) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, chainID, + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, consumerId, consumerIdentities[0].ConsumerConsAddress()) require.True(t, found) require.Equal(t, providerIdentities[0].ProviderConsAddress(), providerAddr) @@ -577,8 +577,8 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetProposedConsumerChain(ctx, chainID, 0) - err := k.AssignConsumerKey(ctx, chainID, + k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), ) @@ -593,7 +593,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { tc.mockSetup(ctx, k, mocks) tc.doActions(ctx, k) - require.True(t, checkCorrectPruningProperty(ctx, k, chainID)) + require.True(t, checkCorrectPruningProperty(ctx, k, consumerId)) ctrl.Finish() }) @@ -613,9 +613,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ - ChainId: "chain", - }) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providerkeeper.Initialized) // Mock that the validator is validating with the single key, as confirmed by provider's staking keeper gomock.InOrder( @@ -625,7 +623,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) { ) // AssignConsumerKey should return an error if we try to re-assign the already existing default key assignment - err := providerKeeper.AssignConsumerKey(ctx, "chain", cId.SDKStakingValidator(), cId.TMProtoCryptoPublicKey()) + err := providerKeeper.AssignConsumerKey(ctx, "consumerId", cId.SDKStakingValidator(), cId.TMProtoCryptoPublicKey()) require.Error(t, err) // Confirm we're not returning an error for some other reason diff --git a/x/ccv/provider/keeper/legacy_proposal.go b/x/ccv/provider/keeper/legacy_proposal.go index d14773e5ed..074b611e47 100644 --- a/x/ccv/provider/keeper/legacy_proposal.go +++ b/x/ccv/provider/keeper/legacy_proposal.go @@ -1,7 +1,6 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -35,30 +34,6 @@ func (k Keeper) HandleLegacyConsumerRewardDenomProposal(ctx sdk.Context, p *type return nil } -// HandleConsumerAdditionProposal will receive the consumer chain's client state from the proposal. -// If the client can be successfully created in a cached context, it stores the proposal as a pending proposal. -// -// Note: This method implements SpawnConsumerChainProposalHandler in spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 -// Spec tag: [CCV-PCF-HCAPROP.1] -func (k Keeper) HandleLegacyConsumerAdditionProposal(ctx sdk.Context, p *types.ConsumerAdditionProposal) error { - // verify the consumer addition proposal execution - // in cached context and discard the cached writes - if _, _, err := k.CreateConsumerClientInCachedCtx(ctx, *p); err != nil { - return err - } - - k.SetPendingConsumerAdditionProp(ctx, p) - - k.Logger(ctx).Info("consumer addition proposal enqueued", - "chainID", p.ChainId, - "title", p.Title, - "spawn time", p.SpawnTime.UTC(), - ) - - return nil -} - // HandleConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. // If the consumer can be successfully stopped in a cached context, it stores the proposal as a pending proposal. // @@ -75,70 +50,10 @@ func (k Keeper) HandleLegacyConsumerRemovalProposal(ctx sdk.Context, p *types.Co k.SetPendingConsumerRemovalProp(ctx, p) k.Logger(ctx).Info("consumer removal proposal enqueued", - "chainID", p.ChainId, + "chain id", p.ChainId, "title", p.Title, "stop time", p.StopTime.UTC(), ) return nil } - -// HandleConsumerModificationProposal modifies a running consumer chain -func (k Keeper) HandleLegacyConsumerModificationProposal(ctx sdk.Context, p *types.ConsumerModificationProposal) error { - if _, found := k.GetConsumerClientId(ctx, p.ChainId); !found { - return errorsmod.Wrapf(types.ErrInvalidConsumerChainID, "consumer %s chain is not running", p.ChainId) - } - - k.SetTopN(ctx, p.ChainId, p.Top_N) - k.SetValidatorsPowerCap(ctx, p.ChainId, p.ValidatorsPowerCap) - k.SetValidatorSetCap(ctx, p.ChainId, p.ValidatorSetCap) - k.SetMinStake(ctx, p.ChainId, p.MinStake) - k.SetInactiveValidatorsAllowed(ctx, p.ChainId, p.AllowInactiveVals) - - k.DeleteAllowlist(ctx, p.ChainId) - for _, address := range p.Allowlist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetAllowlist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) - } - - k.DeleteDenylist(ctx, p.ChainId) - for _, address := range p.Denylist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetDenylist(ctx, p.ChainId, types.NewProviderConsAddress(consAddr)) - } - - oldTopN, found := k.GetTopN(ctx, p.ChainId) - if !found { - oldTopN = 0 - k.Logger(ctx).Info("consumer chain top N not found, treating as 0", "chainID", p.ChainId) - } - - // if the top N changes, we need to update the new minimum power in top N - if p.Top_N != oldTopN { - if p.Top_N > 0 { - // if the chain receives a non-zero top N value, store the minimum power in the top N - activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) - if err != nil { - return err - } - minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, p.Top_N) - if err != nil { - return err - } - k.SetMinimumPowerInTopN(ctx, p.ChainId, minPower) - } else { - // if the chain receives a zero top N value, we delete the min power - k.DeleteMinimumPowerInTopN(ctx, p.ChainId) - } - } - - return nil -} diff --git a/x/ccv/provider/keeper/legacy_proposal_test.go b/x/ccv/provider/keeper/legacy_proposal_test.go index 23c2c6a948..7f8a08d90b 100644 --- a/x/ccv/provider/keeper/legacy_proposal_test.go +++ b/x/ccv/provider/keeper/legacy_proposal_test.go @@ -4,13 +4,10 @@ import ( "testing" "time" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -20,124 +17,6 @@ import ( // Initialization sub-protocol related tests of proposal.go // -// Tests the HandleConsumerAdditionProposal method against the SpawnConsumerChainProposalHandler spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 -// Spec tag: [CCV-PCF-HCAPROP.1] -func TestHandleLegacyConsumerAdditionProposal(t *testing.T) { - type testCase struct { - description string - malleate func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) - prop *providertypes.ConsumerAdditionProposal - // Time when prop is handled - blockTime time.Time - // Whether it's expected that the proposal is successfully verified - // and appended to the pending proposals - expAppendProp bool - } - - // Snapshot times asserted in tests - now := time.Now().UTC() - - tests := []testCase{ - { - description: "expect to append valid proposal", - malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, - prop: providertypes.NewConsumerAdditionProposal( - "title", - "description", - "chainID", - clienttypes.NewHeight(2, 3), - []byte("gen_hash"), - []byte("bin_hash"), - now, // Spawn time - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - blockTime: now, - expAppendProp: true, - }, - { - description: "expect to not append invalid proposal using an already existing chain id", - malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "anyClientId") - }, - - prop: providertypes.NewConsumerAdditionProposal( - "title", - "description", - "chainID", - clienttypes.NewHeight(2, 3), - []byte("gen_hash"), - []byte("bin_hash"), - now, - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - blockTime: now, - expAppendProp: false, - }, - } - - for _, tc := range tests { - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - ctx = ctx.WithBlockTime(tc.blockTime) - - if tc.expAppendProp { - // Mock calls are only asserted if we expect a client to be created. - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{}, 1) - gomock.InOrder( - testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, tc.prop.ChainId, clienttypes.NewHeight(2, 3))..., - ) - } - - tc.malleate(ctx, providerKeeper, tc.prop.ChainId) - - err := providerKeeper.HandleLegacyConsumerAdditionProposal(ctx, tc.prop) - - if tc.expAppendProp { - require.NoError(t, err) - // check that prop was added to the stored pending props - gotProposal, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) - require.True(t, found) - require.Equal(t, *tc.prop, gotProposal) - } else { - require.Error(t, err) - // check that prop wasn't added to the stored pending props - _, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) - require.False(t, found) - } - - ctrl.Finish() - } -} - // TestHandleConsumerRemovalProposal tests HandleConsumerRemovalProposal against its corresponding spec method. // // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 @@ -155,7 +34,7 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { // and appended to the pending proposals expAppendProp bool - // chainID of the consumer chain + // consumerId of the consumer chain // tests need to check that the CCV channel is not closed prematurely chainId string } @@ -174,12 +53,12 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { prop: providertypes.NewConsumerRemovalProposal( "title", "description", - "chainID", + "consumerId", now, ).(*providertypes.ConsumerRemovalProposal), blockTime: hourAfterNow, // After stop time. expAppendProp: true, - chainId: "chainID", + chainId: "consumerId", }, { description: "valid proposal - stop_time in the past", @@ -189,12 +68,12 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { prop: providertypes.NewConsumerRemovalProposal( "title", "description", - "chainID", + "consumerId", hourBeforeNow, ).(*providertypes.ConsumerRemovalProposal), blockTime: hourAfterNow, // After stop time. expAppendProp: true, - chainId: "chainID", + chainId: "consumerId", }, { description: "valid proposal - before stop_time in the future", @@ -204,12 +83,12 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { prop: providertypes.NewConsumerRemovalProposal( "title", "description", - "chainID", + "consumerId", hourAfterNow, ).(*providertypes.ConsumerRemovalProposal), blockTime: now, expAppendProp: true, - chainId: "chainID", + chainId: "consumerId", }, { description: "rejected valid proposal - consumer chain does not exist", @@ -217,12 +96,12 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { prop: providertypes.NewConsumerRemovalProposal( "title", "description", - "chainID-2", + "consumerId-2", hourAfterNow, ).(*providertypes.ConsumerRemovalProposal), blockTime: hourAfterNow, // After stop time. expAppendProp: false, - chainId: "chainID-2", + chainId: "consumerId-2", }, } @@ -238,7 +117,7 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { // Note: when expAppendProp is false, no mocks are setup, // meaning no external keeper methods are allowed to be called. if tc.expAppendProp { - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, tc.prop.ChainId) // Valid client creation is asserted with mock expectations here gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) } @@ -255,7 +134,7 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { require.True(t, found) // confirm that the channel was not closed - _, found = providerKeeper.GetChainToChannel(ctx, tc.chainId) + _, found = providerKeeper.GetConsumerIdToChannelId(ctx, tc.chainId) require.True(t, found) } else { require.Error(t, err) @@ -269,66 +148,3 @@ func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { ctrl.Finish() } } - -func TestHandleConsumerModificationProposal(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - chainID := "chainID" - - // set up a consumer client, so it seems that "chainID" is running - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") - - // set PSS-related fields to update them later on - providerKeeper.SetTopN(ctx, chainID, 50) - providerKeeper.SetValidatorSetCap(ctx, chainID, 10) - providerKeeper.SetValidatorsPowerCap(ctx, chainID, 34) - providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr1"))) - providerKeeper.SetAllowlist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("allowlistedAddr2"))) - providerKeeper.SetDenylist(ctx, chainID, providertypes.NewProviderConsAddress([]byte("denylistedAddr1"))) - providerKeeper.SetMinStake(ctx, chainID, 1000) - providerKeeper.SetInactiveValidatorsAllowed(ctx, chainID, true) - - expectedTopN := uint32(75) - expectedValidatorsPowerCap := uint32(67) - expectedValidatorSetCap := uint32(20) - expectedAllowlistedValidator := "cosmosvalcons1wpex7anfv3jhystyv3eq20r35a" - expectedDenylistedValidator := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - expectedMinStake := uint64(0) - expectedAllowInactiveValidators := false - proposal := providertypes.NewConsumerModificationProposal("title", "description", chainID, - expectedTopN, - expectedValidatorsPowerCap, - expectedValidatorSetCap, - []string{expectedAllowlistedValidator}, - []string{expectedDenylistedValidator}, - expectedMinStake, - expectedAllowInactiveValidators, - ).(*providertypes.ConsumerModificationProposal) - - err := providerKeeper.HandleLegacyConsumerModificationProposal(ctx, proposal) - require.NoError(t, err) - - actualTopN, _ := providerKeeper.GetTopN(ctx, chainID) - require.Equal(t, expectedTopN, actualTopN) - actualValidatorsPowerCap, _ := providerKeeper.GetValidatorsPowerCap(ctx, chainID) - require.Equal(t, expectedValidatorsPowerCap, actualValidatorsPowerCap) - actualValidatorSetCap, _ := providerKeeper.GetValidatorSetCap(ctx, chainID) - require.Equal(t, expectedValidatorSetCap, actualValidatorSetCap) - - allowlistedValidator, err := sdk.ConsAddressFromBech32(expectedAllowlistedValidator) - require.NoError(t, err) - require.Equal(t, 1, len(providerKeeper.GetAllowList(ctx, chainID))) - require.Equal(t, providertypes.NewProviderConsAddress(allowlistedValidator), providerKeeper.GetAllowList(ctx, chainID)[0]) - - denylistedValidator, err := sdk.ConsAddressFromBech32(expectedDenylistedValidator) - require.NoError(t, err) - require.Equal(t, 1, len(providerKeeper.GetDenyList(ctx, chainID))) - require.Equal(t, providertypes.NewProviderConsAddress(denylistedValidator), providerKeeper.GetDenyList(ctx, chainID)[0]) - - actualMinStake, _ := providerKeeper.GetMinStake(ctx, chainID) - require.Equal(t, expectedMinStake, actualMinStake) - - actualAllowInactiveValidators := providerKeeper.AllowsInactiveValidators(ctx, chainID) - require.Equal(t, expectedAllowInactiveValidators, actualAllowInactiveValidators) -} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index da6f63cf8a..9550b7d620 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -2,18 +2,17 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" - + "fmt" + tmtypes "github.com/cometbft/cometbft/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" + "strings" + "time" ) type msgServer struct { @@ -67,11 +66,11 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign return nil, err } - if err := k.Keeper.AssignConsumerKey(ctx, msg.ChainId, validator, consumerTMPublicKey); err != nil { + if err := k.Keeper.AssignConsumerKey(ctx, msg.ConsumerId, validator, consumerTMPublicKey); err != nil { return nil, err } k.Logger(ctx).Info("assigned consumer key", - "consumer chainID", msg.ChainId, + "consumer id", msg.ConsumerId, "validator operator addr", msg.ProviderAddr, "consumer public key", msg.ConsumerKey, ) @@ -87,36 +86,33 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign return &types.MsgAssignConsumerKeyResponse{}, nil } -// ConsumerAddition defines an RPC handler method for MsgConsumerAddition -func (k msgServer) ConsumerAddition(goCtx context.Context, msg *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { +// RemoveConsumer defines an RPC handler method for MsgRemoveConsumer +func (k msgServer) RemoveConsumer( + goCtx context.Context, + msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { if k.GetAuthority() != msg.Authority { return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleConsumerAdditionProposal(ctx, msg) - if err != nil { - return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") - } - return &types.MsgConsumerAdditionResponse{}, nil -} -// ConsumerRemoval defines an RPC handler method for MsgConsumerRemoval -func (k msgServer) ConsumerRemoval( - goCtx context.Context, - msg *types.MsgConsumerRemoval, -) (*types.MsgConsumerRemovalResponse, error) { - if k.GetAuthority() != msg.Authority { - return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) + consumerId := msg.ConsumerId + + phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId) + if !found || phase != Launched { + return nil, errorsmod.Wrapf(types.ErrInvalidPhase, + "chain with consumer id: %s has to be in its launched phase", consumerId) } - ctx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleConsumerRemovalProposal(ctx, msg) - if err != nil { - return nil, errorsmod.Wrapf(err, "failed handling ConsumerAddition proposal") + previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) + if err == nil { + k.Keeper.RemoveConsumerFromToBeStoppedConsumers(ctx, consumerId, previousStopTime) } - return &types.MsgConsumerRemovalResponse{}, nil + k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime) + k.Keeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerId, msg.StopTime) + + return &types.MsgRemoveConsumerResponse{}, nil } // ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms @@ -136,7 +132,7 @@ func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChang func (k msgServer) SubmitConsumerMisbehaviour(goCtx context.Context, msg *types.MsgSubmitConsumerMisbehaviour) (*types.MsgSubmitConsumerMisbehaviourResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.Keeper.HandleConsumerMisbehaviour(ctx, *msg.Misbehaviour); err != nil { + if err := k.Keeper.HandleConsumerMisbehaviour(ctx, msg.ConsumerId, *msg.Misbehaviour); err != nil { return nil, err } @@ -185,9 +181,9 @@ func (k msgServer) SubmitConsumerDoubleVoting(goCtx context.Context, msg *types. return nil, err } - // handle the double voting evidence using the chain ID of the infraction block header - // and the malicious validator's public key - if err := k.Keeper.HandleConsumerDoubleVoting(ctx, evidence, msg.InfractionBlockHeader.Header.ChainID, pubkey); err != nil { + // handle the double voting evidence using the malicious validator's public key + consumerId := msg.ConsumerId + if err := k.Keeper.HandleConsumerDoubleVoting(ctx, consumerId, evidence, pubkey); err != nil { return nil, err } @@ -223,7 +219,7 @@ func (k msgServer) OptIn(goCtx context.Context, msg *types.MsgOptIn) (*types.Msg } providerConsAddr := types.NewProviderConsAddress(consAddrTmp) - err = k.Keeper.HandleOptIn(ctx, msg.ChainId, providerConsAddr, msg.ConsumerKey) + err = k.Keeper.HandleOptIn(ctx, msg.ConsumerId, providerConsAddr, msg.ConsumerKey) if err != nil { return nil, err } @@ -259,7 +255,7 @@ func (k msgServer) OptOut(goCtx context.Context, msg *types.MsgOptOut) (*types.M } providerConsAddr := types.NewProviderConsAddress(consAddrTmp) - err = k.Keeper.HandleOptOut(ctx, msg.ChainId, providerConsAddr) + err = k.Keeper.HandleOptOut(ctx, msg.ConsumerId, providerConsAddr) if err != nil { return nil, err } @@ -293,14 +289,14 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M return nil, err } - if err := k.HandleSetConsumerCommissionRate(ctx, msg.ChainId, types.NewProviderConsAddress(consAddr), msg.Rate); err != nil { + if err := k.HandleSetConsumerCommissionRate(ctx, msg.ConsumerId, types.NewProviderConsAddress(consAddr), msg.Rate); err != nil { return nil, err } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeSetConsumerCommissionRate, - sdk.NewAttribute(types.AttributeConsumerChainID, msg.ChainId), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), sdk.NewAttribute(types.AttributeConsumerCommissionRate, msg.Rate.String()), ), @@ -309,16 +305,158 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M return &types.MsgSetConsumerCommissionRateResponse{}, nil } -func (k msgServer) ConsumerModification(goCtx context.Context, msg *types.MsgConsumerModification) (*types.MsgConsumerModificationResponse, error) { - if k.GetAuthority() != msg.Authority { - return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) +// CreateConsumer creates a consumer chain +func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateConsumer) (*types.MsgCreateConsumerResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + consumerId := k.FetchAndIncrementConsumerId(ctx) + + k.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) + k.SetConsumerChainId(ctx, consumerId, msg.ChainId) + k.SetConsumerPhase(ctx, consumerId, Registered) + + if err := k.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { + return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, + "cannot set consumer metadata: %s", err.Error()) + } + + // initialization parameters are optional and hence could be nil + if msg.InitializationParameters != nil { + if err := k.SetConsumerInitializationParameters(ctx, consumerId, *msg.InitializationParameters); err != nil { + return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, + "cannot set consumer initialization parameters: %s", err.Error()) + } } + // power-shaping parameters are optional and hence could be null + if msg.PowerShapingParameters != nil { + if msg.PowerShapingParameters.Top_N != 0 { + return &types.MsgCreateConsumerResponse{}, errorsmod.Wrap(types.ErrCannotCreateTopNChain, + "cannot create a Top N chain using the `MsgCreateConsumer` message; use `MsgUpdateConsumer` instead") + } + if err := k.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { + return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, + "cannot set power shaping parameters") + } + } + + if spawnTime, canLaunch := k.CanLaunch(ctx, consumerId); canLaunch { + k.SetConsumerPhase(ctx, consumerId, Initialized) + k.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime) + } + + return &types.MsgCreateConsumerResponse{ConsumerId: consumerId}, nil +} + +// UpdateConsumer updates the record of a consumer chain +func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateConsumer) (*types.MsgUpdateConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleConsumerModificationProposal(ctx, msg) + consumerId := msg.ConsumerId + + phase, found := k.GetConsumerPhase(ctx, consumerId) + if found && phase == Stopped { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPhase, + "cannot update consumer chain that is in the stopped phase: %s", consumerId) + } + + // The new owner address can be empty, in which case the consumer chain does not change its owner. + // However, if the new owner address is not empty, we verify that it's a valid account address. + if strings.TrimSpace(msg.NewOwnerAddress) != "" { + if _, err := k.accountKeeper.AddressCodec().StringToBytes(msg.NewOwnerAddress); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidNewOwnerAddress, "invalid new owner address %s", msg.NewOwnerAddress) + } + } + + ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { - return nil, errorsmod.Wrapf(err, "failed handling ConsumerModification proposal") + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) + } + + if msg.Signer != ownerAddress { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + } + + if strings.TrimSpace(msg.NewOwnerAddress) != "" { + k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.NewOwnerAddress) + } + + if msg.Metadata != nil { + if err := k.SetConsumerMetadata(ctx, consumerId, *msg.Metadata); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, + "cannot set consumer metadata: %s", err.Error()) + } + } + + // get the previous spawn time so that we can use it in `PrepareConsumerForLaunch` + var previousSpawnTime time.Time + if previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, msg.ConsumerId); err != nil { + previousSpawnTime = previousInitializationParameters.SpawnTime + } + + if msg.InitializationParameters != nil { + if err = k.Keeper.SetConsumerInitializationParameters(ctx, msg.ConsumerId, *msg.InitializationParameters); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, + "cannot set consumer initialization parameters: %s", err.Error()) + } + } + + if msg.PowerShapingParameters != nil { + // A consumer chain can only become a Top N chain if the owner is the gov module. Because of this, to create a + // Top N chain, we need two `MsgUpdateConsumer` messages: i) one that would set the `ownerAddress` to the gov module + // and ii) one that would set the `Top_N` to something greater than 0. + if msg.PowerShapingParameters.Top_N > 0 && ownerAddress != k.GetAuthority() { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidTransformToTopN, + "an update to a Top N chain can only be done if chain is owner is the gov module") + } + + oldTopN := k.Keeper.GetTopN(ctx, consumerId) + if err = k.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, + "cannot set power shaping parameters") + } + + k.Keeper.UpdateAllowlist(ctx, consumerId, msg.PowerShapingParameters.Allowlist) + k.Keeper.UpdateDenylist(ctx, consumerId, msg.PowerShapingParameters.Denylist) + err = k.Keeper.UpdateMinimumPowerInTopN(ctx, consumerId, oldTopN, msg.PowerShapingParameters.Top_N) + if err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotUpdateMinimumPowerInTopN, + "could not update minimum power in top N, oldTopN: %d, newTopN: %d, error: %s", oldTopN, msg.PowerShapingParameters.Top_N, err.Error()) + } } - return &types.MsgConsumerModificationResponse{}, nil + // A Top N cannot change its owner address to something different from the gov module if the chain + // remains a Top N chain. + currentOwnerAddress, err := k.GetConsumerOwnerAddress(ctx, consumerId) + if err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s: %s", ownerAddress, err.Error()) + } + + currentPowerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot retrieve power shaping parameters: %s", err.Error()) + } + + if currentPowerShapingParameters.Top_N != 0 && currentOwnerAddress != k.GetAuthority() { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidTransformToOptIn, + "a move to a new owner address that is not the gov module can only be done if `Top N` is set to 0") + } + + if spawnTime, canLaunch := k.CanLaunch(ctx, consumerId); canLaunch { + k.SetConsumerPhase(ctx, consumerId, Initialized) + k.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime) + } + + return &types.MsgUpdateConsumerResponse{}, nil +} + +func (k msgServer) ConsumerAddition(_ context.Context, _ *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { + return nil, fmt.Errorf("`MsgConsumerAddition` is deprecated. Use `MsgCreateConsumer`") +} + +func (k msgServer) ConsumerModification(_ context.Context, _ *types.MsgConsumerModification) (*types.MsgConsumerModificationResponse, error) { + return nil, fmt.Errorf("`MsgConsumerModification` is deprecated. Use `MsgUpdateConsumer` instead") +} + +func (k msgServer) ConsumerRemoval(_ context.Context, _ *types.MsgConsumerRemoval) (*types.MsgConsumerRemovalResponse, error) { + return nil, fmt.Errorf("`MsgConsumerRemoval` is deprecated. Use `MsgRemoveConsumer` instead") } diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go new file mode 100644 index 0000000000..9dcf3942fe --- /dev/null +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -0,0 +1,55 @@ +package keeper_test + +import ( + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "github.com/stretchr/testify/require" + "testing" +) + +func TestCreateConsumer(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + msgServer := providerkeeper.NewMsgServerImpl(&providerKeeper) + + consumerMetadata := providertypes.ConsumerMetadata{ + Name: "chain name", + Description: "description", + } + response, err := msgServer.CreateConsumer(ctx, + &providertypes.MsgCreateConsumer{Signer: "signer", ChainId: "chainId", Metadata: consumerMetadata, + InitializationParameters: &providertypes.ConsumerInitializationParameters{}, + PowerShapingParameters: &providertypes.PowerShapingParameters{}}) + require.NoError(t, err) + require.Equal(t, "0", response.ConsumerId) + actualMetadata, err := providerKeeper.GetConsumerMetadata(ctx, "0") + require.NoError(t, err) + require.Equal(t, consumerMetadata, actualMetadata) + ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "0") + require.Equal(t, "signer", ownerAddress) + phase, found := providerKeeper.GetConsumerPhase(ctx, "0") + require.True(t, found) + require.Equal(t, providerkeeper.Registered, phase) + + consumerMetadata = providertypes.ConsumerMetadata{ + Name: "chain name", + Description: "description2", + } + response, err = msgServer.CreateConsumer(ctx, + &providertypes.MsgCreateConsumer{Signer: "signer2", ChainId: "chainId", Metadata: consumerMetadata, + InitializationParameters: &providertypes.ConsumerInitializationParameters{}, + PowerShapingParameters: &providertypes.PowerShapingParameters{}}) + require.NoError(t, err) + // assert that the consumer id is different from the previously registered chain + require.Equal(t, "1", response.ConsumerId) + actualMetadata, err = providerKeeper.GetConsumerMetadata(ctx, "1") + require.NoError(t, err) + require.Equal(t, consumerMetadata, actualMetadata) + ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "1") + require.Equal(t, "signer2", ownerAddress) + phase, found = providerKeeper.GetConsumerPhase(ctx, "1") + require.True(t, found) + require.Equal(t, providerkeeper.Registered, phase) +} diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index 3112124724..305f0f358b 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -13,16 +13,35 @@ import ( "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) -// HandleOptIn prepares validator `providerAddr` to opt in to `chainID` with an optional `consumerKey` consumer public key. +// HandleOptIn prepares validator `providerAddr` to opt in to `consumerId` with an optional `consumerKey` consumer public key. // Note that the validator only opts in at the end of an epoch. -func (k Keeper) HandleOptIn(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, consumerKey string) error { - if !k.IsConsumerProposedOrRegistered(ctx, chainID) { +func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, consumerKey string) error { + phase, found := k.GetConsumerPhase(ctx, consumerId) + if !found || phase == Stopped { return errorsmod.Wrapf( - types.ErrUnknownConsumerChainId, - "opting in to an unknown consumer chain, with id: %s", chainID) + types.ErrInvalidPhase, + "opting in to an unknown (or stopped) consumer chain, with id: %s", consumerId) } - k.SetOptedIn(ctx, chainID, providerAddr) + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + // TODO (PERMISSIONLESS): fix error types + return errorsmod.Wrapf( + types.ErrUnknownConsumerId, + "opting in to an unknown consumer chain, with id (%s): %s", consumerId, err.Error()) + } + optedInToConsumerId, found := k.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) + if found { + return errorsmod.Wrapf(types.ErrAlreadyOptedIn, + "validator is already opted in to a chain (%s) with this chain id (%s)", + optedInToConsumerId, chainId) + } + + k.SetOptedIn(ctx, consumerId, providerAddr) + err = k.AppendOptedInConsumerId(ctx, providerAddr, consumerId) + if err != nil { + return err + } if consumerKey != "" { consumerTMPublicKey, err := k.ParseConsumerKey(consumerKey) @@ -35,7 +54,7 @@ func (k Keeper) HandleOptIn(ctx sdk.Context, chainID string, providerAddr types. return err } - err = k.AssignConsumerKey(ctx, chainID, validator, consumerTMPublicKey) + err = k.AssignConsumerKey(ctx, consumerId, validator, consumerTMPublicKey) if err != nil { return err } @@ -44,18 +63,18 @@ func (k Keeper) HandleOptIn(ctx sdk.Context, chainID string, providerAddr types. return nil } -// HandleOptOut prepares validator `providerAddr` to opt out from running `chainID`. +// HandleOptOut prepares validator `providerAddr` to opt out from running `consumerId`. // Note that the validator only opts out at the end of an epoch. -func (k Keeper) HandleOptOut(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) error { - if _, found := k.GetConsumerClientId(ctx, chainID); !found { +func (k Keeper) HandleOptOut(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) error { + if _, found := k.GetConsumerClientId(ctx, consumerId); !found { // A validator can only opt out from a running chain. We check this by checking the consumer client id, because // `SetConsumerClientId` is set when the chain starts in `CreateConsumerClientInCachedCtx` of `BeginBlockInit`. return errorsmod.Wrapf( - types.ErrUnknownConsumerChainId, - "opting out of an unknown or not running consumer chain, with id: %s", chainID) + types.ErrUnknownConsumerId, + "opting out of an unknown or not running consumer chain, with id: %s", consumerId) } - if topN, found := k.GetTopN(ctx, chainID); found && topN > 0 { + if topN := k.GetTopN(ctx, consumerId); topN > 0 { // a validator cannot opt out from a Top N chain if the validator is in the Top N validators validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) if err != nil { @@ -69,27 +88,27 @@ func (k Keeper) HandleOptOut(ctx sdk.Context, chainID string, providerAddr types if err != nil { return err } - minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, chainID) + minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, consumerId) if !found { return errorsmod.Wrapf( - types.ErrUnknownConsumerChainId, - "Could not find minimum power in top N for chain with id: %s", chainID) + types.ErrUnknownConsumerId, + "Could not find minimum power in top N for chain with consumer id: %s", consumerId) } if power >= minPowerInTopN { return errorsmod.Wrapf( types.ErrCannotOptOutFromTopN, - "validator with power (%d) cannot opt out from Top N chain (%s) because all validators"+ - " with at least %d power have to validate", power, chainID, minPowerInTopN) + "validator with power (%d) cannot opt out from Top N chain with consumer id (%s) because all validators"+ + " with at least %d power have to validate", power, consumerId, minPowerInTopN) } } - k.DeleteOptedIn(ctx, chainID, providerAddr) - return nil + k.DeleteOptedIn(ctx, consumerId, providerAddr) + return k.RemoveOptedInConsumerId(ctx, providerAddr, consumerId) } -// OptInTopNValidators opts in to `chainID` all the `bondedValidators` that have at least `minPowerToOptIn` power -func (k Keeper) OptInTopNValidators(ctx sdk.Context, chainID string, bondedValidators []stakingtypes.Validator, minPowerToOptIn int64) { +// OptInTopNValidators opts in to `consumerId` all the `bondedValidators` that have at least `minPowerToOptIn` power +func (k Keeper) OptInTopNValidators(ctx sdk.Context, consumerId string, bondedValidators []stakingtypes.Validator, minPowerToOptIn int64) { for _, val := range bondedValidators { // log the validator k.Logger(ctx).Debug("Checking whether to opt in validator because of top N", "validator", val.GetOperator()) @@ -117,8 +136,9 @@ func (k Keeper) OptInTopNValidators(ctx sdk.Context, chainID string, bondedValid k.Logger(ctx).Debug("Opting in validator", "validator", val.GetOperator()) // if validator already exists it gets overwritten - k.SetOptedIn(ctx, chainID, types.NewProviderConsAddress(consAddr)) - } + k.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + k.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } // else validators that do not belong to the top N validators but were opted in, remain opted in } } @@ -168,15 +188,15 @@ func (k Keeper) ComputeMinPowerInTopN(ctx sdk.Context, bondedValidators []stakin return 0, fmt.Errorf("should never reach this point with topN (%d), totalPower (%d), and powerSum (%d)", topN, totalPower, powerSum) } -// CapValidatorSet caps the provided `validators` if chain `chainID` is an Opt In chain with a validator-set cap. If cap -// is `k`, `CapValidatorSet` returns the first `k` validators from `validators` with the highest power. -func (k Keeper) CapValidatorSet(ctx sdk.Context, chainID string, validators []types.ConsensusValidator) []types.ConsensusValidator { - if topN, found := k.GetTopN(ctx, chainID); found && topN > 0 { +// CapValidatorSet caps the provided `validators` if chain with `consumerId` is an Opt In chain with a validator-set cap. +// If cap is `k`, `CapValidatorSet` returns the first `k` validators from `validators` with the highest power. +func (k Keeper) CapValidatorSet(ctx sdk.Context, consumerId string, validators []types.ConsensusValidator) []types.ConsensusValidator { + if k.GetTopN(ctx, consumerId) > 0 { // is a no-op if the chain is a Top N chain return validators } - if validatorSetCap, found := k.GetValidatorSetCap(ctx, chainID); found && validatorSetCap != 0 && int(validatorSetCap) < len(validators) { + if validatorSetCap := k.GetValidatorSetCap(ctx, consumerId); validatorSetCap != 0 && int(validatorSetCap) < len(validators) { sort.Slice(validators, func(i, j int) bool { return validators[i].Power > validators[j].Power }) @@ -187,15 +207,15 @@ func (k Keeper) CapValidatorSet(ctx sdk.Context, chainID string, validators []ty } } -// CapValidatorsPower caps the power of the validators on chain `chainID` and returns an updated slice of validators +// CapValidatorsPower caps the power of the validators on chain with `consumerId` and returns an updated slice of validators // with their new powers. Works on a best-basis effort because there are cases where we cannot guarantee that all validators // on the consumer chain have less power than the set validators-power cap. For example, if we have 10 validators and // the power cap is set to 5%, we need at least one validator to have more than 10% of the voting power on the consumer chain. -func (k Keeper) CapValidatorsPower(ctx sdk.Context, chainID string, validators []types.ConsensusValidator) []types.ConsensusValidator { - if p, found := k.GetValidatorsPowerCap(ctx, chainID); found && p > 0 { +func (k Keeper) CapValidatorsPower(ctx sdk.Context, consumerId string, validators []types.ConsensusValidator) []types.ConsensusValidator { + if p := k.GetValidatorsPowerCap(ctx, consumerId); p > 0 { return NoMoreThanPercentOfTheSum(validators, p) } else { - // is a no-op if power cap is not set for `chainID` + // is a no-op if power cap is not set for `consumerId` return validators } } @@ -300,24 +320,24 @@ func NoMoreThanPercentOfTheSum(validators []types.ConsensusValidator, percent ui return updatedValidators } -// CanValidateChain returns true if the validator `providerAddr` is opted-in to chain `chainID` and the allowlist and -// denylist do not prevent the validator from validating the chain. -func (k Keeper) CanValidateChain(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) bool { +// CanValidateChain returns true if the validator `providerAddr` is opted-in to chain with `consumerId` and the allowlist +// and denylist do not prevent the validator from validating the chain. +func (k Keeper) CanValidateChain(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { // only consider opted-in validators - return k.IsOptedIn(ctx, chainID, providerAddr) && + return k.IsOptedIn(ctx, consumerId, providerAddr) && // if an allowlist is declared, only consider allowlisted validators - (k.IsAllowlistEmpty(ctx, chainID) || - k.IsAllowlisted(ctx, chainID, providerAddr)) && + (k.IsAllowlistEmpty(ctx, consumerId) || + k.IsAllowlisted(ctx, consumerId, providerAddr)) && // if a denylist is declared, only consider denylisted validators - (k.IsDenylistEmpty(ctx, chainID) || - !k.IsDenylisted(ctx, chainID, providerAddr)) + (k.IsDenylistEmpty(ctx, consumerId) || + !k.IsDenylisted(ctx, consumerId, providerAddr)) } -// FulfillsMinStake returns true if the validator `providerAddr` has enough stake to validate chain `chainID` +// FulfillsMinStake returns true if the validator `providerAddr` has enough stake to validate chain with `consumerId` // by checking its staked tokens against the minimum stake required to validate the chain. -func (k Keeper) FulfillsMinStake(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) bool { - minStake, found := k.GetMinStake(ctx, chainID) - if !found { +func (k Keeper) FulfillsMinStake(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { + minStake := k.GetMinStake(ctx, consumerId) + if minStake == 0 { return true } @@ -332,7 +352,7 @@ func (k Keeper) FulfillsMinStake(ctx sdk.Context, chainID string, providerAddr t } // ComputeNextValidators computes the validators for the upcoming epoch based on the currently `bondedValidators`. -func (k Keeper) ComputeNextValidators(ctx sdk.Context, chainID string, bondedValidators []stakingtypes.Validator) []types.ConsensusValidator { +func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bondedValidators []stakingtypes.Validator) []types.ConsensusValidator { // sort the bonded validators by number of staked tokens in descending order sort.Slice(bondedValidators, func(i, j int) bool { return bondedValidators[i].GetBondedTokens().GT(bondedValidators[j].GetBondedTokens()) @@ -340,7 +360,7 @@ func (k Keeper) ComputeNextValidators(ctx sdk.Context, chainID string, bondedVal // if inactive validators are not allowed, only consider the first `MaxProviderConsensusValidators` validators // since those are the ones that participate in consensus - allowInactiveVals := k.AllowsInactiveValidators(ctx, chainID) + allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) if !allowInactiveVals { // only leave the first MaxProviderConsensusValidators bonded validators maxProviderConsensusVals := k.GetMaxProviderConsensusValidators(ctx) @@ -349,11 +369,11 @@ func (k Keeper) ComputeNextValidators(ctx sdk.Context, chainID string, bondedVal } } - nextValidators := k.FilterValidators(ctx, chainID, bondedValidators, + nextValidators := k.FilterValidators(ctx, consumerId, bondedValidators, func(providerAddr types.ProviderConsAddress) bool { - return k.CanValidateChain(ctx, chainID, providerAddr) && k.FulfillsMinStake(ctx, chainID, providerAddr) + return k.CanValidateChain(ctx, consumerId, providerAddr) && k.FulfillsMinStake(ctx, consumerId, providerAddr) }) - nextValidators = k.CapValidatorSet(ctx, chainID, nextValidators) - return k.CapValidatorsPower(ctx, chainID, nextValidators) + nextValidators = k.CapValidatorSet(ctx, consumerId, nextValidators) + return k.CapValidatorsPower(ctx, consumerId, nextValidators) } diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index e180554239..c710e7f299 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -32,13 +32,26 @@ func TestHandleOptIn(t *testing.T) { providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) - // trying to opt in to a non-proposed and non-registered chain returns an error - require.Error(t, providerKeeper.HandleOptIn(ctx, "unknownChainID", providerAddr, "")) + // trying to opt in to an unknown chain + require.Error(t, providerKeeper.HandleOptIn(ctx, "unknownConsumerId", providerAddr, "")) - providerKeeper.SetProposedConsumerChain(ctx, "chainID", 1) - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", providerAddr)) - providerKeeper.HandleOptIn(ctx, "chainID", providerAddr, "") - require.True(t, providerKeeper.IsOptedIn(ctx, "chainID", providerAddr)) + // trying to opt in to a stopped consumer chain + providerKeeper.SetConsumerPhase(ctx, "stoppedConsumerId", keeper.Stopped) + require.Error(t, providerKeeper.HandleOptIn(ctx, "stoppedConsumerId", providerAddr, "")) + + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerChainId(ctx, "consumerId", "chainId") + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) + err := providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, "") + require.NoError(t, err) + require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) + + // validator tries to opt in to another chain with chain id ("chainId") while it is already opted in to + // a different chain with the same chain id + providerKeeper.SetConsumerPhase(ctx, "consumerId2", keeper.Initialized) + providerKeeper.SetConsumerChainId(ctx, "consumerId2", "chainId") + err = providerKeeper.HandleOptIn(ctx, "consumerId2", providerAddr, "") + require.ErrorContains(t, err, "validator is already opted in to a chain") } func TestHandleOptInWithConsumerKey(t *testing.T) { @@ -67,25 +80,27 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { } gomock.InOrder(calls...) - providerKeeper.SetProposedConsumerChain(ctx, "chainID", 1) + providerKeeper.SetProposalIdToConsumerId(ctx, 1, "consumerId") // create a sample consumer key to assign to the `providerAddr` validator - // on the consumer chain with id `chainID` + // on the consumer chain with `consumerId` consumerKey := "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}" expectedConsumerPubKey, err := providerKeeper.ParseConsumerKey(consumerKey) require.NoError(t, err) - err = providerKeeper.HandleOptIn(ctx, "chainID", providerAddr, consumerKey) + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerChainId(ctx, "consumerId", "consumerId") + err = providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, consumerKey) require.NoError(t, err) - // assert that the consumeKey was assigned to `providerAddr` validator on chain with id `chainID` - actualConsumerPubKey, found := providerKeeper.GetValidatorConsumerPubKey(ctx, "chainID", providerAddr) + // assert that the consumeKey was assigned to `providerAddr` validator on chain with `consumerId` + actualConsumerPubKey, found := providerKeeper.GetValidatorConsumerPubKey(ctx, "consumerId", providerAddr) require.True(t, found) require.Equal(t, expectedConsumerPubKey, actualConsumerPubKey) // assert that the `consumerAddr` to `providerAddr` association was set as well consumerAddr, _ := ccvtypes.TMCryptoPublicKeyToConsAddr(actualConsumerPubKey) - actualProviderConsAddr, found := providerKeeper.GetValidatorByConsumerAddr(ctx, "chainID", types.NewConsumerConsAddress(consumerAddr)) + actualProviderConsAddr, found := providerKeeper.GetValidatorByConsumerAddr(ctx, "consumerId", types.NewConsumerConsAddress(consumerAddr)) require.True(t, found) require.Equal(t, providerAddr, actualProviderConsAddr) } @@ -100,27 +115,29 @@ func TestHandleOptOut(t *testing.T) { require.Error(t, providerKeeper.HandleOptOut(ctx, "unknownChainID", providerAddr)) // set a consumer client so that the chain is considered running - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") // if validator (`providerAddr`) is already opted in, then an opt-out would remove this validator - providerKeeper.SetOptedIn(ctx, "chainID", providerAddr) - require.True(t, providerKeeper.IsOptedIn(ctx, "chainID", providerAddr)) - providerKeeper.HandleOptOut(ctx, "chainID", providerAddr) - require.False(t, providerKeeper.IsOptedIn(ctx, "chainID", providerAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providerAddr) + require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) + providerKeeper.HandleOptOut(ctx, "consumerId", providerAddr) + require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) } func TestHandleOptOutFromTopNChain(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + consumerId := "consumerId" // set a consumer client so that the chain is considered running - providerKeeper.SetConsumerClientId(ctx, chainID, "clientID") + providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") // set the chain as Top 50 and create 4 validators with 10%, 20%, 30%, and 40% of the total voting power // respectively - providerKeeper.SetTopN(ctx, "chainID", 50) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ + Top_N: 50, + }) valA := createStakingValidator(ctx, mocks, 1, 1, 1) // 10% of the total voting power (can opt out) valAConsAddr, _ := valA.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() @@ -139,29 +156,33 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { // initialize the minPowerInTopN correctly minPowerInTopN, err := providerKeeper.ComputeMinPowerInTopN(ctx, []stakingtypes.Validator{valA, valB, valC, valD}, 50) require.NoError(t, err) - providerKeeper.SetMinimumPowerInTopN(ctx, chainID, minPowerInTopN) + providerKeeper.SetMinimumPowerInTopN(ctx, consumerId, minPowerInTopN) // opt in all validators - providerKeeper.SetOptedIn(ctx, chainID, types.NewProviderConsAddress(valAConsAddr)) - providerKeeper.SetOptedIn(ctx, chainID, types.NewProviderConsAddress(valBConsAddr)) - providerKeeper.SetOptedIn(ctx, chainID, types.NewProviderConsAddress(valCConsAddr)) - providerKeeper.SetOptedIn(ctx, chainID, types.NewProviderConsAddress(valDConsAddr)) + providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valAConsAddr)) + providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valAConsAddr), consumerId) + providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valBConsAddr)) + providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valBConsAddr), consumerId) + providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valCConsAddr)) + providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valCConsAddr), consumerId) + providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valDConsAddr)) + providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valDConsAddr), consumerId) // validators A and B can opt out because they belong the bottom 30% of validators - require.NoError(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(valAConsAddr))) - require.NoError(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(valBConsAddr))) + require.NoError(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valAConsAddr))) + require.NoError(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valBConsAddr))) // validators C and D cannot opt out because C has 30% of the voting power and D has 40% of the voting power // and hence both are needed to keep validating a Top 50 chain - require.Error(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(valCConsAddr))) - require.Error(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(valDConsAddr))) + require.Error(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valCConsAddr))) + require.Error(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valDConsAddr))) // opting out a validator that cannot be found from a Top N chain should also return an error notFoundValidator := createStakingValidator(ctx, mocks, 5, 5, 5) notFoundValidatorConsAddr, _ := notFoundValidator.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, notFoundValidatorConsAddr). Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound) - require.Error(t, providerKeeper.HandleOptOut(ctx, chainID, types.NewProviderConsAddress(notFoundValidatorConsAddr))) + require.Error(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(notFoundValidatorConsAddr))) } func TestHandleSetConsumerCommissionRate(t *testing.T) { @@ -174,18 +195,20 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { require.Error(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, "unknownChainID", providerAddr, math.LegacyZeroDec())) // setup a pending consumer chain - chainID := "pendingChainID" - providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: chainID}) + consumerId := "0" + providerKeeper.FetchAndIncrementConsumerId(ctx) + providerKeeper.SetConsumerPhase(ctx, consumerId, keeper.Initialized) + providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: consumerId}) // check that there's no commission rate set for the validator yet - _, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) + _, found := providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) require.False(t, found) mocks.MockStakingKeeper.EXPECT().MinCommissionRate(ctx).Return(math.LegacyZeroDec(), nil).Times(1) - require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, math.LegacyOneDec())) + require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, consumerId, providerAddr, math.LegacyOneDec())) // check that the commission rate is now set - cr, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) + cr, found := providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) require.Equal(t, math.LegacyOneDec(), cr) require.True(t, found) @@ -196,16 +219,16 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { // try to set a rate slightly below the minimum require.Error(t, providerKeeper.HandleSetConsumerCommissionRate( ctx, - chainID, + consumerId, providerAddr, commissionRate.Sub(math.LegacyNewDec(1).Quo(math.LegacyNewDec(100)))), // 0.5 - 0.01 "commission rate should be rejected (below min), but is not", ) // set a valid commission equal to the minimum - require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, commissionRate)) + require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, consumerId, providerAddr, commissionRate)) // check that the rate was set - cr, found = providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) + cr, found = providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) require.Equal(t, commissionRate, cr) require.True(t, found) } @@ -225,14 +248,14 @@ func TestOptInTopNValidators(t *testing.T) { valDConsAddr, _ := valD.GetConsAddr() // Start Test 1: opt in all validators with power >= 0 - providerKeeper.OptInTopNValidators(ctx, "chainID", []stakingtypes.Validator{valA, valB, valC, valD}, 0) + providerKeeper.OptInTopNValidators(ctx, "consumerId", []stakingtypes.Validator{valA, valB, valC, valD}, 0) expectedOptedInValidators := []types.ProviderConsAddress{ types.NewProviderConsAddress(valAConsAddr), types.NewProviderConsAddress(valBConsAddr), types.NewProviderConsAddress(valCConsAddr), types.NewProviderConsAddress(valDConsAddr), } - actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "chainID") + actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "consumerId") // sort validators first to be able to compare sortUpdates := func(addresses []types.ProviderConsAddress) { @@ -246,31 +269,31 @@ func TestOptInTopNValidators(t *testing.T) { require.Equal(t, expectedOptedInValidators, actualOptedInValidators) // reset state for the upcoming checks - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valAConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valBConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valCConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valDConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valAConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valBConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valCConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valDConsAddr)) // Start Test 2: opt in all validators with power >= 1 // We expect the same `expectedOptedInValidators` as when we opted in all validators with power >= 0 because the // validators with the smallest power have power == 1 - providerKeeper.OptInTopNValidators(ctx, "chainID", []stakingtypes.Validator{valA, valB, valC, valD}, 0) - actualOptedInValidators = providerKeeper.GetAllOptedIn(ctx, "chainID") + providerKeeper.OptInTopNValidators(ctx, "consumerId", []stakingtypes.Validator{valA, valB, valC, valD}, 0) + actualOptedInValidators = providerKeeper.GetAllOptedIn(ctx, "consumerId") sortUpdates(actualOptedInValidators) require.Equal(t, expectedOptedInValidators, actualOptedInValidators) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valAConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valBConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valCConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valDConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valAConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valBConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valCConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valDConsAddr)) // Start Test 3: opt in all validators with power >= 2 and hence we do not expect to opt in validator A - providerKeeper.OptInTopNValidators(ctx, "chainID", []stakingtypes.Validator{valA, valB, valC, valD}, 2) + providerKeeper.OptInTopNValidators(ctx, "consumerId", []stakingtypes.Validator{valA, valB, valC, valD}, 2) expectedOptedInValidators = []types.ProviderConsAddress{ types.NewProviderConsAddress(valBConsAddr), types.NewProviderConsAddress(valCConsAddr), } - actualOptedInValidators = providerKeeper.GetAllOptedIn(ctx, "chainID") + actualOptedInValidators = providerKeeper.GetAllOptedIn(ctx, "consumerId") // sort validators first to be able to compare sortUpdates(expectedOptedInValidators) @@ -278,14 +301,14 @@ func TestOptInTopNValidators(t *testing.T) { require.Equal(t, expectedOptedInValidators, actualOptedInValidators) // reset state for the upcoming checks - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valAConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valBConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valCConsAddr)) - providerKeeper.DeleteOptedIn(ctx, "chainID", types.NewProviderConsAddress(valDConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valAConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valBConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valCConsAddr)) + providerKeeper.DeleteOptedIn(ctx, "consumerId", types.NewProviderConsAddress(valDConsAddr)) // Start Test 4: opt in all validators with power >= 4 and hence we do not expect any opted-in validators - providerKeeper.OptInTopNValidators(ctx, "chainID", []stakingtypes.Validator{valA, valB, valC, valD}, 4) - require.Empty(t, providerKeeper.GetAllOptedIn(ctx, "chainID")) + providerKeeper.OptInTopNValidators(ctx, "consumerId", []stakingtypes.Validator{valA, valB, valC, valD}, 4) + require.Empty(t, providerKeeper.GetAllOptedIn(ctx, "consumerId")) } func TestComputeMinPowerInTopN(t *testing.T) { @@ -356,7 +379,7 @@ func TestComputeMinPowerInTopN(t *testing.T) { require.Error(t, err) } -// TestCanValidateChain returns true if `validator` is opted in, in `chainID. +// TestCanValidateChain returns true if `validator` is opted in, in `consumerId. func TestCanValidateChain(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -366,24 +389,24 @@ func TestCanValidateChain(t *testing.T) { providerAddr := types.NewProviderConsAddress(consAddr) // with no allowlist or denylist, the validator has to be opted in, in order to consider it - require.False(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) - providerKeeper.SetOptedIn(ctx, "chainID", types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) + require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) + require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) // create an allow list but do not add the validator `providerAddr` to it validatorA := createStakingValidator(ctx, mocks, 1, 1, 2) consAddrA, _ := validatorA.GetConsAddr() - providerKeeper.SetAllowlist(ctx, "chainID", types.NewProviderConsAddress(consAddrA)) - require.False(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) - providerKeeper.SetAllowlist(ctx, "chainID", types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) + providerKeeper.SetAllowlist(ctx, "consumerId", types.NewProviderConsAddress(consAddrA)) + require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + providerKeeper.SetAllowlist(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) + require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) // create a denylist but do not add validator `providerAddr` to it - providerKeeper.SetDenylist(ctx, "chainID", types.NewProviderConsAddress(consAddrA)) - require.True(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) + providerKeeper.SetDenylist(ctx, "consumerId", types.NewProviderConsAddress(consAddrA)) + require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) // add validator `providerAddr` to the denylist - providerKeeper.SetDenylist(ctx, "chainID", types.NewProviderConsAddress(consAddr)) - require.False(t, providerKeeper.CanValidateChain(ctx, "chainID", providerAddr)) + providerKeeper.SetDenylist(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) + require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) } func TestCapValidatorSet(t *testing.T) { @@ -409,27 +432,37 @@ func TestCapValidatorSet(t *testing.T) { } validators := []types.ConsensusValidator{validatorA, validatorB, validatorC} - consumerValidators := providerKeeper.CapValidatorSet(ctx, "chainID", validators) + consumerValidators := providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetValidatorSetCap(ctx, "chainID", 0) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorSetCap: 0, + }) + consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetValidatorSetCap(ctx, "chainID", 100) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorSetCap: 100, + }) + consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetValidatorSetCap(ctx, "chainID", 1) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorSetCap: 1, + }) + consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, []types.ConsensusValidator{validatorC}, consumerValidators) - providerKeeper.SetValidatorSetCap(ctx, "chainID", 2) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorSetCap: 2, + }) + consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, []types.ConsensusValidator{validatorC, validatorB}, consumerValidators) - providerKeeper.SetValidatorSetCap(ctx, "chainID", 3) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorSetCap: 3, + }) + consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) require.Equal(t, []types.ConsensusValidator{validatorC, validatorB, validatorA}, consumerValidators) } @@ -477,13 +510,15 @@ func TestCapValidatorsPower(t *testing.T) { } // no capping takes place because validators power-cap is not set - cappedValidators := providerKeeper.CapValidatorsPower(ctx, "chainID", validators) + cappedValidators := providerKeeper.CapValidatorsPower(ctx, "consumerId", validators) sortValidators(validators) sortValidators(cappedValidators) require.Equal(t, validators, cappedValidators) - providerKeeper.SetValidatorsPowerCap(ctx, "chainID", 33) - cappedValidators = providerKeeper.CapValidatorsPower(ctx, "chainID", validators) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + ValidatorsPowerCap: 33, + }) + cappedValidators = providerKeeper.CapValidatorsPower(ctx, "consumerId", validators) sortValidators(expectedValidators) sortValidators(cappedValidators) require.Equal(t, expectedValidators, cappedValidators) @@ -742,9 +777,11 @@ func TestFulfillsMinStake(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - providerKeeper.SetMinStake(ctx, "chainID", tc.minStake) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + MinStake: tc.minStake, + }) for i, valAddr := range consAddrs { - result := providerKeeper.FulfillsMinStake(ctx, "chainID", valAddr) + result := providerKeeper.FulfillsMinStake(ctx, "consumerId", valAddr) require.Equal(t, tc.expectedFulfill[i], result) } }) @@ -764,7 +801,7 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { // opt the validators in for _, valAddr := range consAddrs { - providerKeeper.SetOptedIn(ctx, "chainID", valAddr) + providerKeeper.SetOptedIn(ctx, "consumerId", valAddr) } // Randomly choose values for parameters @@ -774,14 +811,16 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { // Set up the parameters in the provider keeper // do not allow inactive validators - providerKeeper.SetInactiveValidatorsAllowed(ctx, "chainID", false) - providerKeeper.SetMinStake(ctx, "chainID", minStake) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + MinStake: minStake, + AllowInactiveVals: false, + }) params := providerKeeper.GetParams(ctx) params.MaxProviderConsensusValidators = int64(maxProviderConsensusVals) providerKeeper.SetParams(ctx, params) // Compute the next validators - nextVals := providerKeeper.ComputeNextValidators(ctx, "chainID", vals) + nextVals := providerKeeper.ComputeNextValidators(ctx, "consumerId", vals) // Check that the length of nextVals is at most maxProviderConsensusVals require.LessOrEqual(r, len(nextVals), int(maxProviderConsensusVals), "The length of nextVals should be at most maxProviderConsensusVals") diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go new file mode 100644 index 0000000000..b742485f6e --- /dev/null +++ b/x/ccv/provider/keeper/permissionless.go @@ -0,0 +1,747 @@ +package keeper + +import ( + "bytes" + errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + "encoding/binary" + "encoding/gob" + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "strconv" + "time" +) + +// ConsumerPhase captures the phases of a consumer chain according to `docs/docs/adrs/adr-018-permissionless-ics.md` +type ConsumerPhase byte + +const ( + // Registered phase indicates the phase in which a consumer chain has been assigned a unique consumer id. This consumer + // id can be used to interact with the consumer chain (e.g., when a validator opts in to a chain). A chain in this + // phase cannot yet launch. It has to be initialized first. + Registered ConsumerPhase = iota + // Initialized phase indicates the phase in which a consumer chain has set all the needed parameters to launch but + // has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached). + Initialized + // FailedToLaunch phase indicates that the chain attempted but failed to launch (e.g., due to no validator opting in). + FailedToLaunch + // Launched phase corresponds to the phase in which a consumer chain is running and consuming a subset of the validator + // set of the provider. + Launched + // Stopped phase corresponds to the phase in which a previously-launched chain has stopped. + Stopped +) + +// setConsumerId sets the provided consumerId +func (k Keeper) setConsumerId(ctx sdk.Context, consumerId uint64) { + store := ctx.KVStore(k.storeKey) + + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, consumerId) + + store.Set(types.ConsumerIdKey(), buf) +} + +// GetConsumerId returns the last registered consumer id +func (k Keeper) GetConsumerId(ctx sdk.Context) (uint64, bool) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.ConsumerIdKey()) + if buf == nil { + return 0, false + } + return binary.BigEndian.Uint64(buf), true +} + +// FetchAndIncrementConsumerId fetches the first consumer id that can be used and increments the +// underlying consumer id +func (k Keeper) FetchAndIncrementConsumerId(ctx sdk.Context) string { + consumerId, _ := k.GetConsumerId(ctx) + k.setConsumerId(ctx, consumerId+1) + return strconv.FormatUint(consumerId, 10) +} + +// GetConsumerChainId returns the chain id associated with this consumer id +func (k Keeper) GetConsumerChainId(ctx sdk.Context, consumerId string) (string, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToChainIdKey(consumerId)) + if bz == nil { + return "", fmt.Errorf("failed to retrieve chain id for consumer id (%s)", consumerId) + } + return string(bz), nil +} + +// SetConsumerChainId sets the chain id associated with this consumer id +func (k Keeper) SetConsumerChainId(ctx sdk.Context, consumerId string, chainId string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ConsumerIdToChainIdKey(consumerId), []byte(chainId)) +} + +// DeleteConsumerChainId deletes the chain id associated with this consumer id +func (k Keeper) DeleteConsumerChainId(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToChainIdKey(consumerId)) +} + +// GetConsumerOwnerAddress returns the owner address associated with this consumer id +func (k Keeper) GetConsumerOwnerAddress(ctx sdk.Context, consumerId string) (string, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToOwnerAddressKey(consumerId)) + if bz == nil { + return "", fmt.Errorf("failed to retrieve owner address for consumer id (%s)", consumerId) + } + return string(bz), nil +} + +// SetConsumerOwnerAddress sets the chain id associated with this consumer id +func (k Keeper) SetConsumerOwnerAddress(ctx sdk.Context, consumerId string, chainId string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ConsumerIdToOwnerAddressKey(consumerId), []byte(chainId)) +} + +// DeleteConsumerOwnerAddress deletes the owner address associated with this consumer id +func (k Keeper) DeleteConsumerOwnerAddress(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToOwnerAddressKey(consumerId)) +} + +// GetConsumerMetadata returns the registration record associated with this consumer id +func (k Keeper) GetConsumerMetadata(ctx sdk.Context, consumerId string) (types.ConsumerMetadata, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToMetadataKey(consumerId)) + if bz == nil { + return types.ConsumerMetadata{}, fmt.Errorf("failed to retrieve metadata for consumer id (%s)", consumerId) + } + var metadata types.ConsumerMetadata + if err := metadata.Unmarshal(bz); err != nil { + return types.ConsumerMetadata{}, fmt.Errorf("failed to unmarshal metadata for consumer id (%s): %w", consumerId, err) + } + return metadata, nil +} + +// SetConsumerMetadata sets the registration record associated with this consumer id +func (k Keeper) SetConsumerMetadata(ctx sdk.Context, consumerId string, metadata types.ConsumerMetadata) error { + store := ctx.KVStore(k.storeKey) + bz, err := metadata.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal registration metadata (%+v) for consumer id (%s): %w", metadata, consumerId, err) + } + store.Set(types.ConsumerIdToMetadataKey(consumerId), bz) + return nil +} + +// DeleteConsumerMetadata deletes the metadata associated with this consumer id +func (k Keeper) DeleteConsumerMetadata(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToMetadataKey(consumerId)) +} + +// GetConsumerInitializationParameters returns the initialization parameters associated with this consumer id +func (k Keeper) GetConsumerInitializationParameters(ctx sdk.Context, consumerId string) (types.ConsumerInitializationParameters, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToInitializationParametersKey(consumerId)) + if bz == nil { + return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to retrieve initialization parameters for consumer id (%s)", consumerId) + } + var record types.ConsumerInitializationParameters + if err := record.Unmarshal(bz); err != nil { + return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) + } + return record, nil +} + +// SetConsumerInitializationParameters sets the initialization parameters associated with this consumer id +func (k Keeper) SetConsumerInitializationParameters(ctx sdk.Context, consumerId string, record types.ConsumerInitializationParameters) error { + store := ctx.KVStore(k.storeKey) + bz, err := record.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal initialization record (%+v) for consumer id (%s): %w", record, consumerId, err) + } + store.Set(types.ConsumerIdToInitializationParametersKey(consumerId), bz) + return nil +} + +// DeleteConsumerInitializationParameters deletes the initialization parameters associated with this consumer id +func (k Keeper) DeleteConsumerInitializationParameters(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToInitializationParametersKey(consumerId)) +} + +// GetConsumerPowerShapingParameters returns the power-shaping parameters associated with this consumer id +func (k Keeper) GetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) (types.PowerShapingParameters, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToPowerShapingParametersKey(consumerId)) + if bz == nil { + return types.PowerShapingParameters{}, fmt.Errorf("failed to retrieve power-shaping parameters for consumer id (%s)", consumerId) + } + var record types.PowerShapingParameters + if err := record.Unmarshal(bz); err != nil { + return types.PowerShapingParameters{}, fmt.Errorf("failed to unmarshal power-shaping parameters for consumer id (%s): %w", consumerId, err) + } + return record, nil +} + +// SetConsumerPowerShapingParameters sets the power-shaping parameters associated with this consumer id +func (k Keeper) SetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string, parameters types.PowerShapingParameters) error { + store := ctx.KVStore(k.storeKey) + bz, err := parameters.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal power-shaping parameters (%+v) for consumer id (%s): %w", parameters, consumerId, err) + } + store.Set(types.ConsumerIdToPowerShapingParametersKey(consumerId), bz) + return nil +} + +// DeleteConsumerPowerShapingParameters deletes the power-shaping parameters associated with this consumer id +func (k Keeper) DeleteConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToPowerShapingParametersKey(consumerId)) +} + +// GetConsumerPhase returns the phase associated with this consumer id +func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) (ConsumerPhase, bool) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.ConsumerIdToPhaseKey(consumerId)) + if buf == nil { + return ConsumerPhase(0), false + } + return ConsumerPhase(buf[0]), true +} + +// SetConsumerPhase sets the phase associated with this consumer id +// TODO (PERMISSIONLESS): use this method when launching and when stopping a chain +func (k Keeper) SetConsumerPhase(ctx sdk.Context, consumerId string, phase ConsumerPhase) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ConsumerIdToPhaseKey(consumerId), []byte{byte(phase)}) +} + +// DeleteConsumerPhase deletes the phase associated with this consumer id +func (k Keeper) DeleteConsumerPhase(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToPhaseKey(consumerId)) +} + +// GetConsumerStopTime returns the stop time associated with the to-be-stopped chain with consumer id +func (k Keeper) GetConsumerStopTime(ctx sdk.Context, consumerId string) (time.Time, error) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.ConsumerIdToStopTimeKey(consumerId)) + if buf == nil { + return time.Time{}, fmt.Errorf("failed to retrieve stop time for consumer id (%s)", consumerId) + } + var time time.Time + if err := time.UnmarshalBinary(buf); err != nil { + return time, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) + } + return time, nil +} + +// SetConsumerStopTime sets the stop time associated with this consumer id +func (k Keeper) SetConsumerStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { + store := ctx.KVStore(k.storeKey) + buf, err := stopTime.MarshalBinary() + if err != nil { + return fmt.Errorf("failed to marshal stop time (%+v) for consumer id (%s): %w", stopTime, consumerId, err) + } + store.Set(types.ConsumerIdToStopTimeKey(consumerId), buf) + return nil +} + +// DeleteConsumerStopTime deletes the stop time associated with this consumer id +func (k Keeper) DeleteConsumerStopTime(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToStopTimeKey(consumerId)) +} + +// GetConsumersToBeLaunched +func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.SpawnTimeToConsumerIdsKey(spawnTime)) + if bz == nil { + return types.ConsumerIds{}, nil + } + + var consumerIds types.ConsumerIds + + if err := consumerIds.Unmarshal(bz); err != nil { + return types.ConsumerIds{}, fmt.Errorf("failed to unmarshal consumer ids: %w", err) + } + return consumerIds, nil +} + +// AppendSpawnTimeForConsumerToBeLaunched +func (k Keeper) AppendSpawnTimeForConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumerIdsSlice, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + if err != nil { + return err + } + consumerIds := append(consumerIdsSlice.Ids, consumerId) + + appendedConsumerIdsStr := types.ConsumerIds{ + Ids: consumerIds, + } + + bz, err := appendedConsumerIdsStr.Marshal() + if err != nil { + return err + } + + store.Set(types.SpawnTimeToConsumerIdsKey(spawnTime), bz) + return nil +} + +// RemoveConsumerFromToBeLaunchedConsumers +func (k Keeper) RemoveConsumerFromToBeLaunchedConsumers(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + if err != nil { + return err + } + + if len(consumerIds.Ids) == 0 { + return fmt.Errorf("no consumer ids for spawn time: %s", spawnTime.String()) + } + + // find the index of the consumer we want to remove + index := 0 + for i := 0; i < len(consumerIds.Ids); i = i + 1 { + if consumerIds.Ids[i] == consumerId { + index = i + break + } + } + if consumerIds.Ids[index] != consumerId { + return fmt.Errorf("failed to find consumer id (%s) in the chains to be launched", consumerId) + } + + if len(consumerIds.Ids) == 1 { + store.Delete(types.SpawnTimeToConsumerIdsKey(spawnTime)) + return nil + } + + updatedConsumerIds := append(consumerIds.Ids[:index], consumerIds.Ids[index+1:]...) + + updatedConsumerIdsStr := types.ConsumerIds{ + Ids: updatedConsumerIds, + } + + bz, err := updatedConsumerIdsStr.Marshal() + if err != nil { + return err + } + + store.Set(types.SpawnTimeToConsumerIdsKey(spawnTime), bz) + return nil +} + +// TODO (PERMISSIONLESS) merge the functions, they practically do the same + +// GetConsumersToBeStopped +func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.StopTimeToConsumerIdsKey(stopTime)) + if bz == nil { + return types.ConsumerIds{}, nil + } + + var consumerIds types.ConsumerIds + err := consumerIds.Unmarshal(bz) + if err != nil { + return types.ConsumerIds{}, err + } + return consumerIds, nil +} + +// AppendSpawnTimeForConsumerToBeStopped +func (k Keeper) AppendStopTimeForConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumerIdsStr, err := k.GetConsumersToBeStopped(ctx, stopTime) + if err != nil { + return err + } + consumerIds := append(consumerIdsStr.Ids, consumerId) + + consumerIdsNewStr := types.ConsumerIds{ + Ids: consumerIds, + } + + bz, err := consumerIdsNewStr.Marshal() + if err != nil { + return err + } + + store.Set(types.StopTimeToConsumerIdsKey(stopTime), bz) + return nil +} + +// RemoveConsumerFromToBeStoppedConsumers +func (k Keeper) RemoveConsumerFromToBeStoppedConsumers(ctx sdk.Context, consumerId string, stopTime time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumerIds, err := k.GetConsumersToBeStopped(ctx, stopTime) + if err != nil { + return err + } + + if len(consumerIds.Ids) == 0 { + return fmt.Errorf("no consumer ids for stop time: %s", stopTime.String()) + } + + // find the index of the consumer we want to remove + index := 0 + for i := 0; i < len(consumerIds.Ids); i = i + 1 { + if consumerIds.Ids[i] == consumerId { + index = i + break + } + } + if consumerIds.Ids[index] != consumerId { + return fmt.Errorf("failed to find consumer id (%s) in the chains to be stopped", consumerId) + } + + if len(consumerIds.Ids) == 1 { + store.Delete(types.StopTimeToConsumerIdsKey(stopTime)) + return nil + } + + updatedConsumerIds := append(consumerIds.Ids[:index], consumerIds.Ids[index+1:]...) + updatedConsumerIdsStr := types.ConsumerIds{ + Ids: updatedConsumerIds, + } + bz, err := updatedConsumerIdsStr.Marshal() + if err != nil { + return err + } + + store.Set(types.StopTimeToConsumerIdsKey(stopTime), bz) + return nil +} + +// GetOptedInConsumerIds +func (k Keeper) GetOptedInConsumerIds(ctx sdk.Context, providerAddr types.ProviderConsAddress) ([]string, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr)) + if bz == nil { + return []string{}, nil + } + + var consumerIds []string + buf := bytes.NewBuffer(bz) + dec := gob.NewDecoder(buf) + err := dec.Decode(&consumerIds) + return consumerIds, err +} + +// AppendOptedInConsumerId +func (k Keeper) AppendOptedInConsumerId(ctx sdk.Context, providerAddr types.ProviderConsAddress, consumerId string) error { + store := ctx.KVStore(k.storeKey) + + consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + if err != nil { + return err + } + consumerIds = append(consumerIds, consumerId) + + var buf bytes.Buffer + enc := gob.NewEncoder(&buf) + err = enc.Encode(consumerIds) + if err != nil { + return err + } + + store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), buf.Bytes()) + return nil +} + +// RemoveOptedInConsumerId +func (k Keeper) RemoveOptedInConsumerId(ctx sdk.Context, providerAddr types.ProviderConsAddress, consumerId string) error { + store := ctx.KVStore(k.storeKey) + + consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + if err != nil { + return err + } + + if len(consumerIds) == 0 { + return fmt.Errorf("no consumer ids for provider consensus address: %s", providerAddr.String()) + } + + // find the index of the consumer we want to remove + index := 0 + for i := 0; i < len(consumerIds); i = i + 1 { + if consumerIds[i] == consumerId { + index = i + break + } + } + if consumerIds[index] != consumerId { + return fmt.Errorf("failed to find consumer id (%s) from the opted-in chains", consumerId) + } + + if len(consumerIds) == 1 { + store.Delete(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr)) + return nil + } + + updatedConsumerIds := append(consumerIds[:index], consumerIds[index+1:]...) + var buf bytes.Buffer + enc := gob.NewEncoder(&buf) + err = enc.Encode(updatedConsumerIds) + if err != nil { + return err + } + + store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), buf.Bytes()) + return nil +} + +// GetClientIdToConsumerId returns the consumer id associated with this client id +func (k Keeper) GetClientIdToConsumerId(ctx sdk.Context, clientId string) (string, bool) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.ClientIdToConsumerIdKey(clientId)) + if buf == nil { + return "", false + } + return string(buf), true +} + +// SetClientIdToConsumerId sets the client id associated with this consumer id +func (k Keeper) SetClientIdToConsumerId(ctx sdk.Context, clientId string, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ClientIdToConsumerIdKey(clientId), []byte(consumerId)) +} + +// DeleteClientIdToConsumerId deletes the client id to consumer id association +func (k Keeper) DeleteClientIdToConsumerId(ctx sdk.Context, clientId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ClientIdToConsumerIdKey(clientId)) +} + +// GetInitializedConsumersReadyToLaunch returns the consumer ids of the pending initialized consumer chains +// that are ready to launch, i.e., consumer clients to be created. +func (k Keeper) GetInitializedConsumersReadyToLaunch(ctx sdk.Context, limit uint32) []string { + store := ctx.KVStore(k.storeKey) + + spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix}) + defer iterator.Close() + + result := []string{} + for ; iterator.Valid(); iterator.Next() { + spawnTime, err := types.ParseTime(types.SpawnTimeToConsumerIdsKeyPrefix(), iterator.Key()) + if err != nil { + k.Logger(ctx).Error("failed to parse spawn time", + "error", err) + continue + } + if spawnTime.After(ctx.BlockTime()) { + return result + } + + // if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain + consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + if err != nil { + k.Logger(ctx).Error("failed to retrieve consumers to launch", + "spawn time", spawnTime, + "error", err) + continue + } + if len(result)+len(consumerIds.Ids) >= int(limit) { + remainingConsumerIds := len(result) + len(consumerIds.Ids) - int(limit) + if len(consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]) == 0 { + return result + } + return append(result, consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]...) + } else { + result = append(result, consumerIds.Ids...) + } + } + + return result +} + +// LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective +// consumer genesis file +func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { + err := k.CreateConsumerClient(ctx, consumerId) + if err != nil { + return err + } + + consumerGenesis, found := k.GetConsumerGenesis(ctx, consumerId) + if !found { + return errorsmod.Wrapf(types.ErrNoConsumerGenesis, "consumer genesis could not be found") + } + + if len(consumerGenesis.Provider.InitialValSet) == 0 { + return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in") + } + + // The cached context is created with a new EventManager so we merge the event + // into the original context + ctx.EventManager().EmitEvents(ctx.EventManager().Events()) + return nil +} + +// UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id +func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string) { + k.DeleteAllowlist(ctx, consumerId) + for _, address := range allowlist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetAllowlist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } +} + +// UpdateDenylist populates the denylist store for the consumer chain with this consumer id +func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string) { + k.DeleteDenylist(ctx, consumerId) + for _, address := range denylist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetDenylist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } + +} + +// UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id +func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN uint32, newTopN uint32) error { + // if the top N changes, we need to update the new minimum power in top N + if newTopN != oldTopN { + if newTopN > 0 { + // if the chain receives a non-zero top N value, store the minimum power in the top N + bondedValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) + if err != nil { + return err + } + minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, newTopN) + if err != nil { + return err + } + k.SetMinimumPowerInTopN(ctx, consumerId, minPower) + } else { + // if the chain receives a zero top N value, we delete the min power + k.DeleteMinimumPowerInTopN(ctx, consumerId) + } + } + + return nil +} + +// GetLaunchedConsumersReadyToStop returns the consumer ids of the pending launched consumer chains +// that are ready to stop +func (k Keeper) GetLaunchedConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { + store := ctx.KVStore(k.storeKey) + + stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) + defer iterator.Close() + + result := []string{} + for ; iterator.Valid(); iterator.Next() { + stopTime, err := types.ParseTime(types.StopTimeToConsumerIdsKeyPrefix(), iterator.Key()) + if err != nil { + k.Logger(ctx).Error("failed to parse stop time", + "error", err) + continue + } + if stopTime.After(ctx.BlockTime()) { + return result + } + + consumerIds, err := k.GetConsumersToBeStopped(ctx, stopTime) + if err != nil { + k.Logger(ctx).Error("failed to retrieve consumers to stop", + "stop time", stopTime, + "error", err) + continue + } + if len(result)+len(consumerIds.Ids) >= int(limit) { + remainingConsumerIds := len(result) + len(consumerIds.Ids) - int(limit) + if len(consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]) == 0 { + return result + } + return append(result, consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]...) + } else { + result = append(result, consumerIds.Ids...) + } + } + + return result +} + +// IsValidatorOptedInToChainId checks if the validator with `providerAddr` is opted into the chain with the specified `chainId`. +// It returns `found == true` and the corresponding chain's `consumerId` if the validator is opted in. Otherwise, it returns an empty string +// for `consumerId` and `found == false`. +func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types.ProviderConsAddress, chainId string) (string, bool) { + consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + if err != nil { + k.Logger(ctx).Error("failed to retrieve the consumer ids this validator is opted in to", + "providerAddr", providerAddr, + "error", err) + return "", false + } + + for _, consumerId := range consumerIds { + consumerChainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + k.Logger(ctx).Error("cannot find chain id", + "consumerId", consumerId, + "error", err) + continue + } + + if consumerChainId == chainId { + return consumerId, true + } + + } + return "", false +} + +func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) { + if !previousSpawnTime.Equal(time.Time{}) { + // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` + // remove the consumer id from the old spawn time + k.RemoveConsumerFromToBeLaunchedConsumers(ctx, consumerId, previousSpawnTime) + } + k.AppendSpawnTimeForConsumerToBeLaunched(ctx, consumerId, spawnTime) +} + +// CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence +// is ready to launch and at what spawn time +// TODO (PERMISSIONLESS): could remove, all fields should be there because we validate the initialization parameters +func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { + // a chain that is already launched or stopped cannot launch again + phase, found := k.GetConsumerPhase(ctx, consumerId) + if !found || phase == Launched || phase == Stopped { + return time.Time{}, false + } + + initializationParameters, err := k.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + return time.Time{}, false + } + + // a chain can only launch if the spawn time is in the future + spawnTimeInTheFuture := initializationParameters.SpawnTime.After(ctx.BlockTime()) + + genesisHashSet := initializationParameters.GenesisHash != nil + binaryHashSet := initializationParameters.BinaryHash != nil + + consumerRedistributionFractionSet := initializationParameters.ConsumerRedistributionFraction != "" + blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0 + historicalEntriesSet := initializationParameters.HistoricalEntries > 0 + + return initializationParameters.SpawnTime, spawnTimeInTheFuture && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && + blocksPerDistributionTransmissionSet && historicalEntriesSet +} diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go new file mode 100644 index 0000000000..5819e355d0 --- /dev/null +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -0,0 +1,384 @@ +package keeper_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "testing" + "time" +) + +func TestFetchAndIncrementConsumerId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := providerKeeper.FetchAndIncrementConsumerId(ctx) + require.Equal(t, "0", consumerId) + + consumerId = providerKeeper.FetchAndIncrementConsumerId(ctx) + require.Equal(t, "1", consumerId) + + consumerId = providerKeeper.FetchAndIncrementConsumerId(ctx) + require.Equal(t, "2", consumerId) +} + +// TestClientIdToConsumerId tests the getter, setter, and deletion methods of the client id to consumer id methods +func TestClientIdToConsumerId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.False(t, found) + + providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId") + consumerId, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.True(t, found) + require.Equal(t, "consumerId", consumerId) + + // assert that overwriting the current consumer id record works + providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId2") + consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.True(t, found) + require.Equal(t, "consumerId2", consumerId) + + providerKeeper.DeleteClientIdToConsumerId(ctx, "clientId") + consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.False(t, found) + require.Equal(t, "", consumerId) +} + +// TestConsumerIdToRegistrationRecord tests the getter, setter, and deletion methods of the consumer id to registration record methods +func TestConsumerIdToRegistrationRecord(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.GetConsumerMetadata(ctx, "consumerId") + require.Error(t, err) + + expectedRecord := providertypes.ConsumerMetadata{ + Name: "name", + Description: "description", + Metadata: "metadata", + //ChainId: "chain_id", + } + providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedRecord) + actualRecord, err := providerKeeper.GetConsumerMetadata(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, expectedRecord, actualRecord) + + // assert that overwriting the current registration record works + expectedRecord = providertypes.ConsumerMetadata{ + Name: "name 2", + Description: "description 2", + Metadata: "metadata 2", + //ChainId: "chain_id2", + } + providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedRecord) + actualRecord, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, expectedRecord, actualRecord) + + providerKeeper.DeleteConsumerMetadata(ctx, "consumerId") + actualRecord, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") + require.Error(t, err) + require.Equal(t, providertypes.ConsumerMetadata{}, actualRecord) +} + +// TestConsumerIdToInitializationRecord tests the getter, setter, and deletion methods of the consumer id to initialization record methods +func TestConsumerIdToInitializationRecord(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + require.Error(t, err) + + spawnTime := time.Unix(1, 2).UTC() + unbondingPeriod := time.Duration(3456) + ccvTimeoutPeriod := time.Duration(789) + transferTimeoutPeriod := time.Duration(101112) + expectedRecord := providertypes.ConsumerInitializationParameters{ + InitialHeight: types.Height{RevisionNumber: 1, RevisionHeight: 2}, + GenesisHash: []byte{0, 1}, + BinaryHash: []byte{2, 3}, + SpawnTime: spawnTime, + UnbondingPeriod: unbondingPeriod, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, + ConsumerRedistributionFraction: "consumer_redistribution_fraction", + BlocksPerDistributionTransmission: 123, + HistoricalEntries: 456, + DistributionTransmissionChannel: "distribution_transmission_channel", + } + providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedRecord) + actualRecord, err := providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, expectedRecord, actualRecord) + + // assert that overwriting the current initialization record works + spawnTime = time.Unix(2, 3).UTC() + unbondingPeriod = time.Duration(789) + ccvTimeoutPeriod = time.Duration(101112) + transferTimeoutPeriod = time.Duration(131415) + expectedRecord = providertypes.ConsumerInitializationParameters{ + InitialHeight: types.Height{RevisionNumber: 2, RevisionHeight: 3}, + GenesisHash: []byte{2, 3}, + BinaryHash: []byte{4, 5}, + SpawnTime: spawnTime, + UnbondingPeriod: unbondingPeriod, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, + ConsumerRedistributionFraction: "consumer_redistribution_fraction2", + BlocksPerDistributionTransmission: 456, + HistoricalEntries: 789, + DistributionTransmissionChannel: "distribution_transmission_channel2", + } + providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedRecord) + actualRecord, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, expectedRecord, actualRecord) + + providerKeeper.DeleteConsumerInitializationParameters(ctx, "consumerId") + actualRecord, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + require.Error(t, err) + require.Equal(t, providertypes.ConsumerInitializationParameters{}, actualRecord) +} + +// TestConsumerIdToOwnerAddress tests the getter, setter, and deletion methods of the owner address to registration record methods +func TestConsumerIdToOwnerAddress(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner_address") + address, err := providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, "owner_address", address) + + // assert that overwriting the current owner address works + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner_address2") + address, err = providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, "owner_address2", address) +} + +// TestConsumerIdToPhase tests the getter, setter, and deletion methods of the consumer id to phase methods +func TestConsumerIdToPhase(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, found := providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.False(t, found) + + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + phase, found := providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.True(t, found) + require.Equal(t, keeper.Initialized, phase) + + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Launched) + phase, found = providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.True(t, found) + require.Equal(t, keeper.Launched, phase) +} + +// TestConsumerIdToStopTime tests the getter, setter, and deletion methods of the consumer id to stop times +func TestConsumerIdToStopTime(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.Error(t, err) + + expectedStopTime := time.Unix(1234, 56789) + providerKeeper.SetConsumerStopTime(ctx, "consumerId", expectedStopTime) + actualStopTime, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, actualStopTime, expectedStopTime) + + providerKeeper.DeleteConsumerStopTime(ctx, "consumerId") + _, err = providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.Error(t, err) +} + +// TestGetInitializedConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned +func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // no chains to-be-launched exist + require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) + + providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId3", time.Unix(30, 0)) + + // time has not yet reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) + require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(10, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" and "consumerId2" + ctx = ctx.WithBlockTime(time.Unix(20, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of all chains + ctx = ctx.WithBlockTime(time.Unix(30, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // limit the number of returned consumer chains + require.Equal(t, []string{}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 1)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 2)) +} + +func TestGetLaunchedConsumersReadyToStop(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // no chains to-be-stopped exist + require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) + + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) + + // time has not yet reached the stop time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) + require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(10, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of "consumerId1" and "consumerId2" + ctx = ctx.WithBlockTime(time.Unix(20, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of all chains + ctx = ctx.WithBlockTime(time.Unix(30, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) +} + +func TestIsValidatorOptedInToChain(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + chainId := "chainId" + providerAddr := providertypes.NewProviderConsAddress([]byte("providerAddr")) + _, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) + require.False(t, found) + + expectedConsumerId := "consumerId" + providerKeeper.SetConsumerChainId(ctx, expectedConsumerId, chainId) + providerKeeper.SetOptedIn(ctx, expectedConsumerId, providerAddr) + providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, expectedConsumerId) + actualConsumerId, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) + require.True(t, found) + require.Equal(t, expectedConsumerId, actualConsumerId) +} + +func TestUpdateAllowlist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateAllowlist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedAllowlist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) +} + +func TestPopulateDenylist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateDenylist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedDenylist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) +} + +func TestPopulateMinimumPowerInTopN(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + // test case where Top N is 0 in which case there's no minimum power in top N + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 0, + }) + + err := providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 0) + require.NoError(t, err) + _, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.False(t, found) + + // test cases where Top N > 0 and for this we mock some validators + powers := []int64{10, 20, 30} + validators := []stakingtypes.Validator{ + createStakingValidator(ctx, mocks, 1, powers[0], 1), // this validator has ~16 of the total voting power + createStakingValidator(ctx, mocks, 2, powers[1], 2), // this validator has ~33% of the total voting gpower + createStakingValidator(ctx, mocks, 3, powers[2], 3), // this validator has 50% of the total voting power + } + mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() + + maxProviderConsensusValidators := int64(3) + params := providerKeeper.GetParams(ctx) + params.MaxProviderConsensusValidators = maxProviderConsensusValidators + providerKeeper.SetParams(ctx, params) + + // when top N is 50, the minimum power is 30 (because top validator has to validate) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 50, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 50) + require.NoError(t, err) + minimumPowerInTopN, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(30), minimumPowerInTopN) + + // when top N is 51, the minimum power is 20 (because top 2 validators have to validate) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 51, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 50, 51) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(20), minimumPowerInTopN) + + // when top N is 100, the minimum power is 10 (that of the validator with the lowest power) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 100, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 51, 100) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(10), minimumPowerInTopN) + +} diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 9c2f620636..d13ad3d2bd 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -23,43 +23,6 @@ import ( ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// Wrapper for the new proposal message MsgConsumerAddition -// Will replace legacy handler HandleLegacyConsumerAdditionProposal -func (k Keeper) HandleConsumerAdditionProposal(ctx sdk.Context, proposal *types.MsgConsumerAddition) error { - p := types.ConsumerAdditionProposal{ - ChainId: proposal.ChainId, - InitialHeight: proposal.InitialHeight, - GenesisHash: proposal.GenesisHash, - BinaryHash: proposal.BinaryHash, - SpawnTime: proposal.SpawnTime, - UnbondingPeriod: proposal.UnbondingPeriod, - CcvTimeoutPeriod: proposal.CcvTimeoutPeriod, - TransferTimeoutPeriod: proposal.TransferTimeoutPeriod, - ConsumerRedistributionFraction: proposal.ConsumerRedistributionFraction, - BlocksPerDistributionTransmission: proposal.BlocksPerDistributionTransmission, - HistoricalEntries: proposal.HistoricalEntries, - DistributionTransmissionChannel: proposal.DistributionTransmissionChannel, - Top_N: proposal.Top_N, - ValidatorsPowerCap: proposal.ValidatorsPowerCap, - ValidatorSetCap: proposal.ValidatorSetCap, - Allowlist: proposal.Allowlist, - Denylist: proposal.Denylist, - } - - return k.HandleLegacyConsumerAdditionProposal(ctx, &p) -} - -// Wrapper for the new proposal message MsgConsumerRemoval -// Will replace legacy handler HandleLegacyConsumerRemovalProposal -func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, proposal *types.MsgConsumerRemoval) error { - p := types.ConsumerRemovalProposal{ - ChainId: proposal.ChainId, - StopTime: proposal.StopTime, - } - - return k.HandleLegacyConsumerRemovalProposal(ctx, &p) -} - // Wrapper for the new proposal message MsgChangeRewardDenoms // Will replace legacy handler HandleLegacyConsumerRewardDenomProposal func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, proposal *types.MsgChangeRewardDenoms) error { @@ -71,47 +34,35 @@ func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, proposal *typ return k.HandleLegacyConsumerRewardDenomProposal(ctx, &p) } -// HandleConsumerModificationProposal modifies a running consumer chain -func (k Keeper) HandleConsumerModificationProposal(ctx sdk.Context, proposal *types.MsgConsumerModification) error { - p := types.ConsumerModificationProposal{ - Title: proposal.Title, - Description: proposal.Description, - ChainId: proposal.ChainId, - Top_N: proposal.Top_N, - ValidatorsPowerCap: proposal.ValidatorsPowerCap, - ValidatorSetCap: proposal.ValidatorSetCap, - Allowlist: proposal.Allowlist, - Denylist: proposal.Denylist, - MinStake: proposal.MinStake, - AllowInactiveVals: proposal.AllowInactiveVals, +// CreateConsumerClient will create the CCV client for the given consumer chain. The CCV channel must be built +// on top of the CCV client to ensure connection with the right consumer chain. +func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { + initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + return err } - return k.HandleLegacyConsumerModificationProposal(ctx, &p) -} + phase, found := k.GetConsumerPhase(ctx, consumerId) + if !found || phase != Initialized { + return errorsmod.Wrapf(types.ErrInvalidPhase, + "cannot create client for consumer chain that is not in the Initialized phase: %s", consumerId) + } -// CreateConsumerClient will create the CCV client for the given consumer chain. The CCV channel must be built -// on top of the CCV client to ensure connection with the right consumer chain. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-crclient1 -// Spec tag: [CCV-PCF-CRCLIENT.1] -func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditionProposal) error { - chainID := prop.ChainId - // check that a client for this chain does not exist - if _, found := k.GetConsumerClientId(ctx, chainID); found { - return errorsmod.Wrap(types.ErrDuplicateConsumerChain, - fmt.Sprintf("cannot create client for existent consumer chain: %s", chainID)) + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return err } // Set minimum height for equivocation evidence from this consumer chain - k.SetEquivocationEvidenceMinHeight(ctx, chainID, prop.InitialHeight.RevisionHeight) + k.SetEquivocationEvidenceMinHeight(ctx, consumerId, initializationRecord.InitialHeight.RevisionHeight) // Consumers start out with the unbonding period from the consumer addition prop - consumerUnbondingPeriod := prop.UnbondingPeriod + consumerUnbondingPeriod := initializationRecord.UnbondingPeriod // Create client state by getting template client from parameters and filling in zeroed fields from proposal. clientState := k.GetTemplateClient(ctx) - clientState.ChainId = chainID - clientState.LatestHeight = prop.InitialHeight + clientState.ChainId = chainId + clientState.LatestHeight = initializationRecord.InitialHeight trustPeriod, err := ccv.CalculateTrustPeriod(consumerUnbondingPeriod, k.GetTrustingPeriodFraction(ctx)) if err != nil { @@ -120,11 +71,11 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi clientState.TrustingPeriod = trustPeriod clientState.UnbondingPeriod = consumerUnbondingPeriod - consumerGen, validatorSetHash, err := k.MakeConsumerGenesis(ctx, prop) + consumerGen, validatorSetHash, err := k.MakeConsumerGenesis(ctx, consumerId) if err != nil { return err } - err = k.SetConsumerGenesis(ctx, chainID, consumerGen) + err = k.SetConsumerGenesis(ctx, consumerId, consumerGen) if err != nil { return err } @@ -140,20 +91,21 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi if err != nil { return err } - k.SetConsumerClientId(ctx, chainID, clientID) + k.SetConsumerClientId(ctx, consumerId, clientID) + k.SetClientIdToConsumerId(ctx, clientID, consumerId) k.Logger(ctx).Info("consumer chain registered (client created)", - "chainID", chainID, - "clientID", clientID, + "consumer id", consumerId, + "client id", clientID, ) ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeConsumerClientCreated, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(ccv.AttributeChainID, chainID), + sdk.NewAttribute(ccv.AttributeChainID, consumerId), sdk.NewAttribute(clienttypes.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeInitialHeight, prop.InitialHeight.String()), + sdk.NewAttribute(types.AttributeInitialHeight, initializationRecord.InitialHeight.String()), sdk.NewAttribute(types.AttributeTrustingPeriod, clientState.TrustingPeriod.String()), sdk.NewAttribute(types.AttributeUnbondingPeriod, clientState.UnbondingPeriod.String()), ), @@ -162,29 +114,25 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi return nil } -// StopConsumerChain cleans up the states for the given consumer chain ID and -// completes the outstanding unbonding operations on the consumer chain. -// -// This method implements StopConsumerChain from spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 -// Spec tag: [CCV-PCF-STCC.1] -func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan bool) (err error) { - // check that a client for chainID exists - if _, found := k.GetConsumerClientId(ctx, chainID); !found { +// StopConsumerChain cleans up the states for the given consumer id +func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan bool) (err error) { + // check that a client for consumerId exists + // TODO (PERMISSIONLESS): change to use phases instead + if _, found := k.GetConsumerClientId(ctx, consumerId); !found { return errorsmod.Wrap(types.ErrConsumerChainNotFound, - fmt.Sprintf("cannot stop non-existent consumer chain: %s", chainID)) + fmt.Sprintf("cannot stop non-existent consumer chain: %s", consumerId)) } // clean up states - k.DeleteConsumerClientId(ctx, chainID) - k.DeleteConsumerGenesis(ctx, chainID) + k.DeleteConsumerClientId(ctx, consumerId) + k.DeleteConsumerGenesis(ctx, consumerId) // Note: this call panics if the key assignment state is invalid - k.DeleteKeyAssignments(ctx, chainID) - k.DeleteMinimumPowerInTopN(ctx, chainID) - k.DeleteEquivocationEvidenceMinHeight(ctx, chainID) + k.DeleteKeyAssignments(ctx, consumerId) + k.DeleteMinimumPowerInTopN(ctx, consumerId) + k.DeleteEquivocationEvidenceMinHeight(ctx, consumerId) // close channel and delete the mappings between chain ID and channel ID - if channelID, found := k.GetChainToChannel(ctx, chainID); found { + if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { if closeChan { // Close the channel for the given channel ID on the condition // that the channel exists and isn't already in the CLOSED state @@ -193,49 +141,67 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo err := k.chanCloseInit(ctx, channelID) if err != nil { k.Logger(ctx).Error("channel to consumer chain could not be closed", - "chainID", chainID, + "consumerId", consumerId, "channelID", channelID, "error", err.Error(), ) } } } - k.DeleteChainToChannel(ctx, chainID) - k.DeleteChannelToChain(ctx, channelID) + k.DeleteConsumerIdToChannelId(ctx, consumerId) + k.DeleteChannelIdToConsumerId(ctx, channelID) } // delete consumer commission rate - provAddrs := k.GetAllCommissionRateValidators(ctx, chainID) + provAddrs := k.GetAllCommissionRateValidators(ctx, consumerId) for _, addr := range provAddrs { - k.DeleteConsumerCommissionRate(ctx, chainID, addr) + k.DeleteConsumerCommissionRate(ctx, consumerId, addr) } - k.DeleteInitChainHeight(ctx, chainID) - k.DeleteSlashAcks(ctx, chainID) - k.DeletePendingVSCPackets(ctx, chainID) + k.DeleteInitChainHeight(ctx, consumerId) + k.DeleteSlashAcks(ctx, consumerId) + k.DeletePendingVSCPackets(ctx, consumerId) - k.DeleteTopN(ctx, chainID) - k.DeleteValidatorsPowerCap(ctx, chainID) - k.DeleteValidatorSetCap(ctx, chainID) - k.DeleteAllowlist(ctx, chainID) - k.DeleteDenylist(ctx, chainID) - k.DeleteMinStake(ctx, chainID) - k.DisableInactiveValidators(ctx, chainID) + k.DeleteConsumerMetadata(ctx, consumerId) + k.DeleteConsumerPowerShapingParameters(ctx, consumerId) + k.DeleteConsumerPowerShapingParameters(ctx, consumerId) + k.DeleteAllowlist(ctx, consumerId) + k.DeleteDenylist(ctx, consumerId) + k.DeleteAllOptedIn(ctx, consumerId) + k.DeleteConsumerValSet(ctx, consumerId) - k.DeleteAllOptedIn(ctx, chainID) - k.DeleteConsumerValSet(ctx, chainID) + // TODO (PERMISSIONLESS) add newly-added state to be deleted - k.Logger(ctx).Info("consumer chain removed from provider", "chainID", chainID) + k.Logger(ctx).Info("consumer chain removed from provider", "consumerId", consumerId) return nil } -// MakeConsumerGenesis constructs the consumer CCV module part of the genesis state. +// MakeConsumerGenesis returns the created consumer genesis state for consumer chain `consumerId`, +// as well as the validator hash of the initial validator set of the consumer chain func (k Keeper) MakeConsumerGenesis( ctx sdk.Context, - prop *types.ConsumerAdditionProposal, + consumerId string, ) (gen ccv.ConsumerGenesisState, nextValidatorsHash []byte, err error) { - chainID := prop.ChainId + initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + return gen, nil, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, + "initialization record for consumer id: %s is missing", consumerId) + + } + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + powerShapingParameters = types.PowerShapingParameters{ + Top_N: 0, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + MinStake: 0, + AllowInactiveVals: false, + } + } + providerUnbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) if err != nil { return gen, nil, errorsmod.Wrapf(types.ErrNoUnbondingTime, "unbonding time not found: %s", err) @@ -266,7 +232,7 @@ func (k Keeper) MakeConsumerGenesis( return gen, nil, errorsmod.Wrapf(stakingtypes.ErrNoValidatorFound, "error getting last bonded validators: %s", err) } - if prop.Top_N > 0 { + if powerShapingParameters.Top_N > 0 { // get the consensus active validators // we do not want to base the power calculation for the top N // on inactive validators, too, since the top N will be a percentage of the active set power @@ -277,22 +243,21 @@ func (k Keeper) MakeConsumerGenesis( } // in a Top-N chain, we automatically opt in all validators that belong to the top N - minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, prop.Top_N) + minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) if err != nil { return gen, nil, err } // log the minimum power in top N k.Logger(ctx).Info("minimum power in top N at consumer genesis", - "chainID", chainID, + "consumerId", consumerId, "minPower", minPower, ) - k.OptInTopNValidators(ctx, chainID, activeValidators, minPower) - k.SetMinimumPowerInTopN(ctx, chainID, minPower) + k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) + k.SetMinimumPowerInTopN(ctx, consumerId, minPower) } // need to use the bondedValidators, not activeValidators, here since the chain might be opt-in and allow inactive vals - nextValidators := k.ComputeNextValidators(ctx, chainID, bondedValidators) - - k.SetConsumerValSet(ctx, chainID, nextValidators) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators) + k.SetConsumerValSet(ctx, consumerId, nextValidators) // get the initial updates with the latest set consumer public keys initialUpdatesWithConsumerKeys := DiffValidators([]types.ConsensusValidator{}, nextValidators) @@ -306,14 +271,14 @@ func (k Keeper) MakeConsumerGenesis( consumerGenesisParams := ccv.NewParams( true, - prop.BlocksPerDistributionTransmission, - prop.DistributionTransmissionChannel, + initializationRecord.BlocksPerDistributionTransmission, + initializationRecord.DistributionTransmissionChannel, "", // providerFeePoolAddrStr, - prop.CcvTimeoutPeriod, - prop.TransferTimeoutPeriod, - prop.ConsumerRedistributionFraction, - prop.HistoricalEntries, - prop.UnbondingPeriod, + initializationRecord.CcvTimeoutPeriod, + initializationRecord.TransferTimeoutPeriod, + initializationRecord.ConsumerRedistributionFraction, + initializationRecord.HistoricalEntries, + initializationRecord.UnbondingPeriod, []string{}, []string{}, ccv.DefaultRetryDelayPeriod, @@ -331,7 +296,7 @@ func (k Keeper) MakeConsumerGenesis( // SetPendingConsumerAdditionProp stores a pending consumer addition proposal. // // Note that the pending consumer addition proposals are stored under keys with -// the following format: PendingCAPKeyPrefix | spawnTime | chainID +// the following format: PendingCAPKeyPrefix | spawnTime | consumerId // Thus, if multiple consumer addition proposal for the same chain will pass at // the same time, then only the last one will be stored. func (k Keeper) SetPendingConsumerAdditionProp(ctx sdk.Context, prop *types.ConsumerAdditionProposal) { @@ -366,76 +331,34 @@ func (k Keeper) GetPendingConsumerAdditionProp(ctx sdk.Context, spawnTime time.T return prop, true } -// BeginBlockInit iterates over the pending consumer addition proposals in order, and creates -// clients for props in which the spawn time has passed. Executed proposals are deleted. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-bblock-init1 -// Spec tag:[CCV-PCF-BBLOCK-INIT.1] +// BeginBlockInit iterates over the initialized consumers chains and creates clients for chains +// in which the spawn time has passed func (k Keeper) BeginBlockInit(ctx sdk.Context) { - propsToExecute := k.GetConsumerAdditionPropsToExecute(ctx) - - for i, prop := range propsToExecute { - // create consumer client in a cached context to handle errors - cachedCtx, writeFn := ctx.CacheContext() - - k.SetTopN(cachedCtx, prop.ChainId, prop.Top_N) - k.SetValidatorSetCap(cachedCtx, prop.ChainId, prop.ValidatorSetCap) - k.SetValidatorsPowerCap(cachedCtx, prop.ChainId, prop.ValidatorsPowerCap) - k.SetMinStake(cachedCtx, prop.ChainId, prop.MinStake) - k.SetInactiveValidatorsAllowed(cachedCtx, prop.ChainId, prop.AllowInactiveVals) - - for _, address := range prop.Allowlist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetAllowlist(cachedCtx, prop.ChainId, types.NewProviderConsAddress(consAddr)) - } - - for _, address := range prop.Denylist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetDenylist(cachedCtx, prop.ChainId, types.NewProviderConsAddress(consAddr)) - } - - err := k.CreateConsumerClient(cachedCtx, &propsToExecute[i]) + // TODO (PERMISSIONLESS): we can parameterize the limit + for _, consumerId := range k.GetInitializedConsumersReadyToLaunch(ctx, 200) { + record, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { - // drop the proposal - ctx.Logger().Info("consumer client could not be created: %w", err) + ctx.Logger().Error("could not retrieve initialization record", + "consumerId", consumerId, + "error", err) continue } + // Remove consumer to prevent re-trying launching this chain. + // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. + k.RemoveConsumerFromToBeLaunchedConsumers(ctx, consumerId, record.SpawnTime) - consumerGenesis, found := k.GetConsumerGenesis(cachedCtx, prop.ChainId) - if !found { - // drop the proposal - ctx.Logger().Info("consumer genesis could not be created") - continue - } - - if len(consumerGenesis.Provider.InitialValSet) == 0 { - // drop the proposal - ctx.Logger().Info("consumer genesis initial validator set is empty - no validators opted in") + cachedCtx, writeFn := ctx.CacheContext() + err = k.LaunchConsumer(cachedCtx, consumerId) + if err != nil { + ctx.Logger().Error("could not launch chain", + "consumerId", consumerId, + "error", err) continue } + k.SetConsumerPhase(cachedCtx, consumerId, Launched) - // The cached context is created with a new EventManager so we merge the event - // into the original context - ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) - // write cache writeFn() - - k.Logger(ctx).Info("executed consumer addition proposal", - "chainID", prop.ChainId, - "title", prop.Title, - "spawn time", prop.SpawnTime.UTC(), - ) } - // delete the executed proposals - k.DeletePendingConsumerAdditionProps(ctx, propsToExecute...) } // GetConsumerAdditionPropsToExecute returns the pending consumer addition proposals @@ -471,9 +394,9 @@ func (k Keeper) GetConsumerAdditionPropsToExecute(ctx sdk.Context) (propsToExecu // GetAllPendingConsumerAdditionProps gets all pending consumer addition proposals. // // Note that the pending consumer addition proposals are stored under keys with the following format: -// PendingCAPKeyPrefix | spawnTime.UnixNano() | chainID +// PendingCAPKeyPrefix | spawnTime.UnixNano() | consumerId // Thus, the returned array is in spawnTime order. If two proposals have the same spawnTime, -// then they are ordered by chainID. +// then they are ordered by consumerId. func (k Keeper) GetAllPendingConsumerAdditionProps(ctx sdk.Context) (props []types.ConsumerAdditionProposal) { store := ctx.KVStore(k.storeKey) iterator := storetypes.KVStorePrefixIterator(store, types.PendingCAPKeyPrefix()) @@ -507,7 +430,7 @@ func (k Keeper) DeletePendingConsumerAdditionProps(ctx sdk.Context, proposals .. // SetPendingConsumerRemovalProp stores a pending consumer removal proposal. // // Note that the pending removal addition proposals are stored under keys with -// the following format: PendingCRPKeyPrefix | stopTime | chainID +// the following format: PendingCRPKeyPrefix | stopTime | consumerId // Thus, if multiple removal addition proposal for the same chain will pass at // the same time, then only the last one will be stored. func (k Keeper) SetPendingConsumerRemovalProp(ctx sdk.Context, prop *types.ConsumerRemovalProposal) { @@ -541,78 +464,84 @@ func (k Keeper) DeletePendingConsumerRemovalProps(ctx sdk.Context, proposals ... } } -// BeginBlockCCR iterates over the pending consumer removal proposals -// in order and stop/removes the chain if the stop time has passed, -// otherwise it will break out of loop and return. Executed proposals are deleted. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-bblock-ccr1 -// Spec tag: [CCV-PCF-BBLOCK-CCR.1] +// BeginBlockCCR iterates over the pending consumer proposals and stop/removes the chain if the stop time has passed func (k Keeper) BeginBlockCCR(ctx sdk.Context) { - propsToExecute := k.GetConsumerRemovalPropsToExecute(ctx) - - for _, prop := range propsToExecute { + // TODO (PERMISSIONLESS): parameterize the limit + for _, consumerId := range k.GetLaunchedConsumersReadyToStop(ctx, 200) { // stop consumer chain in a cached context to handle errors - cachedCtx, writeFn, err := k.StopConsumerChainInCachedCtx(ctx, prop) + cachedCtx, writeFn := ctx.CacheContext() + + stopTime, err := k.GetConsumerStopTime(ctx, consumerId) + if err != nil { + k.Logger(ctx).Info("chain could not be stopped", + "consumerId", consumerId, + "err", err.Error()) + continue + } + + err = k.StopConsumerChain(cachedCtx, consumerId, true) if err != nil { - // drop the proposal - ctx.Logger().Info("consumer chain could not be stopped: %w", err) + k.Logger(ctx).Info("consumer chain could not be stopped", + "consumerId", consumerId, + "err", err.Error()) continue } // The cached context is created with a new EventManager so we merge the event // into the original context + // TODO (PERMISSIONLESS): verify this here and in the initialized chains to launch ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) - // write cache + + k.SetConsumerPhase(cachedCtx, consumerId, Stopped) + k.RemoveConsumerFromToBeStoppedConsumers(ctx, consumerId, stopTime) writeFn() - k.Logger(ctx).Info("executed consumer removal proposal", - "chainID", prop.ChainId, - "title", prop.Title, - "stop time", prop.StopTime.UTC(), + k.Logger(ctx).Info("executed consumer removal", + "consumer id", consumerId, + "stop time", stopTime, ) } - // delete the executed proposals - k.DeletePendingConsumerRemovalProps(ctx, propsToExecute...) } -// GetConsumerRemovalPropsToExecute iterates over the pending consumer removal proposals -// and returns an ordered list of consumer removal proposals to be executed, -// ie. consumer chains to be stopped and removed from the provider chain. -// A prop is included in the returned list if its proposed stop time has passed. +// TODO (PERMISSIONLESS): leaving commented out because it might be used for migration +//// GetConsumerRemovalPropsToExecute iterates over the pending consumer removal proposals +//// and returns an ordered list of consumer removal proposals to be executed, +//// ie. consumer chains to be stopped and removed from the provider chain. +//// A prop is included in the returned list if its proposed stop time has passed. +//// +//// Note: this method is split out from BeginBlockCCR to be easily unit tested. +//func (k Keeper) GetConsumerRemovalPropsToExecute(ctx sdk.Context) []types.ConsumerRemovalProposal { +// // store the (to be) executed consumer removal proposals in order +// propsToExecute := []types.ConsumerRemovalProposal{} // -// Note: this method is split out from BeginBlockCCR to be easily unit tested. -func (k Keeper) GetConsumerRemovalPropsToExecute(ctx sdk.Context) []types.ConsumerRemovalProposal { - // store the (to be) executed consumer removal proposals in order - propsToExecute := []types.ConsumerRemovalProposal{} - - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PendingCRPKeyPrefix()) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var prop types.ConsumerRemovalProposal - err := prop.Unmarshal(iterator.Value()) - if err != nil { - // An error here would indicate something is very wrong, - // the ConsumerRemovalProposal is assumed to be correctly serialized in SetPendingConsumerRemovalProp. - panic(fmt.Errorf("failed to unmarshal consumer removal proposal: %w", err)) - } - - // If current block time is equal to or after stop time, proposal is ready to be executed - if !ctx.BlockTime().Before(prop.StopTime) { - propsToExecute = append(propsToExecute, prop) - } else { - // No more proposals to check, since they're stored/ordered by timestamp. - break - } - } - - return propsToExecute -} +// store := ctx.KVStore(k.storeKey) +// iterator := storetypes.KVStorePrefixIterator(store, types.PendingCRPKeyPrefix()) +// defer iterator.Close() +// +// for ; iterator.Valid(); iterator.Next() { +// var prop types.ConsumerRemovalProposal +// err := prop.Unmarshal(iterator.Value()) +// if err != nil { +// // An error here would indicate something is very wrong, +// // the ConsumerRemovalProposal is assumed to be correctly serialized in SetPendingConsumerRemovalProp. +// panic(fmt.Errorf("failed to unmarshal consumer removal proposal: %w", err)) +// } +// +// // If current block time is equal to or after stop time, proposal is ready to be executed +// if !ctx.BlockTime().Before(prop.StopTime) { +// propsToExecute = append(propsToExecute, prop) +// } else { +// // No more proposals to check, since they're stored/ordered by timestamp. +// break +// } +// } +// +// return propsToExecute +//} // GetAllPendingConsumerRemovalProps iterates through the pending consumer removal proposals. // // Note that the pending consumer removal proposals are stored under keys with the following format: -// PendingCRPKeyPrefix | stopTime.UnixNano() | chainID +// PendingCRPKeyPrefix | stopTime.UnixNano() | consumerId // Thus, the returned array is in stopTime order. func (k Keeper) GetAllPendingConsumerRemovalProps(ctx sdk.Context) (props []types.ConsumerRemovalProposal) { store := ctx.KVStore(k.storeKey) @@ -634,14 +563,6 @@ func (k Keeper) GetAllPendingConsumerRemovalProps(ctx sdk.Context) (props []type return props } -// CreateConsumerClientInCachedCtx creates a consumer client -// from a given consumer addition proposal in a cached context -func (k Keeper) CreateConsumerClientInCachedCtx(ctx sdk.Context, p types.ConsumerAdditionProposal) (cc sdk.Context, writeCache func(), err error) { - cc, writeCache = ctx.CacheContext() - err = k.CreateConsumerClient(cc, &p) - return -} - // StopConsumerChainInCachedCtx stop a consumer chain // from a given consumer removal proposal in a cached context func (k Keeper) StopConsumerChainInCachedCtx(ctx sdk.Context, p types.ConsumerRemovalProposal) (cc sdk.Context, writeCache func(), err error) { diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 472cb3c64c..1aef84957f 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "bytes" "encoding/json" + "fmt" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" "sort" "testing" "time" @@ -19,7 +21,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -30,128 +31,8 @@ import ( // Initialization sub-protocol related tests of proposal.go // -// Tests the HandleConsumerAdditionProposal method against the SpawnConsumerChainProposalHandler spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcaprop1 -// Spec tag: [CCV-PCF-HCAPROP.1] -func TestHandleConsumerAdditionProposal(t *testing.T) { - type testCase struct { - description string - malleate func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) - prop *providertypes.ConsumerAdditionProposal - // Time when prop is handled - blockTime time.Time - // Whether it's expected that the proposal is successfully verified - // and appended to the pending proposals - expAppendProp bool - } - - // Snapshot times asserted in tests - now := time.Now().UTC() - - tests := []testCase{ - { - description: "expect to append valid proposal", - malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, - prop: providertypes.NewConsumerAdditionProposal( - "title", - "description", - "chainID", - clienttypes.NewHeight(2, 3), - []byte("gen_hash"), - []byte("bin_hash"), - now, // Spawn time - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - blockTime: now, - expAppendProp: true, - }, - { - description: "expect to not append invalid proposal using an already existing chain id", - malleate: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "anyClientId") - }, - - prop: providertypes.NewConsumerAdditionProposal( - "title", - "description", - "chainID", - clienttypes.NewHeight(2, 3), - []byte("gen_hash"), - []byte("bin_hash"), - now, - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - blockTime: now, - expAppendProp: false, - }, - } - - for _, tc := range tests { - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - ctx = ctx.WithBlockTime(tc.blockTime) - - if tc.expAppendProp { - // Mock calls are only asserted if we expect a client to be created. - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set - gomock.InOrder( - testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, tc.prop.ChainId, clienttypes.NewHeight(2, 3))..., - ) - } - - tc.malleate(ctx, providerKeeper, tc.prop.ChainId) - - err := providerKeeper.HandleLegacyConsumerAdditionProposal(ctx, tc.prop) - - if tc.expAppendProp { - require.NoError(t, err) - // check that prop was added to the stored pending props - gotProposal, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) - require.True(t, found) - require.Equal(t, *tc.prop, gotProposal) - } else { - require.Error(t, err) - // check that prop wasn't added to the stored pending props - _, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.prop.SpawnTime, tc.prop.ChainId) - require.False(t, found) - } - - ctrl.Finish() - } -} - // Tests the CreateConsumerClient method against the spec, // with more granularity than what's covered in TestHandleCreateConsumerChainProposal. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-crclient1 -// Spec tag: [CCV-PCF-CRCLIENT.1] func TestCreateConsumerClient(t *testing.T) { type testCase struct { description string @@ -164,6 +45,8 @@ func TestCreateConsumerClient(t *testing.T) { { description: "No state mutation, new client should be created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { + providerKeeper.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) + // Valid client creation is asserted with mock expectations here testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set gomock.InOrder( @@ -173,9 +56,9 @@ func TestCreateConsumerClient(t *testing.T) { expClientCreated: true, }, { - description: "client for this chain already exists, new one is not created", + description: "chain for this consumer id has already launched, and hence client was created, NO new one is created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + providerKeeper.SetConsumerPhase(ctx, "0", providerkeeper.Launched) // Expect none of the client creation related calls to happen mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Times(0) @@ -197,11 +80,15 @@ func TestCreateConsumerClient(t *testing.T) { tc.setup(&providerKeeper, ctx, &mocks) // Call method with same arbitrary values as defined above in mock expectations. - err := providerKeeper.CreateConsumerClient(ctx, testkeeper.GetTestConsumerAdditionProp()) + providerKeeper.SetConsumerChainId(ctx, "0", "chainID") + providerKeeper.SetConsumerMetadata(ctx, "0", testkeeper.GetTestConsumerMetadata()) + providerKeeper.SetConsumerInitializationParameters(ctx, "0", testkeeper.GetTestInitializationParameters()) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", testkeeper.GetTestPowerShapingParameters()) + err := providerKeeper.CreateConsumerClient(ctx, "0") if tc.expClientCreated { require.NoError(t, err) - testCreatedConsumerClient(t, ctx, providerKeeper, "chainID", "clientID") + testCreatedConsumerClient(t, ctx, providerKeeper, "0", "clientID") } else { require.Error(t, err) } @@ -215,17 +102,17 @@ func TestCreateConsumerClient(t *testing.T) { // // Note: Separated from TestCreateConsumerClient to also be called from TestCreateConsumerChainProposal. func testCreatedConsumerClient(t *testing.T, - ctx sdk.Context, providerKeeper providerkeeper.Keeper, expectedChainID, expectedClientID string, + ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId, expectedClientID string, ) { t.Helper() // ClientID should be stored. - clientId, found := providerKeeper.GetConsumerClientId(ctx, expectedChainID) + clientId, found := providerKeeper.GetConsumerClientId(ctx, consumerId) require.True(t, found, "consumer client not found") require.Equal(t, expectedClientID, clientId) // Only assert that consumer genesis was set, // more granular tests on consumer genesis should be defined in TestMakeConsumerGenesis - _, ok := providerKeeper.GetConsumerGenesis(ctx, expectedChainID) + _, ok := providerKeeper.GetConsumerGenesis(ctx, consumerId) require.True(t, ok) } @@ -398,7 +285,7 @@ func TestStopConsumerChain(t *testing.T) { expErr bool } - consumerCID := "chainID" + consumerId := "0" tests := []testCase{ { @@ -411,10 +298,10 @@ func TestStopConsumerChain(t *testing.T) { { description: "valid stop of consumer chain, all mock calls hit", setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks) + testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks, consumerId) // set consumer minimum equivocation height - providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerCID, 1) + providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerId, 1) // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) @@ -433,134 +320,94 @@ func TestStopConsumerChain(t *testing.T) { // Setup specific to test case tc.setup(ctx, &providerKeeper, mocks) - err := providerKeeper.StopConsumerChain(ctx, consumerCID, true) + err := providerKeeper.StopConsumerChain(ctx, consumerId, true) if tc.expErr { - require.Error(t, err) + require.Error(t, err, t) } else { require.NoError(t, err) } - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerCID, "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID") ctrl.Finish() } } -// TestPendingConsumerRemovalPropDeletion tests the getting/setting -// and deletion methods for pending consumer removal props -func TestPendingConsumerRemovalPropDeletion(t *testing.T) { - testCases := []struct { - providertypes.ConsumerRemovalProposal - ExpDeleted bool - }{ - { - ConsumerRemovalProposal: providertypes.ConsumerRemovalProposal{ChainId: "8", StopTime: time.Now().UTC()}, - ExpDeleted: true, - }, - { - ConsumerRemovalProposal: providertypes.ConsumerRemovalProposal{ChainId: "9", StopTime: time.Now().UTC().Add(time.Hour)}, - ExpDeleted: false, - }, - } - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - for _, tc := range testCases { - tc := tc - providerKeeper.SetPendingConsumerRemovalProp(ctx, &tc.ConsumerRemovalProposal) - } - - ctx = ctx.WithBlockTime(time.Now().UTC()) - - propsToExecute := providerKeeper.GetConsumerRemovalPropsToExecute(ctx) - // Delete consumer removal proposals, same as what would be done by BeginBlockCCR - providerKeeper.DeletePendingConsumerRemovalProps(ctx, propsToExecute...) - numDeleted := 0 - for _, tc := range testCases { - res := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.ChainId, tc.StopTime) - if !tc.ExpDeleted { - require.NotEmpty(t, res, "consumer removal prop was deleted: %s %s", tc.ChainId, tc.StopTime.String()) - continue - } - require.Empty(t, res, "consumer removal prop was not deleted %s %s", tc.ChainId, tc.StopTime.String()) - require.Equal(t, propsToExecute[numDeleted].ChainId, tc.ChainId) - numDeleted += 1 - } -} - +// TODO (PERMISSIONLESS) +// WE DO NOT go by order in permissionless (?) DO WE need to? // TestGetConsumerRemovalPropsToExecute tests that pending consumer removal proposals // that are ready to execute are accessed in order by timestamp via the iterator -func TestGetConsumerRemovalPropsToExecute(t *testing.T) { - now := time.Now().UTC() - sampleProp1 := providertypes.ConsumerRemovalProposal{ChainId: "chain-2", StopTime: now} - sampleProp2 := providertypes.ConsumerRemovalProposal{ChainId: "chain-1", StopTime: now.Add(time.Hour)} - sampleProp3 := providertypes.ConsumerRemovalProposal{ChainId: "chain-4", StopTime: now.Add(-time.Hour)} - sampleProp4 := providertypes.ConsumerRemovalProposal{ChainId: "chain-3", StopTime: now} - sampleProp5 := providertypes.ConsumerRemovalProposal{ChainId: "chain-1", StopTime: now.Add(2 * time.Hour)} - - getExpectedOrder := func(props []providertypes.ConsumerRemovalProposal, accessTime time.Time) []providertypes.ConsumerRemovalProposal { - expectedOrder := []providertypes.ConsumerRemovalProposal{} - for _, prop := range props { - if !accessTime.Before(prop.StopTime) { - expectedOrder = append(expectedOrder, prop) - } - } - // sorting by SpawnTime.UnixNano() - sort.Slice(expectedOrder, func(i, j int) bool { - if expectedOrder[i].StopTime.UTC() == expectedOrder[j].StopTime.UTC() { - // proposals with same StopTime - return expectedOrder[i].ChainId < expectedOrder[j].ChainId - } - return expectedOrder[i].StopTime.UTC().Before(expectedOrder[j].StopTime.UTC()) - }) - return expectedOrder - } - - testCases := []struct { - propSubmitOrder []providertypes.ConsumerRemovalProposal - accessTime time.Time - }{ - { - propSubmitOrder: []providertypes.ConsumerRemovalProposal{ - sampleProp1, sampleProp2, sampleProp3, sampleProp4, sampleProp5, - }, - accessTime: now, - }, - { - propSubmitOrder: []providertypes.ConsumerRemovalProposal{ - sampleProp3, sampleProp2, sampleProp1, sampleProp5, sampleProp4, - }, - accessTime: now.Add(time.Hour), - }, - { - propSubmitOrder: []providertypes.ConsumerRemovalProposal{ - sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, - }, - accessTime: now.Add(-2 * time.Hour), - }, - { - propSubmitOrder: []providertypes.ConsumerRemovalProposal{ - sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, - }, - accessTime: now.Add(3 * time.Hour), - }, - } - - for _, tc := range testCases { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - expectedOrderedProps := getExpectedOrder(tc.propSubmitOrder, tc.accessTime) - - for _, prop := range tc.propSubmitOrder { - cpProp := prop - providerKeeper.SetPendingConsumerRemovalProp(ctx, &cpProp) - } - propsToExecute := providerKeeper.GetConsumerRemovalPropsToExecute(ctx.WithBlockTime(tc.accessTime)) - require.Equal(t, expectedOrderedProps, propsToExecute) - } -} +//func TestGetConsumerRemovalPropsToExecute(t *testing.T) { +// now := time.Now().UTC() +// sampleProp1 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-2", StopTime: now} +// sampleProp2 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-1", StopTime: now.Add(time.Hour)} +// sampleProp3 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-4", StopTime: now.Add(-time.Hour)} +// sampleProp4 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-3", StopTime: now} +// sampleProp5 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-1", StopTime: now.Add(2 * time.Hour)} +// +// getExpectedOrder := func(props []providertypes.ConsumerRemovalProposal, accessTime time.Time) []providertypes.ConsumerRemovalProposal { +// expectedOrder := []providertypes.ConsumerRemovalProposal{} +// for _, prop := range props { +// if !accessTime.Before(prop.StopTime) { +// expectedOrder = append(expectedOrder, prop) +// } +// } +// // sorting by SpawnTime.UnixNano() +// sort.Slice(expectedOrder, func(i, j int) bool { +// if expectedOrder[i].StopTime.UTC() == expectedOrder[j].StopTime.UTC() { +// // proposals with same StopTime +// return expectedOrder[i].ConsumerId < expectedOrder[j].ConsumerId +// } +// return expectedOrder[i].StopTime.UTC().Before(expectedOrder[j].StopTime.UTC()) +// }) +// return expectedOrder +// } +// +// testCases := []struct { +// propSubmitOrder []providertypes.ConsumerRemovalProposal +// accessTime time.Time +// }{ +// { +// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ +// sampleProp1, sampleProp2, sampleProp3, sampleProp4, sampleProp5, +// }, +// accessTime: now, +// }, +// { +// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ +// sampleProp3, sampleProp2, sampleProp1, sampleProp5, sampleProp4, +// }, +// accessTime: now.Add(time.Hour), +// }, +// { +// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ +// sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, +// }, +// accessTime: now.Add(-2 * time.Hour), +// }, +// { +// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ +// sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, +// }, +// accessTime: now.Add(3 * time.Hour), +// }, +// } +// +// for _, tc := range testCases { +// providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) +// defer ctrl.Finish() +// +// expectedOrderedProps := getExpectedOrder(tc.propSubmitOrder, tc.accessTime) +// +// for _, prop := range tc.propSubmitOrder { +// cpProp := prop +// providerKeeper.SetPendingConsumerRemovalProp(ctx, &cpProp) +// } +// propsToExecute := providerKeeper.GetConsumerRemovalPropsToExecute(ctx.WithBlockTime(tc.accessTime)) +// require.Equal(t, expectedOrderedProps, propsToExecute) +// } +//} // Test getting both matured and pending consumer removal proposals func TestGetAllConsumerRemovalProps(t *testing.T) { @@ -669,24 +516,33 @@ func TestMakeConsumerGenesis(t *testing.T) { // // Other setup not covered by custom template client state // - ctx = ctx.WithChainID("testchain1") // chainID is obtained from ctx + ctx = ctx.WithChainID("testchain1") // consumerId is obtained from ctx ctx = ctx.WithBlockHeight(5) // RevisionHeight obtained from ctx testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) gomock.InOrder(testkeeper.GetMocksForMakeConsumerGenesis(ctx, &mocks, 1814400000000000)...) // matches params from jsonString - prop := providertypes.ConsumerAdditionProposal{ - Title: "title", - Description: "desc", - ChainId: "testchain1", + consumerMetadata := providertypes.ConsumerMetadata{ + Name: "name", + Description: "description", + } + + ccvTimeoutPeriod := time.Duration(2419200000000000) + transferTimeoutPeriod := time.Duration(3600000000000) + unbondingPeriod := time.Duration(1728000000000000) + initializationParameters := providertypes.ConsumerInitializationParameters{ BlocksPerDistributionTransmission: 1000, - CcvTimeoutPeriod: 2419200000000000, - TransferTimeoutPeriod: 3600000000000, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, ConsumerRedistributionFraction: "0.75", HistoricalEntries: 10000, - UnbondingPeriod: 1728000000000000, + UnbondingPeriod: unbondingPeriod, } - actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, &prop) + providerKeeper.SetConsumerChainId(ctx, "0", "testchain1") + providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) + providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) + + actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, "0") require.NoError(t, err) // JSON string with tabs, newlines and spaces for readability @@ -788,9 +644,6 @@ func TestMakeConsumerGenesis(t *testing.T) { } // TestBeginBlockInit directly tests BeginBlockInit against the spec using helpers defined above. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-bblock-init1 -// Spec tag:[CCV-PCF-BBLOCK-INIT.1] func TestBeginBlockInit(t *testing.T) { now := time.Now().UTC() @@ -800,130 +653,162 @@ func TestBeginBlockInit(t *testing.T) { defer ctrl.Finish() ctx = ctx.WithBlockTime(now) - pendingProps := []*providertypes.ConsumerAdditionProposal{ - providertypes.NewConsumerAdditionProposal( - "title", "spawn time passed", "chain1", clienttypes.NewHeight(3, 4), []byte{}, []byte{}, - now.Add(-time.Hour*2).UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 50, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - providertypes.NewConsumerAdditionProposal( - "title", "spawn time passed", "chain2", clienttypes.NewHeight(3, 4), []byte{}, []byte{}, - now.Add(-time.Hour*1).UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 50, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - providertypes.NewConsumerAdditionProposal( - "title", "spawn time not passed", "chain3", clienttypes.NewHeight(3, 4), []byte{}, []byte{}, - now.Add(time.Hour).UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 50, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - providertypes.NewConsumerAdditionProposal( - "title", "invalid proposal: chain id already exists", "chain2", clienttypes.NewHeight(4, 5), []byte{}, []byte{}, - now.UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 50, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - providertypes.NewConsumerAdditionProposal( - "title", "opt-in chain with at least one validator opted in", "chain5", clienttypes.NewHeight(3, 4), []byte{}, []byte{}, - now.Add(-time.Hour*1).UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), - providertypes.NewConsumerAdditionProposal( - "title", "opt-in chain with no validator opted in", "chain6", clienttypes.NewHeight(3, 4), []byte{}, []byte{}, - now.Add(-time.Minute).UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal), + // initialize registration, initialization, and update records + consumerMetadata := []providertypes.ConsumerMetadata{ + { + Name: "name", + Description: "spawn time passed", + }, + { + Name: "title", + Description: "spawn time passed", + }, + { + Name: "title", + Description: "spawn time not passed", + }, + { + Name: "title", + Description: "opt-in chain with at least one validator opted in", + }, + { + Name: "title", + Description: "opt-in chain with no validator opted in", + }, } + chainIds := []string{"chain0", "chain1", "chain2", "chain3", "chain4"} + + initializationParameters := []providertypes.ConsumerInitializationParameters{ + { + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{}, + BinaryHash: []byte{}, + SpawnTime: now.Add(-time.Hour * 2).UTC(), + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + { + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{}, + BinaryHash: []byte{}, + SpawnTime: now.Add(-time.Hour).UTC(), + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + { + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{}, + BinaryHash: []byte{}, + SpawnTime: now.Add(time.Hour).UTC(), + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + { + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{}, + BinaryHash: []byte{}, + SpawnTime: now.Add(-time.Hour).UTC(), + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + { + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{}, + BinaryHash: []byte{}, + SpawnTime: now.Add(-time.Minute).UTC(), + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + } + powerShapingParameters := []providertypes.PowerShapingParameters{ + { + Top_N: 50, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + }, + { + Top_N: 50, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + }, + { + Top_N: 50, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + }, + { + Top_N: 0, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + }, + { + Top_N: 0, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + }} // Expect client creation for only the first, second, and fifth proposals (spawn time already passed and valid) - expectedCalls := testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain1", clienttypes.NewHeight(3, 4)) - expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain2", clienttypes.NewHeight(3, 4))...) - expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain5", clienttypes.NewHeight(3, 4))...) + expectedCalls := testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain0", clienttypes.NewHeight(3, 4)) + expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain1", clienttypes.NewHeight(3, 4))...) + expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain3", clienttypes.NewHeight(3, 4))...) - // The sixth proposal would have spawn time passed and hence needs the mocks but the client will not be - // created because `chain6` is an Opt In chain and has no validator opted in - expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain6", clienttypes.NewHeight(3, 4))...) + // The fifth chain would have spawn time passed and hence needs the mocks but the client will not be + // created because `chain4` is an Opt In chain and has no validator opted in + expectedCalls = append(expectedCalls, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, "chain4", clienttypes.NewHeight(3, 4))...) gomock.InOrder(expectedCalls...) - for _, prop := range pendingProps { - providerKeeper.SetPendingConsumerAdditionProp(ctx, prop) + // set up all the records + for i, chainId := range chainIds { + providerKeeper.SetConsumerChainId(ctx, fmt.Sprintf("%d", i), chainId) + } + + for i, r := range consumerMetadata { + providerKeeper.SetConsumerMetadata(ctx, fmt.Sprintf("%d", i), r) + } + for i, r := range initializationParameters { + providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) + // set up the chains in their initialized phase, hence they could launch + providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providerkeeper.Initialized) + providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) + } + for i, r := range powerShapingParameters { + providerKeeper.SetConsumerPowerShapingParameters(ctx, fmt.Sprintf("%d", i), r) } // opt in a sample validator so the chain's proposal can successfully execute @@ -933,87 +818,51 @@ func TestBeginBlockInit(t *testing.T) { valAddr, _ := sdk.ValAddressFromBech32(validator.GetOperator()) mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr).Return(int64(1), nil).AnyTimes() - // for the validator, expect a call to GetValidatorByConsAddr with its consensus address mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr).Return(validator, nil).AnyTimes() - providerKeeper.SetOptedIn(ctx, pendingProps[4].ChainId, providertypes.NewProviderConsAddress(consAddr)) + providerKeeper.SetOptedIn(ctx, "3", providertypes.NewProviderConsAddress(consAddr)) providerKeeper.BeginBlockInit(ctx) - // first proposal is not pending anymore because its spawn time already passed and was executed - _, found := providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[0].SpawnTime, pendingProps[0].ChainId) - require.False(t, found) - // first proposal was successfully executed and hence consumer genesis was created - _, found = providerKeeper.GetConsumerGenesis(ctx, pendingProps[0].ChainId) + // first chain was successfully launched + phase, found := providerKeeper.GetConsumerPhase(ctx, "0") require.True(t, found) - - // second proposal is not pending anymore because its spawn time already passed and was executed - _, found = providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[1].SpawnTime, pendingProps[1].ChainId) - require.False(t, found) - // second proposal was successfully executed and hence consumer genesis was created - _, found = providerKeeper.GetConsumerGenesis(ctx, pendingProps[1].ChainId) + require.Equal(t, providerkeeper.Launched, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "0") require.True(t, found) - // third proposal is still stored as pending because its spawn time has not passed - _, found = providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[2].SpawnTime, pendingProps[2].ChainId) + // second chain was successfully launched + phase, found = providerKeeper.GetConsumerPhase(ctx, "1") + require.True(t, found) + require.Equal(t, providerkeeper.Launched, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "1") require.True(t, found) - // because the proposal is still pending, no consumer genesis was created - _, found = providerKeeper.GetConsumerGenesis(ctx, pendingProps[2].ChainId) - require.False(t, found) - // check that the invalid proposals were dropped - _, found = providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[3].SpawnTime, pendingProps[3].ChainId) + // third chain was not launched because its spawn time has not passed + phase, found = providerKeeper.GetConsumerPhase(ctx, "2") + require.True(t, found) + require.Equal(t, providerkeeper.Initialized, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "2") require.False(t, found) - // Note that we do not check that `GetConsumerGenesis(ctx, pendingProps[3].ChainId)` returns `false` here because - // `pendingProps[3]` is an invalid proposal due to the chain id already existing so the consumer genesis also exists - // fifth proposal corresponds to an Opt-In chain with one opted-in validator and hence the proposal gets + // fourth chain corresponds to an Opt-In chain with one opted-in validator and hence the chain gets // successfully executed - _, found = providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[4].SpawnTime, pendingProps[4].ChainId) - require.False(t, found) - // fifth proposal was successfully executed and hence consumer genesis was created - _, found = providerKeeper.GetConsumerGenesis(ctx, pendingProps[4].ChainId) + phase, found = providerKeeper.GetConsumerPhase(ctx, "3") require.True(t, found) - - // sixth proposal corresponds to an Opt-In chain with no opted-in validators and hence the - // proposal is not successful - _, found = providerKeeper.GetPendingConsumerAdditionProp( - ctx, pendingProps[5].SpawnTime, pendingProps[5].ChainId) - // the proposal was dropped and deleted - require.False(t, found) - // no consumer genesis is created - _, found = providerKeeper.GetConsumerGenesis(ctx, pendingProps[5].ChainId) - require.False(t, found) - // no consumer client is associated with this chain - _, found = providerKeeper.GetConsumerClientId(ctx, pendingProps[5].ChainId) - require.False(t, found) - // no fields should be set for this (check some of them) - _, found = providerKeeper.GetTopN(ctx, pendingProps[5].ChainId) - require.False(t, found) - _, found = providerKeeper.GetValidatorsPowerCap(ctx, pendingProps[5].ChainId) - require.False(t, found) - _, found = providerKeeper.GetValidatorSetCap(ctx, pendingProps[5].ChainId) - require.False(t, found) - - // test that Top N is set correctly - require.True(t, providerKeeper.IsTopN(ctx, "chain1")) - topN, found := providerKeeper.GetTopN(ctx, "chain1") + require.Equal(t, providerkeeper.Launched, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "3") require.True(t, found) - require.Equal(t, uint32(50), topN) - require.True(t, providerKeeper.IsOptIn(ctx, "chain4")) + // fifth chain corresponds to an Opt-In chain with no opted-in validators and hence the + // chain launch is NOT successful + phase, found = providerKeeper.GetConsumerPhase(ctx, "4") + require.True(t, found) + require.Equal(t, providerkeeper.Initialized, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "4") + require.False(t, found) } -// TestBeginBlockCCR tests BeginBlockCCR against the spec. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-bblock-ccr1 -// Spec tag: [CCV-PCF-BBLOCK-CCR.1] func TestBeginBlockCCR(t *testing.T) { now := time.Now().UTC() @@ -1023,28 +872,26 @@ func TestBeginBlockCCR(t *testing.T) { defer ctrl.Finish() ctx = ctx.WithBlockTime(now) - pendingProps := []*providertypes.ConsumerRemovalProposal{ - providertypes.NewConsumerRemovalProposal( - "title", "description", "chain1", now.Add(-time.Hour).UTC(), - ).(*providertypes.ConsumerRemovalProposal), - providertypes.NewConsumerRemovalProposal( - "title", "description", "chain2", now, - ).(*providertypes.ConsumerRemovalProposal), - providertypes.NewConsumerRemovalProposal( - "title", "description", "chain3", now.Add(time.Hour).UTC(), - ).(*providertypes.ConsumerRemovalProposal), - } + chainIds := []string{"chain1", "chain2", "chain3"} + consumerIds := []string{"consumerId1", "consumerId2", "consumerId3"} + providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) + providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[1], now) + providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) + providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) // // Mock expectations // expectations := []*gomock.Call{} - for _, prop := range pendingProps { - // A consumer chain is setup corresponding to each prop, making these mocks necessary + for i, _ := range consumerIds { + chainId := chainIds[i] + // A consumer chain is setup corresponding to each consumerId, making these mocks necessary testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) expectations = append(expectations, testkeeper.GetMocksForCreateConsumerClient(ctx, &mocks, - prop.ChainId, clienttypes.NewHeight(2, 3))...) - expectations = append(expectations, testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, prop.ChainId)...) + chainId, clienttypes.NewHeight(2, 3))...) + expectations = append(expectations, testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, chainId)...) } // Only first two consumer chains should be stopped expectations = append(expectations, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) @@ -1055,27 +902,28 @@ func TestBeginBlockCCR(t *testing.T) { // // Remaining setup // - for _, prop := range pendingProps { - // Setup a valid consumer chain for each prop - additionProp := testkeeper.GetTestConsumerAdditionProp() - additionProp.ChainId = prop.ChainId - additionProp.InitialHeight = clienttypes.NewHeight(2, 3) - - err := providerKeeper.CreateConsumerClient(ctx, additionProp) + for i, consumerId := range consumerIds { + // Setup a valid consumer chain for each consumerId + initializationRecord := testkeeper.GetTestInitializationParameters() + initializationRecord.InitialHeight = clienttypes.NewHeight(2, 3) + registrationRecord := testkeeper.GetTestConsumerMetadata() + + providerKeeper.SetConsumerChainId(ctx, consumerId, chainIds[i]) + providerKeeper.SetConsumerMetadata(ctx, consumerId, registrationRecord) + providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, initializationRecord) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, testkeeper.GetTestPowerShapingParameters()) + providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + providerKeeper.SetClientIdToConsumerId(ctx, "clientID", consumerId) + + err := providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) - // Set removal props for all consumer chains - providerKeeper.SetPendingConsumerRemovalProp(ctx, prop) + // after we have created the consumer client, the chain is considered launched and hence we could later stop the chain + providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) } - // Add an invalid prop to the store with an non-existing chain id - invalidProp := providertypes.NewConsumerRemovalProposal( - "title", "description", "chain4", now.Add(-time.Hour).UTC(), - ).(*providertypes.ConsumerRemovalProposal) - providerKeeper.SetPendingConsumerRemovalProp(ctx, invalidProp) - // // Test execution // @@ -1083,16 +931,14 @@ func TestBeginBlockCCR(t *testing.T) { providerKeeper.BeginBlockCCR(ctx) // Only the 3rd (final) proposal is still stored as pending - found := providerKeeper.PendingConsumerRemovalPropExists( - ctx, pendingProps[0].ChainId, pendingProps[0].StopTime) - require.False(t, found) - found = providerKeeper.PendingConsumerRemovalPropExists( - ctx, pendingProps[1].ChainId, pendingProps[1].StopTime) - require.False(t, found) - found = providerKeeper.PendingConsumerRemovalPropExists( - ctx, pendingProps[2].ChainId, pendingProps[2].StopTime) + phase, found := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) require.True(t, found) - found = providerKeeper.PendingConsumerRemovalPropExists( - ctx, invalidProp.ChainId, invalidProp.StopTime) - require.False(t, found) + require.Equal(t, providerkeeper.Stopped, phase) + phase, found = providerKeeper.GetConsumerPhase(ctx, consumerIds[1]) + require.True(t, found) + require.Equal(t, providerkeeper.Stopped, phase) + // third chain had a stopTime in the future and hence did not stop + phase, found = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) + require.True(t, found) + require.Equal(t, providerkeeper.Launched, phase) } diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index c95bd71079..b0e8bb4e83 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -30,9 +30,9 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac "channelID", packet.SourceChannel, "error", err, ) - if chainID, ok := k.GetChannelToChain(ctx, packet.SourceChannel); ok { + if consumerId, ok := k.GetChannelIdToConsumerId(ctx, packet.SourceChannel); ok { // stop consumer chain and release unbonding - return k.StopConsumerChain(ctx, chainID, false) + return k.StopConsumerChain(ctx, consumerId, false) } return errorsmod.Wrapf(providertypes.ErrUnknownConsumerChannelId, "recv ErrorAcknowledgement on unknown channel %s", packet.SourceChannel) } @@ -42,7 +42,7 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac // OnTimeoutPacket aborts the transaction if no chain exists for the destination channel, // otherwise it stops the chain func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error { - chainID, found := k.GetChannelToChain(ctx, packet.SourceChannel) + consumerId, found := k.GetChannelIdToConsumerId(ctx, packet.SourceChannel) if !found { k.Logger(ctx).Error("packet timeout, unknown channel:", "channelID", packet.SourceChannel) // abort transaction @@ -51,9 +51,9 @@ func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) err packet.SourceChannel, ) } - k.Logger(ctx).Info("packet timeout, removing the consumer:", "chainID", chainID) + k.Logger(ctx).Info("packet timeout, removing the consumer:", "consumerId", consumerId) // stop consumer chain and release unbondings - return k.StopConsumerChain(ctx, chainID, false) + return k.StopConsumerChain(ctx, consumerId, false) } // EndBlockVSU contains the EndBlock logic needed for @@ -136,24 +136,24 @@ func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64 { // If the CCV channel is not established for a consumer chain, // the updates will remain queued until the channel is established func (k Keeper) SendVSCPackets(ctx sdk.Context) { - for _, chainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { + for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { // check if CCV channel is established and send - if channelID, found := k.GetChainToChannel(ctx, chainID); found { - k.SendVSCPacketsToChain(ctx, chainID, channelID) + if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { + k.SendVSCPacketsToChain(ctx, consumerId, channelID) } } } // SendVSCPacketsToChain sends all queued VSC packets to the specified chain -func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string) { - pendingPackets := k.GetPendingVSCPackets(ctx, chainID) +func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId string) { + pendingPackets := k.GetPendingVSCPackets(ctx, consumerId) for _, data := range pendingPackets { // send packet over IBC err := ccv.SendIBCPacket( ctx, k.scopedKeeper, k.channelKeeper, - channelID, // source channel id + channelId, // source channel id ccv.ProviderPortID, // source port id data.GetBytes(), k.GetCCVTimeoutPeriod(ctx), @@ -163,20 +163,20 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, chainID, channelID string // IBC client is expired! // leave the packet data stored to be sent once the client is upgraded // the client cannot expire during iteration (in the middle of a block) - k.Logger(ctx).Info("IBC client is expired, cannot send VSC, leaving packet data stored:", "chainID", chainID, "vscid", data.ValsetUpdateId) + k.Logger(ctx).Info("IBC client is expired, cannot send VSC, leaving packet data stored:", "consumerId", consumerId, "vscid", data.ValsetUpdateId) return } // Not able to send packet over IBC! - k.Logger(ctx).Error("cannot send VSC, removing consumer:", "chainID", chainID, "vscid", data.ValsetUpdateId, "err", err.Error()) + k.Logger(ctx).Error("cannot send VSC, removing consumer:", "consumerId", consumerId, "vscid", data.ValsetUpdateId, "err", err.Error()) // If this happens, most likely the consumer is malicious; remove it - err := k.StopConsumerChain(ctx, chainID, true) + err := k.StopConsumerChain(ctx, consumerId, true) if err != nil { panic(fmt.Errorf("consumer chain failed to stop: %w", err)) } return } } - k.DeletePendingVSCPackets(ctx, chainID) + k.DeletePendingVSCPackets(ctx, consumerId) } // QueueVSCPackets queues latest validator updates for every registered consumer chain @@ -192,12 +192,12 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { panic(fmt.Errorf("failed to get last validators: %w", err)) } - for _, chainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { - currentValidators, err := k.GetConsumerValSet(ctx, chainID) + for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + currentValidators, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { panic(fmt.Errorf("failed to get consumer validators: %w", err)) } - topN, _ := k.GetTopN(ctx, chainID) + topN := k.GetTopN(ctx, consumerId) if topN > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N @@ -211,27 +211,27 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, topN) if err != nil { // we panic, since the only way to proceed would be to opt in all validators, which is not the intended behavior - panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", chainID, err)) + panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", consumerId, err)) } // set the minimal power of validators in the top N in the store - k.SetMinimumPowerInTopN(ctx, chainID, minPower) + k.SetMinimumPowerInTopN(ctx, consumerId, minPower) - k.OptInTopNValidators(ctx, chainID, activeValidators, minPower) + k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) } - nextValidators := k.ComputeNextValidators(ctx, chainID, bondedValidators) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators) valUpdates := DiffValidators(currentValidators, nextValidators) - k.SetConsumerValSet(ctx, chainID, nextValidators) + k.SetConsumerValSet(ctx, consumerId, nextValidators) // check whether there are changes in the validator set if len(valUpdates) != 0 { // construct validator set change packet data - packet := ccv.NewValidatorSetChangePacketData(valUpdates, valUpdateID, k.ConsumeSlashAcks(ctx, chainID)) - k.AppendPendingVSCPackets(ctx, chainID, packet) + packet := ccv.NewValidatorSetChangePacketData(valUpdates, valUpdateID, k.ConsumeSlashAcks(ctx, consumerId)) + k.AppendPendingVSCPackets(ctx, consumerId, packet) k.Logger(ctx).Info("VSCPacket enqueued:", - "chainID", chainID, + "consumerId", consumerId, "vscID", valUpdateID, "len updates", len(valUpdates), ) @@ -266,8 +266,8 @@ func (k Keeper) EndBlockCIS(ctx sdk.Context) { k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) // prune previous consumer validator addresses that are no longer needed - for _, chainID := range k.GetAllRegisteredConsumerChainIDs(ctx) { - k.PruneKeyAssignments(ctx, chainID) + for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + k.PruneKeyAssignments(ctx, consumerId) } } @@ -279,7 +279,7 @@ func (k Keeper) OnRecvSlashPacket( data ccv.SlashPacketData, ) (ccv.PacketAckResult, error) { // check that the channel is established, panic if not - chainID, found := k.GetChannelToChain(ctx, packet.DestinationChannel) + consumerId, found := k.GetChannelIdToConsumerId(ctx, packet.DestinationChannel) if !found { // SlashPacket packet was sent on a channel different than any of the established CCV channels; // this should never happen @@ -294,10 +294,10 @@ func (k Keeper) OnRecvSlashPacket( return nil, errorsmod.Wrapf(err, "error validating SlashPacket data") } - if err := k.ValidateSlashPacket(ctx, chainID, packet, data); err != nil { + if err := k.ValidateSlashPacket(ctx, consumerId, packet, data); err != nil { k.Logger(ctx).Error("invalid slash packet", "error", err.Error(), - "chainID", chainID, + "consumerId", consumerId, "consumer cons addr", sdk.ConsAddress(data.Validator.Address).String(), "vscID", data.ValsetUpdateId, "infractionType", data.Infraction, @@ -308,15 +308,15 @@ func (k Keeper) OnRecvSlashPacket( // The slash packet validator address may be known only on the consumer chain, // in this case, it must be mapped back to the consensus address on the provider chain consumerConsAddr := providertypes.NewConsumerConsAddress(data.Validator.Address) - providerConsAddr := k.GetProviderAddrFromConsumerAddr(ctx, chainID, consumerConsAddr) + providerConsAddr := k.GetProviderAddrFromConsumerAddr(ctx, consumerId, consumerConsAddr) if data.Infraction == stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN { // getMappedInfractionHeight is already checked in ValidateSlashPacket - infractionHeight, _ := k.getMappedInfractionHeight(ctx, chainID, data.ValsetUpdateId) + infractionHeight, _ := k.getMappedInfractionHeight(ctx, consumerId, data.ValsetUpdateId) k.SetSlashLog(ctx, providerConsAddr) k.Logger(ctx).Info("SlashPacket received for double-signing", - "chainID", chainID, + "consumerId", consumerId, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), "vscID", data.ValsetUpdateId, @@ -329,11 +329,11 @@ func (k Keeper) OnRecvSlashPacket( } // Check that the validator belongs to the consumer chain valset - if !k.IsConsumerValidator(ctx, chainID, providerConsAddr) { + if !k.IsConsumerValidator(ctx, consumerId, providerConsAddr) { k.Logger(ctx).Error("cannot jail validator %s that does not belong to consumer %s valset", - providerConsAddr.String(), chainID) + providerConsAddr.String(), consumerId) // drop packet but return a slash ack so that the consumer can send another slash packet - k.AppendSlashAck(ctx, chainID, consumerConsAddr.String()) + k.AppendSlashAck(ctx, consumerId, consumerConsAddr.String()) return ccv.SlashPacketHandledResult, nil } @@ -342,7 +342,7 @@ func (k Keeper) OnRecvSlashPacket( // 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, + "consumerId", consumerId, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), "vscID", data.ValsetUpdateId, @@ -356,10 +356,10 @@ func (k Keeper) OnRecvSlashPacket( meter = meter.Sub(k.GetEffectiveValPower(ctx, providerConsAddr)) k.SetSlashMeter(ctx, meter) - k.HandleSlashPacket(ctx, chainID, data) + k.HandleSlashPacket(ctx, consumerId, data) k.Logger(ctx).Info("slash packet received and handled", - "chainID", chainID, + "consumerId", consumerId, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), "vscID", data.ValsetUpdateId, @@ -373,14 +373,14 @@ func (k Keeper) OnRecvSlashPacket( // ValidateSlashPacket validates a recv slash packet before it is // handled or persisted in store. An error is returned if the packet is invalid, // and an error ack should be relayed to the sender. -func (k Keeper) ValidateSlashPacket(ctx sdk.Context, chainID string, +func (k Keeper) ValidateSlashPacket(ctx sdk.Context, consumerId string, packet channeltypes.Packet, data ccv.SlashPacketData, ) error { - _, found := k.getMappedInfractionHeight(ctx, chainID, data.ValsetUpdateId) + _, found := k.getMappedInfractionHeight(ctx, consumerId, data.ValsetUpdateId) // return error if we cannot find infraction height matching the validator update id if !found { return fmt.Errorf("cannot find infraction height matching "+ - "the validator update id %d for chain %s", data.ValsetUpdateId, chainID) + "the validator update id %d for chain %s", data.ValsetUpdateId, consumerId) } return nil @@ -388,13 +388,13 @@ func (k Keeper) ValidateSlashPacket(ctx sdk.Context, chainID string, // HandleSlashPacket potentially jails a misbehaving validator for a downtime infraction. // This method should NEVER be called with a double-sign infraction. -func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.SlashPacketData) { +func (k Keeper) HandleSlashPacket(ctx sdk.Context, consumerId string, data ccv.SlashPacketData) { consumerConsAddr := providertypes.NewConsumerConsAddress(data.Validator.Address) // Obtain provider chain consensus address using the consumer chain consensus address - providerConsAddr := k.GetProviderAddrFromConsumerAddr(ctx, chainID, consumerConsAddr) + providerConsAddr := k.GetProviderAddrFromConsumerAddr(ctx, consumerId, consumerConsAddr) k.Logger(ctx).Debug("HandleSlashPacket", - "chainID", chainID, + "consumerId", consumerId, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), "vscID", data.ValsetUpdateId, @@ -429,7 +429,7 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas return } - infractionHeight, found := k.getMappedInfractionHeight(ctx, chainID, data.ValsetUpdateId) + infractionHeight, found := k.getMappedInfractionHeight(ctx, consumerId, data.ValsetUpdateId) if !found { k.Logger(ctx).Error( "HandleSlashPacket - infraction height not found. But was found during slash packet validation", @@ -442,9 +442,9 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas // Note: the SlashPacket is for downtime infraction, as SlashPackets // for double-signing infractions are already dropped when received - // append the validator address to the slash ack for its chain id + // append the validator address to the slash ack for its consumer id // TODO: consumer cons address should be accepted here - k.AppendSlashAck(ctx, chainID, consumerConsAddr.String()) + k.AppendSlashAck(ctx, consumerId, consumerConsAddr.String()) // jail validator if !validator.IsJailed() { @@ -479,12 +479,12 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas ) } -// getMappedInfractionHeight gets the infraction height mapped from val set ID for the given chain ID +// getMappedInfractionHeight gets the infraction height mapped from val set ID for the given consumer id func (k Keeper) getMappedInfractionHeight(ctx sdk.Context, - chainID string, valsetUpdateID uint64, + consumerId string, valsetUpdateID uint64, ) (height uint64, found bool) { if valsetUpdateID == 0 { - return k.GetInitChainHeight(ctx, chainID) + return k.GetInitChainHeight(ctx, consumerId) } else { return k.GetValsetUpdateBlockHeight(ctx, valsetUpdateID) } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 91de369851..db8c991d7f 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -104,31 +104,31 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{valA, valB}, -1) // set a consumer client, so we have a consumer chain (i.e., `k.GetAllConsumerChains(ctx)` is non empty) - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") // opt in validator A and set as a consumer validator - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valAConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) consumerValidatorA := providertypes.ConsensusValidator{ ProviderConsAddr: valAConsAddr, Power: 1, PublicKey: &valAPubKey, JoinHeight: 123456789, } - providerKeeper.SetConsumerValidator(ctx, "chainID", consumerValidatorA) + providerKeeper.SetConsumerValidator(ctx, "consumerId", consumerValidatorA) // Opt in validator B. Note that validator B is not a consumer validator and hence would become a consumer // validator for the first time after the `QueueVSCPackets` call. - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valBConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valBConsAddr)) providerKeeper.QueueVSCPackets(ctx) // the height of consumer validator A should not be modified because A was already a consumer validator - cv, _ := providerKeeper.GetConsumerValidator(ctx, "chainID", providertypes.NewProviderConsAddress(valAConsAddr)) + cv, _ := providerKeeper.GetConsumerValidator(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) require.Equal(t, consumerValidatorA.JoinHeight, cv.JoinHeight, "the consumer validator's height was erroneously modified") // the height of consumer validator B is set to be the same as the one of the current chain height because this // consumer validator becomes a consumer validator for the first time (i.e., was not a consumer validator in the previous epoch) - cv, _ = providerKeeper.GetConsumerValidator(ctx, "chainID", providertypes.NewProviderConsAddress(valBConsAddr)) + cv, _ = providerKeeper.GetConsumerValidator(ctx, "consumerId", providertypes.NewProviderConsAddress(valBConsAddr)) require.Equal(t, chainHeight, cv.JoinHeight, "the consumer validator's height was not correctly set") } @@ -139,8 +139,8 @@ func TestOnRecvDowntimeSlashPacket(t *testing.T) { 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") + providerKeeper.SetChannelToConsumerId(ctx, "channel-1", "chain-1") + providerKeeper.SetChannelToConsumerId(ctx, "channel-2", "chain-2") // Generate a new slash packet data instance with double sign infraction type packetData := testkeeper.GetNewSlashPacketData() @@ -212,8 +212,8 @@ func TestOnRecvDoubleSignSlashPacket(t *testing.T) { 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") + providerKeeper.SetChannelToConsumerId(ctx, "channel-1", "chain-1") + providerKeeper.SetChannelToConsumerId(ctx, "channel-2", "chain-2") // Generate a new slash packet data instance with double sign infraction type packetData := testkeeper.GetNewSlashPacketData() @@ -294,7 +294,7 @@ func TestValidateSlashPacket(t *testing.T) { packet := channeltypes.Packet{DestinationChannel: "channel-9"} // Pseudo setup ccv channel for channel ID specified in packet. - providerKeeper.SetChannelToChain(ctx, "channel-9", "consumer-chain-id") + providerKeeper.SetChannelToConsumerId(ctx, "channel-9", "consumer-chain-id") // Setup init chain height for consumer (allowing 0 vscID to be valid). providerKeeper.SetInitChainHeight(ctx, "consumer-chain-id", uint64(89)) @@ -497,6 +497,7 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { gomock.InOrder(mockCalls...) // Execute setup + providerKeeper.SetClientIdToConsumerId(ctx, "clientID", "consumerChainID") err := providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientID") @@ -514,7 +515,7 @@ func TestOnTimeoutPacketWithNoChainFound(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - // We do not `SetChannelToChain` for "channelID" and therefore `OnTimeoutPacket` fails + // We do not `SetChannelToConsumerId` for "channelID" and therefore `OnTimeoutPacket` fails packet := channeltypes.Packet{ SourceChannel: "channelID", } @@ -530,14 +531,14 @@ func TestOnTimeoutPacketStopsChain(t *testing.T) { defer ctrl.Finish() providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") packet := channeltypes.Packet{ SourceChannel: "channelID", } err := providerKeeper.OnTimeoutPacket(ctx, packet) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") require.NoError(t, err) } @@ -566,14 +567,14 @@ func TestOnAcknowledgementPacketWithAckError(t *testing.T) { require.True(t, strings.Contains(err.Error(), providertypes.ErrUnknownConsumerChannelId.Error())) // test that we stop the consumer chain when `OnAcknowledgementPacket` returns an error and the chain is found - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") packet := channeltypes.Packet{ SourceChannel: "channelID", } err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") require.NoError(t, err) } @@ -582,9 +583,11 @@ func TestEndBlockVSU(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" - providerKeeper.SetTopN(ctx, chainID, 100) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ + Top_N: 100, + }) // 10 blocks constitute an epoch params := providertypes.DefaultParams() @@ -735,21 +738,21 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 5, []stakingtypes.Validator{valA, valB, valC, valD, valE}, -1) // add a consumer chain - providerKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") - providerKeeper.SetTopN(ctx, "chainID", 50) // would opt in E + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ + Top_N: 50, // would opt in E + ValidatorsPowerCap: 40, // set a power-capping of 40% + }) // opt in all validators - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valAConsAddr)) - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valBConsAddr)) - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valCConsAddr)) - providerKeeper.SetOptedIn(ctx, "chainID", providertypes.NewProviderConsAddress(valDConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valBConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valCConsAddr)) + providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valDConsAddr)) // denylist validator D - providerKeeper.SetDenylist(ctx, "chainID", providertypes.NewProviderConsAddress(valDConsAddr)) - - // set a power-capping of 40% - providerKeeper.SetValidatorsPowerCap(ctx, "chainID", 40) + providerKeeper.SetDenylist(ctx, "consumerId", providertypes.NewProviderConsAddress(valDConsAddr)) // set max provider consensus vals to include all validators params := providerKeeper.GetParams(ctx) @@ -758,7 +761,7 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { providerKeeper.QueueVSCPackets(ctx) - actualQueuedVSCPackets := providerKeeper.GetPendingVSCPackets(ctx, "chainID") + actualQueuedVSCPackets := providerKeeper.GetPendingVSCPackets(ctx, "consumerId") expectedQueuedVSCPackets := []ccv.ValidatorSetChangePacketData{ ccv.NewValidatorSetChangePacketData( []abci.ValidatorUpdate{ diff --git a/x/ccv/provider/keeper/validator_set_update.go b/x/ccv/provider/keeper/validator_set_update.go index 1c55f26553..a0afc94ef9 100644 --- a/x/ccv/provider/keeper/validator_set_update.go +++ b/x/ccv/provider/keeper/validator_set_update.go @@ -12,53 +12,53 @@ import ( ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// GetConsumerChainConsensusValidatorsKey returns the store key for consumer validators of the consumer chain with `chainID` -func (k Keeper) GetConsumerChainConsensusValidatorsKey(ctx sdk.Context, chainID string) []byte { - return types.ChainIdWithLenKey(types.ConsumerValidatorKeyPrefix(), chainID) +// GetConsumerChainConsensusValidatorsKey returns the store key for consumer validators of the consumer chain with `consumerId` +func (k Keeper) GetConsumerChainConsensusValidatorsKey(ctx sdk.Context, consumerId string) []byte { + return types.ConsumerIdWithLenKey(types.ConsumerValidatorKeyPrefix(), consumerId) } -// SetConsumerValidator sets provided consumer `validator` on the consumer chain with `chainID` +// SetConsumerValidator sets provided consumer `validator` on the consumer chain with `consumerId` func (k Keeper) SetConsumerValidator( ctx sdk.Context, - chainID string, + consumerId string, validator types.ConsensusValidator, ) { - k.setValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), validator) + k.setValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId), validator) } // SetConsumerValSet resets the current consumer validators with the `nextValidators` computed by // `FilterValidators` and hence this method should only be called after `FilterValidators` has completed. -func (k Keeper) SetConsumerValSet(ctx sdk.Context, chainID string, nextValidators []types.ConsensusValidator) { - k.setValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), nextValidators) +func (k Keeper) SetConsumerValSet(ctx sdk.Context, consumerId string, nextValidators []types.ConsensusValidator) { + k.setValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId), nextValidators) } // DeleteConsumerValidator removes consumer validator with `providerAddr` address func (k Keeper) DeleteConsumerValidator( ctx sdk.Context, - chainID string, + consumerId string, providerConsAddr types.ProviderConsAddress, ) { - k.deleteValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), providerConsAddr) + k.deleteValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId), providerConsAddr) } -// DeleteConsumerValSet deletes all the stored consumer validators for chain `chainID` +// DeleteConsumerValSet deletes all the stored consumer validators for chain with `consumerId` func (k Keeper) DeleteConsumerValSet( ctx sdk.Context, - chainID string, + consumerId string, ) { - k.deleteValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID)) + k.deleteValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId)) } -// IsConsumerValidator returns `true` if the consumer validator with `providerAddr` exists for chain `chainID` +// IsConsumerValidator returns `true` if the consumer validator with `providerAddr` exists for chain with `consumerId` // and `false` otherwise -func (k Keeper) IsConsumerValidator(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) bool { - return k.isValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID), providerAddr) +func (k Keeper) IsConsumerValidator(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { + return k.isValidator(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId), providerAddr) } -// GetConsumerValidator returns the consumer validator with `providerAddr` if it exists for chain `chainID` -func (k Keeper) GetConsumerValidator(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress) (types.ConsensusValidator, bool) { +// GetConsumerValidator returns the consumer validator with `providerAddr` if it exists for chain with `consumerId` +func (k Keeper) GetConsumerValidator(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) (types.ConsensusValidator, bool) { store := ctx.KVStore(k.storeKey) - marshalledConsumerValidator := store.Get(types.ConsumerValidatorKey(chainID, providerAddr.ToSdkConsAddr())) + marshalledConsumerValidator := store.Get(types.ConsumerValidatorKey(consumerId, providerAddr.ToSdkConsAddr())) if marshalledConsumerValidator == nil { return types.ConsensusValidator{}, false @@ -72,12 +72,12 @@ func (k Keeper) GetConsumerValidator(ctx sdk.Context, chainID string, providerAd return validator, true } -// GetConsumerValSet returns all the consumer validators for chain `chainID` +// GetConsumerValSet returns all the consumer validators for chain with `consumerId` func (k Keeper) GetConsumerValSet( ctx sdk.Context, - chainID string, + consumerId string, ) ([]types.ConsensusValidator, error) { - return k.getValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, chainID)) + return k.getValSet(ctx, k.GetConsumerChainConsensusValidatorsKey(ctx, consumerId)) } // DiffValidators compares the current and the next epoch's consumer validators and returns the `ValidatorUpdate` diff @@ -121,8 +121,8 @@ func DiffValidators( return updates } -// CreateConsumerValidator creates a consumer validator for `chainID` from the given staking `validator` -func (k Keeper) CreateConsumerValidator(ctx sdk.Context, chainID string, validator stakingtypes.Validator) (types.ConsensusValidator, error) { +// CreateConsumerValidator creates a consumer validator for `consumerId` from the given staking `validator` +func (k Keeper) CreateConsumerValidator(ctx sdk.Context, consumerId string, validator stakingtypes.Validator) (types.ConsensusValidator, error) { valAddr, err := sdk.ValAddressFromBech32(validator.GetOperator()) if err != nil { return types.ConsensusValidator{}, err @@ -138,7 +138,7 @@ func (k Keeper) CreateConsumerValidator(ctx sdk.Context, chainID string, validat validator, err) } - consumerPublicKey, found := k.GetValidatorConsumerPubKey(ctx, chainID, types.NewProviderConsAddress(consAddr)) + consumerPublicKey, found := k.GetValidatorConsumerPubKey(ctx, consumerId, types.NewProviderConsAddress(consAddr)) if !found { consumerPublicKey, err = validator.TmConsPublicKey() if err != nil { @@ -147,7 +147,7 @@ func (k Keeper) CreateConsumerValidator(ctx sdk.Context, chainID string, validat } height := ctx.BlockHeight() - if v, found := k.GetConsumerValidator(ctx, chainID, types.ProviderConsAddress{Address: consAddr}); found { + if v, found := k.GetConsumerValidator(ctx, consumerId, types.ProviderConsAddress{Address: consAddr}); found { // if validator was already a consumer validator, then do not update the height set the first time // the validator became a consumer validator height = v.JoinHeight @@ -165,7 +165,7 @@ func (k Keeper) CreateConsumerValidator(ctx sdk.Context, chainID string, validat // the filtered set. func (k Keeper) FilterValidators( ctx sdk.Context, - chainID string, + consumerId string, bondedValidators []stakingtypes.Validator, predicate func(providerAddr types.ProviderConsAddress) bool, ) []types.ConsensusValidator { @@ -177,7 +177,7 @@ func (k Keeper) FilterValidators( } if predicate(types.NewProviderConsAddress(consAddr)) { - nextValidator, err := k.CreateConsumerValidator(ctx, chainID, val) + nextValidator, err := k.CreateConsumerValidator(ctx, consumerId, val) if err != nil { // this should never happen but is recoverable if we exclude this validator from the next validator set k.Logger(ctx).Error("could not create consumer validator", diff --git a/x/ccv/provider/keeper/validator_set_update_test.go b/x/ccv/provider/keeper/validator_set_update_test.go index e343093dad..58ef556aec 100644 --- a/x/ccv/provider/keeper/validator_set_update_test.go +++ b/x/ccv/provider/keeper/validator_set_update_test.go @@ -32,11 +32,11 @@ func TestConsumerValidator(t *testing.T) { PublicKey: &crypto.PublicKey{}, } - require.False(t, providerKeeper.IsConsumerValidator(ctx, "chainID", types.NewProviderConsAddress(validator.ProviderConsAddr))) - providerKeeper.SetConsumerValidator(ctx, "chainID", validator) - require.True(t, providerKeeper.IsConsumerValidator(ctx, "chainID", types.NewProviderConsAddress(validator.ProviderConsAddr))) - providerKeeper.DeleteConsumerValidator(ctx, "chainID", types.NewProviderConsAddress(validator.ProviderConsAddr)) - require.False(t, providerKeeper.IsConsumerValidator(ctx, "chainID", types.NewProviderConsAddress(validator.ProviderConsAddr))) + require.False(t, providerKeeper.IsConsumerValidator(ctx, "consumerId", types.NewProviderConsAddress(validator.ProviderConsAddr))) + providerKeeper.SetConsumerValidator(ctx, "consumerId", validator) + require.True(t, providerKeeper.IsConsumerValidator(ctx, "consumerId", types.NewProviderConsAddress(validator.ProviderConsAddr))) + providerKeeper.DeleteConsumerValidator(ctx, "consumerId", types.NewProviderConsAddress(validator.ProviderConsAddr)) + require.False(t, providerKeeper.IsConsumerValidator(ctx, "consumerId", types.NewProviderConsAddress(validator.ProviderConsAddr))) } func TestGetConsumerValSet(t *testing.T) { @@ -75,7 +75,7 @@ func TestGetConsumerValSet(t *testing.T) { } for _, expectedValidator := range expectedValidators { - providerKeeper.SetConsumerValidator(ctx, "chainID", + providerKeeper.SetConsumerValidator(ctx, "consumerId", types.ConsensusValidator{ ProviderConsAddr: expectedValidator.ProviderConsAddr, Power: expectedValidator.Power, @@ -83,7 +83,7 @@ func TestGetConsumerValSet(t *testing.T) { }) } - actualValidators, err := providerKeeper.GetConsumerValSet(ctx, "chainID") + actualValidators, err := providerKeeper.GetConsumerValSet(ctx, "consumerId") require.NoError(t, err) // sort validators first to be able to compare @@ -126,6 +126,7 @@ func createStakingValidator(ctx sdk.Context, mocks testkeeper.MockedKeepers, ind return stakingtypes.Validator{ OperatorAddress: providerValidatorAddr.String(), ConsensusPubkey: pkAny, + Status: stakingtypes.Bonded, } } @@ -253,7 +254,7 @@ func TestSetConsumerValSet(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" currentValidators := []types.ConsensusValidator{ { @@ -306,7 +307,7 @@ func TestSetConsumerValSet(t *testing.T) { }, } - // set the `currentValidators` for chain `chainID` + // set the `currentValidators` for chain `consumerId` valSet, err := providerKeeper.GetConsumerValSet(ctx, chainID) require.NoError(t, err) require.Empty(t, valSet) @@ -338,7 +339,7 @@ func TestFilterValidatorsConsiderAll(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" // no consumer validators returned if we have no bonded validators considerAll := func(providerAddr types.ProviderConsAddress) bool { return true } @@ -378,7 +379,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" // no consumer validators returned if we have no opted-in validators require.Empty(t, providerKeeper.FilterValidators(ctx, chainID, []stakingtypes.Validator{}, @@ -419,7 +420,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { // the expected actual validators are the opted-in validators but with the correct power and consumer public keys set bondedValidators := []stakingtypes.Validator{valA, valB} - actualValidators := providerKeeper.FilterValidators(ctx, "chainID", bondedValidators, + actualValidators := providerKeeper.FilterValidators(ctx, "consumerId", bondedValidators, func(providerAddr types.ProviderConsAddress) bool { return providerKeeper.IsOptedIn(ctx, chainID, providerAddr) }) @@ -438,7 +439,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { // create a staking validator C that is not opted in, hence `expectedValidators` remains the same valC := createStakingValidator(ctx, mocks, 3, 3, 3) bondedValidators = []stakingtypes.Validator{valA, valB, valC} - actualValidators = providerKeeper.FilterValidators(ctx, "chainID", bondedValidators, + actualValidators = providerKeeper.FilterValidators(ctx, "consumerId", bondedValidators, func(providerAddr types.ProviderConsAddress) bool { return providerKeeper.IsOptedIn(ctx, chainID, providerAddr) }) @@ -452,7 +453,7 @@ func TestCreateConsumerValidator(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "chainID" + chainID := "consumerId" // create a validator which has set a consumer public key valA := createStakingValidator(ctx, mocks, 0, 1, 1) diff --git a/x/ccv/provider/migrations/v5/migration_test.go b/x/ccv/provider/migrations/v5/migration_test.go index 907aa1b019..dce390ad71 100644 --- a/x/ccv/provider/migrations/v5/migration_test.go +++ b/x/ccv/provider/migrations/v5/migration_test.go @@ -16,15 +16,13 @@ func TestMigrateParams(t *testing.T) { provKeeper.SetConsumerClientId(ctx, "chainID", "clientID") // initially top N should not exist - topN, found := provKeeper.GetTopN(ctx, "chainID") - require.False(t, found) + topN := provKeeper.GetTopN(ctx, "chainID") require.Zero(t, topN) // migrate MigrateTopNForRegisteredChains(ctx, provKeeper) // after migration, top N should be 95 - topN, found = provKeeper.GetTopN(ctx, "chainID") - require.True(t, found) + topN = provKeeper.GetTopN(ctx, "chainID") require.Equal(t, uint32(95), topN) } diff --git a/x/ccv/provider/migrations/v5/migrations.go b/x/ccv/provider/migrations/v5/migrations.go index 411efd49e1..1dca37bbae 100644 --- a/x/ccv/provider/migrations/v5/migrations.go +++ b/x/ccv/provider/migrations/v5/migrations.go @@ -2,6 +2,7 @@ package v5 import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" ) @@ -11,8 +12,12 @@ import ( // and a migration to rewrite the proposal is needed. func MigrateTopNForRegisteredChains(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { // Set the topN of each chain to 95 - for _, chainID := range providerKeeper.GetAllRegisteredConsumerChainIDs(ctx) { - providerKeeper.SetTopN(ctx, chainID, 95) + for _, consumerId := range providerKeeper.GetAllRegisteredConsumerIds(ctx) { + // TODO (PERMISSIONLESS): this migration already took place and does not make much sense in the Permissionless world + // living here for now and we should totally remove + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ + Top_N: 95, + }) } } diff --git a/x/ccv/provider/migrations/v6/migrations.go b/x/ccv/provider/migrations/v6/migrations.go index 5829f29222..933c5b9853 100644 --- a/x/ccv/provider/migrations/v6/migrations.go +++ b/x/ccv/provider/migrations/v6/migrations.go @@ -19,15 +19,12 @@ func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { // we only get the registered consumer chains and not also the proposed consumer chains because // the minimal power is first set when the consumer chain addition proposal passes - registeredConsumerChains := providerKeeper.GetAllRegisteredConsumerChainIDs(ctx) + registeredConsumerChains := providerKeeper.GetAllRegisteredConsumerIds(ctx) for _, chain := range registeredConsumerChains { // get the top N - topN, found := providerKeeper.GetTopN(ctx, chain) - if !found { - providerKeeper.Logger(ctx).Error("failed to get top N", "chain", chain) - continue - } else if topN == 0 { + topN := providerKeeper.GetTopN(ctx, chain) + if topN == 0 { providerKeeper.Logger(ctx).Info("top N is 0, not setting minimal power", "chain", chain) } else { // set the minimal power in the top N diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index 320a135a69..65ced5f37e 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -171,10 +171,11 @@ func (AppModule) ConsensusVersion() uint64 { return 8 } // BeginBlock implements the AppModule interface func (am AppModule) BeginBlock(ctx context.Context) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) // Create clients to consumer chains that are due to be spawned via pending consumer addition proposals + sdkCtx := sdk.UnwrapSDKContext(ctx) + // Create clients to consumer chains that are due to be spawned am.keeper.BeginBlockInit(sdkCtx) - // Stop and remove state for any consumer chains that are due to be stopped via pending consumer removal proposals + // Stop and remove state for any consumer chains that are due to be stopped am.keeper.BeginBlockCCR(sdkCtx) // Check for replenishing slash meter before any slash packets are processed for this block am.keeper.BeginBlockCIS(sdkCtx) diff --git a/x/ccv/provider/module_test.go b/x/ccv/provider/module_test.go index 2b2ac1c63f..a019eb162f 100644 --- a/x/ccv/provider/module_test.go +++ b/x/ccv/provider/module_test.go @@ -174,11 +174,11 @@ func TestInitGenesis(t *testing.T) { numStatesCounted := 0 for _, state := range tc.consumerStates { numStatesCounted += 1 - channelID, found := providerKeeper.GetChainToChannel(ctx, state.ChainId) + channelID, found := providerKeeper.GetConsumerIdToChannelId(ctx, state.ChainId) require.True(t, found) require.Equal(t, state.ChannelId, channelID) - chainID, found := providerKeeper.GetChannelToChain(ctx, state.ChannelId) + chainID, found := providerKeeper.GetChannelIdToConsumerId(ctx, state.ChannelId) require.True(t, found) require.Equal(t, state.ChainId, chainID) } diff --git a/x/ccv/provider/proposal_handler.go b/x/ccv/provider/proposal_handler.go index 40a551d185..01d92d3e9e 100644 --- a/x/ccv/provider/proposal_handler.go +++ b/x/ccv/provider/proposal_handler.go @@ -18,11 +18,9 @@ func NewProviderProposalHandler(k keeper.Keeper) govv1beta1.Handler { return func(ctx sdk.Context, content govv1beta1.Content) error { switch c := content.(type) { case *types.ConsumerAdditionProposal: - return k.HandleLegacyConsumerAdditionProposal(ctx, c) + return nil case *types.ConsumerRemovalProposal: - return k.HandleLegacyConsumerRemovalProposal(ctx, c) - case *types.ConsumerModificationProposal: - return k.HandleLegacyConsumerModificationProposal(ctx, c) + return nil case *types.ChangeRewardDenomsProposal: return k.HandleLegacyConsumerRewardDenomProposal(ctx, c) default: diff --git a/x/ccv/provider/proposal_handler_test.go b/x/ccv/provider/proposal_handler_test.go index 67bcad7d15..cf1e82284b 100644 --- a/x/ccv/provider/proposal_handler_test.go +++ b/x/ccv/provider/proposal_handler_test.go @@ -6,14 +6,10 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" "github.com/cosmos/interchain-security/v5/x/ccv/provider" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -30,40 +26,9 @@ func TestProviderProposalHandler(t *testing.T) { name string content govv1beta1.Content blockTime time.Time - expValidConsumerAddition bool expValidConsumerRemoval bool expValidChangeRewardDenom bool }{ - { - name: "valid consumer addition proposal", - content: providertypes.NewConsumerAdditionProposal( - "title", "description", "chainID", - clienttypes.NewHeight(2, 3), []byte("gen_hash"), []byte("bin_hash"), now, - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - blockTime: hourFromNow, // ctx blocktime is after proposal's spawn time - expValidConsumerAddition: true, - }, - { - name: "valid consumer removal proposal", - content: providertypes.NewConsumerRemovalProposal( - "title", "description", "chainID", now), - blockTime: hourFromNow, - expValidConsumerRemoval: true, - }, { name: "valid change reward denoms proposal", content: providertypes.NewChangeRewardDenomsProposal( @@ -93,23 +58,12 @@ func TestProviderProposalHandler(t *testing.T) { // Setup keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, _, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + providerKeeper, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) providerKeeper.SetParams(ctx, providertypes.DefaultParams()) ctx = ctx.WithBlockTime(tc.blockTime) // Mock expectations depending on expected outcome switch { - case tc.expValidConsumerAddition: - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 1, []stakingtypes.Validator{}, 1) - gomock.InOrder(testkeeper.GetMocksForCreateConsumerClient( - ctx, &mocks, "chainID", clienttypes.NewHeight(2, 3), - )...) - - case tc.expValidConsumerRemoval: - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) - - // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel - gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) case tc.expValidChangeRewardDenom: // Nothing to mock } @@ -117,9 +71,7 @@ func TestProviderProposalHandler(t *testing.T) { // Execution proposalHandler := provider.NewProviderProposalHandler(providerKeeper) err := proposalHandler(ctx, tc.content) - - if tc.expValidConsumerAddition || tc.expValidConsumerRemoval || - tc.expValidChangeRewardDenom { + if tc.expValidChangeRewardDenom { require.NoError(t, err) } else { require.Error(t, err) diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index a3593fb22f..18915de7e7 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -24,15 +24,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*govv1beta1.Content)(nil), &ConsumerRemovalProposal{}, ) - registry.RegisterImplementations( - (*govv1beta1.Content)(nil), - &ConsumerModificationProposal{}, - ) registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgAssignConsumerKey{}, - &MsgConsumerAddition{}, - &MsgConsumerRemoval{}, + &MsgCreateConsumer{}, + &MsgUpdateConsumer{}, + &MsgRemoveConsumer{}, &MsgChangeRewardDenoms{}, &MsgUpdateParams{}, ) diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 5109489d76..94e9e5669a 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -6,30 +6,45 @@ import ( // Provider sentinel errors var ( - ErrInvalidConsumerAdditionProposal = errorsmod.Register(ModuleName, 1, "invalid consumer addition proposal") - ErrInvalidConsumerRemovalProp = errorsmod.Register(ModuleName, 2, "invalid consumer removal proposal") - ErrUnknownConsumerChainId = errorsmod.Register(ModuleName, 3, "no consumer chain with this chain id") - ErrUnknownConsumerChannelId = errorsmod.Register(ModuleName, 4, "no consumer chain with this channel id") - ErrInvalidConsumerConsensusPubKey = errorsmod.Register(ModuleName, 5, "empty consumer consensus public key") - ErrInvalidConsumerChainID = errorsmod.Register(ModuleName, 6, "invalid consumer chain id") - ErrConsumerKeyNotFound = errorsmod.Register(ModuleName, 7, "consumer key not found") - ErrNoValidatorConsumerAddress = errorsmod.Register(ModuleName, 8, "error getting validator consumer address") - ErrNoValidatorProviderAddress = errorsmod.Register(ModuleName, 9, "error getting validator provider address") - ErrConsumerKeyInUse = errorsmod.Register(ModuleName, 10, "consumer key is already in use by a validator") - ErrCannotAssignDefaultKeyAssignment = errorsmod.Register(ModuleName, 11, "cannot re-assign default key assignment") - ErrInvalidConsumerParams = errorsmod.Register(ModuleName, 12, "invalid consumer params") - ErrInvalidProviderAddress = errorsmod.Register(ModuleName, 13, "invalid provider address") - ErrInvalidConsumerRewardDenom = errorsmod.Register(ModuleName, 14, "invalid consumer reward denom") - ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 15, "invalid depositor address") - ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") - ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists") - ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") - ErrInvalidConsumerCommissionRate = errorsmod.Register(ModuleName, 19, "consumer commission rate is invalid") - ErrCannotOptOutFromTopN = errorsmod.Register(ModuleName, 20, "cannot opt out from a Top N chain") - ErrNoUnconfirmedVSCPacket = errorsmod.Register(ModuleName, 21, "no unconfirmed vsc packet for this chain id") - ErrInvalidConsumerModificationProposal = errorsmod.Register(ModuleName, 22, "invalid consumer modification proposal") - ErrNoUnbondingTime = errorsmod.Register(ModuleName, 23, "provider unbonding time not found") - ErrInvalidAddress = errorsmod.Register(ModuleName, 24, "invalid address") - ErrUnauthorized = errorsmod.Register(ModuleName, 25, "unauthorized") - ErrBlankConsumerChainID = errorsmod.Register(ModuleName, 26, "consumer chain id must not be blank") + ErrInvalidConsumerAdditionProposal = errorsmod.Register(ModuleName, 1, "invalid consumer addition proposal") + ErrInvalidConsumerRemovalProp = errorsmod.Register(ModuleName, 2, "invalid consumer removal proposal") + ErrUnknownConsumerId = errorsmod.Register(ModuleName, 3, "no consumer chain with this consumer id") + ErrUnknownConsumerChannelId = errorsmod.Register(ModuleName, 4, "no consumer chain with this channel id") + ErrInvalidConsumerConsensusPubKey = errorsmod.Register(ModuleName, 5, "empty consumer consensus public key") + ErrInvalidConsumerId = errorsmod.Register(ModuleName, 6, "invalid consumer id") + ErrConsumerKeyNotFound = errorsmod.Register(ModuleName, 7, "consumer key not found") + ErrNoValidatorConsumerAddress = errorsmod.Register(ModuleName, 8, "error getting validator consumer address") + ErrNoValidatorProviderAddress = errorsmod.Register(ModuleName, 9, "error getting validator provider address") + ErrConsumerKeyInUse = errorsmod.Register(ModuleName, 10, "consumer key is already in use by a validator") + ErrCannotAssignDefaultKeyAssignment = errorsmod.Register(ModuleName, 11, "cannot re-assign default key assignment") + ErrInvalidConsumerParams = errorsmod.Register(ModuleName, 12, "invalid consumer params") + ErrInvalidProviderAddress = errorsmod.Register(ModuleName, 13, "invalid provider address") + ErrInvalidConsumerRewardDenom = errorsmod.Register(ModuleName, 14, "invalid consumer reward denom") + ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 15, "invalid depositor address") + ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") + ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists") + ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") + ErrInvalidConsumerCommissionRate = errorsmod.Register(ModuleName, 19, "consumer commission rate is invalid") + ErrCannotOptOutFromTopN = errorsmod.Register(ModuleName, 20, "cannot opt out from a Top N chain") + ErrNoUnconfirmedVSCPacket = errorsmod.Register(ModuleName, 21, "no unconfirmed vsc packet for this chain id") + ErrInvalidConsumerModificationProposal = errorsmod.Register(ModuleName, 22, "invalid consumer modification proposal") + ErrNoUnbondingTime = errorsmod.Register(ModuleName, 23, "provider unbonding time not found") + ErrInvalidAddress = errorsmod.Register(ModuleName, 24, "invalid address") + ErrUnauthorized = errorsmod.Register(ModuleName, 25, "unauthorized") + ErrBlankConsumerChainID = errorsmod.Register(ModuleName, 26, "consumer chain id must not be blank") + ErrInvalidPhase = errorsmod.Register(ModuleName, 27, "cannot perform action in the current phase of consumer chain") + ErrInvalidConsumerMetadata = errorsmod.Register(ModuleName, 28, "invalid consumer metadata") + ErrInvalidPowerShapingParameters = errorsmod.Register(ModuleName, 29, "invalid power shaping parameters") + ErrInvalidConsumerInitializationParameters = errorsmod.Register(ModuleName, 30, "invalid consumer initialization parameters") + ErrCannotUpdateMinimumPowerInTopN = errorsmod.Register(ModuleName, 31, "cannot update minimum power in Top N") + ErrNoChainId = errorsmod.Register(ModuleName, 32, "missing chain id for consumer chain") + ErrNoConsumerGenesis = errorsmod.Register(ModuleName, 33, "missing consumer genesis") + ErrInvalidConsumerGenesis = errorsmod.Register(ModuleName, 34, "invalid consumer genesis") + ErrNoConsumerId = errorsmod.Register(ModuleName, 35, "missing consumer id") + ErrAlreadyOptedIn = errorsmod.Register(ModuleName, 36, "already opted in to a chain with the same chain id") + ErrNoOwnerAddress = errorsmod.Register(ModuleName, 37, "missing owner address") + ErrInvalidNewOwnerAddress = errorsmod.Register(ModuleName, 38, "invalid new owner address") + ErrInvalidTransformToTopN = errorsmod.Register(ModuleName, 39, "invalid transform to Top N chain") + ErrInvalidTransformToOptIn = errorsmod.Register(ModuleName, 40, "invalid transform to Opt In chain") + ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") ) diff --git a/x/ccv/provider/types/events.go b/x/ccv/provider/types/events.go index 9abcba7836..982b383f03 100644 --- a/x/ccv/provider/types/events.go +++ b/x/ccv/provider/types/events.go @@ -18,5 +18,5 @@ const ( AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" AttributeConsumerRewardDenom = "consumer_reward_denom" AttributeConsumerCommissionRate = "consumer_commission_rate" - AttributeConsumerChainID = "consumer_chain_id" + AttributeConsumerId = "consumer_chain_id" ) diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index bd9ccbd807..b9bf842a43 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -49,11 +49,11 @@ const ( SlashMeterReplenishTimeCandidateKeyName = "SlashMeterReplenishTimeCandidateKey" - ChainToChannelKeyName = "ChainToChannelKey" + ConsumerIdToChannelIdKeyName = "ConsumerIdToChannelIdKey" - ChannelToChainKeyName = "ChannelToChainKey" + ChannelIdToConsumerIdKeyName = "ChannelToConsumerIdKey" - ChainToClientKeyName = "ChainToClientKey" + ConsumerIdToClientIdKeyName = "ConsumerIdToClientIdKey" DeprecatedInitTimeoutTimestampKeyName = "DeprecatedInitTimeoutTimestampKey" @@ -81,7 +81,7 @@ const ( ThrottledPacketDataKeyName = "ThrottledPacketDataKey" - GlobalSlashEntryKeyName = "GlobalSlashEntryKey" + DeprecatedGlobalSlashEntryKeyName = "DeprecatedGlobalSlashEntryKey" ConsumerValidatorsKeyName = "ConsumerValidatorsKey" @@ -105,11 +105,11 @@ const ( OptedInKeyName = "OptedInKey" - TopNKeyName = "TopNKey" + DeprecatedTopNKeyName = "DeprecatedTopNKey" - ValidatorsPowerCapKeyName = "ValidatorsPowerCapKey" + DeprecatedValidatorsPowerCapKeyName = "DeprecatedValidatorsPowerCapKey" - ValidatorSetCapKeyName = "ValidatorSetCapKey" + DeprecatedValidatorSetCapKeyName = "DeprecatedValidatorSetCapKey" AllowlistKeyName = "AllowlistKey" @@ -123,11 +123,35 @@ const ( LastProviderConsensusValsKeyName = "LastProviderConsensusValsKey" - MinStakeKeyName = "MinStakeKey" + DeprecatedMinStakeKeyName = "DeprecatedMinStakeKey" - AllowInactiveValidatorsKeyName = "AllowInactiveValidatorsKey" + DeprecatedAllowInactiveValidatorsKeyName = "DeprecatedAllowInactiveValidatorsKey" ConsumerAddrsToPruneV2KeyName = "ConsumerAddrsToPruneV2Key" + + ConsumerIdKeyName = "ConsumerIdKey" + + ConsumerIdToChainIdKeyName = "ConsumerIdToChainIdKey" + + ConsumerIdToOwnerAddressKeyName = "ConsumerIdToOwnerAddress" + + ConsumerIdToConsumerMetadataKeyName = "ConsumerIdToMetadataKey" + + ConsumerIdToInitializationParametersKeyName = "ConsumerIdToInitializationParametersKey" + + ConsumerIdToPowerShapingParameters = "ConsumerIdToPowerShapingParametersKey" + + ConsumerIdToPhaseKeyName = "ConsumerIdToPhaseKey" + + ConsumerIdToStopTimeKeyName = "ConsumerIdToStopTimeKey" + + SpawnTimeToConsumerIdsKeyName = "SpawnTimeToConsumerIdsKeyName" + + StopTimeToConsumerIdsKeyName = "StopTimeToConsumerIdsKeyName" + + ProviderConsAddrToOptedInConsumerIdsKeyName = "ProviderConsAddrToOptedInConsumerIdsKeyName" + + ClientIdToConsumerIdKeyName = "ClientIdToConsumerIdKey" ) // getKeyPrefixes returns a constant map of all the byte prefixes for existing keys @@ -157,16 +181,16 @@ func getKeyPrefixes() map[string]byte { // SlashMeterReplenishTimeCandidateKey is the key for storing the slash meter replenish time candidate SlashMeterReplenishTimeCandidateKeyName: 4, - // ChainToChannelKey is the key for storing mapping + // ConsumerIdToChannelIdKey is the key for storing mapping // from chainID to the channel ID that is used to send over validator set changes. - ChainToChannelKeyName: 5, + ConsumerIdToChannelIdKeyName: 5, - // ChannelToChainKey is the key for storing mapping + // ChannelToConsumerIdKey is the key for storing mapping // from the CCV channel ID to the consumer chain ID. - ChannelToChainKeyName: 6, + ChannelIdToConsumerIdKeyName: 6, - // ChainToClientKey is the key for storing the client ID for a given consumer chainID. - ChainToClientKeyName: 7, + // ConsumerIdToClientIdKey is the key for storing the client ID for a given consumer chainID. + ConsumerIdToClientIdKeyName: 7, // InitTimeoutTimestampKey is the key for storing // the init timeout timestamp for a given consumer chainID. @@ -223,7 +247,8 @@ func getKeyPrefixes() map[string]byte { ThrottledPacketDataKeyName: 20, // GlobalSlashEntryKey is the key for storing global slash queue entries - GlobalSlashEntryKeyName: 21, + // [DEPRECATED] + DeprecatedGlobalSlashEntryKeyName: 21, // ConsumerValidatorsKey is the key for storing the validator assigned keys for every consumer chain ConsumerValidatorsKeyName: 22, @@ -270,18 +295,24 @@ func getKeyPrefixes() map[string]byte { // OptedInKey is the key for storing whether a validator is opted in to validate on a consumer chain OptedInKeyName: 32, - // TopNKey is the key for storing the mapping from a consumer chain to the N value of this chain, + // DeprecatedTopNKey is the key for storing the mapping from a consumer chain to the N value of this chain, // that corresponds to the N% of the top validators that have to validate this consumer chain - TopNKeyName: 33, + // NOTE: This prefix is deprecated, but left in place to avoid state migrations + // [DEPRECATED] + DeprecatedTopNKeyName: 33, - // ValidatorsPowerCapKey is the key for storing the mapping from a consumer chain to the power-cap value of this chain, + // DeprecatedValidatorsPowerCapKey is the key for storing the mapping from a consumer chain to the power-cap value of this chain, // that corresponds to p% such that no validator can have more than p% of the voting power on the consumer chain. // Operates on a best-effort basis. - ValidatorsPowerCapKeyName: 34, + // NOTE: This prefix is deprecated, but left in place to avoid state migrations + // [DEPRECATED] + DeprecatedValidatorsPowerCapKeyName: 34, - // ValidatorSetCapKey is the key for storing the mapping from a consumer chain to the validator-set cap value + // DeprecatedValidatorSetCapKey is the key for storing the mapping from a consumer chain to the validator-set cap value // of this chain. - ValidatorSetCapKeyName: 35, + // NOTE: This prefix is deprecated, but left in place to avoid state migrations + // [DEPRECATED] + DeprecatedValidatorSetCapKeyName: 35, // AllowlistKey is the key for storing the mapping from a consumer chain to the set of validators that are // allowlisted. @@ -311,14 +342,44 @@ func getKeyPrefixes() map[string]byte { // sent to the consensus engine of the provider chain LastProviderConsensusValsKeyName: 42, - // MinStakeKey is the byte prefix for storing the mapping from consumer chains to the minimum stake required to be a validator on the consumer chain - // The minimum stake must be stored on the provider chain, not on the consumer chain itself, since it filters out - // validators from the VSCPackets that we send to the consumer chain. - MinStakeKeyName: 43, + // ConsumerIdKeyName is the key for storing the consumer id for the next registered consumer chain + ConsumerIdKeyName: 43, + + // ConsumerIdToChainIdKeyName is the key for storing the chain id for the given consumer id + ConsumerIdToChainIdKeyName: 44, + + // ConsumerIdToOwnerAddressKeyName is the key for storing the owner address for the given consumer id + ConsumerIdToOwnerAddressKeyName: 45, + + // ConsumerIdToConsumerMetadataKeyName is the key for storing the metadata for the given consumer id + ConsumerIdToConsumerMetadataKeyName: 46, + + // ConsumerIdToInitializationParametersKeyName is the key for storing the initialization parameters for the given consumer id + ConsumerIdToInitializationParametersKeyName: 47, + + // ConsumerIdToPowerShapingParameters is the key for storing the power-shaping parameters for the given consumer id + ConsumerIdToPowerShapingParameters: 48, + + // ConsumerIdToPhaseKeyName is the key for storing the phase of a consumer chain with the given consumer id + ConsumerIdToPhaseKeyName: 49, + + // ConsumerIdToStopTimeKeyName is the key for storing the stop time of a consumer chain that is to be removed + ConsumerIdToStopTimeKeyName: 50, + + // SpawnTimeToConsumerIdKeyName is the key for storing pending initialized consumers that are to be launched. + // For a specific spawn time, it might store multiple consumer chain ids for chains that are to be launched. + SpawnTimeToConsumerIdsKeyName: 51, + + // StopTimeToConsumerIdKeyName is the key for storing pending launched consumers that are to be stopped. + // For a specific stop time, it might store multiple consumer chain ids for chains that are to be stopped. + StopTimeToConsumerIdsKeyName: 52, - // AllowInactiveValidatorsKey is the byte prefix for storing the mapping from consumer chains to the boolean value - // that determines whether inactive validators can validate on that chain - AllowInactiveValidatorsKeyName: 44, + // ProviderConsAddrToOptedInConsumerIdsKeyName is the key for storing all the consumer ids that a validator + // is currently opted in to. + ProviderConsAddrToOptedInConsumerIdsKeyName: 53, + + // ClientIdToConsumerIdKeyName is the key for storing the consumer id for the given client id + ClientIdToConsumerIdKeyName: 54, // NOTE: DO NOT ADD NEW BYTE PREFIXES HERE WITHOUT ADDING THEM TO TestPreserveBytePrefix() IN keys_test.go } @@ -392,29 +453,29 @@ func SlashMeterReplenishTimeCandidateKey() []byte { return []byte{mustGetKeyPrefix(SlashMeterReplenishTimeCandidateKeyName)} } -// ChainToChannelKey returns the key under which the CCV channel ID will be stored for the given consumer chain. -func ChainToChannelKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(ChainToChannelKeyName)}, []byte(chainID)...) +// ConsumerIdToChannelIdKey returns the key under which the CCV channel ID will be stored for the given consumer chain. +func ConsumerIdToChannelIdKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(ConsumerIdToChannelIdKeyName)}, []byte(consumerId)...) } -// ChannelToChainKeyPrefix returns the key prefix for storing the consumer chain IDs. -func ChannelToChainKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(ChannelToChainKeyName)} +// ChannelIdToConsumerIdKeyPrefix returns the key prefix for storing the consumer chain ids. +func ChannelIdToConsumerIdKeyPrefix() []byte { + return []byte{mustGetKeyPrefix(ChannelIdToConsumerIdKeyName)} } -// ChannelToChainKey returns the key under which the consumer chain ID will be stored for the given channelID. -func ChannelToChainKey(channelID string) []byte { - return append(ChannelToChainKeyPrefix(), []byte(channelID)...) +// ChannelToConsumerIdKey returns the key under which the consumer chain id will be stored for the given channelId. +func ChannelToConsumerIdKey(channelId string) []byte { + return append(ChannelIdToConsumerIdKeyPrefix(), []byte(channelId)...) } -// ChainToClientKeyPrefix returns the key prefix for storing the clientID for the given chainID. -func ChainToClientKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(ChainToClientKeyName)} +// ConsumerIdToClientIdKeyPrefix returns the key prefix for storing the clientId for the given consumerId. +func ConsumerIdToClientIdKeyPrefix() []byte { + return []byte{mustGetKeyPrefix(ConsumerIdToClientIdKeyName)} } -// ChainToClientKey returns the key under which the clientID for the given chainID is stored. -func ChainToClientKey(chainID string) []byte { - return append(ChainToClientKeyPrefix(), []byte(chainID)...) +// ConsumerIdToClientIdKey returns the key under which the clientId for the given consumerId is stored. +func ConsumerIdToClientIdKey(consumerId string) []byte { + return append(ConsumerIdToClientIdKeyPrefix(), []byte(consumerId)...) } // PendingCAPKeyPrefix returns the key prefix for storing a pending consumer addition proposal @@ -468,25 +529,25 @@ func ValsetUpdateBlockHeightKey(valsetUpdateId uint64) []byte { } // ConsumerGenesisKey returns the key corresponding to consumer genesis state material -// (consensus state and client state) indexed by consumer chain id -func ConsumerGenesisKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(ConsumerGenesisKeyName)}, []byte(chainID)...) +// (consensus state and client state) indexed by consumer id +func ConsumerGenesisKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(ConsumerGenesisKeyName)}, []byte(consumerId)...) } -// SlashAcksKey returns the key under which slashing acks are stored for a given chain ID -func SlashAcksKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(SlashAcksKeyName)}, []byte(chainID)...) +// SlashAcksKey returns the key under which slashing acks are stored for a given consumer id +func SlashAcksKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(SlashAcksKeyName)}, []byte(consumerId)...) } -// InitChainHeightKey returns the key under which the block height for a given chain ID is stored -func InitChainHeightKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(InitChainHeightKeyName)}, []byte(chainID)...) +// InitChainHeightKey returns the key under which the block height for a given consumer id is stored +func InitChainHeightKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(InitChainHeightKeyName)}, []byte(consumerId)...) } // PendingVSCsKey returns the key under which -// pending ValidatorSetChangePacket data is stored for a given chain ID -func PendingVSCsKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(PendingVSCsKeyName)}, []byte(chainID)...) +// pending ValidatorSetChangePacket data is stored for a given consumer id +func PendingVSCsKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(PendingVSCsKeyName)}, []byte(consumerId)...) } // ThrottledPacketDataSizeKey returns the key storing the size of the throttled packet data queue for a given chain ID @@ -518,50 +579,6 @@ func ParseThrottledPacketDataKey(key []byte) (chainId string, ibcSeqNum uint64, return ParseChainIdAndUintIdKey(ThrottledPacketDataKeyPrefix(), key) } -// GlobalSlashEntryKeyPrefix returns the key for storing a global slash queue entry. -func GlobalSlashEntryKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(GlobalSlashEntryKeyName)} -} - -// GlobalSlashEntryKey returns the key for storing a global slash queue entry. -func GlobalSlashEntryKey(entry GlobalSlashEntry) []byte { - recvTime := uint64(entry.RecvTime.UTC().UnixNano()) - return ccvtypes.AppendMany( - // Append byte prefix - GlobalSlashEntryKeyPrefix(), - // Append time bz - sdk.Uint64ToBigEndian(recvTime), - // Append ibc seq num - sdk.Uint64ToBigEndian(entry.IbcSeqNum), - // Append consumer chain id - []byte(entry.ConsumerChainID), - ) -} - -// MustParseGlobalSlashEntryKey returns the received time and chainID for a global slash queue entry key, -// or panics if the key is invalid. -func MustParseGlobalSlashEntryKey(bz []byte) ( - recvTime time.Time, consumerChainID string, ibcSeqNum uint64, -) { - // Prefix is in first byte - expectedPrefix := GlobalSlashEntryKeyPrefix() - if prefix := bz[:1]; !bytes.Equal(prefix, expectedPrefix) { - panic(fmt.Sprintf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix)) - } - - // 8 bytes for uint64 storing time bytes - timeBz := sdk.BigEndianToUint64(bz[1:9]) - recvTime = time.Unix(0, int64(timeBz)).UTC() - - // 8 bytes for uint64 storing ibc seq num - ibcSeqNum = sdk.BigEndianToUint64(bz[9:17]) - - // ChainID is stored after 8 byte ibc seq num - chainID := string(bz[17:]) - - return recvTime, chainID, ibcSeqNum -} - // ConsumerValidatorsKey returns the key for storing the validator assigned keys for every consumer chain func ConsumerValidatorsKeyPrefix() byte { return mustGetKeyPrefix(ConsumerValidatorsKeyName) @@ -569,8 +586,8 @@ func ConsumerValidatorsKeyPrefix() byte { // ConsumerValidatorsKey returns the key under which the // validator assigned keys for every consumer chain are stored -func ConsumerValidatorsKey(chainID string, addr ProviderConsAddress) []byte { - return ChainIdAndConsAddrKey(ConsumerValidatorsKeyPrefix(), chainID, addr.ToSdkConsAddr()) +func ConsumerValidatorsKey(consumerId string, addr ProviderConsAddress) []byte { + return ConsumerIdAndConsAddrKey(ConsumerValidatorsKeyPrefix(), consumerId, addr.ToSdkConsAddr()) } // ValidatorsByConsumerAddrKeyPrefix returns the key prefix for storing the mapping from validator addresses @@ -581,8 +598,8 @@ func ValidatorsByConsumerAddrKeyPrefix() byte { // ValidatorsByConsumerAddrKey returns the key for storing the mapping from validator addresses // on consumer chains to validator addresses on the provider chain -func ValidatorsByConsumerAddrKey(chainID string, addr ConsumerConsAddress) []byte { - return ChainIdAndConsAddrKey(ValidatorsByConsumerAddrKeyPrefix(), chainID, addr.ToSdkConsAddr()) +func ValidatorsByConsumerAddrKey(consumerId string, addr ConsumerConsAddress) []byte { + return ConsumerIdAndConsAddrKey(ValidatorsByConsumerAddrKeyPrefix(), consumerId, addr.ToSdkConsAddr()) } // SlashLogKey returns the key to a validator's slash log @@ -601,9 +618,9 @@ func ConsumerRewardDenomsKey(denom string) []byte { } // EquivocationEvidenceMinHeightKey returns the key storing the minimum height -// of a valid consumer equivocation evidence for a given consumer chain ID -func EquivocationEvidenceMinHeightKey(consumerChainID string) []byte { - return append([]byte{mustGetKeyPrefix(EquivocationEvidenceMinHeightKeyName)}, []byte(consumerChainID)...) +// of a valid consumer equivocation evidence for a given consumer id +func EquivocationEvidenceMinHeightKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(EquivocationEvidenceMinHeightKeyName)}, []byte(consumerId)...) } // ProposedConsumerChainKeyPrefix returns the key prefix for storing proposed consumer chainId @@ -638,37 +655,21 @@ func ConsumerValidatorKeyPrefix() byte { } // ConsumerValidatorKey returns the key for storing consumer validators -// for the given consumer chain `chainID` and validator with `providerAddr` -func ConsumerValidatorKey(chainID string, providerAddr []byte) []byte { - prefix := ChainIdWithLenKey(ConsumerValidatorKeyPrefix(), chainID) +// for the given consumer chain `consumerId` and validator with `providerAddr` +func ConsumerValidatorKey(consumerId string, providerAddr []byte) []byte { + prefix := ConsumerIdWithLenKey(ConsumerValidatorKeyPrefix(), consumerId) return append(prefix, providerAddr...) } -// TopNKey returns the key used to store the Top N value per consumer chain. -// This value corresponds to the N% of the top validators that have to validate the consumer chain. -func TopNKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(TopNKeyName), chainID) -} - -// ValidatorSetPowerKey returns the key of consumer chain `chainID` -func ValidatorsPowerCapKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(ValidatorsPowerCapKeyName), chainID) -} - -// ValidatorSetCapKey returns the key of consumer chain `chainID` -func ValidatorSetCapKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(ValidatorSetCapKeyName), chainID) -} - // AllowlistKeyPrefix returns the key prefix for storing consumer chains allowlists func AllowlistKeyPrefix() byte { return mustGetKeyPrefix(AllowlistKeyName) } // AllowlistKey returns the key for storing consumer chains allowlists -func AllowlistKey(chainID string, providerAddr ProviderConsAddress) []byte { +func AllowlistKey(consumerId string, providerAddr ProviderConsAddress) []byte { return append( - ChainIdWithLenKey(AllowlistKeyPrefix(), chainID), + ConsumerIdWithLenKey(AllowlistKeyPrefix(), consumerId), providerAddr.ToSdkConsAddr().Bytes()..., ) } @@ -679,9 +680,9 @@ func DenylistKeyPrefix() byte { } // DenylistKey returns the key for storing consumer chains denylists -func DenylistKey(chainID string, providerAddr ProviderConsAddress) []byte { +func DenylistKey(consumerId string, providerAddr ProviderConsAddress) []byte { return append( - ChainIdWithLenKey(DenylistKeyPrefix(), chainID), + ConsumerIdWithLenKey(DenylistKeyPrefix(), consumerId), providerAddr.ToSdkConsAddr().Bytes()..., ) } @@ -692,14 +693,14 @@ func OptedInKeyPrefix() byte { } // OptedInKey returns the key used to store whether a validator is opted in on a consumer chain. -func OptedInKey(chainID string, providerAddr ProviderConsAddress) []byte { - prefix := ChainIdWithLenKey(OptedInKeyPrefix(), chainID) +func OptedInKey(consumerId string, providerAddr ProviderConsAddress) []byte { + prefix := ConsumerIdWithLenKey(OptedInKeyPrefix(), consumerId) return append(prefix, providerAddr.ToSdkConsAddr().Bytes()...) } // ConsumerRewardsAllocationKey returns the key used to store the ICS rewards per consumer chain -func ConsumerRewardsAllocationKey(chainID string) []byte { - return append([]byte{mustGetKeyPrefix(ConsumerRewardsAllocationKeyName)}, []byte(chainID)...) +func ConsumerRewardsAllocationKey(consumerId string) []byte { + return append([]byte{mustGetKeyPrefix(ConsumerRewardsAllocationKeyName)}, []byte(consumerId)...) } // ConsumerCommissionRateKeyPrefix returns the key prefix for storing the commission rate per validator per consumer chain. @@ -708,16 +709,16 @@ func ConsumerCommissionRateKeyPrefix() byte { } // ConsumerCommissionRateKey returns the key used to store the commission rate per validator per consumer chain. -func ConsumerCommissionRateKey(chainID string, providerAddr ProviderConsAddress) []byte { - return ChainIdAndConsAddrKey( +func ConsumerCommissionRateKey(consumerId string, providerAddr ProviderConsAddress) []byte { + return ConsumerIdAndConsAddrKey( ConsumerCommissionRateKeyPrefix(), - chainID, + consumerId, providerAddr.ToSdkConsAddr(), ) } -func MinimumPowerInTopNKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(MinimumPowerInTopNKeyName), chainID) +func MinimumPowerInTopNKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(MinimumPowerInTopNKeyName), consumerId) } // ConsumerAddrsToPruneV2KeyPrefix returns the key prefix for storing the consumer validators @@ -730,8 +731,8 @@ func ConsumerAddrsToPruneV2KeyPrefix() byte { // ConsumerAddrsToPruneV2Key returns the key for storing the consumer validators // addresses that need to be pruned. -func ConsumerAddrsToPruneV2Key(chainID string, pruneTs time.Time) []byte { - return ChainIdAndTsKey(ConsumerAddrsToPruneV2KeyPrefix(), chainID, pruneTs) +func ConsumerAddrsToPruneV2Key(consumerId string, pruneTs time.Time) []byte { + return ConsumerIdAndTsKey(ConsumerAddrsToPruneV2KeyPrefix(), consumerId, pruneTs) } // LastProviderConsensusValsPrefix returns the key prefix for storing the last validator set sent to the consensus engine of the provider chain @@ -739,13 +740,125 @@ func LastProviderConsensusValsPrefix() []byte { return []byte{mustGetKeyPrefix(LastProviderConsensusValsKeyName)} } -// MinStakeKey returns the key used to store the minimum stake required to validate on consumer chain `chainID` -func MinStakeKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(MinStakeKeyName), chainID) +// ConsumerIdKey returns the key used to store the consumerId of the next registered chain +func ConsumerIdKey() []byte { + return []byte{mustGetKeyPrefix(ConsumerIdKeyName)} +} + +// ConsumerIdToChainIdKey returns the key used to store the chain id of this consumer id +func ConsumerIdToChainIdKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToChainIdKeyName), consumerId) +} + +// ConsumerIdToOwnerAddressKey returns the owner address of this consumer id +func ConsumerIdToOwnerAddressKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToOwnerAddressKeyName), consumerId) +} + +// ConsumerIdToMetadataKeyPrefix returns the key prefix for storing consumer metadata +func ConsumerIdToMetadataKeyPrefix() byte { + return mustGetKeyPrefix(ConsumerIdToConsumerMetadataKeyName) +} + +// ConsumerIdToMetadataKey returns the key used to store the metadata that corresponds to this consumer id +func ConsumerIdToMetadataKey(consumerId string) []byte { + return ConsumerIdWithLenKey(ConsumerIdToMetadataKeyPrefix(), consumerId) +} + +// ConsumerIdToInitializationParametersKeyPrefix returns the key prefix for storing consumer initialization records +func ConsumerIdToInitializationParametersKeyPrefix() byte { + return mustGetKeyPrefix(ConsumerIdToInitializationParametersKeyName) +} + +// ConsumerIdToInitializationParametersKey returns the key used to store the initialization record that corresponds to this consumer id +func ConsumerIdToInitializationParametersKey(consumerId string) []byte { + return ConsumerIdWithLenKey(ConsumerIdToInitializationParametersKeyPrefix(), consumerId) +} + +// ConsumerIdToPowerShapingParametersKey returns the key used to store the update record that corresponds to this consumer id +func ConsumerIdToPowerShapingParametersKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPowerShapingParameters), consumerId) +} + +// ConsumerIdToPhaseKey returns the key used to store the phase that corresponds to this consumer id +func ConsumerIdToPhaseKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId) +} + +// ConsumerIdToStopTimeKey returns the key used to store the stop time that corresponds to a to-be-stopped chain with consumer id +func ConsumerIdToStopTimeKey(consumerId string) []byte { + return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToStopTimeKeyName), consumerId) +} + +// ConsumerIdToStopTimeKeyPrefix returns the key prefix for storing the stop times of consumer chains +// that are about to be stopped +func ConsumerIdToStopTimeKeyPrefix() byte { + return mustGetKeyPrefix(ConsumerIdToStopTimeKeyName) +} + +// SpawnTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be launched +func SpawnTimeToConsumerIdsKeyPrefix() byte { + return mustGetKeyPrefix(SpawnTimeToConsumerIdsKeyName) +} + +// SpawnTimeToConsumerIdsKey returns the key prefix for storing the spawn times of consumer chains +// that are about to be launched +func SpawnTimeToConsumerIdsKey(spawnTime time.Time) []byte { + return ccvtypes.AppendMany( + // append the prefix + []byte{SpawnTimeToConsumerIdsKeyPrefix()}, + // append the time + sdk.FormatTimeBytes(spawnTime), + ) +} + +// StopTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be stopped +func StopTimeToConsumerIdsKeyPrefix() byte { + return mustGetKeyPrefix(StopTimeToConsumerIdsKeyName) } -func AllowInactiveValidatorsKey(chainID string) []byte { - return ChainIdWithLenKey(mustGetKeyPrefix(AllowInactiveValidatorsKeyName), chainID) +// StopTimeToConsumerIdsKey returns the key prefix for storing the stop times of consumer chains +// that are about to be stopped +func StopTimeToConsumerIdsKey(spawnTime time.Time) []byte { + return ccvtypes.AppendMany( + // append the prefix + []byte{StopTimeToConsumerIdsKeyPrefix()}, + // append the time + sdk.FormatTimeBytes(spawnTime), + ) +} + +// ParseTime returns the marshalled time +func ParseTime(prefix byte, bz []byte) (time.Time, error) { + expectedPrefix := []byte{prefix} + prefixL := len(expectedPrefix) + if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { + return time.Time{}, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) + } + timestamp, err := sdk.ParseTimeBytes(bz[prefixL:]) + if err != nil { + return time.Time{}, err + } + return timestamp, nil +} + +// ProviderConsAddrToOptedInConsumerIdsKey returns the key for storing all the consumer ids that `providerAddr` +// has opted-in to +func ProviderConsAddrToOptedInConsumerIdsKey(providerAddr ProviderConsAddress) []byte { + return append([]byte{mustGetKeyPrefix(ProviderConsAddrToOptedInConsumerIdsKeyName)}, providerAddr.ToSdkConsAddr().Bytes()...) +} + +// ClientIdToConsumerIdKey returns the consumer id that corresponds to this client id +func ClientIdToConsumerIdKey(clientId string) []byte { + clientIdLength := len(clientId) + return ccvtypes.AppendMany( + // Append the prefix + []byte{mustGetKeyPrefix(ClientIdToConsumerIdKeyName)}, + // Append the client id length + sdk.Uint64ToBigEndian(uint64(clientIdLength)), + // Append the client id + []byte(clientId), + ) } // NOTE: DO NOT ADD FULLY DEFINED KEY FUNCTIONS WITHOUT ADDING THEM TO getAllFullyDefinedKeys() IN keys_test.go @@ -758,10 +871,10 @@ func AllowInactiveValidatorsKey(chainID string) []byte { // Generic helpers section // -// ChainIdAndTsKey returns the key with the following format: -// bytePrefix | len(chainID) | chainID | timestamp -func ChainIdAndTsKey(prefix byte, chainID string, timestamp time.Time) []byte { - partialKey := ChainIdWithLenKey(prefix, chainID) +// ConsumerIdAndTsKey returns the key with the following format: +// bytePrefix | len(consumerId) | consumerId | timestamp +func ConsumerIdAndTsKey(prefix byte, consumerId string, timestamp time.Time) []byte { + partialKey := ConsumerIdWithLenKey(prefix, consumerId) timeBz := sdk.FormatTimeBytes(timestamp) return ccvtypes.AppendMany( // Append the partialKey @@ -771,40 +884,51 @@ func ChainIdAndTsKey(prefix byte, chainID string, timestamp time.Time) []byte { ) } -// ChainIdWithLenKey returns the key with the following format: -// bytePrefix | len(chainID) | chainID -func ChainIdWithLenKey(prefix byte, chainID string) []byte { - chainIdL := len(chainID) +// ParseConsumerIdAndTsKey returns the consumer id and time for a ConsumerIdIdAndTs key +func ParseConsumerIdAndTsKey(prefix byte, bz []byte) (string, time.Time, error) { + expectedPrefix := []byte{prefix} + prefixL := len(expectedPrefix) + if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { + return "", time.Time{}, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) + } + consumerIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + consumerId := string(bz[prefixL+8 : prefixL+8+int(consumerIdL)]) + timestamp, err := sdk.ParseTimeBytes(bz[prefixL+8+int(consumerIdL):]) + if err != nil { + return "", time.Time{}, err + } + return consumerId, timestamp, nil +} + +// ConsumerIdWithLenKey returns the key with the following format: +// bytePrefix | len(consumerId) | consumerId +func ConsumerIdWithLenKey(prefix byte, consumerId string) []byte { return ccvtypes.AppendMany( // Append the prefix []byte{prefix}, - // Append the chainID length - sdk.Uint64ToBigEndian(uint64(chainIdL)), - // Append the chainID - []byte(chainID), + // Append the consumer id length + sdk.Uint64ToBigEndian(uint64(len(consumerId))), + // Append the consumer id + []byte(consumerId), ) } -// ParseChainIdAndTsKey returns the chain ID and time for a ChainIdAndTs key -func ParseChainIdAndTsKey(prefix byte, bz []byte) (string, time.Time, error) { +// ParseConsumerIdWithLenKey returns the consumer id ConsumerIdWithLen key +func ParseConsumerIdWithLenKey(prefix byte, bz []byte) (string, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { - return "", time.Time{}, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) - } - chainIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) - chainID := string(bz[prefixL+8 : prefixL+8+int(chainIdL)]) - timestamp, err := sdk.ParseTimeBytes(bz[prefixL+8+int(chainIdL):]) - if err != nil { - return "", time.Time{}, err + return "", fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) } - return chainID, timestamp, nil + consumerIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + consumerId := string(bz[prefixL+8 : prefixL+8+int(consumerIdL)]) + return consumerId, nil } // ChainIdAndUintIdKey returns the key with the following format: // bytePrefix | len(chainID) | chainID | uint64(ID) func ChainIdAndUintIdKey(prefix byte, chainID string, uintId uint64) []byte { - partialKey := ChainIdWithLenKey(prefix, chainID) + partialKey := ConsumerIdWithLenKey(prefix, chainID) return ccvtypes.AppendMany( // Append the partialKey partialKey, @@ -826,10 +950,10 @@ func ParseChainIdAndUintIdKey(prefix byte, bz []byte) (string, uint64, error) { return chainID, uintID, nil } -// ChainIdAndConsAddrKey returns the key with the following format: -// bytePrefix | len(chainID) | chainID | ConsAddress -func ChainIdAndConsAddrKey(prefix byte, chainID string, addr sdk.ConsAddress) []byte { - partialKey := ChainIdWithLenKey(prefix, chainID) +// ConsumerIdAndConsAddrKey returns the key with the following format: +// bytePrefix | len(consumerId) | consumerId | ConsAddress +func ConsumerIdAndConsAddrKey(prefix byte, consumerId string, addr sdk.ConsAddress) []byte { + partialKey := ConsumerIdWithLenKey(prefix, consumerId) return ccvtypes.AppendMany( // Append the partialKey partialKey, @@ -838,7 +962,7 @@ func ChainIdAndConsAddrKey(prefix byte, chainID string, addr sdk.ConsAddress) [] ) } -// ParseChainIdAndConsAddrKey returns the chain ID and ConsAddress for a ChainIdAndConsAddrKey key +// ParseChainIdAndConsAddrKey returns the chain ID and ConsAddress for a ConsumerIdAndConsAddrKey key func ParseChainIdAndConsAddrKey(prefix byte, bz []byte) (string, sdk.ConsAddress, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index 800b6ee669..f3ecb4da6c 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -41,11 +41,11 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(4), providertypes.SlashMeterReplenishTimeCandidateKey()[0]) i++ - require.Equal(t, byte(5), providertypes.ChainToChannelKey("chainID")[0]) + require.Equal(t, byte(5), providertypes.ConsumerIdToChannelIdKey("chainID")[0]) i++ - require.Equal(t, byte(6), providertypes.ChannelToChainKeyPrefix()[0]) + require.Equal(t, byte(6), providertypes.ChannelIdToConsumerIdKeyPrefix()[0]) i++ - require.Equal(t, byte(7), providertypes.ChainToClientKeyPrefix()[0]) + require.Equal(t, byte(7), providertypes.ConsumerIdToClientIdKeyPrefix()[0]) i++ // reserve 8 as deprecated i++ @@ -73,7 +73,8 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(20), providertypes.ThrottledPacketDataKeyPrefix()) i++ - require.Equal(t, byte(21), providertypes.GlobalSlashEntryKeyPrefix()[0]) + // DEPRECATED + // require.Equal(t, uint8(21), providertypes.GlobalSlashEntryKeyPrefix()[0]) i++ require.Equal(t, byte(22), providertypes.ConsumerValidatorsKeyPrefix()) i++ @@ -97,11 +98,14 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(32), providertypes.OptedInKeyPrefix()) i++ - require.Equal(t, byte(33), providertypes.TopNKey("chainID")[0]) + // DEPRECATED + //require.Equal(t, byte(33), providertypes.TopNKey("chainID")[0]) i++ - require.Equal(t, byte(34), providertypes.ValidatorsPowerCapKey("chainID")[0]) + // DEPRECATED + //require.Equal(t, byte(34), providertypes.ValidatorsPowerCapKey("chainID")[0]) i++ - require.Equal(t, byte(35), providertypes.ValidatorSetCapKey("chainID")[0]) + // DEPRECATED + //require.Equal(t, byte(35), providertypes.ValidatorSetCapKey("chainID")[0]) i++ require.Equal(t, byte(36), providertypes.AllowlistKeyPrefix()) i++ @@ -117,9 +121,29 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(42), providertypes.LastProviderConsensusValsPrefix()[0]) i++ - require.Equal(t, byte(43), providertypes.MinStakeKey("chainID")[0]) + require.Equal(t, byte(43), providertypes.ConsumerIdKey()[0]) i++ - require.Equal(t, byte(44), providertypes.AllowInactiveValidatorsKey("chainID")[0]) + require.Equal(t, byte(44), providertypes.ConsumerIdToChainIdKey("consumerId")[0]) + i++ + require.Equal(t, byte(45), providertypes.ConsumerIdToOwnerAddressKey("consumerId")[0]) + i++ + require.Equal(t, byte(46), providertypes.ConsumerIdToMetadataKeyPrefix()) + i++ + require.Equal(t, byte(47), providertypes.ConsumerIdToInitializationParametersKeyPrefix()) + i++ + require.Equal(t, byte(48), providertypes.ConsumerIdToPowerShapingParametersKey("consumerId")[0]) + i++ + require.Equal(t, byte(49), providertypes.ConsumerIdToPhaseKey("consumerId")[0]) + i++ + require.Equal(t, byte(50), providertypes.ConsumerIdToStopTimeKeyPrefix()) + i++ + require.Equal(t, byte(51), providertypes.SpawnTimeToConsumerIdsKeyPrefix()) + i++ + require.Equal(t, byte(52), providertypes.StopTimeToConsumerIdsKeyPrefix()) + i++ + require.Equal(t, byte(53), providertypes.ProviderConsAddrToOptedInConsumerIdsKey(providertypes.NewProviderConsAddress([]byte{0x05}))[0]) + i++ + require.Equal(t, byte(54), providertypes.ClientIdToConsumerIdKey("clientId")[0]) i++ prefixes := providertypes.GetAllKeyPrefixes() @@ -156,9 +180,9 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.ValidatorSetUpdateIdKey(), providertypes.SlashMeterKey(), providertypes.SlashMeterReplenishTimeCandidateKey(), - providertypes.ChainToChannelKey("chainID"), - providertypes.ChannelToChainKey("channelID"), - providertypes.ChainToClientKey("chainID"), + providertypes.ConsumerIdToChannelIdKey("chainID"), + providertypes.ChannelToConsumerIdKey("channelID"), + providertypes.ConsumerIdToClientIdKey("chainID"), providertypes.PendingCAPKey(time.Time{}, "chainID"), providertypes.PendingCRPKey(time.Time{}, "chainID"), providertypes.ValsetUpdateBlockHeightKey(7), @@ -168,7 +192,6 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.PendingVSCsKey("chainID"), providertypes.ThrottledPacketDataSizeKey("chainID"), providertypes.ThrottledPacketDataKey("chainID", 88), - providertypes.GlobalSlashEntryKey(providertypes.GlobalSlashEntry{}), providertypes.ConsumerValidatorsKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.ValidatorsByConsumerAddrKey("chainID", providertypes.NewConsumerConsAddress([]byte{0x05})), providertypes.SlashLogKey(providertypes.NewProviderConsAddress([]byte{0x05})), @@ -176,9 +199,6 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.EquivocationEvidenceMinHeightKey("chainID"), providertypes.ProposedConsumerChainKey(1), providertypes.ConsumerValidatorKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05}).Address.Bytes()), - providertypes.TopNKey("chainID"), - providertypes.ValidatorsPowerCapKey("chainID"), - providertypes.ValidatorSetCapKey("chainID"), providertypes.AllowlistKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.DenylistKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.OptedInKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), @@ -186,9 +206,19 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.ConsumerCommissionRateKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.MinimumPowerInTopNKey("chainID"), providertypes.ConsumerAddrsToPruneV2Key("chainID", time.Time{}), - providertypes.MinStakeKey("chainID"), - providertypes.AllowInactiveValidatorsKey("chainID"), providerkeeper.GetValidatorKey(types.LastProviderConsensusValsPrefix(), providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.ConsumerIdKey(), + providertypes.ConsumerIdToChainIdKey("consumerId"), + providertypes.ConsumerIdToOwnerAddressKey("consumerId"), + providertypes.ConsumerIdToMetadataKey("consumerId"), + providertypes.ConsumerIdToInitializationParametersKey("consumerId"), + providertypes.ConsumerIdToPowerShapingParametersKey("consumerId"), + providertypes.ConsumerIdToPhaseKey("consumerId"), + providertypes.ConsumerIdToStopTimeKey("consumerId"), + providertypes.SpawnTimeToConsumerIdsKey(time.Time{}), + providertypes.StopTimeToConsumerIdsKey(time.Time{}), + providertypes.ProviderConsAddrToOptedInConsumerIdsKey(providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.ClientIdToConsumerIdKey("clientId"), } } @@ -206,12 +236,12 @@ func TestChainIdAndTsKeyAndParse(t *testing.T) { } for _, test := range tests { - key := providertypes.ChainIdAndTsKey(test.prefix, test.chainID, test.timestamp) + key := providertypes.ConsumerIdAndTsKey(test.prefix, test.chainID, test.timestamp) require.NotEmpty(t, key) // Expected bytes = prefix + chainID length + chainID + time bytes expectedLen := 1 + 8 + len(test.chainID) + len(sdk.FormatTimeBytes(time.Time{})) require.Equal(t, expectedLen, len(key)) - parsedID, parsedTime, err := providertypes.ParseChainIdAndTsKey(test.prefix, key) + parsedID, parsedTime, err := providertypes.ParseConsumerIdAndTsKey(test.prefix, key) require.Equal(t, test.chainID, parsedID) require.Equal(t, test.timestamp.UTC(), parsedTime.UTC()) require.NoError(t, err) @@ -270,33 +300,6 @@ func TestThrottledPacketDataKeyAndParse(t *testing.T) { require.NotEqual(t, key1, key2) } -// Tests the construction and parsing of keys for global slash entries -func TestGlobalSlashEntryKeyAndParse(t *testing.T) { - now := time.Now() - - providerConsAddrs := []providertypes.ProviderConsAddress{ - cryptoutil.NewCryptoIdentityFromIntSeed(0).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(1).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(2).ProviderConsAddress(), - } - - entries := []providertypes.GlobalSlashEntry{} - entries = append(entries, providertypes.NewGlobalSlashEntry(now, "chain-0", 2, providerConsAddrs[0])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour), "chain-7896978", 3, providerConsAddrs[1])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(3*time.Hour), "chain-1", 4723894, providerConsAddrs[2])) - - for _, entry := range entries { - key := providertypes.GlobalSlashEntryKey(entry) - require.NotEmpty(t, key) - // This key should be of set length: prefix + 8 + 8 + chainID - require.Equal(t, 1+8+8+len(entry.ConsumerChainID), len(key)) - parsedRecvTime, parsedChainID, parsedIBCSeqNum := providertypes.MustParseGlobalSlashEntryKey(key) - require.Equal(t, entry.RecvTime, parsedRecvTime) - require.Equal(t, entry.ConsumerChainID, parsedChainID) - require.Equal(t, entry.IbcSeqNum, parsedIBCSeqNum) - } -} - // Tests the construction and parsing of ChainIdAndConsAddr keys func TestChainIdAndConsAddrAndParse(t *testing.T) { cIds := []*cryptoutil.CryptoIdentity{ @@ -319,7 +322,7 @@ func TestChainIdAndConsAddrAndParse(t *testing.T) { } for _, test := range tests { - key := providertypes.ChainIdAndConsAddrKey(test.prefix, test.chainID, test.addr) + key := providertypes.ConsumerIdAndConsAddrKey(test.prefix, test.chainID, test.addr) require.NotEmpty(t, key) // Expected bytes = prefix + chainID length + chainID + consAddr bytes expectedLen := 1 + 8 + len(test.chainID) + len(test.addr) @@ -334,9 +337,9 @@ func TestChainIdAndConsAddrAndParse(t *testing.T) { // Test key packing functions with the format func TestKeysWithPrefixAndId(t *testing.T) { funcs := []func(string) []byte{ - providertypes.ChainToChannelKey, - providertypes.ChannelToChainKey, - providertypes.ChainToClientKey, + providertypes.ConsumerIdToChannelIdKey, + providertypes.ChannelToConsumerIdKey, + providertypes.ConsumerIdToClientIdKey, providertypes.ConsumerGenesisKey, providertypes.SlashAcksKey, providertypes.InitChainHeightKey, diff --git a/x/ccv/provider/types/legacy_proposal.go b/x/ccv/provider/types/legacy_proposal.go index 3124cc3d87..f29f3b6c07 100644 --- a/x/ccv/provider/types/legacy_proposal.go +++ b/x/ccv/provider/types/legacy_proposal.go @@ -20,8 +20,8 @@ import ( const ( ProposalTypeConsumerAddition = "ConsumerAddition" - ProposalTypeConsumerRemoval = "ConsumerRemoval" - ProposalTypeConsumerModification = "ConsumerModification" + ProposalTypeConsumerRemoval = "RemoveConsumer" + ProposalTypeConsumerModification = "UpdateConsumer" ProposalTypeEquivocation = "Equivocation" ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms" ) @@ -29,7 +29,6 @@ const ( var ( _ govv1beta1.Content = &ConsumerAdditionProposal{} _ govv1beta1.Content = &ConsumerRemovalProposal{} - _ govv1beta1.Content = &ConsumerModificationProposal{} _ govv1beta1.Content = &ChangeRewardDenomsProposal{} _ govv1beta1.Content = &EquivocationProposal{} ) @@ -240,55 +239,6 @@ func (sccp *ConsumerRemovalProposal) ValidateBasic() error { return nil } -// NewConsumerModificationProposal creates a new consumer modification proposal. -func NewConsumerModificationProposal(title, description, chainID string, - topN uint32, - validatorsPowerCap uint32, - validatorSetCap uint32, - allowlist []string, - denylist []string, - minStake uint64, - allowInactiveVals bool, -) govv1beta1.Content { - return &ConsumerModificationProposal{ - Title: title, - Description: description, - ChainId: chainID, - Top_N: topN, - ValidatorsPowerCap: validatorsPowerCap, - ValidatorSetCap: validatorSetCap, - Allowlist: allowlist, - Denylist: denylist, - MinStake: minStake, - AllowInactiveVals: allowInactiveVals, - } -} - -// ProposalRoute returns the routing key of a consumer modification proposal. -func (cccp *ConsumerModificationProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type of the consumer modification proposal. -func (cccp *ConsumerModificationProposal) ProposalType() string { - return ProposalTypeConsumerModification -} - -// ValidateBasic runs basic stateless validity checks -func (cccp *ConsumerModificationProposal) ValidateBasic() error { - if err := govv1beta1.ValidateAbstract(cccp); err != nil { - return err - } - - if strings.TrimSpace(cccp.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerModificationProposal, "consumer chain id must not be blank") - } - - err := ValidatePSSFeatures(cccp.Top_N, cccp.ValidatorsPowerCap) - if err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) - } - return nil -} - // NewEquivocationProposal creates a new equivocation proposal. // [DEPRECATED]: do not use because equivocations can be submitted // and verified automatically on the provider. diff --git a/x/ccv/provider/types/legacy_proposal_test.go b/x/ccv/provider/types/legacy_proposal_test.go index 02fdb5245e..180a4978bd 100644 --- a/x/ccv/provider/types/legacy_proposal_test.go +++ b/x/ccv/provider/types/legacy_proposal_test.go @@ -542,82 +542,68 @@ func TestChangeRewardDenomsProposalValidateBasic(t *testing.T) { } } -func TestConsumerModificationProposalValidateBasic(t *testing.T) { +func TestMsgUpdateConsumerValidateBasic(t *testing.T) { testCases := []struct { - name string - proposal govv1beta1.Content - expPass bool + name string + powerShapingParameters types.PowerShapingParameters + expPass bool }{ { "success", - types.NewConsumerModificationProposal("title", "description", "chainID", - 50, - 100, - 34, - []string{"addr1"}, - nil, - 0, - false, - ), + types.PowerShapingParameters{ + Top_N: 50, + ValidatorsPowerCap: 100, + ValidatorSetCap: 34, + Allowlist: []string{"addr1"}, + Denylist: nil, + MinStake: 0, + AllowInactiveVals: false, + }, true, }, - { - "invalid chain id", - types.NewConsumerModificationProposal("title", "description", " ", - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, { "top N is invalid", - types.NewConsumerModificationProposal("title", "description", "chainID", - 10, - 0, - 0, - nil, - nil, - 0, - false, - ), + types.PowerShapingParameters{ + Top_N: 10, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + }, false, }, { "validators power cap is invalid", - types.NewConsumerModificationProposal("title", "description", "chainID", - 50, - 101, - 0, - nil, - nil, - 0, - false, - ), + types.PowerShapingParameters{ + Top_N: 50, + ValidatorsPowerCap: 101, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + MinStake: 0, + AllowInactiveVals: false, + }, false, }, { "valid proposal", - types.NewConsumerModificationProposal("title", "description", "chainID", - 0, - 34, - 101, - []string{"addr1"}, - []string{"addr2", "addr3"}, - 0, - false, - ), + types.PowerShapingParameters{ + Top_N: 54, + ValidatorsPowerCap: 92, + ValidatorSetCap: 0, + Allowlist: []string{"addr1"}, + Denylist: []string{"addr2", "addr3"}, + MinStake: 0, + AllowInactiveVals: false, + }, true, }, } for _, tc := range testCases { - - err := tc.proposal.ValidateBasic() + // TODO (PERMISSIONLESS) add more tests + msg, _ := types.NewMsgUpdateConsumer("", "0", "cosmos1p3ucd3ptpw902fluyjzhq3ffgq4ntddac9sa3s", nil, nil, &tc.powerShapingParameters) + err := msg.ValidateBasic() if tc.expPass { require.NoError(t, err, "valid case: %s should not return error. got %w", tc.name, err) } else { diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index c47c62e0a0..21b9173eca 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -3,7 +3,10 @@ package types import ( "encoding/json" "fmt" + cmttypes "github.com/cometbft/cometbft/types" + "strconv" "strings" + "time" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" @@ -23,6 +26,9 @@ const ( TypeMsgAssignConsumerKey = "assign_consumer_key" TypeMsgSubmitConsumerMisbehaviour = "submit_consumer_misbehaviour" TypeMsgSubmitConsumerDoubleVoting = "submit_consumer_double_vote" + TypeMsgCreateConsumer = "create_consumer" + TypeMsgUpdateConsumer = "update_consumer" + TypeMsgRemoveConsumer = "remove_consumer" TypeMsgOptIn = "opt_in" TypeMsgOptOut = "opt_out" TypeMsgSetConsumerCommissionRate = "set_consumer_commission_rate" @@ -30,23 +36,23 @@ const ( var ( _ sdk.Msg = (*MsgAssignConsumerKey)(nil) - _ sdk.Msg = (*MsgConsumerAddition)(nil) - _ sdk.Msg = (*MsgConsumerRemoval)(nil) - _ sdk.Msg = (*MsgConsumerModification)(nil) _ sdk.Msg = (*MsgChangeRewardDenoms)(nil) _ sdk.Msg = (*MsgSubmitConsumerMisbehaviour)(nil) _ sdk.Msg = (*MsgSubmitConsumerDoubleVoting)(nil) + _ sdk.Msg = (*MsgCreateConsumer)(nil) + _ sdk.Msg = (*MsgUpdateConsumer)(nil) + _ sdk.Msg = (*MsgRemoveConsumer)(nil) _ sdk.Msg = (*MsgOptIn)(nil) _ sdk.Msg = (*MsgOptOut)(nil) _ sdk.Msg = (*MsgSetConsumerCommissionRate)(nil) _ sdk.HasValidateBasic = (*MsgAssignConsumerKey)(nil) - _ sdk.HasValidateBasic = (*MsgConsumerAddition)(nil) - _ sdk.HasValidateBasic = (*MsgConsumerRemoval)(nil) - _ sdk.HasValidateBasic = (*MsgConsumerModification)(nil) _ sdk.HasValidateBasic = (*MsgChangeRewardDenoms)(nil) _ sdk.HasValidateBasic = (*MsgSubmitConsumerMisbehaviour)(nil) _ sdk.HasValidateBasic = (*MsgSubmitConsumerDoubleVoting)(nil) + _ sdk.HasValidateBasic = (*MsgCreateConsumer)(nil) + _ sdk.HasValidateBasic = (*MsgUpdateConsumer)(nil) + _ sdk.HasValidateBasic = (*MsgRemoveConsumer)(nil) _ sdk.HasValidateBasic = (*MsgOptIn)(nil) _ sdk.HasValidateBasic = (*MsgOptOut)(nil) _ sdk.HasValidateBasic = (*MsgSetConsumerCommissionRate)(nil) @@ -54,11 +60,11 @@ var ( // NewMsgAssignConsumerKey creates a new MsgAssignConsumerKey instance. // Delegator address and validator address are the same. -func NewMsgAssignConsumerKey(chainID string, providerValidatorAddress sdk.ValAddress, +func NewMsgAssignConsumerKey(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string, ) (*MsgAssignConsumerKey, error) { return &MsgAssignConsumerKey{ - ChainId: chainID, + ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, Signer: signer, @@ -94,14 +100,8 @@ func (msg MsgAssignConsumerKey) GetSignBytes() []byte { // ValidateBasic implements the sdk.Msg interface. func (msg MsgAssignConsumerKey) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") - } - // It is possible to assign keys for consumer chains that are not yet approved. - // This can only be done by a signing validator, but it is still sensible - // to limit the chainID size to prevent abuse. - if 128 < len(msg.ChainId) { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err } _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil { @@ -148,6 +148,9 @@ func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { if msg.Submitter == "" { return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter) } + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err + } if err := msg.Misbehaviour.ValidateBasic(); err != nil { return err @@ -208,6 +211,10 @@ func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error { return fmt.Errorf("invalid infraction block header, validator set is nil") } + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err + } + return nil } @@ -227,11 +234,171 @@ func (msg MsgSubmitConsumerDoubleVoting) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{addr} } +// NewMsgCreateConsumer creates a new MsgCreateConsumer instance +func NewMsgCreateConsumer(signer string, chainId string, metadata ConsumerMetadata, + initializationParameters *ConsumerInitializationParameters, powerShapingParameters *PowerShapingParameters) (*MsgCreateConsumer, error) { + return &MsgCreateConsumer{ + Signer: signer, + ChainId: chainId, + Metadata: metadata, + InitializationParameters: initializationParameters, + PowerShapingParameters: powerShapingParameters, + }, nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgCreateConsumer) Type() string { + return TypeMsgCreateConsumer +} + +// Route implements the sdk.Msg interface. +func (msg MsgCreateConsumer) Route() string { return RouterKey } + +// ValidateBasic implements the sdk.Msg interface. +func (msg MsgCreateConsumer) ValidateBasic() error { + if err := ValidateField("chain id", msg.ChainId, cmttypes.MaxChainIDLen); err != nil { + return err + } + + if err := ValidateConsumerMetadata(msg.Metadata); err != nil { + return err + } + + if msg.InitializationParameters != nil { + if err := ValidateInitializationParameters(*msg.InitializationParameters); err != nil { + return err + } + } + + if msg.PowerShapingParameters != nil { + if msg.PowerShapingParameters.Top_N != 0 { + return fmt.Errorf("cannot create a Top N chain through `MsgCreateConsumer`; " + + "first create the chain and then use `MsgUpdateConsumer` to make the chain Top N") + } + if err := ValidatePowerShapingParameters(*msg.PowerShapingParameters); err != nil { + return err + } + } + + return nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgCreateConsumer) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + // GetSigners implements the sdk.Msg interface. It returns the address(es) that // must sign over msg.GetSignBytes(). -// If the validator address is not same as delegator's, then the validator must -// sign the msg as well. -func (msg *MsgConsumerAddition) GetSigners() []sdk.AccAddress { +func (msg MsgCreateConsumer) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Signer) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +// NewMsgUpdateConsumer creates a new MsgUpdateConsumer instance +func NewMsgUpdateConsumer(signer string, consumerId string, ownerAddress string, metadata *ConsumerMetadata, + initializationParameters *ConsumerInitializationParameters, powerShapingParameters *PowerShapingParameters) (*MsgUpdateConsumer, error) { + return &MsgUpdateConsumer{ + Signer: signer, + ConsumerId: consumerId, + NewOwnerAddress: ownerAddress, + Metadata: metadata, + InitializationParameters: initializationParameters, + PowerShapingParameters: powerShapingParameters, + }, nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgUpdateConsumer) Type() string { + return TypeMsgUpdateConsumer +} + +// Route implements the sdk.Msg interface. +func (msg MsgUpdateConsumer) Route() string { return RouterKey } + +// ValidateBasic implements the sdk.Msg interface. +func (msg MsgUpdateConsumer) ValidateBasic() error { + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err + } + + if msg.Metadata != nil { + if err := ValidateConsumerMetadata(*msg.Metadata); err != nil { + return err + } + } + + if msg.InitializationParameters != nil { + if err := ValidateInitializationParameters(*msg.InitializationParameters); err != nil { + return err + } + } + + if msg.PowerShapingParameters != nil { + if err := ValidatePowerShapingParameters(*msg.PowerShapingParameters); err != nil { + return err + } + } + + return nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgUpdateConsumer) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg MsgUpdateConsumer) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Signer) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +// NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance +func NewMsgRemoveConsumer(signer string, consumerId string, stopTime time.Time) (*MsgRemoveConsumer, error) { + return &MsgRemoveConsumer{ + Authority: signer, + ConsumerId: consumerId, + StopTime: stopTime, + }, nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgRemoveConsumer) Type() string { + return TypeMsgRemoveConsumer +} + +// Route implements the sdk.Msg interface. +func (msg MsgRemoveConsumer) Route() string { return RouterKey } + +// ValidateBasic implements the sdk.Msg interface. +func (msg MsgRemoveConsumer) ValidateBasic() error { + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err + } + return nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgRemoveConsumer) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg MsgRemoveConsumer) GetSigners() []sdk.AccAddress { valAddr, err := sdk.ValAddressFromBech32(msg.Authority) if err != nil { // same behavior as in cosmos-sdk @@ -240,8 +407,11 @@ func (msg *MsgConsumerAddition) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{valAddr.Bytes()} } +// Route implements the sdk.Msg interface. +func (msg MsgConsumerAddition) Route() string { return RouterKey } + // ValidateBasic implements the sdk.Msg interface. -func (msg *MsgConsumerAddition) ValidateBasic() error { +func (msg MsgConsumerAddition) ValidateBasic() error { if strings.TrimSpace(msg.ChainId) == "" { return ErrBlankConsumerChainID } @@ -292,19 +462,28 @@ func (msg *MsgConsumerAddition) ValidateBasic() error { return nil } -func (msg *MsgConsumerRemoval) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "consumer chain id must not be blank") - } +// Type implements the sdk.Msg interface. +func (msg MsgConsumerAddition) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} - if msg.StopTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "spawn time cannot be zero") +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg MsgConsumerAddition) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Authority) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) } - return nil + return []sdk.AccAddress{valAddr.Bytes()} } +// Route implements the sdk.Msg interface. +func (msg MsgConsumerModification) Route() string { return RouterKey } + // ValidateBasic implements the sdk.Msg interface. -func (msg *MsgConsumerModification) ValidateBasic() error { +func (msg MsgConsumerModification) ValidateBasic() error { if strings.TrimSpace(msg.ChainId) == "" { return ErrBlankConsumerChainID } @@ -317,10 +496,59 @@ func (msg *MsgConsumerModification) ValidateBasic() error { return nil } +// Type implements the sdk.Msg interface. +func (msg MsgConsumerModification) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg MsgConsumerModification) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Authority) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +// Route implements the sdk.Msg interface. +func (msg MsgConsumerRemoval) Route() string { return RouterKey } + +// ValidateBasic implements the sdk.Msg interface. +func (msg MsgConsumerRemoval) ValidateBasic() error { + if strings.TrimSpace(msg.ChainId) == "" { + return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "consumer chain id must not be blank") + } + + if msg.StopTime.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "spawn time cannot be zero") + } + return nil +} + +// Type implements the sdk.Msg interface. +func (msg MsgConsumerRemoval) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} + +// GetSigners implements the sdk.Msg interface. It returns the address(es) that +// must sign over msg.GetSignBytes(). +func (msg MsgConsumerRemoval) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.Authority) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + // NewMsgOptIn creates a new NewMsgOptIn instance. -func NewMsgOptIn(chainID string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { +func NewMsgOptIn(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { return &MsgOptIn{ - ChainId: chainID, + ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, Signer: signer, @@ -348,14 +576,8 @@ func (msg MsgOptIn) GetSigners() []sdk.AccAddress { // ValidateBasic implements the sdk.Msg interface. func (msg MsgOptIn) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") - } - // It is possible to opt in to validate on consumer chains that are not yet approved. - // This can only be done by a signing validator, but it is still sensible - // to limit the chainID size to prevent abuse. - if 128 < len(msg.ChainId) { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err } _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil { @@ -371,9 +593,9 @@ func (msg MsgOptIn) ValidateBasic() error { } // NewMsgOptOut creates a new NewMsgOptIn instance. -func NewMsgOptOut(chainID string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { +func NewMsgOptOut(consumerId string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { return &MsgOptOut{ - ChainId: chainID, + ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), Signer: signer, }, nil @@ -406,14 +628,8 @@ func (msg MsgOptOut) GetSignBytes() []byte { // ValidateBasic implements the sdk.Msg interface. func (msg MsgOptOut) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") - } - // It is possible to assign keys for consumer chains that are not yet approved. - // This can only be done by a signing validator, but it is still sensible - // to limit the chainID size to prevent abuse. - if 128 < len(msg.ChainId) { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err } _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil { @@ -423,9 +639,9 @@ func (msg MsgOptOut) ValidateBasic() error { } // NewMsgSetConsumerCommissionRate creates a new MsgSetConsumerCommissionRate msg instance. -func NewMsgSetConsumerCommissionRate(chainID string, commission math.LegacyDec, providerValidatorAddress sdk.ValAddress, signer string) *MsgSetConsumerCommissionRate { +func NewMsgSetConsumerCommissionRate(consumerId string, commission math.LegacyDec, providerValidatorAddress sdk.ValAddress, signer string) *MsgSetConsumerCommissionRate { return &MsgSetConsumerCommissionRate{ - ChainId: chainID, + ConsumerId: consumerId, Rate: commission, ProviderAddr: providerValidatorAddress.String(), Signer: signer, @@ -441,12 +657,8 @@ func (msg MsgSetConsumerCommissionRate) Type() string { } func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") - } - - if 128 < len(msg.ChainId) { - return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return err } _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) if err != nil { @@ -507,3 +719,138 @@ func (msg MsgSetConsumerCommissionRate) GetSignBytes() []byte { bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } + +// ValidateConsumerId validates the provided consumer id and returns an error if it is not valid +func ValidateConsumerId(consumerId string) error { + if strings.TrimSpace(consumerId) == "" { + return errorsmod.Wrapf(ErrInvalidConsumerId, "consumer id cannot be blank") + } + + // check that `consumerId` corresponds to a `uint64` + _, err := strconv.ParseUint(consumerId, 10, 64) + if err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerId, "consumer id (%s) cannot be parsed: %s", consumerId, err.Error()) + } + + return nil +} + +// ValidateField validates that `field` is not empty and has at most `maxLength` characters +func ValidateField(nameOfTheField string, field string, maxLength int) error { + if strings.TrimSpace(field) == "" { + return fmt.Errorf("%s cannot be empty", nameOfTheField) + } else if len(field) > maxLength { + return fmt.Errorf("%s is too long; got: %d, max: %d", nameOfTheField, len(field), maxLength) + } + return nil +} + +// ValidateConsumerMetadata validates that all the provided metadata are in the expected range +func ValidateConsumerMetadata(metadata ConsumerMetadata) error { + const maxNameLength = 100 + const maxDescriptionLength = 50000 + const maxMetadataLength = 1000 + + if err := ValidateField("name", metadata.Name, maxNameLength); err != nil { + return err + } + + if err := ValidateField("description", metadata.Description, maxDescriptionLength); err != nil { + return err + } + + if err := ValidateField("metadata", metadata.Metadata, maxMetadataLength); err != nil { + return err + } + + return nil +} + +// ValidatePowerShapingParameters validates that all the provided power-shaping parameters are in the expected range +func ValidatePowerShapingParameters(powerShapingParameters PowerShapingParameters) error { + const maxAllowlistLength = 500 + const maxDenylistLength = 500 + + // Top N corresponds to the top N% of validators that have to validate the consumer chain and can only be 0 (for an + // Opt In chain) or in the range [50, 100] (for a Top N chain). + if powerShapingParameters.Top_N != 0 && (powerShapingParameters.Top_N < 50 || powerShapingParameters.Top_N > 100) { + return fmt.Errorf("parameter Top N can either be 0 or in the range [50, 100]") + } + + if powerShapingParameters.ValidatorsPowerCap != 0 && powerShapingParameters.ValidatorsPowerCap > 100 { + return fmt.Errorf("validators' power cap has to be in the range [1, 100]") + } + + if len(powerShapingParameters.Allowlist) > maxAllowlistLength { + return fmt.Errorf("allowlist cannot exceed length: %d", maxAllowlistLength) + } + + if len(powerShapingParameters.Denylist) > maxDenylistLength { + return fmt.Errorf("denylist cannot exceed length: %d", maxDenylistLength) + } + + return nil +} + +// ValidateInitializationParameters validates that all the provided parameters are in the expected range +func ValidateInitializationParameters(initializationParameters ConsumerInitializationParameters) error { + const maxGenesisHashLength = 1000 + const maxBinaryHashLength = 1000 + const maxConsumerRedistributionFractionLength = 50 + const maxDistributionTransmissionChannelLength = 1000 + + if initializationParameters.InitialHeight.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "initial height cannot be zero") + } + + if len(initializationParameters.GenesisHash) == 0 { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "genesis hash cannot be empty") + } else if len(initializationParameters.GenesisHash) > maxGenesisHashLength { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "genesis hash cannot exceed %d bytes", maxGenesisHashLength) + } + + if len(initializationParameters.BinaryHash) == 0 { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "binary hash cannot be empty") + } else if len(initializationParameters.BinaryHash) > maxBinaryHashLength { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "binary hash cannot exceed %d bytes", maxBinaryHashLength) + } + + if initializationParameters.SpawnTime.IsZero() { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "spawn time cannot be zero") + } + + if err := ccvtypes.ValidateStringFraction(initializationParameters.ConsumerRedistributionFraction); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "consumer redistribution fraction is invalid: %s", err.Error()) + } else if err := ValidateField("consumer redistribution fraction", initializationParameters.ConsumerRedistributionFraction, maxConsumerRedistributionFractionLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "consumer redistribution fraction is invalid: %s", err.Error()) + } + + if err := ccvtypes.ValidatePositiveInt64(initializationParameters.BlocksPerDistributionTransmission); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "blocks per distribution transmission has to be positive") + } + + if err := ccvtypes.ValidateDistributionTransmissionChannel(initializationParameters.DistributionTransmissionChannel); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "distribution transmission channel is invalid: %s", err.Error()) + } else if len(initializationParameters.DistributionTransmissionChannel) > maxDistributionTransmissionChannelLength { + // note that the distribution transmission channel can be the empty string (i.e., "") and hence we only check its max length here + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "distribution transmission channel exceeds %d length", maxDistributionTransmissionChannelLength) + } + + if err := ccvtypes.ValidatePositiveInt64(initializationParameters.HistoricalEntries); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "historical entries has to be positive") + } + + if err := ccvtypes.ValidateDuration(initializationParameters.CcvTimeoutPeriod); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "ccv timeout period cannot be zero") + } + + if err := ccvtypes.ValidateDuration(initializationParameters.TransferTimeoutPeriod); err != nil { + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "transfer timeout period cannot be zero") + } + + if err := ccvtypes.ValidateDuration(initializationParameters.UnbondingPeriod); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "invalid unbonding period: %s", err.Error()) + } + + return nil +} diff --git a/x/ccv/provider/types/msg_test.go b/x/ccv/provider/types/msg_test.go new file mode 100644 index 0000000000..da6d24d793 --- /dev/null +++ b/x/ccv/provider/types/msg_test.go @@ -0,0 +1,21 @@ +package types_test + +import ( + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "github.com/stretchr/testify/require" + "testing" +) + +func TestValidateConsumerId(t *testing.T) { + // empty consumer id + require.Error(t, types.ValidateConsumerId("")) + + // not a `uint64` where `uint64` is in the range [0, 2^64) + require.Error(t, types.ValidateConsumerId("a")) + require.Error(t, types.ValidateConsumerId("-2545")) + require.Error(t, types.ValidateConsumerId("18446744073709551616")) // 2^64 + + // valid consumer id + require.NoError(t, types.ValidateConsumerId("0")) + require.NoError(t, types.ValidateConsumerId("18446744073709551615")) // 2^64 - 1 +} diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 7c30781221..a0d0fa1dd8 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -37,6 +37,7 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// WARNING: This message is deprecated in favor of `MsgCreateConsumer`. // ConsumerAdditionProposal is a governance proposal on the provider chain to // spawn a new consumer chain. If it passes, then all validators on the provider // chain are expected to validate the consumer chain at spawn time or get @@ -151,6 +152,7 @@ func (m *ConsumerAdditionProposal) XXX_DiscardUnknown() { var xxx_messageInfo_ConsumerAdditionProposal proto.InternalMessageInfo +// WARNING: This message is deprecated in favor of `MsgRemoveConsumer`. // ConsumerRemovalProposal is a governance proposal on the provider chain to // remove (and stop) a consumer chain. If it passes, all the consumer chain's // state is removed from the provider chain. The outstanding unbonding operation @@ -229,6 +231,7 @@ func (m *ConsumerRemovalProposal) GetStopTime() time.Time { return time.Time{} } +// WARNING: This message is deprecated in favor of `MsgUpdateConsumer`. // ConsumerModificationProposal is a governance proposal on the provider chain to modify parameters of a running // consumer chain. If it passes, the consumer chain's state is updated to take into account the newest params. type ConsumerModificationProposal struct { @@ -899,6 +902,7 @@ func (m *AddressList) GetAddresses() [][]byte { return nil } +// WARNING: This message is deprecated and is not used. // ChannelToChain is used to map a CCV channel ID to the consumer chainID type ChannelToChain struct { ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` @@ -1372,6 +1376,381 @@ func (m *ConsumerRewardsAllocation) GetRewards() github_com_cosmos_cosmos_sdk_ty return nil } +// ConsumerMetadata contains general information about the registered chain +type ConsumerMetadata struct { + // the name of the chain + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // the description of the chain + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // the metadata (e.g., GitHub repository URL) of the chain + Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (m *ConsumerMetadata) Reset() { *m = ConsumerMetadata{} } +func (m *ConsumerMetadata) String() string { return proto.CompactTextString(m) } +func (*ConsumerMetadata) ProtoMessage() {} +func (*ConsumerMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{19} +} +func (m *ConsumerMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerMetadata.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 *ConsumerMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerMetadata.Merge(m, src) +} +func (m *ConsumerMetadata) XXX_Size() int { + return m.Size() +} +func (m *ConsumerMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerMetadata proto.InternalMessageInfo + +func (m *ConsumerMetadata) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ConsumerMetadata) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ConsumerMetadata) GetMetadata() string { + if m != nil { + return m.Metadata + } + return "" +} + +// ConsumerInitializationParameters are the parameters needed to launch a chain +type ConsumerInitializationParameters struct { + // the proposed initial height of new consumer chain. + // For a completely new chain, this will be {0,1}. However, it may be + // different if this is a chain that is converting to a consumer chain. + InitialHeight types.Height `protobuf:"bytes,1,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height"` + // The hash of the consumer chain genesis state without the consumer CCV + // module genesis params. It is used for off-chain confirmation of + // genesis.json validity by validators and other parties. + GenesisHash []byte `protobuf:"bytes,2,opt,name=genesis_hash,json=genesisHash,proto3" json:"genesis_hash,omitempty"` + // The hash of the consumer chain binary that should be run by validators on + // chain initialization. It is used for off-chain confirmation of binary + // validity by validators and other parties. + BinaryHash []byte `protobuf:"bytes,3,opt,name=binary_hash,json=binaryHash,proto3" json:"binary_hash,omitempty"` + // spawn time is the time on the provider chain at which the consumer chain + // genesis is finalized and all validators will be responsible for starting + // their consumer chain validator node. + SpawnTime time.Time `protobuf:"bytes,4,opt,name=spawn_time,json=spawnTime,proto3,stdtime" json:"spawn_time"` + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + UnbondingPeriod time.Duration `protobuf:"bytes,5,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` + // Sent CCV related IBC packets will timeout after this duration + CcvTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` + // Sent transfer related IBC packets will timeout after this duration + TransferTimeoutPeriod time.Duration `protobuf:"bytes,7,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"` + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + ConsumerRedistributionFraction string `protobuf:"bytes,8,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` + // BlocksPerDistributionTransmission is the number of blocks between + // ibc-token-transfers from the consumer chain to the provider chain. On + // sending transmission event, `consumer_redistribution_fraction` of the + // accumulated tokens are sent to the consumer redistribution address. + BlocksPerDistributionTransmission int64 `protobuf:"varint,9,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + HistoricalEntries int64 `protobuf:"varint,10,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` + // The ID of a token transfer channel used for the Reward Distribution + // sub-protocol. If DistributionTransmissionChannel == "", a new transfer + // channel is created on top of the same connection as the CCV channel. + // Note that transfer_channel_id is the ID of the channel end on the consumer + // chain. it is most relevant for chains performing a sovereign to consumer + // changeover in order to maintain the existing ibc transfer channel + DistributionTransmissionChannel string `protobuf:"bytes,11,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"` +} + +func (m *ConsumerInitializationParameters) Reset() { *m = ConsumerInitializationParameters{} } +func (m *ConsumerInitializationParameters) String() string { return proto.CompactTextString(m) } +func (*ConsumerInitializationParameters) ProtoMessage() {} +func (*ConsumerInitializationParameters) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{20} +} +func (m *ConsumerInitializationParameters) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerInitializationParameters) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerInitializationParameters.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 *ConsumerInitializationParameters) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerInitializationParameters.Merge(m, src) +} +func (m *ConsumerInitializationParameters) XXX_Size() int { + return m.Size() +} +func (m *ConsumerInitializationParameters) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerInitializationParameters.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerInitializationParameters proto.InternalMessageInfo + +func (m *ConsumerInitializationParameters) GetInitialHeight() types.Height { + if m != nil { + return m.InitialHeight + } + return types.Height{} +} + +func (m *ConsumerInitializationParameters) GetGenesisHash() []byte { + if m != nil { + return m.GenesisHash + } + return nil +} + +func (m *ConsumerInitializationParameters) GetBinaryHash() []byte { + if m != nil { + return m.BinaryHash + } + return nil +} + +func (m *ConsumerInitializationParameters) GetSpawnTime() time.Time { + if m != nil { + return m.SpawnTime + } + return time.Time{} +} + +func (m *ConsumerInitializationParameters) GetUnbondingPeriod() time.Duration { + if m != nil { + return m.UnbondingPeriod + } + return 0 +} + +func (m *ConsumerInitializationParameters) GetCcvTimeoutPeriod() time.Duration { + if m != nil { + return m.CcvTimeoutPeriod + } + return 0 +} + +func (m *ConsumerInitializationParameters) GetTransferTimeoutPeriod() time.Duration { + if m != nil { + return m.TransferTimeoutPeriod + } + return 0 +} + +func (m *ConsumerInitializationParameters) GetConsumerRedistributionFraction() string { + if m != nil { + return m.ConsumerRedistributionFraction + } + return "" +} + +func (m *ConsumerInitializationParameters) GetBlocksPerDistributionTransmission() int64 { + if m != nil { + return m.BlocksPerDistributionTransmission + } + return 0 +} + +func (m *ConsumerInitializationParameters) GetHistoricalEntries() int64 { + if m != nil { + return m.HistoricalEntries + } + return 0 +} + +func (m *ConsumerInitializationParameters) GetDistributionTransmissionChannel() string { + if m != nil { + return m.DistributionTransmissionChannel + } + return "" +} + +// PowerShapingParameters contains parameters that shape the validator set that we send to the consumer chain +type PowerShapingParameters struct { + // Corresponds to the percentage of validators that have to validate the chain under the Top N case. + // For example, 53 corresponds to a Top 53% chain, meaning that the top 53% provider validators by voting power + // have to validate the proposed consumer chain. top_N can either be 0 or any value in [50, 100]. + // A chain can join with top_N == 0 as an Opt In chain, or with top_N ∈ [50, 100] as a Top N chain. + Top_N uint32 `protobuf:"varint,1,opt,name=top_N,json=topN,proto3" json:"top_N,omitempty"` + // Corresponds to the maximum power (percentage-wise) a validator can have on the consumer chain. For instance, if + // `validators_power_cap` is set to 32, it means that no validator can have more than 32% of the voting power on the + // consumer chain. Note that this might not be feasible. For example, think of a consumer chain with only + // 5 validators and with `validators_power_cap` set to 10%. In such a scenario, at least one validator would need + // to have more than 20% of the total voting power. Therefore, `validators_power_cap` operates on a best-effort basis. + ValidatorsPowerCap uint32 `protobuf:"varint,2,opt,name=validators_power_cap,json=validatorsPowerCap,proto3" json:"validators_power_cap,omitempty"` + // Corresponds to the maximum number of validators that can validate a consumer chain. + // Only applicable to Opt In chains. Setting `validator_set_cap` on a Top N chain is a no-op. + ValidatorSetCap uint32 `protobuf:"varint,3,opt,name=validator_set_cap,json=validatorSetCap,proto3" json:"validator_set_cap,omitempty"` + // corresponds to a list of provider consensus addresses of validators that are the ONLY ones that can validate the consumer chain + Allowlist []string `protobuf:"bytes,4,rep,name=allowlist,proto3" json:"allowlist,omitempty"` + // corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain + Denylist []string `protobuf:"bytes,5,rep,name=denylist,proto3" json:"denylist,omitempty"` + // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. + MinStake uint64 `protobuf:"varint,6,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` + // Corresponds to whether inactive validators are allowed to validate the consumer chain. + AllowInactiveVals bool `protobuf:"varint,7,opt,name=allow_inactive_vals,json=allowInactiveVals,proto3" json:"allow_inactive_vals,omitempty"` +} + +func (m *PowerShapingParameters) Reset() { *m = PowerShapingParameters{} } +func (m *PowerShapingParameters) String() string { return proto.CompactTextString(m) } +func (*PowerShapingParameters) ProtoMessage() {} +func (*PowerShapingParameters) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{21} +} +func (m *PowerShapingParameters) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PowerShapingParameters) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PowerShapingParameters.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 *PowerShapingParameters) XXX_Merge(src proto.Message) { + xxx_messageInfo_PowerShapingParameters.Merge(m, src) +} +func (m *PowerShapingParameters) XXX_Size() int { + return m.Size() +} +func (m *PowerShapingParameters) XXX_DiscardUnknown() { + xxx_messageInfo_PowerShapingParameters.DiscardUnknown(m) +} + +var xxx_messageInfo_PowerShapingParameters proto.InternalMessageInfo + +func (m *PowerShapingParameters) GetTop_N() uint32 { + if m != nil { + return m.Top_N + } + return 0 +} + +func (m *PowerShapingParameters) GetValidatorsPowerCap() uint32 { + if m != nil { + return m.ValidatorsPowerCap + } + return 0 +} + +func (m *PowerShapingParameters) GetValidatorSetCap() uint32 { + if m != nil { + return m.ValidatorSetCap + } + return 0 +} + +func (m *PowerShapingParameters) GetAllowlist() []string { + if m != nil { + return m.Allowlist + } + return nil +} + +func (m *PowerShapingParameters) GetDenylist() []string { + if m != nil { + return m.Denylist + } + return nil +} + +func (m *PowerShapingParameters) GetMinStake() uint64 { + if m != nil { + return m.MinStake + } + return 0 +} + +func (m *PowerShapingParameters) GetAllowInactiveVals() bool { + if m != nil { + return m.AllowInactiveVals + } + return false +} + +// ConsumerIds contains consumer ids of chains +// Used so we can easily (de)serialize slices of strings +type ConsumerIds struct { + Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` +} + +func (m *ConsumerIds) Reset() { *m = ConsumerIds{} } +func (m *ConsumerIds) String() string { return proto.CompactTextString(m) } +func (*ConsumerIds) ProtoMessage() {} +func (*ConsumerIds) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{22} +} +func (m *ConsumerIds) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerIds) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerIds.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 *ConsumerIds) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerIds.Merge(m, src) +} +func (m *ConsumerIds) XXX_Size() int { + return m.Size() +} +func (m *ConsumerIds) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerIds.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerIds proto.InternalMessageInfo + +func (m *ConsumerIds) GetIds() []string { + if m != nil { + return m.Ids + } + return nil +} + func init() { proto.RegisterType((*ConsumerAdditionProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerAdditionProposal") proto.RegisterType((*ConsumerRemovalProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerRemovalProposal") @@ -1392,6 +1771,10 @@ func init() { proto.RegisterType((*ConsumerAddrsToPruneV2)(nil), "interchain_security.ccv.provider.v1.ConsumerAddrsToPruneV2") proto.RegisterType((*ConsensusValidator)(nil), "interchain_security.ccv.provider.v1.ConsensusValidator") proto.RegisterType((*ConsumerRewardsAllocation)(nil), "interchain_security.ccv.provider.v1.ConsumerRewardsAllocation") + proto.RegisterType((*ConsumerMetadata)(nil), "interchain_security.ccv.provider.v1.ConsumerMetadata") + proto.RegisterType((*ConsumerInitializationParameters)(nil), "interchain_security.ccv.provider.v1.ConsumerInitializationParameters") + proto.RegisterType((*PowerShapingParameters)(nil), "interchain_security.ccv.provider.v1.PowerShapingParameters") + proto.RegisterType((*ConsumerIds)(nil), "interchain_security.ccv.provider.v1.ConsumerIds") } func init() { @@ -1399,129 +1782,140 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 1946 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6f, 0x1b, 0xc7, - 0x15, 0xd7, 0x8a, 0x94, 0x44, 0x0e, 0xf5, 0x39, 0x52, 0xec, 0x95, 0xa2, 0x92, 0x34, 0x53, 0x1b, - 0x6c, 0x5c, 0x2f, 0x23, 0x05, 0x05, 0x0c, 0xb7, 0x81, 0x21, 0x51, 0x4e, 0x6c, 0xa9, 0x71, 0xd8, - 0x15, 0xa1, 0x00, 0xe9, 0x61, 0x31, 0x9c, 0x1d, 0x91, 0x53, 0xed, 0xee, 0xac, 0x67, 0x86, 0x2b, - 0xf3, 0xd2, 0x73, 0x2f, 0x05, 0xd2, 0x5b, 0xd0, 0x4b, 0x73, 0x2c, 0x7a, 0xea, 0xa1, 0xe8, 0x1f, - 0xd0, 0x53, 0x50, 0xa0, 0x68, 0x8e, 0x3d, 0x25, 0x85, 0x7d, 0xe8, 0xa1, 0x40, 0xaf, 0xbd, 0x16, - 0x33, 0xfb, 0xc1, 0xa5, 0x3e, 0x1c, 0x1a, 0x69, 0x2e, 0xd2, 0xee, 0x7b, 0xbf, 0xf7, 0x9b, 0x37, - 0x33, 0xef, 0x8b, 0x0b, 0x76, 0x69, 0x20, 0x09, 0xc7, 0x03, 0x44, 0x03, 0x47, 0x10, 0x3c, 0xe4, - 0x54, 0x8e, 0x5a, 0x18, 0x47, 0xad, 0x90, 0xb3, 0x88, 0xba, 0x84, 0xb7, 0xa2, 0x9d, 0xec, 0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f, 0x51, 0x1d, 0x24, 0x21, 0x16, - 0x33, 0x7d, 0xa6, 0x98, 0x56, 0x32, 0xe3, 0x8e, 0xb6, 0x85, 0x3f, 0x03, 0x10, 0xe3, 0x48, 0xbb, - 0xc4, 0x86, 0x32, 0x65, 0x2c, 0x4f, 0xcf, 0xb8, 0x8a, 0x71, 0xd4, 0x8d, 0xad, 0x13, 0xca, 0x9f, - 0x83, 0x9b, 0x92, 0xa3, 0x40, 0x9c, 0x12, 0x7e, 0x91, 0x17, 0x4c, 0xcf, 0xfb, 0x46, 0xca, 0x31, - 0x49, 0xfe, 0x18, 0xd4, 0x71, 0x12, 0x40, 0x0e, 0x27, 0x2e, 0x15, 0x92, 0xd3, 0xde, 0x50, 0xd9, - 0x3a, 0xa7, 0x1c, 0x61, 0x1d, 0x23, 0x15, 0x1d, 0x04, 0xd5, 0x14, 0x67, 0x4f, 0xc0, 0xde, 0x4f, - 0x50, 0xf0, 0x23, 0xf0, 0xfd, 0x9e, 0xc7, 0xf0, 0x99, 0x50, 0xce, 0x39, 0x13, 0x4c, 0x7a, 0x69, - 0x9f, 0x0a, 0xa1, 0xd8, 0x16, 0xeb, 0x46, 0xb3, 0x60, 0xdf, 0x8a, 0xb1, 0x1d, 0xc2, 0x0f, 0x72, - 0xc8, 0x6e, 0x0e, 0x08, 0xef, 0x01, 0x38, 0xa0, 0x42, 0x32, 0x4e, 0x31, 0xf2, 0x1c, 0x12, 0x48, - 0x4e, 0x89, 0x30, 0x97, 0xb4, 0xf9, 0xda, 0x58, 0xf3, 0x28, 0x56, 0xc0, 0x43, 0x70, 0xeb, 0xda, - 0x45, 0x1d, 0x3c, 0x40, 0x41, 0x40, 0x3c, 0x73, 0x59, 0x6f, 0xa5, 0xe6, 0x5e, 0xb3, 0x66, 0x3b, - 0x86, 0xc1, 0x75, 0x30, 0x27, 0x59, 0xe8, 0x3c, 0x35, 0x57, 0xea, 0x46, 0x73, 0xc9, 0x2e, 0x4a, - 0x16, 0x3e, 0x85, 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1b, 0xc7, + 0xf5, 0xd7, 0x8a, 0x94, 0x44, 0x0e, 0xf5, 0x83, 0x1a, 0x3b, 0xf6, 0x4a, 0xd1, 0x97, 0xa4, 0x37, + 0x5f, 0x1b, 0x6c, 0x5c, 0x2f, 0x23, 0x05, 0x05, 0x0c, 0xb7, 0x81, 0x21, 0x51, 0x4e, 0x2c, 0xa9, + 0x71, 0xd8, 0x95, 0xa0, 0x00, 0xe9, 0x61, 0x31, 0xdc, 0x1d, 0x91, 0x53, 0xed, 0xee, 0xac, 0x67, + 0x86, 0x2b, 0xb3, 0x87, 0x9e, 0x8b, 0x02, 0x05, 0xd2, 0x9e, 0x82, 0x5e, 0x9a, 0x63, 0xd1, 0x53, + 0x0f, 0x45, 0xff, 0x80, 0x9e, 0x82, 0x02, 0x45, 0x73, 0xec, 0x29, 0x29, 0xec, 0x43, 0x0f, 0x05, + 0x7a, 0xed, 0xb5, 0x98, 0xd9, 0x1f, 0x5c, 0xea, 0x97, 0x69, 0x58, 0xee, 0x45, 0xda, 0x79, 0xef, + 0xf3, 0xde, 0xbc, 0x99, 0x79, 0xbf, 0x66, 0x08, 0x36, 0x48, 0x20, 0x30, 0x73, 0xfa, 0x88, 0x04, + 0x36, 0xc7, 0xce, 0x80, 0x11, 0x31, 0x6c, 0x39, 0x4e, 0xd4, 0x0a, 0x19, 0x8d, 0x88, 0x8b, 0x59, + 0x2b, 0x5a, 0xcf, 0xbe, 0xcd, 0x90, 0x51, 0x41, 0xe1, 0x3b, 0xe7, 0xc8, 0x98, 0x8e, 0x13, 0x99, + 0x19, 0x2e, 0x5a, 0x5f, 0xbd, 0x7d, 0x91, 0xe2, 0x68, 0xbd, 0x75, 0x42, 0x18, 0x8e, 0x75, 0xad, + 0x5e, 0xef, 0xd1, 0x1e, 0x55, 0x9f, 0x2d, 0xf9, 0x95, 0x50, 0xeb, 0x3d, 0x4a, 0x7b, 0x1e, 0x6e, + 0xa9, 0x51, 0x77, 0x70, 0xd4, 0x12, 0xc4, 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d, 0xcb, 0x67, 0x2e, 0xbb, 0x96, 0xcf, 0x4e, 0x76, 0x2d, + 0x9f, 0xbb, 0xe8, 0x5a, 0x5e, 0x07, 0x95, 0x2c, 0x41, 0xb8, 0x1c, 0x56, 0x41, 0x81, 0xb8, 0x69, + 0x33, 0x29, 0x3f, 0xb7, 0x3e, 0xfd, 0xea, 0x79, 0x4d, 0xfb, 0xfa, 0x79, 0x4d, 0xfb, 0xc7, 0xf3, + 0x9a, 0xf6, 0xf9, 0x8b, 0xda, 0xd4, 0xd7, 0x2f, 0x6a, 0x53, 0x7f, 0x7f, 0x51, 0x9b, 0xfa, 0xec, + 0x83, 0xb3, 0xd9, 0x6f, 0x54, 0x5d, 0xee, 0x65, 0xbf, 0x00, 0x44, 0xdf, 0x6b, 0x3d, 0x1b, 0xff, + 0x7d, 0x41, 0x25, 0xc6, 0xee, 0xac, 0x72, 0xec, 0xf7, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x45, + 0xe0, 0x33, 0x4d, 0x90, 0x18, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -2589,14 +2983,264 @@ func (m *ConsumerRewardsAllocation) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func encodeVarintProvider(dAtA []byte, offset int, v uint64) int { - offset -= sovProvider(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } +func (m *ConsumerMetadata) 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 *ConsumerMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ConsumerInitializationParameters) 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 *ConsumerInitializationParameters) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerInitializationParameters) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DistributionTransmissionChannel) > 0 { + i -= len(m.DistributionTransmissionChannel) + copy(dAtA[i:], m.DistributionTransmissionChannel) + i = encodeVarintProvider(dAtA, i, uint64(len(m.DistributionTransmissionChannel))) + i-- + dAtA[i] = 0x5a + } + if m.HistoricalEntries != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.HistoricalEntries)) + i-- + dAtA[i] = 0x50 + } + if m.BlocksPerDistributionTransmission != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) + i-- + dAtA[i] = 0x48 + } + if len(m.ConsumerRedistributionFraction) > 0 { + i -= len(m.ConsumerRedistributionFraction) + copy(dAtA[i:], m.ConsumerRedistributionFraction) + i = encodeVarintProvider(dAtA, i, uint64(len(m.ConsumerRedistributionFraction))) + i-- + dAtA[i] = 0x42 + } + n17, err17 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) + if err17 != nil { + return 0, err17 + } + i -= n17 + i = encodeVarintProvider(dAtA, i, uint64(n17)) + i-- + dAtA[i] = 0x3a + n18, err18 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err18 != nil { + return 0, err18 + } + i -= n18 + i = encodeVarintProvider(dAtA, i, uint64(n18)) + i-- + dAtA[i] = 0x32 + n19, err19 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err19 != nil { + return 0, err19 + } + i -= n19 + i = encodeVarintProvider(dAtA, i, uint64(n19)) + i-- + dAtA[i] = 0x2a + n20, err20 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.SpawnTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SpawnTime):]) + if err20 != nil { + return 0, err20 + } + i -= n20 + i = encodeVarintProvider(dAtA, i, uint64(n20)) + i-- + dAtA[i] = 0x22 + if len(m.BinaryHash) > 0 { + i -= len(m.BinaryHash) + copy(dAtA[i:], m.BinaryHash) + i = encodeVarintProvider(dAtA, i, uint64(len(m.BinaryHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.GenesisHash) > 0 { + i -= len(m.GenesisHash) + copy(dAtA[i:], m.GenesisHash) + i = encodeVarintProvider(dAtA, i, uint64(len(m.GenesisHash))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.InitialHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProvider(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *PowerShapingParameters) 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 *PowerShapingParameters) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PowerShapingParameters) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AllowInactiveVals { + i-- + if m.AllowInactiveVals { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.MinStake != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.MinStake)) + i-- + dAtA[i] = 0x30 + } + if len(m.Denylist) > 0 { + for iNdEx := len(m.Denylist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denylist[iNdEx]) + copy(dAtA[i:], m.Denylist[iNdEx]) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Denylist[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Allowlist) > 0 { + for iNdEx := len(m.Allowlist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Allowlist[iNdEx]) + copy(dAtA[i:], m.Allowlist[iNdEx]) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Allowlist[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.ValidatorSetCap != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.ValidatorSetCap)) + i-- + dAtA[i] = 0x18 + } + if m.ValidatorsPowerCap != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.ValidatorsPowerCap)) + i-- + dAtA[i] = 0x10 + } + if m.Top_N != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.Top_N)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ConsumerIds) 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 *ConsumerIds) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerIds) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ids) > 0 { + for iNdEx := len(m.Ids) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Ids[iNdEx]) + copy(dAtA[i:], m.Ids[iNdEx]) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Ids[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintProvider(dAtA []byte, offset int, v uint64) int { + offset -= sovProvider(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } dAtA[offset] = uint8(v) return base } @@ -3072,39 +3716,152 @@ func (m *ConsumerRewardsAllocation) Size() (n int) { return n } -func sovProvider(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozProvider(x uint64) (n int) { - return sovProvider(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func (m *ConsumerMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + return n } -func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowProvider - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ConsumerAdditionProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ConsumerAdditionProposal: illegal tag %d (wire type %d)", fieldNum, wire) + +func (m *ConsumerInitializationParameters) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.InitialHeight.Size() + n += 1 + l + sovProvider(uint64(l)) + l = len(m.GenesisHash) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = len(m.BinaryHash) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SpawnTime) + n += 1 + l + sovProvider(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod) + n += 1 + l + sovProvider(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod) + n += 1 + l + sovProvider(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod) + n += 1 + l + sovProvider(uint64(l)) + l = len(m.ConsumerRedistributionFraction) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + if m.BlocksPerDistributionTransmission != 0 { + n += 1 + sovProvider(uint64(m.BlocksPerDistributionTransmission)) + } + if m.HistoricalEntries != 0 { + n += 1 + sovProvider(uint64(m.HistoricalEntries)) + } + l = len(m.DistributionTransmissionChannel) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + return n +} + +func (m *PowerShapingParameters) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Top_N != 0 { + n += 1 + sovProvider(uint64(m.Top_N)) + } + if m.ValidatorsPowerCap != 0 { + n += 1 + sovProvider(uint64(m.ValidatorsPowerCap)) + } + if m.ValidatorSetCap != 0 { + n += 1 + sovProvider(uint64(m.ValidatorSetCap)) + } + if len(m.Allowlist) > 0 { + for _, s := range m.Allowlist { + l = len(s) + n += 1 + l + sovProvider(uint64(l)) + } + } + if len(m.Denylist) > 0 { + for _, s := range m.Denylist { + l = len(s) + n += 1 + l + sovProvider(uint64(l)) + } + } + if m.MinStake != 0 { + n += 1 + sovProvider(uint64(m.MinStake)) + } + if m.AllowInactiveVals { + n += 2 + } + return n +} + +func (m *ConsumerIds) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Ids) > 0 { + for _, s := range m.Ids { + l = len(s) + n += 1 + l + sovProvider(uint64(l)) + } + } + return n +} + +func sovProvider(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozProvider(x uint64) (n int) { + return sovProvider(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ConsumerAdditionProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConsumerAdditionProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerAdditionProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -6368,6 +7125,829 @@ func (m *ConsumerRewardsAllocation) Unmarshal(dAtA []byte) error { } return nil } +func (m *ConsumerMetadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConsumerMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsumerInitializationParameters) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConsumerInitializationParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerInitializationParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InitialHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GenesisHash = append(m.GenesisHash[:0], dAtA[iNdEx:postIndex]...) + if m.GenesisHash == nil { + m.GenesisHash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BinaryHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BinaryHash = append(m.BinaryHash[:0], dAtA[iNdEx:postIndex]...) + if m.BinaryHash == nil { + m.BinaryHash = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpawnTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.SpawnTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.CcvTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferTimeoutPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.TransferTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRedistributionFraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerDistributionTransmission", wireType) + } + m.BlocksPerDistributionTransmission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) + } + m.HistoricalEntries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HistoricalEntries |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionTransmissionChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DistributionTransmissionChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PowerShapingParameters) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PowerShapingParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PowerShapingParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Top_N", wireType) + } + m.Top_N = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Top_N |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsPowerCap", wireType) + } + m.ValidatorsPowerCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorsPowerCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSetCap", wireType) + } + m.ValidatorSetCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorSetCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowlist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Allowlist = append(m.Allowlist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denylist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + m.MinStake = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinStake |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowInactiveVals", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AllowInactiveVals = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsumerIds) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ConsumerIds: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerIds: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + 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 ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ids = append(m.Ids, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipProvider(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index bc7866140f..aee4e3d717 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -9,6 +9,7 @@ import ( fmt "fmt" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/cosmos-proto" + types1 "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -38,7 +39,9 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryConsumerGenesisRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerGenesisRequest) Reset() { *m = QueryConsumerGenesisRequest{} } @@ -74,6 +77,7 @@ func (m *QueryConsumerGenesisRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerGenesisRequest proto.InternalMessageInfo +// Deprecated: Do not use. func (m *QueryConsumerGenesisRequest) GetChainId() string { if m != nil { return m.ChainId @@ -81,6 +85,13 @@ func (m *QueryConsumerGenesisRequest) GetChainId() string { return "" } +func (m *QueryConsumerGenesisRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryConsumerGenesisResponse struct { GenesisState types.ConsumerGenesisState `protobuf:"bytes,1,opt,name=genesis_state,json=genesisState,proto3" json:"genesis_state"` } @@ -483,10 +494,12 @@ func (m *Chain) GetDenylist() []string { } type QueryValidatorConsumerAddrRequest struct { - // The id of the consumer chain - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,2,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` + // The id of the consumer chain + ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorConsumerAddrRequest) Reset() { *m = QueryValidatorConsumerAddrRequest{} } @@ -568,10 +581,12 @@ func (m *QueryValidatorConsumerAddrResponse) GetConsumerAddress() string { } type QueryValidatorProviderAddrRequest struct { - // The id of the provider chain - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The consensus address of the validator on the consumer chain ConsumerAddress string `protobuf:"bytes,2,opt,name=consumer_address,json=consumerAddress,proto3" json:"consumer_address,omitempty" yaml:"address"` + // The id of the consumer chain + ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorProviderAddrRequest) Reset() { *m = QueryValidatorProviderAddrRequest{} } @@ -922,8 +937,10 @@ func (m *QueryProposedChainIDsResponse) GetProposedChains() []ProposedChain { } type ProposedChain struct { - ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"` // Deprecated: Do not use. ProposalID uint64 `protobuf:"varint,2,opt,name=proposalID,proto3" json:"proposalID,omitempty"` + ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *ProposedChain) Reset() { *m = ProposedChain{} } @@ -959,6 +976,7 @@ func (m *ProposedChain) XXX_DiscardUnknown() { var xxx_messageInfo_ProposedChain proto.InternalMessageInfo +// Deprecated: Do not use. func (m *ProposedChain) GetChainID() string { if m != nil { return m.ChainID @@ -973,9 +991,18 @@ func (m *ProposedChain) GetProposalID() uint64 { return 0 } +func (m *ProposedChain) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryAllPairsValConAddrByConsumerChainIDRequest struct { + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The id of the consumer chain - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Reset() { @@ -1015,6 +1042,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest proto.InternalMessageInfo +// Deprecated: Do not use. func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetChainId() string { if m != nil { return m.ChainId @@ -1022,6 +1050,13 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetChainId() string { return "" } +func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryAllPairsValConAddrByConsumerChainIDResponse struct { PairValConAddr []*PairValConAddrProviderAndConsumer `protobuf:"bytes,1,rep,name=pair_val_con_addr,json=pairValConAddr,proto3" json:"pair_val_con_addr,omitempty"` } @@ -1213,7 +1248,9 @@ func (m *QueryParamsResponse) GetParams() Params { } type QueryConsumerChainOptedInValidatorsRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerChainOptedInValidatorsRequest) Reset() { @@ -1253,6 +1290,7 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerChainOptedInValidatorsRequest proto.InternalMessageInfo +// Deprecated: Do not use. func (m *QueryConsumerChainOptedInValidatorsRequest) GetChainId() string { if m != nil { return m.ChainId @@ -1260,6 +1298,13 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) GetChainId() string { return "" } +func (m *QueryConsumerChainOptedInValidatorsRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryConsumerChainOptedInValidatorsResponse struct { // The consensus addresses of the validators on the provider chain ValidatorsProviderAddresses []string `protobuf:"bytes,1,rep,name=validators_provider_addresses,json=validatorsProviderAddresses,proto3" json:"validators_provider_addresses,omitempty"` @@ -1310,7 +1355,9 @@ func (m *QueryConsumerChainOptedInValidatorsResponse) GetValidatorsProviderAddre } type QueryConsumerValidatorsRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerValidatorsRequest) Reset() { *m = QueryConsumerValidatorsRequest{} } @@ -1346,6 +1393,7 @@ func (m *QueryConsumerValidatorsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerValidatorsRequest proto.InternalMessageInfo +// Deprecated: Do not use. func (m *QueryConsumerValidatorsRequest) GetChainId() string { if m != nil { return m.ChainId @@ -1353,15 +1401,42 @@ func (m *QueryConsumerValidatorsRequest) GetChainId() string { return "" } +func (m *QueryConsumerValidatorsRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryConsumerValidatorsValidator struct { // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,1,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` // The consumer public key of the validator used on the consumer chain ConsumerKey *crypto.PublicKey `protobuf:"bytes,2,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` + // [DEPRECATED] use `consumer_power` instead + Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"` // Deprecated: Do not use. + // [DEPRECATED] use `consumer_commission_rate` instead + Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` // Deprecated: Do not use. // The power of the validator used on the consumer chain - Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"` + ConsumerPower int64 `protobuf:"varint,5,opt,name=consumer_power,json=consumerPower,proto3" json:"consumer_power,omitempty"` // The rate to charge delegators on the consumer chain, as a fraction - Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` + ConsumerCommissionRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=consumer_commission_rate,json=consumerCommissionRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"consumer_commission_rate"` + // The rate to charge delegators on the provider chain, as a fraction + ProviderCommissionRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=provider_commission_rate,json=providerCommissionRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"provider_commission_rate"` + // description defines the description terms for the validator + Description types1.Description `protobuf:"bytes,8,opt,name=description,proto3" json:"description"` + // provider_operator_address defines the address of the validator's operator + ProviderOperatorAddress string `protobuf:"bytes,9,opt,name=provider_operator_address,json=providerOperatorAddress,proto3" json:"provider_operator_address,omitempty"` + // jailed defined whether the validator has been jailed from bonded status or not. + Jailed bool `protobuf:"varint,10,opt,name=jailed,proto3" json:"jailed,omitempty"` + // status is the validator status (bonded/unbonding/unbonded). + Status types1.BondStatus `protobuf:"varint,11,opt,name=status,proto3,enum=cosmos.staking.v1beta1.BondStatus" json:"status,omitempty"` + // provider_tokens defines the delegated tokens (incl. self-delegation). + ProviderTokens cosmossdk_io_math.Int `protobuf:"bytes,12,opt,name=provider_tokens,json=providerTokens,proto3,customtype=cosmossdk.io/math.Int" json:"provider_tokens"` + // The power of the validator used on the provider chain + ProviderPower int64 `protobuf:"varint,13,opt,name=provider_power,json=providerPower,proto3" json:"provider_power,omitempty"` + // validates_current_epoch defines whether the validator has to validate for the current epoch or not + ValidatesCurrentEpoch bool `protobuf:"varint,14,opt,name=validates_current_epoch,json=validatesCurrentEpoch,proto3" json:"validates_current_epoch,omitempty"` } func (m *QueryConsumerValidatorsValidator) Reset() { *m = QueryConsumerValidatorsValidator{} } @@ -1411,6 +1486,7 @@ func (m *QueryConsumerValidatorsValidator) GetConsumerKey() *crypto.PublicKey { return nil } +// Deprecated: Do not use. func (m *QueryConsumerValidatorsValidator) GetPower() int64 { if m != nil { return m.Power @@ -1418,6 +1494,55 @@ func (m *QueryConsumerValidatorsValidator) GetPower() int64 { return 0 } +func (m *QueryConsumerValidatorsValidator) GetConsumerPower() int64 { + if m != nil { + return m.ConsumerPower + } + return 0 +} + +func (m *QueryConsumerValidatorsValidator) GetDescription() types1.Description { + if m != nil { + return m.Description + } + return types1.Description{} +} + +func (m *QueryConsumerValidatorsValidator) GetProviderOperatorAddress() string { + if m != nil { + return m.ProviderOperatorAddress + } + return "" +} + +func (m *QueryConsumerValidatorsValidator) GetJailed() bool { + if m != nil { + return m.Jailed + } + return false +} + +func (m *QueryConsumerValidatorsValidator) GetStatus() types1.BondStatus { + if m != nil { + return m.Status + } + return types1.Unspecified +} + +func (m *QueryConsumerValidatorsValidator) GetProviderPower() int64 { + if m != nil { + return m.ProviderPower + } + return 0 +} + +func (m *QueryConsumerValidatorsValidator) GetValidatesCurrentEpoch() bool { + if m != nil { + return m.ValidatesCurrentEpoch + } + return false +} + type QueryConsumerValidatorsResponse struct { Validators []*QueryConsumerValidatorsValidator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` } @@ -1560,9 +1685,11 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) GetConsumerChainIds( } type QueryValidatorConsumerCommissionRateRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,2,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` + ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorConsumerCommissionRateRequest) Reset() { @@ -1602,6 +1729,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryValidatorConsumerCommissionRateRequest proto.InternalMessageInfo +// Deprecated: Do not use. func (m *QueryValidatorConsumerCommissionRateRequest) GetChainId() string { if m != nil { return m.ChainId @@ -1616,6 +1744,13 @@ func (m *QueryValidatorConsumerCommissionRateRequest) GetProviderAddress() strin return "" } +func (m *QueryValidatorConsumerCommissionRateRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryValidatorConsumerCommissionRateResponse struct { // The rate to charge delegators on the consumer chain, as a fraction Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` @@ -1739,6 +1874,97 @@ func (m *QueryBlocksUntilNextEpochResponse) GetBlocksUntilNextEpoch() uint64 { return 0 } +type QueryConsumerIdFromClientIdRequest struct { + // the client id (on the provider) that is tracking the consumer chain + // the client id can be found from the consumer chain by querying (i.e., `query ccvconsumer provider-info`) + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (m *QueryConsumerIdFromClientIdRequest) Reset() { *m = QueryConsumerIdFromClientIdRequest{} } +func (m *QueryConsumerIdFromClientIdRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerIdFromClientIdRequest) ProtoMessage() {} +func (*QueryConsumerIdFromClientIdRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_422512d7b7586cd7, []int{36} +} +func (m *QueryConsumerIdFromClientIdRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerIdFromClientIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerIdFromClientIdRequest.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 *QueryConsumerIdFromClientIdRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerIdFromClientIdRequest.Merge(m, src) +} +func (m *QueryConsumerIdFromClientIdRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerIdFromClientIdRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerIdFromClientIdRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerIdFromClientIdRequest proto.InternalMessageInfo + +func (m *QueryConsumerIdFromClientIdRequest) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +type QueryConsumerIdFromClientIdResponse struct { + // the consumer id of the chain associated with this client id + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` +} + +func (m *QueryConsumerIdFromClientIdResponse) Reset() { *m = QueryConsumerIdFromClientIdResponse{} } +func (m *QueryConsumerIdFromClientIdResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerIdFromClientIdResponse) ProtoMessage() {} +func (*QueryConsumerIdFromClientIdResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_422512d7b7586cd7, []int{37} +} +func (m *QueryConsumerIdFromClientIdResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerIdFromClientIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerIdFromClientIdResponse.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 *QueryConsumerIdFromClientIdResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerIdFromClientIdResponse.Merge(m, src) +} +func (m *QueryConsumerIdFromClientIdResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerIdFromClientIdResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerIdFromClientIdResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerIdFromClientIdResponse proto.InternalMessageInfo + +func (m *QueryConsumerIdFromClientIdResponse) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + func init() { proto.RegisterType((*QueryConsumerGenesisRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerGenesisRequest") proto.RegisterType((*QueryConsumerGenesisResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerGenesisResponse") @@ -1776,6 +2002,8 @@ func init() { proto.RegisterType((*QueryValidatorConsumerCommissionRateResponse)(nil), "interchain_security.ccv.provider.v1.QueryValidatorConsumerCommissionRateResponse") proto.RegisterType((*QueryBlocksUntilNextEpochRequest)(nil), "interchain_security.ccv.provider.v1.QueryBlocksUntilNextEpochRequest") proto.RegisterType((*QueryBlocksUntilNextEpochResponse)(nil), "interchain_security.ccv.provider.v1.QueryBlocksUntilNextEpochResponse") + proto.RegisterType((*QueryConsumerIdFromClientIdRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerIdFromClientIdRequest") + proto.RegisterType((*QueryConsumerIdFromClientIdResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerIdFromClientIdResponse") } func init() { @@ -1783,133 +2011,159 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2002 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x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 0x6f, 0x47, 0x4c, 0x7b, 0xd6, 0x49, 0xd9, 0x3e, - 0x84, 0xbf, 0x29, 0x81, 0xaf, 0xe7, 0x61, 0x62, 0x70, 0x67, 0x84, 0xc6, 0x24, 0x93, 0x5d, 0xca, - 0x1f, 0x1c, 0x21, 0xa2, 0x88, 0xd4, 0x23, 0x1e, 0xa9, 0x87, 0xf0, 0x7b, 0x45, 0x22, 0x15, 0x43, - 0x19, 0x01, 0x63, 0x4c, 0x64, 0x55, 0x56, 0xbc, 0xfe, 0xd5, 0xd9, 0x06, 0x27, 0x4e, 0xdc, 0xe6, - 0x28, 0xef, 0x10, 0x51, 0x54, 0xb6, 0x46, 0x03, 0x19, 0xa1, 0xef, 0xcf, 0x3e, 0x59, 0xff, 0x94, - 0xc4, 0x9f, 0x07, 0x59, 0xec, 0x18, 0x16, 0x78, 0x7a, 0xe9, 0xc3, 0xc0, 0xe5, 0x1b, 0xa3, 0xc2, - 0x14, 0xef, 0x00, 0x7b, 0x90, 0xf9, 0xea, 0x77, 0x3f, 0x7b, 0x51, 0x96, 0x3e, 0x7f, 0x51, 0x96, - 0xfe, 0xfa, 0xa2, 0x2c, 0x7d, 0xf2, 0xb2, 0x3c, 0xf6, 0xf9, 0xcb, 0xf2, 0xd8, 0x9f, 0x5e, 0x96, - 0xc7, 0x1e, 0x5e, 0xab, 0xdb, 0x6c, 0xff, 0x70, 0x4f, 0x35, 0x49, 0x43, 0xfc, 0xa1, 0x9d, 0x58, - 0xe5, 0xdb, 0xf1, 0x2a, 0xcd, 0x4b, 0xda, 0xd3, 0x8e, 0x8e, 0xac, 0xe5, 0x61, 0xba, 0x37, 0xc9, - 0xff, 0xc9, 0xb8, 0xf8, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x36, 0xa0, 0x9e, 0x70, 0x20, - 0x00, 0x00, + // 2427 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x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a6, 0x74, 0x37, 0x3b, 0x38, + 0xc7, 0x15, 0x8e, 0x8a, 0x43, 0x36, 0x36, 0xef, 0xc2, 0x79, 0x00, 0x6b, 0x9a, 0x21, 0x99, 0xf8, + 0x91, 0x13, 0xdf, 0x86, 0xe4, 0x4a, 0x0c, 0xcd, 0x71, 0x85, 0x41, 0x71, 0xa2, 0xa6, 0x19, 0xeb, + 0xce, 0x44, 0xc5, 0xd8, 0x74, 0x64, 0x17, 0xc0, 0x64, 0x43, 0xd6, 0x35, 0x55, 0xb6, 0xb1, 0x45, + 0xd8, 0x12, 0x45, 0x36, 0xb3, 0xc3, 0x14, 0x0f, 0x06, 0x73, 0x74, 0x51, 0x59, 0x36, 0xe1, 0x3c, + 0x78, 0xcd, 0x1f, 0x95, 0x08, 0xb2, 0xa9, 0xf8, 0x08, 0x15, 0x3f, 0xe6, 0x4f, 0x6c, 0x20, 0xdb, + 0x91, 0x9d, 0x01, 0x63, 0xb2, 0xae, 0xe3, 0x47, 0xba, 0x46, 0xec, 0xec, 0x91, 0xb9, 0xc1, 0xc2, + 0x98, 0x18, 0x0c, 0xc0, 0x1c, 0x18, 0x55, 0x91, 0xd1, 0xa4, 0x93, 0xa3, 0x74, 0xd2, 0xff, 0xe6, + 0x7f, 0xc5, 0x81, 0x33, 0xf4, 0x8c, 0x1e, 0x78, 0x90, 0xa1, 0x20, 0xb0, 0x52, 0xde, 0xf3, 0x6b, + 0xe0, 0x55, 0xef, 0x48, 0x24, 0x59, 0x55, 0x2d, 0x44, 0x88, 0xeb, 0xc1, 0x12, 0xfc, 0xf2, 0x79, + 0x7e, 0xa2, 0x29, 0xd7, 0xf4, 0xab, 0x3c, 0x9b, 0xe0, 0xc5, 0x63, 0x9e, 0xec, 0xb2, 0x3b, 0x12, + 0x4f, 0x13, 0x83, 0xf1, 0x34, 0x71, 0x75, 0xf4, 0x83, 0x8f, 0xf2, 0x03, 0x7f, 0xff, 0x28, 0x3f, + 0xc0, 0xdf, 0x03, 0xfc, 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xab, 0x6a, 0xf6, 0x6e, + 0x7d, 0xa7, 0xa8, 0xe0, 0x1a, 0xfb, 0x27, 0xad, 0xd0, 0x2e, 0x97, 0xfd, 0x5d, 0x1a, 0x6f, 0x08, + 0x8f, 0x63, 0x65, 0x7a, 0xd3, 0x44, 0x64, 0x67, 0x84, 0xfe, 0x10, 0xfe, 0xfa, 0xff, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x69, 0x3e, 0x82, 0x9f, 0x44, 0x27, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1970,6 +2224,9 @@ type QueryClient interface { // QueryBlocksUntilNextEpoch returns the number of blocks until the next epoch // starts and validator updates are sent to the consumer chains QueryBlocksUntilNextEpoch(ctx context.Context, in *QueryBlocksUntilNextEpochRequest, opts ...grpc.CallOption) (*QueryBlocksUntilNextEpochResponse, error) + // QueryConsumerIdFromClientId returns the consumer id of the chain + // associated with the provided client id + QueryConsumerIdFromClientId(ctx context.Context, in *QueryConsumerIdFromClientIdRequest, opts ...grpc.CallOption) (*QueryConsumerIdFromClientIdResponse, error) } type queryClient struct { @@ -2124,6 +2381,15 @@ func (c *queryClient) QueryBlocksUntilNextEpoch(ctx context.Context, in *QueryBl return out, nil } +func (c *queryClient) QueryConsumerIdFromClientId(ctx context.Context, in *QueryConsumerIdFromClientIdRequest, opts ...grpc.CallOption) (*QueryConsumerIdFromClientIdResponse, error) { + out := new(QueryConsumerIdFromClientIdResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryConsumerIdFromClientId", 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 @@ -2172,6 +2438,9 @@ type QueryServer interface { // QueryBlocksUntilNextEpoch returns the number of blocks until the next epoch // starts and validator updates are sent to the consumer chains QueryBlocksUntilNextEpoch(context.Context, *QueryBlocksUntilNextEpochRequest) (*QueryBlocksUntilNextEpochResponse, error) + // QueryConsumerIdFromClientId returns the consumer id of the chain + // associated with the provided client id + QueryConsumerIdFromClientId(context.Context, *QueryConsumerIdFromClientIdRequest) (*QueryConsumerIdFromClientIdResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2226,6 +2495,9 @@ func (*UnimplementedQueryServer) QueryConsumerValidators(ctx context.Context, re func (*UnimplementedQueryServer) QueryBlocksUntilNextEpoch(ctx context.Context, req *QueryBlocksUntilNextEpochRequest) (*QueryBlocksUntilNextEpochResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryBlocksUntilNextEpoch not implemented") } +func (*UnimplementedQueryServer) QueryConsumerIdFromClientId(ctx context.Context, req *QueryConsumerIdFromClientIdRequest) (*QueryConsumerIdFromClientIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerIdFromClientId not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2519,6 +2791,24 @@ func _Query_QueryBlocksUntilNextEpoch_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Query_QueryConsumerIdFromClientId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConsumerIdFromClientIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryConsumerIdFromClientId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryConsumerIdFromClientId", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryConsumerIdFromClientId(ctx, req.(*QueryConsumerIdFromClientIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.provider.v1.Query", HandlerType: (*QueryServer)(nil), @@ -2587,6 +2877,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryBlocksUntilNextEpoch", Handler: _Query_QueryBlocksUntilNextEpoch_Handler, }, + { + MethodName: "QueryConsumerIdFromClientId", + Handler: _Query_QueryConsumerIdFromClientId_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/provider/v1/query.proto", @@ -2612,6 +2906,13 @@ func (m *QueryConsumerGenesisRequest) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x12 + } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -2926,6 +3227,13 @@ func (m *QueryValidatorConsumerAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x1a + } if len(m.ProviderAddress) > 0 { i -= len(m.ProviderAddress) copy(dAtA[i:], m.ProviderAddress) @@ -2993,6 +3301,13 @@ func (m *QueryValidatorProviderAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x1a + } if len(m.ConsumerAddress) > 0 { i -= len(m.ConsumerAddress) copy(dAtA[i:], m.ConsumerAddress) @@ -3239,6 +3554,13 @@ func (m *ProposedChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x1a + } if m.ProposalID != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.ProposalID)) i-- @@ -3274,6 +3596,13 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) MarshalToSizedBuffer(d _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x12 + } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -3446,6 +3775,13 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) MarshalToSizedBuffer(dAtA [ _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x12 + } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -3508,6 +3844,13 @@ func (m *QueryConsumerValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x12 + } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -3538,6 +3881,88 @@ func (m *QueryConsumerValidatorsValidator) MarshalToSizedBuffer(dAtA []byte) (in _ = i var l int _ = l + if m.ValidatesCurrentEpoch { + i-- + if m.ValidatesCurrentEpoch { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x70 + } + if m.ProviderPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProviderPower)) + i-- + dAtA[i] = 0x68 + } + { + size := m.ProviderTokens.Size() + i -= size + if _, err := m.ProviderTokens.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x58 + } + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x50 + } + if len(m.ProviderOperatorAddress) > 0 { + i -= len(m.ProviderOperatorAddress) + copy(dAtA[i:], m.ProviderOperatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ProviderOperatorAddress))) + i-- + dAtA[i] = 0x4a + } + { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.ProviderCommissionRate.Size() + i -= size + if _, err := m.ProviderCommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.ConsumerCommissionRate.Size() + i -= size + if _, err := m.ConsumerCommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.ConsumerPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ConsumerPower)) + i-- + dAtA[i] = 0x28 + } { size := m.Rate.Size() i -= size @@ -3694,6 +4119,13 @@ func (m *QueryValidatorConsumerCommissionRateRequest) MarshalToSizedBuffer(dAtA _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x1a + } if len(m.ProviderAddress) > 0 { i -= len(m.ProviderAddress) copy(dAtA[i:], m.ProviderAddress) @@ -3795,42 +4227,106 @@ func (m *QueryBlocksUntilNextEpochResponse) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryConsumerIdFromClientIdRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *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 *QueryConsumerIdFromClientIdRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryConsumerGenesisResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryConsumerIdFromClientIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.GenesisState.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryConsumerChainsRequest) Size() (n int) { +func (m *QueryConsumerIdFromClientIdResponse) 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 *QueryConsumerIdFromClientIdResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsumerIdFromClientIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + 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)) + } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConsumerGenesisResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.GenesisState.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryConsumerChainsRequest) Size() (n int) { if m == nil { return 0 } @@ -3953,6 +4449,10 @@ func (m *QueryValidatorConsumerAddrRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -3983,6 +4483,10 @@ func (m *QueryValidatorProviderAddrRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4086,6 +4590,10 @@ func (m *ProposedChain) Size() (n int) { if m.ProposalID != 0 { n += 1 + sovQuery(uint64(m.ProposalID)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4099,6 +4607,10 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4168,6 +4680,10 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4196,6 +4712,10 @@ func (m *QueryConsumerValidatorsRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4218,6 +4738,33 @@ func (m *QueryConsumerValidatorsValidator) Size() (n int) { } l = m.Rate.Size() n += 1 + l + sovQuery(uint64(l)) + if m.ConsumerPower != 0 { + n += 1 + sovQuery(uint64(m.ConsumerPower)) + } + l = m.ConsumerCommissionRate.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.ProviderCommissionRate.Size() + n += 1 + l + sovQuery(uint64(l)) + l = m.Description.Size() + n += 1 + l + sovQuery(uint64(l)) + l = len(m.ProviderOperatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Jailed { + n += 2 + } + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + l = m.ProviderTokens.Size() + n += 1 + l + sovQuery(uint64(l)) + if m.ProviderPower != 0 { + n += 1 + sovQuery(uint64(m.ProviderPower)) + } + if m.ValidatesCurrentEpoch { + n += 2 + } return n } @@ -4278,6 +4825,10 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4313,6 +4864,32 @@ func (m *QueryBlocksUntilNextEpochResponse) Size() (n int) { return n } +func (m *QueryConsumerIdFromClientIdRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConsumerIdFromClientIdResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4380,6 +4957,38 @@ func (m *QueryConsumerGenesisRequest) Unmarshal(dAtA []byte) error { } m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5237,6 +5846,38 @@ func (m *QueryValidatorConsumerAddrRequest) Unmarshal(dAtA []byte) error { } m.ProviderAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5433,6 +6074,38 @@ func (m *QueryValidatorProviderAddrRequest) Unmarshal(dAtA []byte) error { } m.ConsumerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6053,6 +6726,38 @@ func (m *ProposedChain) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6135,23 +6840,55 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) } 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 + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - iNdEx += skippy - } - } - - if iNdEx > l { + 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.ConsumerId = 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 @@ -6584,6 +7321,38 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) Unmarshal(dAtA []byte) erro } m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6748,6 +7517,38 @@ func (m *QueryConsumerValidatorsRequest) Unmarshal(dAtA []byte) error { } m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6919,61 +7720,30 @@ func (m *QueryConsumerValidatorsValidator) Unmarshal(dAtA []byte) error { 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 *QueryConsumerValidatorsResponse) 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 + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerPower", wireType) } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.ConsumerPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ConsumerPower |= int64(b&0x7F) << shift + if b < 0x80 { + break + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryConsumerValidatorsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerValidatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerCommissionRate", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -6983,79 +7753,29 @@ func (m *QueryConsumerValidatorsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Validators = append(m.Validators, &QueryConsumerValidatorsValidator{}) - if err := m.Validators[len(m.Validators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ConsumerCommissionRate.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 *QueryConsumerChainsValidatorHasToValidateRequest) 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: QueryConsumerChainsValidatorHasToValidateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainsValidatorHasToValidateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderCommissionRate", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7083,29 +7803,374 @@ func (m *QueryConsumerChainsValidatorHasToValidateRequest) Unmarshal(dAtA []byte if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { + if err := m.ProviderCommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} + 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.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderOperatorAddress", 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.ProviderOperatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= types1.BondStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderTokens", 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 + } + if err := m.ProviderTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderPower", wireType) + } + m.ProviderPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ProviderPower |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatesCurrentEpoch", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ValidatesCurrentEpoch = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryConsumerValidatorsResponse) 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: QueryConsumerValidatorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerValidatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Validators = append(m.Validators, &QueryConsumerValidatorsValidator{}) + if err := m.Validators[len(m.Validators)-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 *QueryConsumerChainsValidatorHasToValidateRequest) 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: QueryConsumerChainsValidatorHasToValidateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerChainsValidatorHasToValidateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddress", 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.ProviderAddress = 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 *QueryConsumerChainsValidatorHasToValidateResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -7281,6 +8346,38 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Unmarshal(dAtA []byte) err } m.ProviderAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7505,6 +8602,170 @@ func (m *QueryBlocksUntilNextEpochResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryConsumerIdFromClientIdRequest) 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: QueryConsumerIdFromClientIdRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerIdFromClientIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", 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.ClientId = 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 *QueryConsumerIdFromClientIdResponse) 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: QueryConsumerIdFromClientIdResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerIdFromClientIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = 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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index a115ace156..a533712da9 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -33,6 +33,10 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +var ( + filter_Query_QueryConsumerGenesis_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerGenesisRequest var metadata runtime.ServerMetadata @@ -55,6 +59,13 @@ func request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.QueryConsumerGenesis(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -82,6 +93,85 @@ func local_request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryConsumerGenesis(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_QueryConsumerGenesis_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerGenesisRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryConsumerGenesis(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerGenesisRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.QueryConsumerGenesis(ctx, &protoReq) return msg, metadata, err @@ -268,13 +358,31 @@ func local_request_Query_QueryProposedConsumerChainIDs_0(ctx context.Context, ma } var ( - filter_Query_QueryAllPairsValConAddrByConsumerChainID_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_QueryAllPairsValConAddrByConsumerChainID_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -291,6 +399,24 @@ func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context. var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -303,6 +429,78 @@ func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context. } +var ( + filter_Query_QueryAllPairsValConAddrByConsumerChainID_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest var metadata runtime.ServerMetadata @@ -321,6 +519,10 @@ func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_QueryConsumerChainOptedInValidators_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerChainOptedInValidatorsRequest var metadata runtime.ServerMetadata @@ -343,6 +545,13 @@ func request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, ma return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.QueryConsumerChainOptedInValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -370,6 +579,85 @@ func local_request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Conte return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryConsumerChainOptedInValidators(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_QueryConsumerChainOptedInValidators_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerChainOptedInValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryConsumerChainOptedInValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerChainOptedInValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.QueryConsumerChainOptedInValidators(ctx, &protoReq) return msg, metadata, err @@ -429,6 +717,10 @@ func local_request_Query_QueryConsumerChainsValidatorHasToValidate_0(ctx context } +var ( + filter_Query_QueryValidatorConsumerCommissionRate_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0, "provider_address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + func request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryValidatorConsumerCommissionRateRequest var metadata runtime.ServerMetadata @@ -462,6 +754,13 @@ func request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, m return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.QueryValidatorConsumerCommissionRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -500,11 +799,116 @@ func local_request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Cont return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.QueryValidatorConsumerCommissionRate(ctx, &protoReq) return msg, metadata, err } +var ( + filter_Query_QueryValidatorConsumerCommissionRate_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0, "provider_address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Query_QueryValidatorConsumerCommissionRate_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorConsumerCommissionRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") + } + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryValidatorConsumerCommissionRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryValidatorConsumerCommissionRate_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorConsumerCommissionRateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") + } + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryValidatorConsumerCommissionRate(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_QueryConsumerValidators_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerValidatorsRequest var metadata runtime.ServerMetadata @@ -527,6 +931,13 @@ func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runt return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.QueryConsumerValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -551,28 +962,161 @@ func local_request_Query_QueryConsumerValidators_0(ctx context.Context, marshale protoReq.ChainId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryConsumerValidators(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_QueryConsumerValidators_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_QueryConsumerValidators_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryConsumerValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryConsumerValidators_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerValidatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryConsumerValidators(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryBlocksUntilNextEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlocksUntilNextEpochRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryBlocksUntilNextEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryBlocksUntilNextEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlocksUntilNextEpochRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryBlocksUntilNextEpoch(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryConsumerIdFromClientId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerIdFromClientIdRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } + + protoReq.ClientId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) } - msg, err := server.QueryConsumerValidators(ctx, &protoReq) + msg, err := client.QueryConsumerIdFromClientId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Query_QueryBlocksUntilNextEpoch_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBlocksUntilNextEpochRequest +func local_request_Query_QueryConsumerIdFromClientId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerIdFromClientIdRequest var metadata runtime.ServerMetadata - msg, err := client.QueryBlocksUntilNextEpoch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err + var ( + val string + ok bool + err error + _ = err + ) -} + val, ok = pathParams["client_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "client_id") + } -func local_request_Query_QueryBlocksUntilNextEpoch_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBlocksUntilNextEpochRequest - var metadata runtime.ServerMetadata + protoReq.ClientId, err = runtime.String(val) - msg, err := server.QueryBlocksUntilNextEpoch(ctx, &protoReq) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "client_id", err) + } + + msg, err := server.QueryConsumerIdFromClientId(ctx, &protoReq) return msg, metadata, err } @@ -606,6 +1150,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryConsumerGenesis_1, 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_QueryConsumerGenesis_1(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_QueryConsumerGenesis_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -813,6 +1380,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1, 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_QueryAllPairsValConAddrByConsumerChainID_1(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_QueryAllPairsValConAddrByConsumerChainID_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -859,6 +1449,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryConsumerChainOptedInValidators_1, 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_QueryConsumerChainOptedInValidators_1(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_QueryConsumerChainOptedInValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerChainsValidatorHasToValidate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -905,6 +1518,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryValidatorConsumerCommissionRate_1, 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_QueryValidatorConsumerCommissionRate_1(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_QueryValidatorConsumerCommissionRate_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerValidators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -928,6 +1564,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryConsumerValidators_1, 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_QueryConsumerValidators_1(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_QueryConsumerValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryBlocksUntilNextEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -951,6 +1610,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryConsumerIdFromClientId_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_QueryConsumerIdFromClientId_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_QueryConsumerIdFromClientId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1012,6 +1694,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryConsumerGenesis_1, 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_QueryConsumerGenesis_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryConsumerGenesis_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1192,6 +1894,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1, 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_QueryAllPairsValConAddrByConsumerChainID_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1232,6 +1954,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryConsumerChainOptedInValidators_1, 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_QueryConsumerChainOptedInValidators_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryConsumerChainOptedInValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerChainsValidatorHasToValidate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1272,6 +2014,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryValidatorConsumerCommissionRate_1, 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_QueryValidatorConsumerCommissionRate_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryValidatorConsumerCommissionRate_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryConsumerValidators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1292,6 +2054,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryConsumerValidators_1, 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_QueryConsumerValidators_1(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryConsumerValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_QueryBlocksUntilNextEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1312,12 +2094,34 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryConsumerIdFromClientId_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_QueryConsumerIdFromClientId_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_QueryConsumerIdFromClientId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_QueryConsumerGenesis_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerGenesis_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chains"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryConsumerChainStarts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chain_start_proposals"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1334,24 +2138,36 @@ var ( pattern_Query_QueryProposedConsumerChainIDs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "proposed_consumer_chains"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryConsumerChainOptedInValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "opted_in_validators", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerChainOptedInValidators_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "opted_in_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerChainsValidatorHasToValidate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_chains_per_validator", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryValidatorConsumerCommissionRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_commission_rate", "chain_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryValidatorConsumerCommissionRate_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_commission_rate", "consumer_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_validators", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerValidators_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryBlocksUntilNextEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "blocks_until_next_epoch"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryConsumerIdFromClientId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_id", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_QueryConsumerGenesis_0 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerGenesis_1 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerChains_0 = runtime.ForwardResponseMessage forward_Query_QueryConsumerChainStarts_0 = runtime.ForwardResponseMessage @@ -1370,15 +2186,25 @@ var ( forward_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.ForwardResponseMessage + forward_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.ForwardResponseMessage + forward_Query_QueryParams_0 = runtime.ForwardResponseMessage forward_Query_QueryConsumerChainOptedInValidators_0 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerChainOptedInValidators_1 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerChainsValidatorHasToValidate_0 = runtime.ForwardResponseMessage forward_Query_QueryValidatorConsumerCommissionRate_0 = runtime.ForwardResponseMessage + forward_Query_QueryValidatorConsumerCommissionRate_1 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerValidators_0 = runtime.ForwardResponseMessage + forward_Query_QueryConsumerValidators_1 = runtime.ForwardResponseMessage + forward_Query_QueryBlocksUntilNextEpoch_0 = runtime.ForwardResponseMessage + + forward_Query_QueryConsumerIdFromClientId_0 = runtime.ForwardResponseMessage ) diff --git a/x/ccv/provider/types/throttle.go b/x/ccv/provider/types/throttle.go deleted file mode 100644 index e41396eb3a..0000000000 --- a/x/ccv/provider/types/throttle.go +++ /dev/null @@ -1,17 +0,0 @@ -package types - -import ( - "time" -) - -// NewGlobalSlashEntry creates a new GlobalSlashEntry. -func NewGlobalSlashEntry(recvTime time.Time, consumerChainID string, - ibcSeqNum uint64, providerValConsAddr ProviderConsAddress, -) GlobalSlashEntry { - return GlobalSlashEntry{ - RecvTime: recvTime.UTC(), // UTC prevents serialization inconsistencies - ConsumerChainID: consumerChainID, - IbcSeqNum: ibcSeqNum, - ProviderValConsAddr: providerValConsAddr.ToSdkConsAddr(), - } -} diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 292e870a9b..b5c78c5e32 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -43,8 +43,8 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgAssignConsumerKey struct { - // The chain id of the consumer chain to assign a consensus public key to - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The validator address on the provider ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` // The consensus public key to use on the consumer. @@ -53,6 +53,8 @@ type MsgAssignConsumerKey struct { ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` // Tx signer address Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // the consumer id of the consumer chain to assign a consensus public key to + ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgAssignConsumerKey) Reset() { *m = MsgAssignConsumerKey{} } @@ -131,6 +133,8 @@ type MsgSubmitConsumerMisbehaviour struct { // The Misbehaviour of the consumer chain wrapping // two conflicting IBC headers Misbehaviour *_07_tendermint.Misbehaviour `protobuf:"bytes,2,opt,name=misbehaviour,proto3" json:"misbehaviour,omitempty"` + // the consumer id of the consumer chain where the misbehaviour occurred + ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgSubmitConsumerMisbehaviour) Reset() { *m = MsgSubmitConsumerMisbehaviour{} } @@ -211,6 +215,8 @@ type MsgSubmitConsumerDoubleVoting struct { DuplicateVoteEvidence *types.DuplicateVoteEvidence `protobuf:"bytes,2,opt,name=duplicate_vote_evidence,json=duplicateVoteEvidence,proto3" json:"duplicate_vote_evidence,omitempty"` // The light client header of the infraction block InfractionBlockHeader *_07_tendermint.Header `protobuf:"bytes,3,opt,name=infraction_block_header,json=infractionBlockHeader,proto3" json:"infraction_block_header,omitempty"` + // the consumer id of the consumer chain where the double-voting took place + ConsumerId string `protobuf:"bytes,4,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgSubmitConsumerDoubleVoting) Reset() { *m = MsgSubmitConsumerDoubleVoting{} } @@ -373,12 +379,7 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -// MsgConsumerAddition defines the message used to spawn a new consumer chain using a v1 governance proposal. -// If it passes, then all validators on the provider chain are expected to validate -// the consumer chain at spawn time or get slashed. -// It is recommended that spawn time occurs after the proposal end time. -// -// Note: this replaces ConsumerAdditionProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgCreateConsumer` instead type MsgConsumerAddition struct { // the proposed chain-id of the new consumer chain, must be different from all // other consumer chain ids of the executing provider chain. @@ -663,12 +664,7 @@ func (m *MsgConsumerAdditionResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgConsumerAdditionResponse proto.InternalMessageInfo -// MsgConsumerRemoval message contains a governance proposal on the provider chain to -// remove (and stop) a consumer chain. If it passes, all the consumer chain's -// state is removed from the provider chain. The outstanding unbonding operation -// funds are released. -// -// Note: this replaces ConsumerRemovalProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgRemoveConsumer` instead type MsgConsumerRemoval struct { // the chain-id of the consumer chain to be stopped ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -770,6 +766,109 @@ func (m *MsgConsumerRemovalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgConsumerRemovalResponse proto.InternalMessageInfo +// MsgRemoveConsumer defines the message used to remove (and stop) a consumer chain. +// If it passes, all the consumer chain's state is eventually removed from the provider chain. +type MsgRemoveConsumer struct { + // the consumer id of the consumer chain to be stopped + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + // the time on the provider chain at which all validators are responsible to + // stop their consumer chain validator node + StopTime time.Time `protobuf:"bytes,2,opt,name=stop_time,json=stopTime,proto3,stdtime" json:"stop_time"` + // signer address + Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` +} + +func (m *MsgRemoveConsumer) Reset() { *m = MsgRemoveConsumer{} } +func (m *MsgRemoveConsumer) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveConsumer) ProtoMessage() {} +func (*MsgRemoveConsumer) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{12} +} +func (m *MsgRemoveConsumer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveConsumer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveConsumer.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 *MsgRemoveConsumer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveConsumer.Merge(m, src) +} +func (m *MsgRemoveConsumer) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveConsumer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveConsumer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveConsumer proto.InternalMessageInfo + +func (m *MsgRemoveConsumer) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + +func (m *MsgRemoveConsumer) GetStopTime() time.Time { + if m != nil { + return m.StopTime + } + return time.Time{} +} + +func (m *MsgRemoveConsumer) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +// MsgRemoveConsumerResponse defines response type for MsgRemoveConsumer messages +type MsgRemoveConsumerResponse struct { +} + +func (m *MsgRemoveConsumerResponse) Reset() { *m = MsgRemoveConsumerResponse{} } +func (m *MsgRemoveConsumerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveConsumerResponse) ProtoMessage() {} +func (*MsgRemoveConsumerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{13} +} +func (m *MsgRemoveConsumerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveConsumerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveConsumerResponse.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 *MsgRemoveConsumerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveConsumerResponse.Merge(m, src) +} +func (m *MsgRemoveConsumerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveConsumerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveConsumerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveConsumerResponse proto.InternalMessageInfo + // ChangeRewardDenomsProposal is a governance proposal on the provider chain to // mutate the set of denoms accepted by the provider as rewards. // @@ -787,7 +886,7 @@ func (m *MsgChangeRewardDenoms) Reset() { *m = MsgChangeRewardDenoms{} } func (m *MsgChangeRewardDenoms) String() string { return proto.CompactTextString(m) } func (*MsgChangeRewardDenoms) ProtoMessage() {} func (*MsgChangeRewardDenoms) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{12} + return fileDescriptor_43221a4391e9fbf4, []int{14} } func (m *MsgChangeRewardDenoms) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -845,7 +944,7 @@ func (m *MsgChangeRewardDenomsResponse) Reset() { *m = MsgChangeRewardDe func (m *MsgChangeRewardDenomsResponse) String() string { return proto.CompactTextString(m) } func (*MsgChangeRewardDenomsResponse) ProtoMessage() {} func (*MsgChangeRewardDenomsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{13} + return fileDescriptor_43221a4391e9fbf4, []int{15} } func (m *MsgChangeRewardDenomsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -875,8 +974,8 @@ func (m *MsgChangeRewardDenomsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgChangeRewardDenomsResponse proto.InternalMessageInfo type MsgOptIn struct { - // the chain id of the consumer chain to opt in to - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // the validator address on the provider ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` // (optional) The consensus public key to use on the consumer in json string format corresponding to proto-any, @@ -886,13 +985,15 @@ type MsgOptIn struct { ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` // signer address Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // the consumer id of the consumer chain to opt in to + ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgOptIn) Reset() { *m = MsgOptIn{} } func (m *MsgOptIn) String() string { return proto.CompactTextString(m) } func (*MsgOptIn) ProtoMessage() {} func (*MsgOptIn) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{14} + return fileDescriptor_43221a4391e9fbf4, []int{16} } func (m *MsgOptIn) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -928,7 +1029,7 @@ func (m *MsgOptInResponse) Reset() { *m = MsgOptInResponse{} } func (m *MsgOptInResponse) String() string { return proto.CompactTextString(m) } func (*MsgOptInResponse) ProtoMessage() {} func (*MsgOptInResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{15} + return fileDescriptor_43221a4391e9fbf4, []int{17} } func (m *MsgOptInResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -958,19 +1059,21 @@ func (m *MsgOptInResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgOptInResponse proto.InternalMessageInfo type MsgOptOut struct { - // the chain id of the consumer chain to opt out from - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // the validator address on the provider ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` // signer address Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` + // the consumer id of the consumer chain to opt out from + ConsumerId string `protobuf:"bytes,4,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgOptOut) Reset() { *m = MsgOptOut{} } func (m *MsgOptOut) String() string { return proto.CompactTextString(m) } func (*MsgOptOut) ProtoMessage() {} func (*MsgOptOut) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{16} + return fileDescriptor_43221a4391e9fbf4, []int{18} } func (m *MsgOptOut) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1006,7 +1109,7 @@ func (m *MsgOptOutResponse) Reset() { *m = MsgOptOutResponse{} } func (m *MsgOptOutResponse) String() string { return proto.CompactTextString(m) } func (*MsgOptOutResponse) ProtoMessage() {} func (*MsgOptOutResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{17} + return fileDescriptor_43221a4391e9fbf4, []int{19} } func (m *MsgOptOutResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1040,20 +1143,22 @@ var xxx_messageInfo_MsgOptOutResponse proto.InternalMessageInfo type MsgSetConsumerCommissionRate struct { // The validator address on the provider ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` - // The chain id of the consumer chain to set a commission rate - ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // [DEPRECATED] use `consumer_id` instead + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The rate to charge delegators on the consumer chain, as a fraction // TODO: migrate rate from sdk.Dec to math.LegacyDec Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` // signer address Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // the consumer id of the consumer chain to set the commission rate + ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerCommissionRate{} } func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRate) ProtoMessage() {} func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{18} + return fileDescriptor_43221a4391e9fbf4, []int{20} } func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1089,7 +1194,7 @@ func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetCons func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{19} + return fileDescriptor_43221a4391e9fbf4, []int{21} } func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1118,11 +1223,7 @@ func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo -// MsgConsumerModification message contains a governance proposal on the provider chain to -// modify a running consumer chain. If it passes, the consumer chain's -// parameters are updated. -// -// Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon +// [DEPRECATED] Use `MsgUpdateConsumer` instead type MsgConsumerModification struct { // the title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -1161,7 +1262,7 @@ func (m *MsgConsumerModification) Reset() { *m = MsgConsumerModification func (m *MsgConsumerModification) String() string { return proto.CompactTextString(m) } func (*MsgConsumerModification) ProtoMessage() {} func (*MsgConsumerModification) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{20} + return fileDescriptor_43221a4391e9fbf4, []int{22} } func (m *MsgConsumerModification) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1274,7 +1375,7 @@ func (m *MsgConsumerModificationResponse) Reset() { *m = MsgConsumerModi func (m *MsgConsumerModificationResponse) String() string { return proto.CompactTextString(m) } func (*MsgConsumerModificationResponse) ProtoMessage() {} func (*MsgConsumerModificationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{21} + return fileDescriptor_43221a4391e9fbf4, []int{23} } func (m *MsgConsumerModificationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1303,6 +1404,258 @@ func (m *MsgConsumerModificationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgConsumerModificationResponse proto.InternalMessageInfo +// MsgCreateConsumer defines the message that creates a consumer chain +type MsgCreateConsumer struct { + // signer address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // the chain id of the new consumer chain + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Metadata ConsumerMetadata `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata"` + InitializationParameters *ConsumerInitializationParameters `protobuf:"bytes,4,opt,name=initialization_parameters,json=initializationParameters,proto3" json:"initialization_parameters,omitempty"` + PowerShapingParameters *PowerShapingParameters `protobuf:"bytes,5,opt,name=power_shaping_parameters,json=powerShapingParameters,proto3" json:"power_shaping_parameters,omitempty"` +} + +func (m *MsgCreateConsumer) Reset() { *m = MsgCreateConsumer{} } +func (m *MsgCreateConsumer) String() string { return proto.CompactTextString(m) } +func (*MsgCreateConsumer) ProtoMessage() {} +func (*MsgCreateConsumer) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{24} +} +func (m *MsgCreateConsumer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateConsumer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateConsumer.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 *MsgCreateConsumer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateConsumer.Merge(m, src) +} +func (m *MsgCreateConsumer) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateConsumer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateConsumer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateConsumer proto.InternalMessageInfo + +func (m *MsgCreateConsumer) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgCreateConsumer) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *MsgCreateConsumer) GetMetadata() ConsumerMetadata { + if m != nil { + return m.Metadata + } + return ConsumerMetadata{} +} + +func (m *MsgCreateConsumer) GetInitializationParameters() *ConsumerInitializationParameters { + if m != nil { + return m.InitializationParameters + } + return nil +} + +func (m *MsgCreateConsumer) GetPowerShapingParameters() *PowerShapingParameters { + if m != nil { + return m.PowerShapingParameters + } + return nil +} + +// MsgCreateConsumerResponse defines response type for MsgCreateConsumer +type MsgCreateConsumerResponse struct { + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` +} + +func (m *MsgCreateConsumerResponse) Reset() { *m = MsgCreateConsumerResponse{} } +func (m *MsgCreateConsumerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateConsumerResponse) ProtoMessage() {} +func (*MsgCreateConsumerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{25} +} +func (m *MsgCreateConsumerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateConsumerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateConsumerResponse.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 *MsgCreateConsumerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateConsumerResponse.Merge(m, src) +} +func (m *MsgCreateConsumerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateConsumerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateConsumerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateConsumerResponse proto.InternalMessageInfo + +func (m *MsgCreateConsumerResponse) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + +// MsgUpdateConsumer defines the message used to modify a consumer chain. +type MsgUpdateConsumer struct { + // signer address + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // the consumer id of the consumer chain to be updated + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + // the new owner of the consumer when updated + NewOwnerAddress string `protobuf:"bytes,3,opt,name=new_owner_address,json=newOwnerAddress,proto3" json:"new_owner_address,omitempty"` + // the metadata of the consumer when updated + Metadata *ConsumerMetadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // initialization parameters can only be updated before a chain has launched + InitializationParameters *ConsumerInitializationParameters `protobuf:"bytes,5,opt,name=initialization_parameters,json=initializationParameters,proto3" json:"initialization_parameters,omitempty"` + // the power-shaping parameters of the consumer when updated + PowerShapingParameters *PowerShapingParameters `protobuf:"bytes,6,opt,name=power_shaping_parameters,json=powerShapingParameters,proto3" json:"power_shaping_parameters,omitempty"` +} + +func (m *MsgUpdateConsumer) Reset() { *m = MsgUpdateConsumer{} } +func (m *MsgUpdateConsumer) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateConsumer) ProtoMessage() {} +func (*MsgUpdateConsumer) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{26} +} +func (m *MsgUpdateConsumer) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateConsumer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateConsumer.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 *MsgUpdateConsumer) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateConsumer.Merge(m, src) +} +func (m *MsgUpdateConsumer) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateConsumer) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateConsumer.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateConsumer proto.InternalMessageInfo + +func (m *MsgUpdateConsumer) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgUpdateConsumer) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + +func (m *MsgUpdateConsumer) GetNewOwnerAddress() string { + if m != nil { + return m.NewOwnerAddress + } + return "" +} + +func (m *MsgUpdateConsumer) GetMetadata() *ConsumerMetadata { + if m != nil { + return m.Metadata + } + return nil +} + +func (m *MsgUpdateConsumer) GetInitializationParameters() *ConsumerInitializationParameters { + if m != nil { + return m.InitializationParameters + } + return nil +} + +func (m *MsgUpdateConsumer) GetPowerShapingParameters() *PowerShapingParameters { + if m != nil { + return m.PowerShapingParameters + } + return nil +} + +// MsgUpdateConsumerResponse defines response type for MsgUpdateConsumer messages +type MsgUpdateConsumerResponse struct { +} + +func (m *MsgUpdateConsumerResponse) Reset() { *m = MsgUpdateConsumerResponse{} } +func (m *MsgUpdateConsumerResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateConsumerResponse) ProtoMessage() {} +func (*MsgUpdateConsumerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{27} +} +func (m *MsgUpdateConsumerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateConsumerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateConsumerResponse.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 *MsgUpdateConsumerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateConsumerResponse.Merge(m, src) +} +func (m *MsgUpdateConsumerResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateConsumerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateConsumerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateConsumerResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgAssignConsumerKey)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKey") proto.RegisterType((*MsgAssignConsumerKeyResponse)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKeyResponse") @@ -1316,6 +1669,8 @@ func init() { proto.RegisterType((*MsgConsumerAdditionResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerAdditionResponse") proto.RegisterType((*MsgConsumerRemoval)(nil), "interchain_security.ccv.provider.v1.MsgConsumerRemoval") proto.RegisterType((*MsgConsumerRemovalResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerRemovalResponse") + proto.RegisterType((*MsgRemoveConsumer)(nil), "interchain_security.ccv.provider.v1.MsgRemoveConsumer") + proto.RegisterType((*MsgRemoveConsumerResponse)(nil), "interchain_security.ccv.provider.v1.MsgRemoveConsumerResponse") proto.RegisterType((*MsgChangeRewardDenoms)(nil), "interchain_security.ccv.provider.v1.MsgChangeRewardDenoms") proto.RegisterType((*MsgChangeRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.MsgChangeRewardDenomsResponse") proto.RegisterType((*MsgOptIn)(nil), "interchain_security.ccv.provider.v1.MsgOptIn") @@ -1326,6 +1681,10 @@ func init() { proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRateResponse") proto.RegisterType((*MsgConsumerModification)(nil), "interchain_security.ccv.provider.v1.MsgConsumerModification") proto.RegisterType((*MsgConsumerModificationResponse)(nil), "interchain_security.ccv.provider.v1.MsgConsumerModificationResponse") + proto.RegisterType((*MsgCreateConsumer)(nil), "interchain_security.ccv.provider.v1.MsgCreateConsumer") + proto.RegisterType((*MsgCreateConsumerResponse)(nil), "interchain_security.ccv.provider.v1.MsgCreateConsumerResponse") + proto.RegisterType((*MsgUpdateConsumer)(nil), "interchain_security.ccv.provider.v1.MsgUpdateConsumer") + proto.RegisterType((*MsgUpdateConsumerResponse)(nil), "interchain_security.ccv.provider.v1.MsgUpdateConsumerResponse") } func init() { @@ -1333,118 +1692,137 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 1764 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x8f, 0x1c, 0x47, - 0x15, 0xdf, 0xf6, 0x7e, 0x78, 0xe6, 0xcd, 0x7e, 0xf6, 0xae, 0xd9, 0xd9, 0xb6, 0x33, 0xb3, 0x5e, - 0x42, 0xb2, 0x32, 0xd9, 0xee, 0xd8, 0x90, 0x04, 0x56, 0x41, 0xb0, 0x1f, 0x06, 0x6f, 0x60, 0xed, - 0xa5, 0x6d, 0x8c, 0x04, 0x12, 0xad, 0x9a, 0xee, 0x72, 0x4f, 0xc9, 0xdd, 0x5d, 0xad, 0xae, 0x9a, - 0x71, 0xe6, 0x16, 0xe5, 0x84, 0x84, 0x84, 0x82, 0xc4, 0x01, 0x71, 0xca, 0x01, 0x21, 0x21, 0x01, - 0xf2, 0x21, 0x27, 0x6e, 0xdc, 0x7c, 0x8c, 0x22, 0x0e, 0x28, 0x07, 0x83, 0xec, 0x43, 0x38, 0xf3, - 0x17, 0xa0, 0xaa, 0xae, 0xee, 0xe9, 0xd9, 0x99, 0x9d, 0xf4, 0x8e, 0xc3, 0x21, 0x97, 0xd1, 0x74, - 0xbd, 0xdf, 0xfb, 0xd5, 0xef, 0xbd, 0xea, 0x7a, 0xaf, 0xaa, 0xe1, 0x35, 0x12, 0x71, 0x9c, 0xb8, - 0x6d, 0x44, 0x22, 0x87, 0x61, 0xb7, 0x93, 0x10, 0xde, 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0xe6, 0x94, 0xad, 0x08, 0x76, - 0x17, 0x65, 0x3c, 0x39, 0xf5, 0xd6, 0x06, 0xac, 0x9f, 0x52, 0x99, 0x47, 0xf0, 0x69, 0x05, 0x56, - 0x8f, 0x99, 0x9f, 0x45, 0xb9, 0xe7, 0x79, 0x44, 0x64, 0x69, 0x5c, 0x01, 0xf8, 0x01, 0x2c, 0x92, - 0x88, 0x70, 0x82, 0x02, 0xa7, 0x8d, 0x45, 0xea, 0x95, 0x60, 0x43, 0x2e, 0x86, 0x28, 0x7a, 0xa6, - 0x2a, 0x75, 0x72, 0x01, 0x04, 0x42, 0xe9, 0x5b, 0x50, 0x7e, 0xe9, 0xa0, 0x28, 0x08, 0x3e, 0x8e, - 0x30, 0x23, 0xcc, 0x69, 0x23, 0xd6, 0x96, 0x6b, 0x3a, 0x6f, 0xd7, 0xd4, 0xd8, 0x2d, 0xc4, 0xda, - 0x7a, 0x13, 0x6a, 0x2d, 0x12, 0xa1, 0xa4, 0x97, 0x22, 0x66, 0x24, 0x02, 0xd2, 0x21, 0x09, 0x38, - 0x00, 0x60, 0x31, 0x7a, 0x14, 0x39, 0xa2, 0x0d, 0xd4, 0x67, 0x95, 0x90, 0xb4, 0xc4, 0x9b, 0x59, - 0x89, 0x37, 0xef, 0x65, 0x3d, 0x62, 0xbf, 0x22, 0x84, 0x7c, 0xf0, 0xaf, 0xa6, 0x66, 0x57, 0xa5, - 0x9f, 0xb0, 0xe8, 0xb7, 0x61, 0xb9, 0x13, 0xb5, 0x68, 0xe4, 0x91, 0xc8, 0x77, 0x62, 0x9c, 0x10, - 0xea, 0xd5, 0xe7, 0x24, 0xd5, 0xc6, 0x10, 0xd5, 0xa1, 0xea, 0x26, 0x29, 0xd3, 0xef, 0x04, 0xd3, - 0x52, 0xee, 0x7c, 0x22, 0x7d, 0xf5, 0x1f, 0x83, 0xee, 0xba, 0x5d, 0x29, 0x89, 0x76, 0x78, 0xc6, - 0x78, 0xb1, 0x3c, 0xe3, 0xb2, 0xeb, 0x76, 0xef, 0xa5, 0xde, 0x8a, 0xf2, 0xe7, 0xb0, 0xce, 0x13, - 0x14, 0xb1, 0x07, 0x38, 0x39, 0xcd, 0x5b, 0x29, 0xcf, 0x7b, 0x29, 0xe3, 0x18, 0x24, 0xbf, 0x05, - 0x9b, 0x79, 0x65, 0x4e, 0xb0, 0x47, 0x18, 0x4f, 0x48, 0xab, 0x23, 0x37, 0x5d, 0xb6, 0x6d, 0xea, - 0x55, 0xf9, 0x12, 0x34, 0x32, 0x9c, 0x3d, 0x00, 0xfb, 0xbe, 0x42, 0xe9, 0x77, 0xe0, 0x65, 0xb9, - 0x4d, 0x99, 0x10, 0xe7, 0x0c, 0x30, 0xc9, 0xa9, 0x43, 0xc2, 0x98, 0x60, 0x83, 0x4d, 0x6d, 0x7b, - 0xda, 0xbe, 0x9a, 0x62, 0x4f, 0x70, 0x72, 0x58, 0x40, 0xde, 0x2b, 0x00, 0xf5, 0x1d, 0xd0, 0xdb, - 0x84, 0x71, 0x9a, 0x10, 0x17, 0x05, 0x0e, 0x8e, 0x78, 0x42, 0x30, 0xab, 0xd7, 0xa4, 0xfb, 0x4a, - 0xdf, 0x72, 0x33, 0x35, 0xe8, 0xef, 0xc0, 0xd5, 0x33, 0x27, 0x75, 0xdc, 0x36, 0x8a, 0x22, 0x1c, - 0xd4, 0xe7, 0x65, 0x28, 0x4d, 0xef, 0x8c, 0x39, 0x0f, 0x52, 0x98, 0xbe, 0x0a, 0xb3, 0x9c, 0xc6, - 0xce, 0xed, 0xfa, 0xc2, 0xa6, 0xb6, 0xbd, 0x60, 0xcf, 0x70, 0x1a, 0xdf, 0xd6, 0x5f, 0x87, 0xb5, - 0x2e, 0x0a, 0x88, 0x87, 0x38, 0x4d, 0x98, 0x13, 0xd3, 0x47, 0x38, 0x71, 0x5c, 0x14, 0xd7, 0x17, - 0x25, 0x46, 0xef, 0xdb, 0x4e, 0x84, 0xe9, 0x00, 0xc5, 0xfa, 0x35, 0x58, 0xc9, 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7, 0x9c, 0x9f, 0xf7, 0x62, 0xcc, 0x91, 0x25, 0xbf, + 0x03, 0x96, 0x93, 0x83, 0x12, 0x62, 0x87, 0x30, 0x1e, 0x92, 0x66, 0x47, 0x9e, 0xca, 0xf8, 0x5c, + 0xe9, 0x15, 0x59, 0x04, 0x4b, 0x31, 0xce, 0xcc, 0xc0, 0xbe, 0xa5, 0x50, 0x70, 0x1f, 0xbc, 0x24, + 0xcf, 0x31, 0x13, 0xce, 0x59, 0x19, 0x26, 0x69, 0xda, 0x23, 0x8c, 0x09, 0x36, 0xb0, 0xac, 0xad, + 0x16, 0xcd, 0xab, 0x11, 0xf6, 0x00, 0x87, 0x3b, 0x29, 0xe4, 0xbd, 0x14, 0x10, 0xae, 0x01, 0xd8, + 0x22, 0x8c, 0xd3, 0x90, 0xd8, 0xa8, 0x6d, 0x61, 0x9f, 0x87, 0x04, 0x33, 0xbd, 0x2a, 0xd5, 0x67, + 0x7b, 0x92, 0xdb, 0x91, 0x00, 0xbe, 0x01, 0xae, 0x9e, 0x68, 0xd4, 0xb2, 0x5b, 0xc8, 0xf7, 0x71, + 0x5b, 0x9f, 0x94, 0xa1, 0xd4, 0x9d, 0x13, 0x6c, 0x6e, 0x47, 0x30, 0x38, 0x07, 0xc6, 0x39, 0x0d, + 0xac, 0xbb, 0xfa, 0x85, 0x65, 0x6d, 0xf5, 0x82, 0x59, 0xe2, 0x34, 0xb8, 0x0b, 0x5f, 0x03, 0xf3, + 0x5d, 0xd4, 0x26, 0x0e, 0xe2, 0x34, 0x64, 0x56, 0x40, 0x8f, 0x70, 0x68, 0xd9, 0x28, 0xd0, 0xa7, + 0x24, 0x06, 0xf6, 0x64, 0x07, 0x42, 0xb4, 0x8d, 0x02, 0x78, 0x0d, 0xcc, 0x26, 0xab, 0x16, 0xc3, + 0x5c, 0xc2, 0xa7, 0x25, 0x7c, 0x3a, 0x11, 0x1c, 0x62, 0x2e, 0xb0, 0x97, 0x41, 0x05, 0xb5, 0xdb, + 0xf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 0x5d, 0xd2, 0x1e, + 0x3f, 0x5b, 0x1a, 0xfb, 0xe8, 0xd9, 0xd2, 0xd8, 0x9f, 0x9f, 0x2d, 0x8d, 0x7d, 0xff, 0x6b, 0x2e, + 0xe1, 0xad, 0x4e, 0xd3, 0xb0, 0xa9, 0xa7, 0x7e, 0xae, 0x6d, 0xf4, 0xac, 0xae, 0x25, 0xbf, 0xb6, + 0x76, 0x6f, 0x34, 0xde, 0xce, 0xfe, 0xe4, 0x2a, 0x7f, 0x5c, 0x6a, 0x4e, 0xc8, 0x4f, 0x60, 0x5f, + 0xfc, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x52, 0x0c, 0x87, 0x39, 0xee, 0x1e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1464,6 +1842,9 @@ type MsgClient interface { SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) ConsumerAddition(ctx context.Context, in *MsgConsumerAddition, opts ...grpc.CallOption) (*MsgConsumerAdditionResponse, error) ConsumerRemoval(ctx context.Context, in *MsgConsumerRemoval, opts ...grpc.CallOption) (*MsgConsumerRemovalResponse, error) + CreateConsumer(ctx context.Context, in *MsgCreateConsumer, opts ...grpc.CallOption) (*MsgCreateConsumerResponse, error) + UpdateConsumer(ctx context.Context, in *MsgUpdateConsumer, opts ...grpc.CallOption) (*MsgUpdateConsumerResponse, error) + RemoveConsumer(ctx context.Context, in *MsgRemoveConsumer, opts ...grpc.CallOption) (*MsgRemoveConsumerResponse, error) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) @@ -1507,6 +1888,7 @@ func (c *msgClient) SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmi return out, nil } +// Deprecated: Do not use. func (c *msgClient) ConsumerAddition(ctx context.Context, in *MsgConsumerAddition, opts ...grpc.CallOption) (*MsgConsumerAdditionResponse, error) { out := new(MsgConsumerAdditionResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerAddition", in, out, opts...) @@ -1516,6 +1898,7 @@ func (c *msgClient) ConsumerAddition(ctx context.Context, in *MsgConsumerAdditio return out, nil } +// Deprecated: Do not use. func (c *msgClient) ConsumerRemoval(ctx context.Context, in *MsgConsumerRemoval, opts ...grpc.CallOption) (*MsgConsumerRemovalResponse, error) { out := new(MsgConsumerRemovalResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerRemoval", in, out, opts...) @@ -1525,6 +1908,33 @@ func (c *msgClient) ConsumerRemoval(ctx context.Context, in *MsgConsumerRemoval, return out, nil } +func (c *msgClient) CreateConsumer(ctx context.Context, in *MsgCreateConsumer, opts ...grpc.CallOption) (*MsgCreateConsumerResponse, error) { + out := new(MsgCreateConsumerResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/CreateConsumer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateConsumer(ctx context.Context, in *MsgUpdateConsumer, opts ...grpc.CallOption) (*MsgUpdateConsumerResponse, error) { + out := new(MsgUpdateConsumerResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/UpdateConsumer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveConsumer(ctx context.Context, in *MsgRemoveConsumer, opts ...grpc.CallOption) (*MsgRemoveConsumerResponse, error) { + out := new(MsgRemoveConsumerResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/RemoveConsumer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/UpdateParams", in, out, opts...) @@ -1561,6 +1971,7 @@ func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetCon return out, nil } +// Deprecated: Do not use. func (c *msgClient) ConsumerModification(ctx context.Context, in *MsgConsumerModification, opts ...grpc.CallOption) (*MsgConsumerModificationResponse, error) { out := new(MsgConsumerModificationResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/ConsumerModification", in, out, opts...) @@ -1586,6 +1997,9 @@ type MsgServer interface { SubmitConsumerDoubleVoting(context.Context, *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) ConsumerAddition(context.Context, *MsgConsumerAddition) (*MsgConsumerAdditionResponse, error) ConsumerRemoval(context.Context, *MsgConsumerRemoval) (*MsgConsumerRemovalResponse, error) + CreateConsumer(context.Context, *MsgCreateConsumer) (*MsgCreateConsumerResponse, error) + UpdateConsumer(context.Context, *MsgUpdateConsumer) (*MsgUpdateConsumerResponse, error) + RemoveConsumer(context.Context, *MsgRemoveConsumer) (*MsgRemoveConsumerResponse, error) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) OptIn(context.Context, *MsgOptIn) (*MsgOptInResponse, error) OptOut(context.Context, *MsgOptOut) (*MsgOptOutResponse, error) @@ -1613,6 +2027,15 @@ func (*UnimplementedMsgServer) ConsumerAddition(ctx context.Context, req *MsgCon func (*UnimplementedMsgServer) ConsumerRemoval(ctx context.Context, req *MsgConsumerRemoval) (*MsgConsumerRemovalResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ConsumerRemoval not implemented") } +func (*UnimplementedMsgServer) CreateConsumer(ctx context.Context, req *MsgCreateConsumer) (*MsgCreateConsumerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateConsumer not implemented") +} +func (*UnimplementedMsgServer) UpdateConsumer(ctx context.Context, req *MsgUpdateConsumer) (*MsgUpdateConsumerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateConsumer not implemented") +} +func (*UnimplementedMsgServer) RemoveConsumer(ctx context.Context, req *MsgRemoveConsumer) (*MsgRemoveConsumerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveConsumer not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -1726,8 +2149,62 @@ func _Msg_ConsumerRemoval_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } -func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateParams) +func _Msg_CreateConsumer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateConsumer) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateConsumer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/CreateConsumer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateConsumer(ctx, req.(*MsgCreateConsumer)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateConsumer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateConsumer) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateConsumer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/UpdateConsumer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateConsumer(ctx, req.(*MsgUpdateConsumer)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveConsumer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveConsumer) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveConsumer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/RemoveConsumer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveConsumer(ctx, req.(*MsgRemoveConsumer)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) if err := dec(in); err != nil { return nil, err } @@ -1858,6 +2335,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ConsumerRemoval", Handler: _Msg_ConsumerRemoval_Handler, }, + { + MethodName: "CreateConsumer", + Handler: _Msg_CreateConsumer_Handler, + }, + { + MethodName: "UpdateConsumer", + Handler: _Msg_UpdateConsumer_Handler, + }, + { + MethodName: "RemoveConsumer", + Handler: _Msg_RemoveConsumer_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -1907,6 +2396,13 @@ func (m *MsgAssignConsumerKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x2a + } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -1981,6 +2477,13 @@ func (m *MsgSubmitConsumerMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x1a + } if m.Misbehaviour != nil { { size, err := m.Misbehaviour.MarshalToSizedBuffer(dAtA[:i]) @@ -2046,6 +2549,13 @@ func (m *MsgSubmitConsumerDoubleVoting) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x22 + } if m.InfractionBlockHeader != nil { { size, err := m.InfractionBlockHeader.MarshalToSizedBuffer(dAtA[:i]) @@ -2432,6 +2942,74 @@ func (m *MsgConsumerRemovalResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *MsgRemoveConsumer) 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 *MsgRemoveConsumer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0x1a + } + n11, err11 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StopTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime):]) + if err11 != nil { + return 0, err11 + } + i -= n11 + i = encodeVarintTx(dAtA, i, uint64(n11)) + i-- + dAtA[i] = 0x12 + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveConsumerResponse) 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 *MsgRemoveConsumerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveConsumerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgChangeRewardDenoms) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2523,6 +3101,13 @@ func (m *MsgOptIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x2a + } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -2597,6 +3182,13 @@ func (m *MsgOptOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x22 + } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -2664,6 +3256,13 @@ func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, e _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x2a + } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -2843,95 +3442,311 @@ func (m *MsgConsumerModificationResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgCreateConsumer) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgAssignConsumerKey) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgCreateConsumer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.PowerShapingParameters != nil { + { + size, err := m.PowerShapingParameters.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a } - l = len(m.ProviderAddr) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.InitializationParameters != nil { + { + size, err := m.InitializationParameters.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 } - l = len(m.ConsumerKey) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + i-- + dAtA[i] = 0x1a + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 } - return n + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *MsgAssignConsumerKeyResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgCreateConsumerResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgSubmitConsumerMisbehaviour) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgCreateConsumerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateConsumerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Submitter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Misbehaviour != nil { - l = m.Misbehaviour.Size() - n += 1 + l + sovTx(uint64(l)) + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgSubmitConsumerMisbehaviourResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgUpdateConsumer) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -func (m *MsgSubmitConsumerDoubleVoting) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgUpdateConsumer) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Submitter) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.DuplicateVoteEvidence != nil { - l = m.DuplicateVoteEvidence.Size() - n += 1 + l + sovTx(uint64(l)) - } + if m.PowerShapingParameters != nil { + { + size, err := m.PowerShapingParameters.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.InitializationParameters != nil { + { + size, err := m.InitializationParameters.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if m.Metadata != nil { + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.NewOwnerAddress) > 0 { + i -= len(m.NewOwnerAddress) + copy(dAtA[i:], m.NewOwnerAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewOwnerAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateConsumerResponse) 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 *MsgUpdateConsumerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateConsumerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAssignConsumerKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerKey) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAssignConsumerKeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitConsumerMisbehaviour) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Misbehaviour != nil { + l = m.Misbehaviour.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitConsumerMisbehaviourResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitConsumerDoubleVoting) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.DuplicateVoteEvidence != nil { + l = m.DuplicateVoteEvidence.Size() + n += 1 + l + sovTx(uint64(l)) + } if m.InfractionBlockHeader != nil { l = m.InfractionBlockHeader.Size() n += 1 + l + sovTx(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3081,6 +3896,34 @@ func (m *MsgConsumerRemovalResponse) Size() (n int) { return n } +func (m *MsgRemoveConsumer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime) + n += 1 + l + sovTx(uint64(l)) + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRemoveConsumerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgChangeRewardDenoms) Size() (n int) { if m == nil { return 0 @@ -3137,6 +3980,10 @@ func (m *MsgOptIn) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3167,6 +4014,10 @@ func (m *MsgOptOut) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3199,6 +4050,10 @@ func (m *MsgSetConsumerCommissionRate) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -3272,6 +4127,88 @@ func (m *MsgConsumerModificationResponse) Size() (n int) { return n } +func (m *MsgCreateConsumer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovTx(uint64(l)) + if m.InitializationParameters != nil { + l = m.InitializationParameters.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.PowerShapingParameters != nil { + l = m.PowerShapingParameters.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateConsumerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateConsumer) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewOwnerAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.InitializationParameters != nil { + l = m.InitializationParameters.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.PowerShapingParameters != nil { + l = m.PowerShapingParameters.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateConsumerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3435,6 +4372,38 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { } m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3603,6 +4572,38 @@ func (m *MsgSubmitConsumerMisbehaviour) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3807,6 +4808,38 @@ func (m *MsgSubmitConsumerDoubleVoting) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -4899,7 +5932,7 @@ func (m *MsgConsumerRemovalResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { +func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4922,15 +5955,15 @@ func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChangeRewardDenoms: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRemoveConsumer: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChangeRewardDenoms: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRemoveConsumer: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DenomsToAdd", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4958,13 +5991,13 @@ func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DenomsToAdd = append(m.DenomsToAdd, string(dAtA[iNdEx:postIndex])) + m.ConsumerId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DenomsToRemove", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StopTime", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4974,23 +6007,24 @@ func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.DenomsToRemove = append(m.DenomsToRemove, string(dAtA[iNdEx:postIndex])) + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StopTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 { @@ -5045,7 +6079,7 @@ func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgChangeRewardDenomsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRemoveConsumerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5068,10 +6102,10 @@ func (m *MsgChangeRewardDenomsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRemoveConsumerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRemoveConsumerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -5095,7 +6129,7 @@ func (m *MsgChangeRewardDenomsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptIn) Unmarshal(dAtA []byte) error { +func (m *MsgChangeRewardDenoms) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5118,15 +6152,15 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptIn: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeRewardDenoms: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptIn: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeRewardDenoms: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToAdd", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5154,11 +6188,11 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.DenomsToAdd = append(m.DenomsToAdd, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToRemove", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5186,43 +6220,11 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.DenomsToRemove = append(m.DenomsToRemove, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerKey = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5250,7 +6252,7 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -5273,7 +6275,7 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { +func (m *MsgChangeRewardDenomsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5296,10 +6298,10 @@ func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptInResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptInResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgChangeRewardDenomsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -5323,7 +6325,7 @@ func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptOut) Unmarshal(dAtA []byte) error { +func (m *MsgOptIn) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5346,10 +6348,10 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptOut: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptIn: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptOut: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptIn: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5417,6 +6419,38 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { m.ProviderAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } @@ -5448,6 +6482,38 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { } m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -5469,7 +6535,7 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { +func (m *MsgOptInResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5492,10 +6558,10 @@ func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgOptOutResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptInResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgOptOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptInResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -5519,7 +6585,7 @@ func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { +func (m *MsgOptOut) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5542,15 +6608,15 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRate: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptOut: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptOut: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5578,11 +6644,11 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5610,11 +6676,11 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5642,13 +6708,11 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5676,7 +6740,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.ConsumerId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -5699,7 +6763,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { +func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5722,10 +6786,10 @@ func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgOptOutResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgOptOutResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -5749,7 +6813,7 @@ func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { +func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5772,15 +6836,15 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgConsumerModification: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgConsumerModification: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5808,11 +6872,11 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Title = string(dAtA[iNdEx:postIndex]) + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5840,11 +6904,11 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Description = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5872,13 +6936,15 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Top_N", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - m.Top_N = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5888,16 +6954,29 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Top_N |= uint32(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsPowerCap", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } - m.ValidatorsPowerCap = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -5907,33 +6986,127 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ValidatorsPowerCap |= uint32(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSetCap", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx } - m.ValidatorSetCap = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ValidatorSetCap |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx } - case 7: + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgConsumerModification: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgConsumerModification: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Allowlist", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5961,11 +7134,11 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Allowlist = append(m.Allowlist, string(dAtA[iNdEx:postIndex])) + m.Title = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denylist", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5993,11 +7166,11 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) + m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6025,13 +7198,13 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 10: + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Top_N", wireType) } - m.MinStake = 0 + m.Top_N = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6041,16 +7214,16 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MinStake |= uint64(b&0x7F) << shift + m.Top_N |= uint32(b&0x7F) << shift if b < 0x80 { break } } - case 11: + case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowInactiveVals", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsPowerCap", wireType) } - var v int + m.ValidatorsPowerCap = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -6060,26 +7233,179 @@ func (m *MsgConsumerModification) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.ValidatorsPowerCap |= uint32(b&0x7F) << shift if b < 0x80 { break } } - m.AllowInactiveVals = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSetCap", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx + m.ValidatorSetCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorSetCap |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Allowlist", wireType) } - iNdEx += skippy - } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Allowlist = append(m.Allowlist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denylist", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + m.MinStake = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinStake |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowInactiveVals", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AllowInactiveVals = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } if iNdEx > l { @@ -6137,6 +7463,611 @@ func (m *MsgConsumerModificationResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateConsumer) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateConsumer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateConsumer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitializationParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InitializationParameters == nil { + m.InitializationParameters = &ConsumerInitializationParameters{} + } + if err := m.InitializationParameters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PowerShapingParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PowerShapingParameters == nil { + m.PowerShapingParameters = &PowerShapingParameters{} + } + if err := m.PowerShapingParameters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateConsumerResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateConsumerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateConsumerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateConsumer) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateConsumer: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateConsumer: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewOwnerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewOwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ConsumerMetadata{} + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitializationParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InitializationParameters == nil { + m.InitializationParameters = &ConsumerInitializationParameters{} + } + if err := m.InitializationParameters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PowerShapingParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PowerShapingParameters == nil { + m.PowerShapingParameters = &PowerShapingParameters{} + } + if err := m.PowerShapingParameters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateConsumerResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateConsumerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateConsumerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index 5773461c34..b643bb1a6d 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -143,6 +143,7 @@ type BankKeeper interface { // AccountKeeper defines the expected account keeper used for simulations type AccountKeeper interface { GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI + AddressCodec() addresscodec.Codec } // IBCTransferKeeper defines the expected interface needed for distribution transfer From 2d404f002dcb257b0392e3659b6adcf9e316a6ad Mon Sep 17 00:00:00 2001 From: insumity Date: Mon, 26 Aug 2024 15:13:47 +0200 Subject: [PATCH 02/43] fixed bug on removing previous spawn time & added tests --- testutil/ibc_testing/generic_setup.go | 2 +- testutil/keeper/unit_test_helpers.go | 2 +- x/ccv/provider/keeper/keeper.go | 2 +- x/ccv/provider/keeper/msg_server.go | 57 ++- x/ccv/provider/keeper/msg_server_test.go | 112 ++++++ x/ccv/provider/keeper/permissionless.go | 240 +++++------- x/ccv/provider/keeper/permissionless_test.go | 372 +++++++++++++++---- x/ccv/provider/keeper/proposal.go | 8 +- x/ccv/provider/keeper/proposal_test.go | 8 +- 9 files changed, 535 insertions(+), 268 deletions(-) diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index d9aa02d732..12fe71a34e 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -159,7 +159,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, keeper.Initialized) - providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(providerChain.GetContext(), consumerId, coordinator.CurrentTime) // opt-in all validators lastVals, err := providerApp.GetProviderKeeper().GetLastBondedValidators(providerChain.GetContext()) diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index ef8d3a747f..b27129c543 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -283,7 +283,7 @@ func GetTestConsumerMetadata() providertypes.ConsumerMetadata { func GetTestInitializationParameters() providertypes.ConsumerInitializationParameters { initialHeight := clienttypes.NewHeight(4, 5) - spawnTime := time.Now() + spawnTime := time.Now().UTC() ccvTimeoutPeriod := types.DefaultCCVTimeoutPeriod transferTimeoutPeriod := types.DefaultTransferTimeoutPeriod unbondingPeriod := types.DefaultConsumerUnbondingPeriod diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 46f641f660..66df230b09 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -750,7 +750,7 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { } consumerIds := []string{} - for i := uint64(0); i <= latestConsumerId; i++ { + for i := uint64(0); i < latestConsumerId; i++ { consumerId := fmt.Sprintf("%d", i) phase, foundPhase := k.GetConsumerPhase(ctx, consumerId) if !foundPhase || (phase != Registered && phase != Initialized && phase != Launched) { diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 9550b7d620..eb9f9b4f75 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -106,11 +106,11 @@ func (k msgServer) RemoveConsumer( previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) if err == nil { - k.Keeper.RemoveConsumerFromToBeStoppedConsumers(ctx, consumerId, previousStopTime) + k.Keeper.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, previousStopTime) } k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime) - k.Keeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerId, msg.StopTime) + k.Keeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerId, msg.StopTime) return &types.MsgRemoveConsumerResponse{}, nil } @@ -309,20 +309,20 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateConsumer) (*types.MsgCreateConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - consumerId := k.FetchAndIncrementConsumerId(ctx) + consumerId := k.Keeper.FetchAndIncrementConsumerId(ctx) - k.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) - k.SetConsumerChainId(ctx, consumerId, msg.ChainId) - k.SetConsumerPhase(ctx, consumerId, Registered) + k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) + k.Keeper.SetConsumerChainId(ctx, consumerId, msg.ChainId) + k.Keeper.SetConsumerPhase(ctx, consumerId, Registered) - if err := k.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { + if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, "cannot set consumer metadata: %s", err.Error()) } // initialization parameters are optional and hence could be nil if msg.InitializationParameters != nil { - if err := k.SetConsumerInitializationParameters(ctx, consumerId, *msg.InitializationParameters); err != nil { + if err := k.Keeper.SetConsumerInitializationParameters(ctx, consumerId, *msg.InitializationParameters); err != nil { return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, "cannot set consumer initialization parameters: %s", err.Error()) } @@ -334,15 +334,15 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon return &types.MsgCreateConsumerResponse{}, errorsmod.Wrap(types.ErrCannotCreateTopNChain, "cannot create a Top N chain using the `MsgCreateConsumer` message; use `MsgUpdateConsumer` instead") } - if err := k.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { + if err := k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot set power shaping parameters") } } - if spawnTime, canLaunch := k.CanLaunch(ctx, consumerId); canLaunch { - k.SetConsumerPhase(ctx, consumerId, Initialized) - k.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime) + if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { + k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) + k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime) } return &types.MsgCreateConsumerResponse{ConsumerId: consumerId}, nil @@ -353,20 +353,12 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon ctx := sdk.UnwrapSDKContext(goCtx) consumerId := msg.ConsumerId - phase, found := k.GetConsumerPhase(ctx, consumerId) + phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId) if found && phase == Stopped { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPhase, "cannot update consumer chain that is in the stopped phase: %s", consumerId) } - // The new owner address can be empty, in which case the consumer chain does not change its owner. - // However, if the new owner address is not empty, we verify that it's a valid account address. - if strings.TrimSpace(msg.NewOwnerAddress) != "" { - if _, err := k.accountKeeper.AddressCodec().StringToBytes(msg.NewOwnerAddress); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidNewOwnerAddress, "invalid new owner address %s", msg.NewOwnerAddress) - } - } - ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) @@ -376,12 +368,18 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) } + // The new owner address can be empty, in which case the consumer chain does not change its owner. + // However, if the new owner address is not empty, we verify that it's a valid account address. if strings.TrimSpace(msg.NewOwnerAddress) != "" { + if _, err := k.accountKeeper.AddressCodec().StringToBytes(msg.NewOwnerAddress); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidNewOwnerAddress, "invalid new owner address %s", msg.NewOwnerAddress) + } + k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.NewOwnerAddress) } if msg.Metadata != nil { - if err := k.SetConsumerMetadata(ctx, consumerId, *msg.Metadata); err != nil { + if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, *msg.Metadata); err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, "cannot set consumer metadata: %s", err.Error()) } @@ -389,7 +387,8 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon // get the previous spawn time so that we can use it in `PrepareConsumerForLaunch` var previousSpawnTime time.Time - if previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, msg.ConsumerId); err != nil { + previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, msg.ConsumerId) + if err == nil { previousSpawnTime = previousInitializationParameters.SpawnTime } @@ -410,7 +409,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon } oldTopN := k.Keeper.GetTopN(ctx, consumerId) - if err = k.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { + if err = k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot set power shaping parameters") } @@ -426,12 +425,12 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon // A Top N cannot change its owner address to something different from the gov module if the chain // remains a Top N chain. - currentOwnerAddress, err := k.GetConsumerOwnerAddress(ctx, consumerId) + currentOwnerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s: %s", ownerAddress, err.Error()) } - currentPowerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + currentPowerShapingParameters, err := k.Keeper.GetConsumerPowerShapingParameters(ctx, consumerId) if err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot retrieve power shaping parameters: %s", err.Error()) } @@ -441,9 +440,9 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon "a move to a new owner address that is not the gov module can only be done if `Top N` is set to 0") } - if spawnTime, canLaunch := k.CanLaunch(ctx, consumerId); canLaunch { - k.SetConsumerPhase(ctx, consumerId, Initialized) - k.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime) + if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { + k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) + k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime) } return &types.MsgUpdateConsumerResponse{}, nil diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index 9dcf3942fe..075a1308bd 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -1,11 +1,13 @@ package keeper_test import ( + "github.com/cosmos/cosmos-sdk/codec/address" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/stretchr/testify/require" "testing" + "time" ) func TestCreateConsumer(t *testing.T) { @@ -53,3 +55,113 @@ func TestCreateConsumer(t *testing.T) { require.True(t, found) require.Equal(t, providerkeeper.Registered, phase) } + +func TestUpdateConsumer(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + msgServer := providerkeeper.NewMsgServerImpl(&providerKeeper) + + // try to update a non-existing (i.e., no consumer id exists) + _, err := msgServer.UpdateConsumer(ctx, + &providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "0", NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + Metadata: nil, + InitializationParameters: nil, + PowerShapingParameters: nil, + }) + require.Error(t, err, "cannot update consumer chain") + + // create a chain before updating it + createConsumerResponse, err := msgServer.CreateConsumer(ctx, + &providertypes.MsgCreateConsumer{Signer: "signer", ChainId: "chainId", + Metadata: providertypes.ConsumerMetadata{ + Name: "name", + Description: "description", + Metadata: "metadata", + }, + InitializationParameters: nil, + PowerShapingParameters: nil, + }) + require.NoError(t, err) + consumerId := createConsumerResponse.ConsumerId + + mocks.MockAccountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() + _, err = msgServer.UpdateConsumer(ctx, + &providertypes.MsgUpdateConsumer{Signer: "wrong signer", ConsumerId: consumerId, NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + Metadata: nil, + InitializationParameters: nil, + PowerShapingParameters: nil, + }) + require.Error(t, err, "expected owner address") + + expectedConsumerMetadata := providertypes.ConsumerMetadata{ + Name: "name2", + Description: "description2", + Metadata: "metadata2", + } + + expectedInitializationParameters := testkeeper.GetTestInitializationParameters() + expectedPowerShapingParameters := testkeeper.GetTestPowerShapingParameters() + + expectedOwnerAddress := "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la" + _, err = msgServer.UpdateConsumer(ctx, + &providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: consumerId, NewOwnerAddress: expectedOwnerAddress, + Metadata: &expectedConsumerMetadata, + InitializationParameters: &expectedInitializationParameters, + PowerShapingParameters: &expectedPowerShapingParameters}) + require.NoError(t, err) + + // assert that owner address was updated + ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedOwnerAddress, ownerAddress) + + // assert that consumer metadata were updated + actualConsumerMetadata, err := providerKeeper.GetConsumerMetadata(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedConsumerMetadata, actualConsumerMetadata) + + // assert that initialization parameters were updated + actualInitializationParameters, err := providerKeeper.GetConsumerInitializationParameters(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedInitializationParameters, actualInitializationParameters) + + // assert that power-shaping parameters were updated + actualPowerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) + + // assert phase + phase, found := providerKeeper.GetConsumerPhase(ctx, consumerId) + require.True(t, found) + require.Equal(t, providerkeeper.Initialized, phase) + + // assert that chain is set to launch + consumerIds, err := providerKeeper.GetConsumersToBeLaunched(ctx, expectedInitializationParameters.SpawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{consumerId}, + }, consumerIds) + + // re-update (change spawnTime) and verify that the chain is still to be launched at the new spawn time + previousSpawnTime := expectedInitializationParameters.SpawnTime + updatedSpawnTime := expectedInitializationParameters.SpawnTime.Add(time.Hour) + expectedInitializationParameters.SpawnTime = updatedSpawnTime + _, err = msgServer.UpdateConsumer(ctx, + &providertypes.MsgUpdateConsumer{Signer: expectedOwnerAddress, ConsumerId: consumerId, + Metadata: &expectedConsumerMetadata, + InitializationParameters: &expectedInitializationParameters, + PowerShapingParameters: &expectedPowerShapingParameters}) + require.NoError(t, err) + + consumerIds, err = providerKeeper.GetConsumersToBeLaunched(ctx, previousSpawnTime) + require.NoError(t, err) + require.Empty(t, consumerIds) + + consumerIds, err = providerKeeper.GetConsumersToBeLaunched(ctx, updatedSpawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{consumerId}, + }, consumerIds) + +} diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index b742485f6e..dbe25b5088 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -1,11 +1,9 @@ package keeper import ( - "bytes" errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" "encoding/binary" - "encoding/gob" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -43,7 +41,7 @@ func (k Keeper) setConsumerId(ctx sdk.Context, consumerId uint64) { store.Set(types.ConsumerIdKey(), buf) } -// GetConsumerId returns the last registered consumer id +// GetConsumerId returns the next to-be-assigned consumer id func (k Keeper) GetConsumerId(ctx sdk.Context) (uint64, bool) { store := ctx.KVStore(k.storeKey) buf := store.Get(types.ConsumerIdKey()) @@ -151,11 +149,11 @@ func (k Keeper) GetConsumerInitializationParameters(ctx sdk.Context, consumerId } // SetConsumerInitializationParameters sets the initialization parameters associated with this consumer id -func (k Keeper) SetConsumerInitializationParameters(ctx sdk.Context, consumerId string, record types.ConsumerInitializationParameters) error { +func (k Keeper) SetConsumerInitializationParameters(ctx sdk.Context, consumerId string, parameters types.ConsumerInitializationParameters) error { store := ctx.KVStore(k.storeKey) - bz, err := record.Marshal() + bz, err := parameters.Marshal() if err != nil { - return fmt.Errorf("failed to marshal initialization record (%+v) for consumer id (%s): %w", record, consumerId, err) + return fmt.Errorf("failed to marshal initialization parameters (%+v) for consumer id (%s): %w", parameters, consumerId, err) } store.Set(types.ConsumerIdToInitializationParametersKey(consumerId), bz) return nil @@ -209,7 +207,6 @@ func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) (ConsumerPh } // SetConsumerPhase sets the phase associated with this consumer id -// TODO (PERMISSIONLESS): use this method when launching and when stopping a chain func (k Keeper) SetConsumerPhase(ctx sdk.Context, consumerId string, phase ConsumerPhase) { store := ctx.KVStore(k.storeKey) store.Set(types.ConsumerIdToPhaseKey(consumerId), []byte{byte(phase)}) @@ -252,10 +249,10 @@ func (k Keeper) DeleteConsumerStopTime(ctx sdk.Context, consumerId string) { store.Delete(types.ConsumerIdToStopTimeKey(consumerId)) } -// GetConsumersToBeLaunched -func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error) { +// getConsumerIdsBasedOnTime returns all the consumer ids stored under this specific `key(time)` +func (k Keeper) getConsumerIdsBasedOnTime(ctx sdk.Context, key func(time.Time) []byte, time time.Time) (types.ConsumerIds, error) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.SpawnTimeToConsumerIdsKey(spawnTime)) + bz := store.Get(key(time)) if bz == nil { return types.ConsumerIds{}, nil } @@ -268,233 +265,181 @@ func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) ( return consumerIds, nil } -// AppendSpawnTimeForConsumerToBeLaunched -func (k Keeper) AppendSpawnTimeForConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { +// appendConsumerIdOnTime appends the consumer id on all the other consumer ids under `key(time)` +func (k Keeper) appendConsumerIdOnTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { store := ctx.KVStore(k.storeKey) - consumerIdsSlice, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) if err != nil { return err } - consumerIds := append(consumerIdsSlice.Ids, consumerId) - appendedConsumerIdsStr := types.ConsumerIds{ - Ids: consumerIds, + consumersWithAppend := types.ConsumerIds{ + Ids: append(consumers.Ids, consumerId), } - bz, err := appendedConsumerIdsStr.Marshal() + bz, err := consumersWithAppend.Marshal() if err != nil { return err } - store.Set(types.SpawnTimeToConsumerIdsKey(spawnTime), bz) + store.Set(key(time), bz) return nil } -// RemoveConsumerFromToBeLaunchedConsumers -func (k Keeper) RemoveConsumerFromToBeLaunchedConsumers(ctx sdk.Context, consumerId string, spawnTime time.Time) error { +// removeConsumerIdFromTime removes consumer id stored under `key(time)` +func (k Keeper) removeConsumerIdFromTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { store := ctx.KVStore(k.storeKey) - consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) if err != nil { return err } - if len(consumerIds.Ids) == 0 { - return fmt.Errorf("no consumer ids for spawn time: %s", spawnTime.String()) + if len(consumers.Ids) == 0 { + return fmt.Errorf("no consumer ids found for this time: %s", time.String()) } // find the index of the consumer we want to remove - index := 0 - for i := 0; i < len(consumerIds.Ids); i = i + 1 { - if consumerIds.Ids[i] == consumerId { + index := -1 + for i := 0; i < len(consumers.Ids); i = i + 1 { + if consumers.Ids[i] == consumerId { index = i break } } - if consumerIds.Ids[index] != consumerId { - return fmt.Errorf("failed to find consumer id (%s) in the chains to be launched", consumerId) + + if index == -1 { + return fmt.Errorf("failed to find consumer id (%s)", consumerId) } - if len(consumerIds.Ids) == 1 { - store.Delete(types.SpawnTimeToConsumerIdsKey(spawnTime)) + if len(consumers.Ids) == 1 { + store.Delete(key(time)) return nil } - updatedConsumerIds := append(consumerIds.Ids[:index], consumerIds.Ids[index+1:]...) - - updatedConsumerIdsStr := types.ConsumerIds{ - Ids: updatedConsumerIds, + consumersWithRemoval := types.ConsumerIds{ + Ids: append(consumers.Ids[:index], consumers.Ids[index+1:]...), } - bz, err := updatedConsumerIdsStr.Marshal() + bz, err := consumersWithRemoval.Marshal() if err != nil { return err } - store.Set(types.SpawnTimeToConsumerIdsKey(spawnTime), bz) + store.Set(key(time), bz) return nil } -// TODO (PERMISSIONLESS) merge the functions, they practically do the same - -// GetConsumersToBeStopped -func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.StopTimeToConsumerIdsKey(stopTime)) - if bz == nil { - return types.ConsumerIds{}, nil - } - - var consumerIds types.ConsumerIds - err := consumerIds.Unmarshal(bz) - if err != nil { - return types.ConsumerIds{}, err - } - return consumerIds, nil +// GetConsumersToBeLaunched returns all the consumer ids of chains stored under this spawn time +func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error) { + return k.getConsumerIdsBasedOnTime(ctx, types.SpawnTimeToConsumerIdsKey, spawnTime) } -// AppendSpawnTimeForConsumerToBeStopped -func (k Keeper) AppendStopTimeForConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { - store := ctx.KVStore(k.storeKey) - - consumerIdsStr, err := k.GetConsumersToBeStopped(ctx, stopTime) - if err != nil { - return err - } - consumerIds := append(consumerIdsStr.Ids, consumerId) - - consumerIdsNewStr := types.ConsumerIds{ - Ids: consumerIds, - } - - bz, err := consumerIdsNewStr.Marshal() - if err != nil { - return err - } - - store.Set(types.StopTimeToConsumerIdsKey(stopTime), bz) - return nil +// AppendConsumerToBeLaunchedOnSpawnTime appends the provider consumer id for the given spawn time +func (k Keeper) AppendConsumerToBeLaunchedOnSpawnTime(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + return k.appendConsumerIdOnTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) } -// RemoveConsumerFromToBeStoppedConsumers -func (k Keeper) RemoveConsumerFromToBeStoppedConsumers(ctx sdk.Context, consumerId string, stopTime time.Time) error { - store := ctx.KVStore(k.storeKey) - - consumerIds, err := k.GetConsumersToBeStopped(ctx, stopTime) - if err != nil { - return err - } - - if len(consumerIds.Ids) == 0 { - return fmt.Errorf("no consumer ids for stop time: %s", stopTime.String()) - } - - // find the index of the consumer we want to remove - index := 0 - for i := 0; i < len(consumerIds.Ids); i = i + 1 { - if consumerIds.Ids[i] == consumerId { - index = i - break - } - } - if consumerIds.Ids[index] != consumerId { - return fmt.Errorf("failed to find consumer id (%s) in the chains to be stopped", consumerId) - } +// RemoveConsumerToBeLaunchedFromSpawnTime removes consumer id from if stored for this specific spawn time +func (k Keeper) RemoveConsumerToBeLaunchedFromSpawnTime(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + return k.removeConsumerIdFromTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) +} - if len(consumerIds.Ids) == 1 { - store.Delete(types.StopTimeToConsumerIdsKey(stopTime)) - return nil - } +// GetConsumersToBeStopped returns all the consumer ids of chains stored under this stop time +func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { + return k.getConsumerIdsBasedOnTime(ctx, types.StopTimeToConsumerIdsKey, stopTime) +} - updatedConsumerIds := append(consumerIds.Ids[:index], consumerIds.Ids[index+1:]...) - updatedConsumerIdsStr := types.ConsumerIds{ - Ids: updatedConsumerIds, - } - bz, err := updatedConsumerIdsStr.Marshal() - if err != nil { - return err - } +// AppendConsumerToBeStoppedOnStopTime appends the provider consumer id for the given stop time +func (k Keeper) AppendConsumerToBeStoppedOnStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { + return k.appendConsumerIdOnTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) +} - store.Set(types.StopTimeToConsumerIdsKey(stopTime), bz) - return nil +// RemoveConsumerToBeStoppedFromStopTime removes consumer id from if stored for this specific stop time +func (k Keeper) RemoveConsumerToBeStoppedFromStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { + return k.removeConsumerIdFromTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) } -// GetOptedInConsumerIds -func (k Keeper) GetOptedInConsumerIds(ctx sdk.Context, providerAddr types.ProviderConsAddress) ([]string, error) { +// GetOptedInConsumerIds returns all the consumer ids where the given validator is opted in +func (k Keeper) GetOptedInConsumerIds(ctx sdk.Context, providerAddr types.ProviderConsAddress) (types.ConsumerIds, error) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr)) if bz == nil { - return []string{}, nil + return types.ConsumerIds{}, nil + } + + var consumerIds types.ConsumerIds + if err := consumerIds.Unmarshal(bz); err != nil { + return types.ConsumerIds{}, fmt.Errorf("failed to unmarshal consumer ids: %w", err) } - var consumerIds []string - buf := bytes.NewBuffer(bz) - dec := gob.NewDecoder(buf) - err := dec.Decode(&consumerIds) - return consumerIds, err + return consumerIds, nil } -// AppendOptedInConsumerId +// AppendOptedInConsumerId appends given consumer id to the list of consumers that validator has opted in func (k Keeper) AppendOptedInConsumerId(ctx sdk.Context, providerAddr types.ProviderConsAddress, consumerId string) error { store := ctx.KVStore(k.storeKey) - consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + consumers, err := k.GetOptedInConsumerIds(ctx, providerAddr) if err != nil { return err } - consumerIds = append(consumerIds, consumerId) - var buf bytes.Buffer - enc := gob.NewEncoder(&buf) - err = enc.Encode(consumerIds) + consumersWithAppend := types.ConsumerIds{ + Ids: append(consumers.Ids, consumerId), + } + + bz, err := consumersWithAppend.Marshal() if err != nil { return err } - store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), buf.Bytes()) + store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), bz) return nil } -// RemoveOptedInConsumerId +// RemoveOptedInConsumerId removes the consumer id from this validator because it is not opted in anymore func (k Keeper) RemoveOptedInConsumerId(ctx sdk.Context, providerAddr types.ProviderConsAddress, consumerId string) error { store := ctx.KVStore(k.storeKey) - consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + consumers, err := k.GetOptedInConsumerIds(ctx, providerAddr) if err != nil { return err } - if len(consumerIds) == 0 { - return fmt.Errorf("no consumer ids for provider consensus address: %s", providerAddr.String()) + if len(consumers.Ids) == 0 { + return fmt.Errorf("no consumer ids found for this provviderAddr: %s", providerAddr.String()) } // find the index of the consumer we want to remove - index := 0 - for i := 0; i < len(consumerIds); i = i + 1 { - if consumerIds[i] == consumerId { + index := -1 + for i := 0; i < len(consumers.Ids); i = i + 1 { + if consumers.Ids[i] == consumerId { index = i break } } - if consumerIds[index] != consumerId { - return fmt.Errorf("failed to find consumer id (%s) from the opted-in chains", consumerId) + + if index == -1 { + return fmt.Errorf("failed to find consumer id (%s)", consumerId) } - if len(consumerIds) == 1 { + if len(consumers.Ids) == 1 { store.Delete(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr)) return nil } - updatedConsumerIds := append(consumerIds[:index], consumerIds[index+1:]...) - var buf bytes.Buffer - enc := gob.NewEncoder(&buf) - err = enc.Encode(updatedConsumerIds) + consumersWithRemoval := types.ConsumerIds{ + Ids: append(consumers.Ids[:index], consumers.Ids[index+1:]...), + } + + bz, err := consumersWithRemoval.Marshal() if err != nil { return err } - store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), buf.Bytes()) + store.Set(types.ProviderConsAddrToOptedInConsumerIdsKey(providerAddr), bz) return nil } @@ -683,7 +628,7 @@ func (k Keeper) GetLaunchedConsumersReadyToStop(ctx sdk.Context, limit uint32) [ // It returns `found == true` and the corresponding chain's `consumerId` if the validator is opted in. Otherwise, it returns an empty string // for `consumerId` and `found == false`. func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types.ProviderConsAddress, chainId string) (string, bool) { - consumerIds, err := k.GetOptedInConsumerIds(ctx, providerAddr) + consumers, err := k.GetOptedInConsumerIds(ctx, providerAddr) if err != nil { k.Logger(ctx).Error("failed to retrieve the consumer ids this validator is opted in to", "providerAddr", providerAddr, @@ -691,7 +636,7 @@ func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types. return "", false } - for _, consumerId := range consumerIds { + for _, consumerId := range consumers.Ids { consumerChainId, err := k.GetConsumerChainId(ctx, consumerId) if err != nil { k.Logger(ctx).Error("cannot find chain id", @@ -709,12 +654,15 @@ func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types. } func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) { + fmt.Printf("previousSpawnTime: \n(%+v)\n", previousSpawnTime) + fmt.Printf("time.Time: \n(%+v)\n", time.Time{}) if !previousSpawnTime.Equal(time.Time{}) { + fmt.Println("mpika edo") // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` - // remove the consumer id from the old spawn time - k.RemoveConsumerFromToBeLaunchedConsumers(ctx, consumerId, previousSpawnTime) + // remove the consumer id from the previous spawn time + k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, previousSpawnTime) } - k.AppendSpawnTimeForConsumerToBeLaunched(ctx, consumerId, spawnTime) + k.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerId, spawnTime) } // CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index 5819e355d0..34458ce0d0 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -13,160 +13,220 @@ import ( "time" ) -func TestFetchAndIncrementConsumerId(t *testing.T) { +// TestConsumerId tests setters and getters of consumer id (i.e., `FetchAndIncrementConsumerId` and `GetConsumerId`) +func TestConsumerId(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + _, found := providerKeeper.GetConsumerId(ctx) + require.False(t, found) + consumerId := providerKeeper.FetchAndIncrementConsumerId(ctx) require.Equal(t, "0", consumerId) + consumerIdNum, found := providerKeeper.GetConsumerId(ctx) + require.Equal(t, uint64(1), consumerIdNum) + require.True(t, found) consumerId = providerKeeper.FetchAndIncrementConsumerId(ctx) require.Equal(t, "1", consumerId) + consumerIdNum, found = providerKeeper.GetConsumerId(ctx) + require.Equal(t, uint64(2), consumerIdNum) + require.True(t, found) +} - consumerId = providerKeeper.FetchAndIncrementConsumerId(ctx) - require.Equal(t, "2", consumerId) +// TestConsumerChainId tests the getter, setter, and deletion of the consumer to chain id methods +func TestConsumerChainId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.GetConsumerChainId(ctx, "chainId") + require.Error(t, err, "failed to retrieve chain id") + + providerKeeper.SetConsumerChainId(ctx, "chainId", "chainId") + chainId, err := providerKeeper.GetConsumerChainId(ctx, "chainId") + require.NoError(t, err) + require.Equal(t, "chainId", chainId) + + // write under a different key + providerKeeper.SetConsumerChainId(ctx, "consumerId2", "chainId") + chainId, err = providerKeeper.GetConsumerChainId(ctx, "consumerId2") + require.NoError(t, err) + require.Equal(t, "chainId", chainId) + + // assert that overwriting the current key works + providerKeeper.SetConsumerChainId(ctx, "chainId", "chainId2") + chainId, err = providerKeeper.GetConsumerChainId(ctx, "chainId") + require.NoError(t, err) + require.Equal(t, "chainId2", chainId) + + providerKeeper.DeleteConsumerChainId(ctx, "chainId") + _, err = providerKeeper.GetConsumerChainId(ctx, "chainId") + require.Error(t, err, "failed to retrieve chain id") } -// TestClientIdToConsumerId tests the getter, setter, and deletion methods of the client id to consumer id methods -func TestClientIdToConsumerId(t *testing.T) { +// TestConsumerOwnerAddress tests the getter, setter, and deletion of the consumer to owner address methods +func TestConsumerOwnerAddress(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - _, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.False(t, found) + _, err := providerKeeper.GetConsumerOwnerAddress(ctx, "ownerAddress") + require.Error(t, err, "failed to retrieve owner address") - providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId") - consumerId, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.True(t, found) - require.Equal(t, "consumerId", consumerId) + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner address") + ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, "owner address", ownerAddress) - // assert that overwriting the current consumer id record works - providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId2") - consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.True(t, found) - require.Equal(t, "consumerId2", consumerId) + // write under a different key + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId2", "owner address") + ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId2") + require.NoError(t, err) + require.Equal(t, "owner address", ownerAddress) - providerKeeper.DeleteClientIdToConsumerId(ctx, "clientId") - consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.False(t, found) - require.Equal(t, "", consumerId) + // assert that overwriting the current key works + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner address2") + ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, "owner address2", ownerAddress) + + providerKeeper.DeleteConsumerOwnerAddress(ctx, "consumerId") + _, err = providerKeeper.GetConsumerChainId(ctx, "consumerId") + require.Error(t, err, "failed to retrieve owner address") } -// TestConsumerIdToRegistrationRecord tests the getter, setter, and deletion methods of the consumer id to registration record methods -func TestConsumerIdToRegistrationRecord(t *testing.T) { +// TestConsumerMetadata tests the getter, setter, and deletion of the consumer id to consumer metadata methods +func TestConsumerMetadata(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() _, err := providerKeeper.GetConsumerMetadata(ctx, "consumerId") require.Error(t, err) - expectedRecord := providertypes.ConsumerMetadata{ + expectedMetadata := providertypes.ConsumerMetadata{ Name: "name", Description: "description", Metadata: "metadata", //ChainId: "chain_id", } - providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedRecord) - actualRecord, err := providerKeeper.GetConsumerMetadata(ctx, "consumerId") + providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedMetadata) + actualMetadata, err := providerKeeper.GetConsumerMetadata(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, expectedRecord, actualRecord) + require.Equal(t, expectedMetadata, actualMetadata) // assert that overwriting the current registration record works - expectedRecord = providertypes.ConsumerMetadata{ + expectedMetadata = providertypes.ConsumerMetadata{ Name: "name 2", Description: "description 2", Metadata: "metadata 2", //ChainId: "chain_id2", } - providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedRecord) - actualRecord, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") + providerKeeper.SetConsumerMetadata(ctx, "consumerId", expectedMetadata) + actualMetadata, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, expectedRecord, actualRecord) + require.Equal(t, expectedMetadata, actualMetadata) providerKeeper.DeleteConsumerMetadata(ctx, "consumerId") - actualRecord, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") + actualMetadata, err = providerKeeper.GetConsumerMetadata(ctx, "consumerId") require.Error(t, err) - require.Equal(t, providertypes.ConsumerMetadata{}, actualRecord) + require.Equal(t, providertypes.ConsumerMetadata{}, actualMetadata) } -// TestConsumerIdToInitializationRecord tests the getter, setter, and deletion methods of the consumer id to initialization record methods -func TestConsumerIdToInitializationRecord(t *testing.T) { +// TestConsumerInitializationParameters tests the getter, setter, and deletion of the consumer id to initialization parameters methods +func TestConsumerInitializationParameters(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() _, err := providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") require.Error(t, err) - spawnTime := time.Unix(1, 2).UTC() - unbondingPeriod := time.Duration(3456) - ccvTimeoutPeriod := time.Duration(789) - transferTimeoutPeriod := time.Duration(101112) - expectedRecord := providertypes.ConsumerInitializationParameters{ + expectedInitializationParameters := providertypes.ConsumerInitializationParameters{ InitialHeight: types.Height{RevisionNumber: 1, RevisionHeight: 2}, GenesisHash: []byte{0, 1}, BinaryHash: []byte{2, 3}, - SpawnTime: spawnTime, - UnbondingPeriod: unbondingPeriod, - CcvTimeoutPeriod: ccvTimeoutPeriod, - TransferTimeoutPeriod: transferTimeoutPeriod, + SpawnTime: time.Unix(1, 2).UTC(), + UnbondingPeriod: time.Duration(3456), + CcvTimeoutPeriod: time.Duration(789), + TransferTimeoutPeriod: time.Duration(101112), ConsumerRedistributionFraction: "consumer_redistribution_fraction", BlocksPerDistributionTransmission: 123, HistoricalEntries: 456, DistributionTransmissionChannel: "distribution_transmission_channel", } - providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedRecord) - actualRecord, err := providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedInitializationParameters) + actualInitializationParameters, err := providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, expectedRecord, actualRecord) + require.Equal(t, expectedInitializationParameters, actualInitializationParameters) // assert that overwriting the current initialization record works - spawnTime = time.Unix(2, 3).UTC() - unbondingPeriod = time.Duration(789) - ccvTimeoutPeriod = time.Duration(101112) - transferTimeoutPeriod = time.Duration(131415) - expectedRecord = providertypes.ConsumerInitializationParameters{ + expectedInitializationParameters = providertypes.ConsumerInitializationParameters{ InitialHeight: types.Height{RevisionNumber: 2, RevisionHeight: 3}, GenesisHash: []byte{2, 3}, BinaryHash: []byte{4, 5}, - SpawnTime: spawnTime, - UnbondingPeriod: unbondingPeriod, - CcvTimeoutPeriod: ccvTimeoutPeriod, - TransferTimeoutPeriod: transferTimeoutPeriod, + SpawnTime: time.Unix(2, 3).UTC(), + UnbondingPeriod: time.Duration(789), + CcvTimeoutPeriod: time.Duration(101112), + TransferTimeoutPeriod: time.Duration(131415), ConsumerRedistributionFraction: "consumer_redistribution_fraction2", BlocksPerDistributionTransmission: 456, HistoricalEntries: 789, DistributionTransmissionChannel: "distribution_transmission_channel2", } - providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedRecord) - actualRecord, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", expectedInitializationParameters) + actualInitializationParameters, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, expectedRecord, actualRecord) + require.Equal(t, expectedInitializationParameters, actualInitializationParameters) providerKeeper.DeleteConsumerInitializationParameters(ctx, "consumerId") - actualRecord, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") + actualInitializationParameters, err = providerKeeper.GetConsumerInitializationParameters(ctx, "consumerId") require.Error(t, err) - require.Equal(t, providertypes.ConsumerInitializationParameters{}, actualRecord) + require.Equal(t, providertypes.ConsumerInitializationParameters{}, actualInitializationParameters) } -// TestConsumerIdToOwnerAddress tests the getter, setter, and deletion methods of the owner address to registration record methods -func TestConsumerIdToOwnerAddress(t *testing.T) { +// TestConsumerPowerShapingParameters tests the getter, setter, and deletion of the consumer id to power-shaping parameters methods +func TestConsumerPowerShapingParameters(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner_address") - address, err := providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.Error(t, err) + + expectedPowerShapingParameters := providertypes.PowerShapingParameters{ + Top_N: 10, + ValidatorsPowerCap: 34, + ValidatorSetCap: 10, + Allowlist: []string{"allowlist1", "allowlist2"}, + Denylist: []string{"denylist1", "denylist2"}, + MinStake: 234, + AllowInactiveVals: true, + } + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", expectedPowerShapingParameters) + actualPowerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, "owner_address", address) + require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) - // assert that overwriting the current owner address works - providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner_address2") - address, err = providerKeeper.GetConsumerOwnerAddress(ctx, "consumerId") + // assert that overwriting the current initialization record works + expectedPowerShapingParameters = providertypes.PowerShapingParameters{ + Top_N: 12, + ValidatorsPowerCap: 67, + ValidatorSetCap: 20, + Allowlist: []string{"allowlist3", "allowlist4"}, + Denylist: []string{"denylist3", "denylist4"}, + MinStake: 567, + AllowInactiveVals: false, + } + providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", expectedPowerShapingParameters) + actualPowerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, "owner_address2", address) + require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) + + providerKeeper.DeleteConsumerPowerShapingParameters(ctx, "consumerId") + actualPowerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.Error(t, err) + require.Equal(t, providertypes.PowerShapingParameters{}, actualPowerShapingParameters) } -// TestConsumerIdToPhase tests the getter, setter, and deletion methods of the consumer id to phase methods -func TestConsumerIdToPhase(t *testing.T) { +// TestConsumerPhase tests the getter, setter, and deletion of the consumer id to phase methods +func TestConsumerPhase(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -184,8 +244,8 @@ func TestConsumerIdToPhase(t *testing.T) { require.Equal(t, keeper.Launched, phase) } -// TestConsumerIdToStopTime tests the getter, setter, and deletion methods of the consumer id to stop times -func TestConsumerIdToStopTime(t *testing.T) { +// TestConsumerStopTime tests the getter, setter, and deletion of the consumer id to stop times methods +func TestConsumerStopTime(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -203,6 +263,130 @@ func TestConsumerIdToStopTime(t *testing.T) { require.Error(t, err) } +// TestConsumersToBeLaunched tests `AppendConsumerToBeLaunchedOnSpawnTime`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunchedFromSpawnTime` +func TestConsumersToBeLaunched(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + spawnTime := time.Now() + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", spawnTime) + consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1"}, consumers.Ids) + + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", spawnTime) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) + + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", spawnTime) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) + + err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId2", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // also add consumer ids under a different spawn time and verify everything under the original spawn time is still there + spawnTimePlusOneHour := spawnTime.Add(time.Hour) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId4", spawnTimePlusOneHour) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) + require.NoError(t, err) + require.Equal(t, []string{"consumerId4"}, consumers.Ids) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // start removing all consumers from `spawnTime` + err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId3", spawnTime) + require.NoError(t, err) + err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId1", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // remove from `spawnTimePlusOneHour` + err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId4", spawnTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // add another consumer for `spawnTime` + err = providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId5", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId5"}, consumers.Ids) +} + +// TestConsumersToBeStopped tests `AppendConsumerToBeLaunchedOnSpawnTime`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunchedFromSpawnTime` +func TestConsumersToBeStopped(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + stopTime := time.Now() + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId1", stopTime) + consumers, err := providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1"}, consumers.Ids) + + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId2", stopTime) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) + + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId3", stopTime) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) + + err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId2", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // also add consumer ids under a different stop time and verify everything under the original stop time is still there + stopTimePlusOneHour := stopTime.Add(time.Hour) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId4", stopTimePlusOneHour) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + require.NoError(t, err) + require.Equal(t, []string{"consumerId4"}, consumers.Ids) + + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // start removing all consumers from `stopTime` + err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId3", stopTime) + require.NoError(t, err) + err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId1", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // remove from `stopTimePlusOneHour` + err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId4", stopTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // add another consumer for `stopTime` + err = providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId5", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId5"}, consumers.Ids) +} + // TestGetInitializedConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) @@ -211,9 +395,9 @@ func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { // no chains to-be-launched exist require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) - providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, "consumerId3", time.Unix(30, 0)) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", time.Unix(30, 0)) // time has not yet reached the spawn time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) @@ -237,6 +421,31 @@ func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 2)) } +// TestConsumerChainId tests the getter, setter, and deletion of the client id to consumer id methods +func TestClientIdToConsumerId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.False(t, found) + + providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId") + consumerId, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.True(t, found) + require.Equal(t, "consumerId", consumerId) + + // assert that overwriting the current consumer id record works + providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId2") + consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.True(t, found) + require.Equal(t, "consumerId2", consumerId) + + providerKeeper.DeleteClientIdToConsumerId(ctx, "clientId") + consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") + require.False(t, found) + require.Equal(t, "", consumerId) +} + func TestGetLaunchedConsumersReadyToStop(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -244,9 +453,9 @@ func TestGetLaunchedConsumersReadyToStop(t *testing.T) { // no chains to-be-stopped exist require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId3", time.Unix(30, 0)) // time has not yet reached the stop time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) @@ -302,7 +511,7 @@ func TestUpdateAllowlist(t *testing.T) { require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) } -func TestPopulateDenylist(t *testing.T) { +func TestUpdateDenylist(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -321,7 +530,7 @@ func TestPopulateDenylist(t *testing.T) { require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) } -func TestPopulateMinimumPowerInTopN(t *testing.T) { +func TestUpdateMinimumPowerInTopN(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -380,5 +589,4 @@ func TestPopulateMinimumPowerInTopN(t *testing.T) { minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) require.True(t, found) require.Equal(t, int64(10), minimumPowerInTopN) - } diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index d13ad3d2bd..8361eb0dbb 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -45,7 +45,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { phase, found := k.GetConsumerPhase(ctx, consumerId) if !found || phase != Initialized { return errorsmod.Wrapf(types.ErrInvalidPhase, - "cannot create client for consumer chain that is not in the Initialized phase: %s", consumerId) + "cannot create client for consumer chain that is not in the Initialized phase but in phase %d: %s", phase, consumerId) } chainId, err := k.GetConsumerChainId(ctx, consumerId) @@ -94,7 +94,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { k.SetConsumerClientId(ctx, consumerId, clientID) k.SetClientIdToConsumerId(ctx, clientID, consumerId) - k.Logger(ctx).Info("consumer chain registered (client created)", + k.Logger(ctx).Info("consumer chain launched (client created)", "consumer id", consumerId, "client id", clientID, ) @@ -345,7 +345,7 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { } // Remove consumer to prevent re-trying launching this chain. // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. - k.RemoveConsumerFromToBeLaunchedConsumers(ctx, consumerId, record.SpawnTime) + k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, record.SpawnTime) cachedCtx, writeFn := ctx.CacheContext() err = k.LaunchConsumer(cachedCtx, consumerId) @@ -492,7 +492,7 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) k.SetConsumerPhase(cachedCtx, consumerId, Stopped) - k.RemoveConsumerFromToBeStoppedConsumers(ctx, consumerId, stopTime) + k.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, stopTime) writeFn() k.Logger(ctx).Info("executed consumer removal", diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 1aef84957f..ee0f8039cd 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -805,7 +805,7 @@ func TestBeginBlockInit(t *testing.T) { providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) // set up the chains in their initialized phase, hence they could launch providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providerkeeper.Initialized) - providerKeeper.AppendSpawnTimeForConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, fmt.Sprintf("%d", i), r.SpawnTime) } for i, r := range powerShapingParameters { providerKeeper.SetConsumerPowerShapingParameters(ctx, fmt.Sprintf("%d", i), r) @@ -875,11 +875,11 @@ func TestBeginBlockCCR(t *testing.T) { chainIds := []string{"chain1", "chain2", "chain3"} consumerIds := []string{"consumerId1", "consumerId2", "consumerId3"} providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[1], now) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[1], now) providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) - providerKeeper.AppendStopTimeForConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) + providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[2], now.Add(time.Hour)) // // Mock expectations From d124adaca58540a651cc6eaca06ae3f6b675b239 Mon Sep 17 00:00:00 2001 From: insumity Date: Mon, 26 Aug 2024 16:47:42 +0200 Subject: [PATCH 03/43] added some additional tests --- x/ccv/provider/keeper/msg_server.go | 10 +- x/ccv/provider/keeper/msg_server_test.go | 1 - x/ccv/provider/keeper/permissionless.go | 105 +++++---- x/ccv/provider/keeper/permissionless_test.go | 212 +++++++++++++++---- x/ccv/provider/keeper/proposal.go | 2 + x/ccv/provider/types/errors.go | 1 + 6 files changed, 234 insertions(+), 97 deletions(-) diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index eb9f9b4f75..fb81b0ef12 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -342,7 +342,10 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) - k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime) + if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { + return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + "cannot prepare chain with consumer id (%s) for launch", consumerId) + } } return &types.MsgCreateConsumerResponse{ConsumerId: consumerId}, nil @@ -442,7 +445,10 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) - k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime) + if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { + return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + "cannot prepare chain with consumer id (%s) for launch", consumerId) + } } return &types.MsgUpdateConsumerResponse{}, nil diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index 075a1308bd..b9e1f05b58 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -163,5 +163,4 @@ func TestUpdateConsumer(t *testing.T) { require.Equal(t, providertypes.ConsumerIds{ Ids: []string{consumerId}, }, consumerIds) - } diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index dbe25b5088..1c4a6a5597 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -508,6 +508,48 @@ func (k Keeper) GetInitializedConsumersReadyToLaunch(ctx sdk.Context, limit uint return result } +// GetLaunchedConsumersReadyToStop returns the consumer ids of the pending launched consumer chains +// that are ready to stop +func (k Keeper) GetLaunchedConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { + store := ctx.KVStore(k.storeKey) + + stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) + defer iterator.Close() + + result := []string{} + for ; iterator.Valid(); iterator.Next() { + stopTime, err := types.ParseTime(types.StopTimeToConsumerIdsKeyPrefix(), iterator.Key()) + if err != nil { + k.Logger(ctx).Error("failed to parse stop time", + "error", err) + continue + } + if stopTime.After(ctx.BlockTime()) { + return result + } + + consumers, err := k.GetConsumersToBeStopped(ctx, stopTime) + if err != nil { + k.Logger(ctx).Error("failed to retrieve consumers to stop", + "stop time", stopTime, + "error", err) + continue + } + if len(result)+len(consumers.Ids) >= int(limit) { + remainingConsumerIds := len(result) + len(consumers.Ids) - int(limit) + if len(consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]) == 0 { + return result + } + return append(result, consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]...) + } else { + result = append(result, consumers.Ids...) + } + } + + return result +} + // LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective // consumer genesis file func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { @@ -518,16 +560,13 @@ func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { consumerGenesis, found := k.GetConsumerGenesis(ctx, consumerId) if !found { - return errorsmod.Wrapf(types.ErrNoConsumerGenesis, "consumer genesis could not be found") + return errorsmod.Wrapf(types.ErrNoConsumerGenesis, "consumer genesis could not be found for consumer id: %s", consumerId) } if len(consumerGenesis.Provider.InitialValSet) == 0 { - return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in") + return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in consumer id: %s", consumerId) } - // The cached context is created with a new EventManager so we merge the event - // into the original context - ctx.EventManager().EmitEvents(ctx.EventManager().Events()) return nil } @@ -582,48 +621,6 @@ func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, old return nil } -// GetLaunchedConsumersReadyToStop returns the consumer ids of the pending launched consumer chains -// that are ready to stop -func (k Keeper) GetLaunchedConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { - store := ctx.KVStore(k.storeKey) - - stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() - iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) - defer iterator.Close() - - result := []string{} - for ; iterator.Valid(); iterator.Next() { - stopTime, err := types.ParseTime(types.StopTimeToConsumerIdsKeyPrefix(), iterator.Key()) - if err != nil { - k.Logger(ctx).Error("failed to parse stop time", - "error", err) - continue - } - if stopTime.After(ctx.BlockTime()) { - return result - } - - consumerIds, err := k.GetConsumersToBeStopped(ctx, stopTime) - if err != nil { - k.Logger(ctx).Error("failed to retrieve consumers to stop", - "stop time", stopTime, - "error", err) - continue - } - if len(result)+len(consumerIds.Ids) >= int(limit) { - remainingConsumerIds := len(result) + len(consumerIds.Ids) - int(limit) - if len(consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]) == 0 { - return result - } - return append(result, consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]...) - } else { - result = append(result, consumerIds.Ids...) - } - } - - return result -} - // IsValidatorOptedInToChainId checks if the validator with `providerAddr` is opted into the chain with the specified `chainId`. // It returns `found == true` and the corresponding chain's `consumerId` if the validator is opted in. Otherwise, it returns an empty string // for `consumerId` and `found == false`. @@ -653,16 +650,18 @@ func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types. return "", false } -func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) { - fmt.Printf("previousSpawnTime: \n(%+v)\n", previousSpawnTime) - fmt.Printf("time.Time: \n(%+v)\n", time.Time{}) +// PrepareConsumerForLaunch prepares to move the launch of a consumer chain from the previous spawn time to spawn time. +// Previous spawn time can correspond to its zero value if the validator was not previously set for launch. +func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) error { if !previousSpawnTime.Equal(time.Time{}) { - fmt.Println("mpika edo") // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` // remove the consumer id from the previous spawn time - k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, previousSpawnTime) + err := k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, previousSpawnTime) + if err != nil { + return err + } } - k.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerId, spawnTime) + return k.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerId, spawnTime) } // CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index 34458ce0d0..7e290dea5b 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -387,38 +387,58 @@ func TestConsumersToBeStopped(t *testing.T) { require.Equal(t, []string{"consumerId5"}, consumers.Ids) } -// TestGetInitializedConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned -func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { +// TestOptedInConsumerIds tests the `GetOptedInConsumerIds`, `AppendOptedInConsumerId`, and `RemoveOptedInConsumerId` methods +func TestGetOptedInConsumerIds(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - // no chains to-be-launched exist - require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) + providerAddr := providertypes.NewProviderConsAddress([]byte("providerAddr")) + consumers, err := providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Empty(t, consumers) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", time.Unix(30, 0)) + err = providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, "consumerId1") + require.NoError(t, err) + consumers, err = providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{"consumerId1"}, + }, consumers) - // time has not yet reached the spawn time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) - require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + err = providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, "consumerId2") + require.NoError(t, err) + consumers, err = providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{"consumerId1", "consumerId2"}, + }, consumers) - // time has reached the spawn time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(10, 0)) - require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + err = providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, "consumerId3") + require.NoError(t, err) + consumers, err = providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{"consumerId1", "consumerId2", "consumerId3"}, + }, consumers) - // time has reached the spawn time of "consumerId1" and "consumerId2" - ctx = ctx.WithBlockTime(time.Unix(20, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + // remove all the consumer ids + err = providerKeeper.RemoveOptedInConsumerId(ctx, providerAddr, "consumerId2") + require.NoError(t, err) + consumers, err = providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{ + Ids: []string{"consumerId1", "consumerId3"}, + }, consumers) - // time has reached the spawn time of all chains - ctx = ctx.WithBlockTime(time.Unix(30, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + err = providerKeeper.RemoveOptedInConsumerId(ctx, providerAddr, "consumerId3") + require.NoError(t, err) - // limit the number of returned consumer chains - require.Equal(t, []string{}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 0)) - require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 1)) - require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 2)) + err = providerKeeper.RemoveOptedInConsumerId(ctx, providerAddr, "consumerId1") + require.NoError(t, err) + + consumers, err = providerKeeper.GetOptedInConsumerIds(ctx, providerAddr) + require.NoError(t, err) + require.Empty(t, consumers) } // TestConsumerChainId tests the getter, setter, and deletion of the client id to consumer id methods @@ -446,6 +466,40 @@ func TestClientIdToConsumerId(t *testing.T) { require.Equal(t, "", consumerId) } +// TestGetInitializedConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned +func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // no chains to-be-launched exist + require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) + + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", time.Unix(30, 0)) + + // time has not yet reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) + require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(10, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" and "consumerId2" + ctx = ctx.WithBlockTime(time.Unix(20, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of all chains + ctx = ctx.WithBlockTime(time.Unix(30, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) + + // limit the number of returned consumer chains + require.Equal(t, []string{}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 1)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 2)) +} + func TestGetLaunchedConsumersReadyToStop(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -474,24 +528,6 @@ func TestGetLaunchedConsumersReadyToStop(t *testing.T) { require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) } -func TestIsValidatorOptedInToChain(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - chainId := "chainId" - providerAddr := providertypes.NewProviderConsAddress([]byte("providerAddr")) - _, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) - require.False(t, found) - - expectedConsumerId := "consumerId" - providerKeeper.SetConsumerChainId(ctx, expectedConsumerId, chainId) - providerKeeper.SetOptedIn(ctx, expectedConsumerId, providerAddr) - providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, expectedConsumerId) - actualConsumerId, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) - require.True(t, found) - require.Equal(t, expectedConsumerId, actualConsumerId) -} - func TestUpdateAllowlist(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -590,3 +626,97 @@ func TestUpdateMinimumPowerInTopN(t *testing.T) { require.True(t, found) require.Equal(t, int64(10), minimumPowerInTopN) } + +func TestIsValidatorOptedInToChain(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + chainId := "chainId" + providerAddr := providertypes.NewProviderConsAddress([]byte("providerAddr")) + _, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) + require.False(t, found) + + expectedConsumerId := "consumerId" + providerKeeper.SetConsumerChainId(ctx, expectedConsumerId, chainId) + providerKeeper.SetOptedIn(ctx, expectedConsumerId, providerAddr) + providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, expectedConsumerId) + actualConsumerId, found := providerKeeper.IsValidatorOptedInToChainId(ctx, providerAddr, chainId) + require.True(t, found) + require.Equal(t, expectedConsumerId, actualConsumerId) +} + +func TestPrepareConsumerForLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + spawnTime := time.Now().UTC() + err := providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", time.Time{}, spawnTime) + require.NoError(t, err) + + consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) + + nextSpawnTime := spawnTime.Add(time.Hour) + err = providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", spawnTime, nextSpawnTime) + require.NoError(t, err) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Empty(t, consumers) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, nextSpawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) +} + +func TestCanLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // cannot launch an unknown chain + _, canLaunch := providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // cannot launch a chain without initialization parameters + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // set valid initialization parameters + initializationParameters := testkeeper.GetTestInitializationParameters() + err := providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) + require.NoError(t, err) + + // cannot launch a launched chain + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Launched) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // cannot launch a stopped chain + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Stopped) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // initialized chain can launch + providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.True(t, canLaunch) + + // initialized chain that has spawn time in the past cannot launch + ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(time.Second)) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // reset block time so the chain can launch + ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(-time.Second)) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.True(t, canLaunch) + + // chain cannot launch without a genesis hash + initializationParameters.GenesisHash = nil + err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.NoError(t, err) + require.False(t, canLaunch) +} diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 8361eb0dbb..407d0e2bb3 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -357,6 +357,8 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { } k.SetConsumerPhase(cachedCtx, consumerId, Launched) + // the cached context is created with a new EventManager, so we merge the events into the original context + ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) writeFn() } } diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 94e9e5669a..b7ab44d029 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -47,4 +47,5 @@ var ( ErrInvalidTransformToTopN = errorsmod.Register(ModuleName, 39, "invalid transform to Top N chain") ErrInvalidTransformToOptIn = errorsmod.Register(ModuleName, 40, "invalid transform to Opt In chain") ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") + ErrCannotPrepareForLaunch = errorsmod.Register(ModuleName, 42, "cannot prepare chain for launch") ) From 2c20186a2d9e56feb9931939764d9a999e0e678f Mon Sep 17 00:00:00 2001 From: insumity Date: Tue, 27 Aug 2024 10:15:57 +0200 Subject: [PATCH 04/43] added tests on the hooks --- x/ccv/provider/keeper/distribution.go | 22 ++++---- x/ccv/provider/keeper/hooks.go | 47 ++++------------ x/ccv/provider/keeper/permissionless.go | 52 ++++++++++++++++++ x/ccv/provider/keeper/permissionless_test.go | 58 ++++++++++++++++++++ x/ccv/provider/keeper/proposal.go | 8 +-- 5 files changed, 136 insertions(+), 51 deletions(-) diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 13698cde32..9291e57a76 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -74,33 +74,33 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { return } - // Iterate over all registered consumer chains - for _, consumerChainID := range k.GetAllRegisteredConsumerIds(ctx) { + // Iterate over all launched consumer chains + for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { // note that it's possible that no rewards are collected even though the // reward pool isn't empty. This can happen if the reward pool holds some tokens // of non-whitelisted denominations. - alloc := k.GetConsumerRewardsAllocation(ctx, consumerChainID) + alloc := k.GetConsumerRewardsAllocation(ctx, consumerId) if alloc.Rewards.IsZero() { continue } // temporary workaround to keep CanWithdrawInvariant happy // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 - if k.ComputeConsumerTotalVotingPower(ctx, consumerChainID) == 0 { + if k.ComputeConsumerTotalVotingPower(ctx, consumerId) == 0 { rewardsToSend, rewardsChange := alloc.Rewards.TruncateDecimal() err := k.distributionKeeper.FundCommunityPool(context.Context(ctx), rewardsToSend, k.accountKeeper.GetModuleAccount(ctx, types.ConsumerRewardsPool).GetAddress()) if err != nil { k.Logger(ctx).Error( "fail to allocate rewards from consumer chain %s to community pool: %s", - consumerChainID, + consumerId, err, ) } // set the consumer allocation to the remaining reward decimals alloc.Rewards = rewardsChange - k.SetConsumerRewardsAllocation(ctx, consumerChainID, alloc) + k.SetConsumerRewardsAllocation(ctx, consumerId, alloc) return } @@ -112,7 +112,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { if err != nil { k.Logger(ctx).Error( "cannot get community tax while allocating rewards from consumer chain %s: %s", - consumerChainID, + consumerId, err, ) continue @@ -132,7 +132,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { if err != nil { k.Logger(ctx).Error( "cannot send rewards to distribution module account %s: %s", - consumerChainID, + consumerId, err, ) continue @@ -141,7 +141,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { // allocate tokens to consumer validators k.AllocateTokensToConsumerValidators( ctx, - consumerChainID, + consumerId, sdk.NewDecCoinsFromCoins(validatorsRewardsTrunc...), ) @@ -151,7 +151,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { if err != nil { k.Logger(ctx).Error( "fail to allocate rewards from consumer chain %s to community pool: %s", - consumerChainID, + consumerId, err, ) continue @@ -159,7 +159,7 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { // set consumer allocations to the remaining rewards decimals alloc.Rewards = validatorsRewardsChange.Add(remainingChanges...) - k.SetConsumerRewardsAllocation(ctx, consumerChainID, alloc) + k.SetConsumerRewardsAllocation(ctx, consumerId, alloc) } } diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 841db8330e..a1576ff33d 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -115,44 +115,19 @@ func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalId uint64) return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) } - hasUpdateConsumerMsg := false - for _, msg := range p.GetMessages() { - sdkMsg, isMsgUpdateConsumer := msg.GetCachedValue().(*providertypes.MsgUpdateConsumer) - if isMsgUpdateConsumer { - // A `MsgUpdateConsumer` can only succeed if the owner of the consumer chain is the gov module. - // If that's not the case, we immediately fail the proposal. - // Note that someone could potentially change the owner of a chain to be that of the gov module - // while a proposal is active and before the proposal is executed. Even then, we still do not allow - // `MsgUpdateConsumer` proposals if the owner of the chain is not the gov module to avoid someone forgetting - // to change the owner address while the proposal is active. - ownerAddress, err := h.k.GetConsumerOwnerAddress(ctx, sdkMsg.ConsumerId) - if err != nil { - return fmt.Errorf("cannot find owner address for consumer with consumer id (%s): %s", sdkMsg.ConsumerId, err.Error()) - } else if ownerAddress != h.k.GetAuthority() { - return fmt.Errorf("owner address (%s) is not the gov module (%s)", ownerAddress, h.k.GetAuthority()) - } - - if hasUpdateConsumerMsg { - return fmt.Errorf("proposal can contain at most one `MsgUpdateConsumer` message") - } - hasUpdateConsumerMsg = true - h.k.SetProposalIdToConsumerId(ctx, proposalId, sdkMsg.ConsumerId) - } + err = DoesNotHaveDeprecatedMessage(&p) + if err != nil { + return err + } - // if the proposal contains a deprecated message, cancel the proposal - _, isMsgConsumerAddition := msg.GetCachedValue().(*providertypes.MsgConsumerAddition) - if isMsgConsumerAddition { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerAddition`; use `MsgCreateConsumer` instead") - } + msgUpdateConsumer, err := h.k.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &p) + if err != nil { + return err + } - _, isMsgConsumerModification := msg.GetCachedValue().(*providertypes.MsgConsumerModification) - if isMsgConsumerModification { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerModification`; use `MsgUpdateConsumer` instead") - } - _, isMsgConsumerRemoval := msg.GetCachedValue().(*providertypes.MsgConsumerRemoval) - if isMsgConsumerRemoval { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerRemoval`; use `MsgRemoveConsumer` instead") - } + if msgUpdateConsumer != nil { + // a correctly set `MsgUpdateConsumer` was found + h.k.SetProposalIdToConsumerId(ctx, proposalId, msgUpdateConsumer.ConsumerId) } return nil diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index 1c4a6a5597..af979ff07e 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -6,6 +6,7 @@ import ( "encoding/binary" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "strconv" "time" @@ -692,3 +693,54 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) return initializationParameters.SpawnTime, spawnTimeInTheFuture && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && blocksPerDistributionTransmissionSet && historicalEntriesSet } + +// HasAtMostOnceCorrectMsgUpdateConsumer checks that the proposal has at most one `MsgUpdateConsumer` that is +// correctly set (i.e., the owner address of the to-be-updated consumer corresponds to the gov module). Returns +// the single `MsgUpdateConsumer` message if only one correctly set exists. +func (k Keeper) HasAtMostOnceCorrectMsgUpdateConsumer(ctx sdk.Context, proposal *govv1.Proposal) (*types.MsgUpdateConsumer, error) { + var msgUpdateConsumer *types.MsgUpdateConsumer + for _, msg := range proposal.GetMessages() { + sdkMsg, isMsgUpdateConsumer := msg.GetCachedValue().(*types.MsgUpdateConsumer) + if isMsgUpdateConsumer { + // A `MsgUpdateConsumer` can only succeed if the owner of the consumer chain is the gov module. + // If that's not the case, we immediately fail the proposal. + // Note that someone could potentially change the owner of a chain to be that of the gov module + // while a proposal is active and before the proposal is executed. Even then, we still do not allow + // `MsgUpdateConsumer` proposals if the owner of the chain is not the gov module to avoid someone forgetting + // to change the owner address while the proposal is active. + ownerAddress, err := k.GetConsumerOwnerAddress(ctx, sdkMsg.ConsumerId) + if err != nil { + return nil, fmt.Errorf("cannot find owner address for consumer with consumer id (%s): %s", sdkMsg.ConsumerId, err.Error()) + } else if ownerAddress != k.GetAuthority() { + return nil, fmt.Errorf("owner address (%s) is not the gov module (%s)", ownerAddress, k.GetAuthority()) + } + + if msgUpdateConsumer != nil { + return nil, fmt.Errorf("proposal can contain at most one `MsgUpdateConsumer` message") + } + msgUpdateConsumer = sdkMsg + } + } + return msgUpdateConsumer, nil +} + +// DoesNotHaveDeprecatedMessage checks that the provided proposal does not contain any deprecated messages and returns +// an error if this is the case +func DoesNotHaveDeprecatedMessage(proposal *govv1.Proposal) error { + for _, msg := range proposal.GetMessages() { + // if the proposal contains a deprecated message, cancel the proposal + _, isMsgConsumerAddition := msg.GetCachedValue().(*types.MsgConsumerAddition) + if isMsgConsumerAddition { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerAddition`; use `MsgCreateConsumer` instead") + } + _, isMsgConsumerModification := msg.GetCachedValue().(*types.MsgConsumerModification) + if isMsgConsumerModification { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerModification`; use `MsgUpdateConsumer` instead") + } + _, isMsgConsumerRemoval := msg.GetCachedValue().(*types.MsgConsumerRemoval) + if isMsgConsumerRemoval { + return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerRemoval`; use `MsgRemoveConsumer` instead") + } + } + return nil +} diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index 7e290dea5b..ebd02e61d4 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -2,6 +2,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" @@ -720,3 +721,60 @@ func TestCanLaunch(t *testing.T) { require.NoError(t, err) require.False(t, canLaunch) } + +func TestHasAtMostOnceCorrectMsgUpdateConsumer(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + expectedMsgUpdateConsumer := providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "consumerId", NewOwnerAddress: "new owner address"} + + proposal, err := govv1.NewProposal([]sdk.Msg{&expectedMsgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) + + _, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) + require.ErrorContains(t, err, "cannot find owner address") + + // set owner address that is not the gov module + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner address") + _, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) + require.ErrorContains(t, err, "is not the gov module") + + // set owner address that is the gov module + providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn") + actualMsgUpdateConsumer, err := providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) + require.NoError(t, err) + require.Equal(t, expectedMsgUpdateConsumer, *actualMsgUpdateConsumer) + + // a proposal with 2 `MsgUpdateConsumer` messages + invalidProposal, err := govv1.NewProposal([]sdk.Msg{&expectedMsgUpdateConsumer, &expectedMsgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + actualMsgUpdateConsumer, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &invalidProposal) + require.ErrorContains(t, err, "proposal can contain at most one") + require.Nil(t, actualMsgUpdateConsumer) +} + +func TestDoesNotHaveDeprecatedMessage(t *testing.T) { + msgConsumerAddition := providertypes.MsgConsumerAddition{} + proposal, err := govv1.NewProposal([]sdk.Msg{&msgConsumerAddition}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) + err = keeper.DoesNotHaveDeprecatedMessage(&proposal) + require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerAddition`") + + msgConsumerModification := providertypes.MsgConsumerModification{} + proposal, err = govv1.NewProposal([]sdk.Msg{&msgConsumerModification}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) + err = keeper.DoesNotHaveDeprecatedMessage(&proposal) + require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerModification`") + + msgConsumerRemoval := providertypes.MsgConsumerRemoval{} + proposal, err = govv1.NewProposal([]sdk.Msg{&msgConsumerRemoval}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) + err = keeper.DoesNotHaveDeprecatedMessage(&proposal) + require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerRemoval`") + + // a proposal with no deprecated messages + msgUpdateConsumer := providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "consumerId", NewOwnerAddress: "new owner address"} + proposal, err = govv1.NewProposal([]sdk.Msg{&msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) + err = keeper.DoesNotHaveDeprecatedMessage(&proposal) + require.Nil(t, err) +} diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 407d0e2bb3..e16ec3ebff 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -488,13 +488,13 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { "err", err.Error()) continue } - // The cached context is created with a new EventManager so we merge the event - // into the original context - // TODO (PERMISSIONLESS): verify this here and in the initialized chains to launch - ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) k.SetConsumerPhase(cachedCtx, consumerId, Stopped) k.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, stopTime) + + // The cached context is created with a new EventManager so we merge the event into the original context + ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) + writeFn() k.Logger(ctx).Info("executed consumer removal", From 25f6b82e7041a96b11a9a6c02aedadcfb94db38e Mon Sep 17 00:00:00 2001 From: insumity Date: Tue, 27 Aug 2024 13:04:29 +0200 Subject: [PATCH 05/43] removed check that spawn time is in the future --- x/ccv/provider/keeper/permissionless.go | 5 ++--- x/ccv/provider/keeper/permissionless_test.go | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index af979ff07e..7353b13f86 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -680,8 +680,7 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) return time.Time{}, false } - // a chain can only launch if the spawn time is in the future - spawnTimeInTheFuture := initializationParameters.SpawnTime.After(ctx.BlockTime()) + spawnTimeIsNotZero := !initializationParameters.SpawnTime.Equal(time.Time{}) genesisHashSet := initializationParameters.GenesisHash != nil binaryHashSet := initializationParameters.BinaryHash != nil @@ -690,7 +689,7 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0 historicalEntriesSet := initializationParameters.HistoricalEntries > 0 - return initializationParameters.SpawnTime, spawnTimeInTheFuture && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && + return initializationParameters.SpawnTime, spawnTimeIsNotZero && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && blocksPerDistributionTransmissionSet && historicalEntriesSet } diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index ebd02e61d4..a18fe738cc 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -704,16 +704,6 @@ func TestCanLaunch(t *testing.T) { _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.True(t, canLaunch) - // initialized chain that has spawn time in the past cannot launch - ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(time.Second)) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // reset block time so the chain can launch - ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(-time.Second)) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.True(t, canLaunch) - // chain cannot launch without a genesis hash initializationParameters.GenesisHash = nil err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) From 88a6375e53d983768b5333615f4a3ec0b162e1ce Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 27 Aug 2024 17:06:11 +0200 Subject: [PATCH 06/43] feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity * fix tests --------- Co-authored-by: insumity --- x/ccv/provider/keeper/grpc_query.go | 36 +++--- x/ccv/provider/keeper/partial_set_security.go | 57 ++++++++- .../keeper/partial_set_security_test.go | 113 ++++++++++++++++-- x/ccv/provider/keeper/proposal.go | 6 +- x/ccv/provider/keeper/relay.go | 5 +- 5 files changed, 177 insertions(+), 40 deletions(-) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 5408cc606a..4a167599ec 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -437,29 +437,29 @@ func (k Keeper) hasToValidate( if err != nil { return false, nil } + + minPowerToOptIn := int64(0) + // If the consumer is TopN compute the minimum power if topN := k.GetTopN(ctx, consumerId); topN > 0 { - // in a Top-N chain, we automatically opt in all validators that belong to the top N - minPower, found := k.GetMinimumPowerInTopN(ctx, consumerId) - if found { - k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) - } else { - k.Logger(ctx).Error("did not find min power in top N for chain", "chain", consumerId) + // compute the minimum power to opt-in since the one in the state is stale + // Note that the effective min power will be computed at the end of the epoch + minPowerToOptIn, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + if err != nil { + return false, err } } - // if the validator is opted in and belongs to the validators of the next epoch, then if nothing changes + // if the validator belongs to the validators of the next epoch, then if nothing changes // the validator would have to validate in the next epoch - if k.IsOptedIn(ctx, consumerId, provAddr) { - lastVals, err := k.GetLastBondedValidators(ctx) - if err != nil { - return false, err - } - nextValidators := k.ComputeNextValidators(ctx, consumerId, lastVals) - for _, v := range nextValidators { - consAddr := sdk.ConsAddress(v.ProviderConsAddr) - if provAddr.ToSdkConsAddr().Equals(consAddr) { - return true, nil - } + lastVals, err := k.GetLastBondedValidators(ctx) + if err != nil { + return false, err + } + nextValidators := k.ComputeNextValidators(ctx, consumerId, lastVals, minPowerToOptIn) + for _, v := range nextValidators { + consAddr := sdk.ConsAddress(v.ProviderConsAddr) + if provAddr.ToSdkConsAddr().Equals(consAddr) { + return true, nil } } diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index 305f0f358b..6787429a6f 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -137,7 +137,6 @@ func (k Keeper) OptInTopNValidators(ctx sdk.Context, consumerId string, bondedVa // if validator already exists it gets overwritten k.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(consAddr)) - k.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(consAddr)) } // else validators that do not belong to the top N validators but were opted in, remain opted in } } @@ -322,9 +321,17 @@ func NoMoreThanPercentOfTheSum(validators []types.ConsensusValidator, percent ui // CanValidateChain returns true if the validator `providerAddr` is opted-in to chain with `consumerId` and the allowlist // and denylist do not prevent the validator from validating the chain. -func (k Keeper) CanValidateChain(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { +func (k Keeper) CanValidateChain(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, minPowerToOptIn int64) bool { + // check if the validator is already opted-in + optedIn := k.IsOptedIn(ctx, consumerId, providerAddr) + + // check if the validator is automatically opted-in for a topN chain + if !optedIn && k.GetTopN(ctx, consumerId) > 0 { + optedIn = k.HasMinPower(ctx, providerAddr, minPowerToOptIn) + } + // only consider opted-in validators - return k.IsOptedIn(ctx, consumerId, providerAddr) && + return optedIn && // if an allowlist is declared, only consider allowlisted validators (k.IsAllowlistEmpty(ctx, consumerId) || k.IsAllowlisted(ctx, consumerId, providerAddr)) && @@ -352,7 +359,7 @@ func (k Keeper) FulfillsMinStake(ctx sdk.Context, consumerId string, providerAdd } // ComputeNextValidators computes the validators for the upcoming epoch based on the currently `bondedValidators`. -func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bondedValidators []stakingtypes.Validator) []types.ConsensusValidator { +func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bondedValidators []stakingtypes.Validator, minPowerToOptIn int64) []types.ConsensusValidator { // sort the bonded validators by number of staked tokens in descending order sort.Slice(bondedValidators, func(i, j int) bool { return bondedValidators[i].GetBondedTokens().GT(bondedValidators[j].GetBondedTokens()) @@ -371,9 +378,49 @@ func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bonded nextValidators := k.FilterValidators(ctx, consumerId, bondedValidators, func(providerAddr types.ProviderConsAddress) bool { - return k.CanValidateChain(ctx, consumerId, providerAddr) && k.FulfillsMinStake(ctx, consumerId, providerAddr) + return k.CanValidateChain(ctx, consumerId, providerAddr, minPowerToOptIn) && k.FulfillsMinStake(ctx, consumerId, providerAddr) }) nextValidators = k.CapValidatorSet(ctx, consumerId, nextValidators) return k.CapValidatorsPower(ctx, consumerId, nextValidators) } + +// HasMinPower returns true if the `providerAddr` voting power is GTE than the given minimum power +func (k Keeper) HasMinPower(ctx sdk.Context, providerAddr types.ProviderConsAddress, minPower int64) bool { + val, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.Address) + if err != nil { + k.Logger(ctx).Error( + "cannot get last validator power", + "provider address", + providerAddr, + "error", + err, + ) + return false + } + + valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) + if err != nil { + k.Logger(ctx).Error( + "could not retrieve validator address", + "operator address", + val.GetOperator(), + "error", + err, + ) + return false + } + + power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) + if err != nil { + k.Logger(ctx).Error("could not retrieve last power of validator address", + "operator address", + val.GetOperator(), + "error", + err, + ) + return false + } + + return power >= minPower +} diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index c710e7f299..671150f865 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -2,6 +2,7 @@ package keeper_test import ( "bytes" + "fmt" "sort" "testing" @@ -384,29 +385,45 @@ func TestCanValidateChain(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - validator := createStakingValidator(ctx, mocks, 0, 1, 1) + consumerID := "0" + + validator := createStakingValidator(ctx, mocks, 0, 1, 1) // adds GetLastValidatorPower expectation to mocks consAddr, _ := validator.GetConsAddr() providerAddr := types.NewProviderConsAddress(consAddr) // with no allowlist or denylist, the validator has to be opted in, in order to consider it - require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) - providerKeeper.SetOptedIn(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 0)) + + // with TopN chains, the validator can be considered, + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), providerAddr.Address).Return(validator, nil).Times(2) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 50}) + // validator's power is LT the min power + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) + // validator's power is GTE the min power + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + + // when validator is opted-in it can validate regardless of its min power + providerKeeper.SetOptedIn(ctx, consumerID, types.NewProviderConsAddress(consAddr)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) + + // With OptIn chains, validator can validate only if it has already opted-in + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 0}) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) // create an allow list but do not add the validator `providerAddr` to it validatorA := createStakingValidator(ctx, mocks, 1, 1, 2) consAddrA, _ := validatorA.GetConsAddr() - providerKeeper.SetAllowlist(ctx, "consumerId", types.NewProviderConsAddress(consAddrA)) - require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) - providerKeeper.SetAllowlist(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + providerKeeper.SetAllowlist(ctx, consumerID, types.NewProviderConsAddress(consAddrA)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + providerKeeper.SetAllowlist(ctx, consumerID, types.NewProviderConsAddress(consAddr)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) // create a denylist but do not add validator `providerAddr` to it - providerKeeper.SetDenylist(ctx, "consumerId", types.NewProviderConsAddress(consAddrA)) - require.True(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + providerKeeper.SetDenylist(ctx, consumerID, types.NewProviderConsAddress(consAddrA)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) // add validator `providerAddr` to the denylist - providerKeeper.SetDenylist(ctx, "consumerId", types.NewProviderConsAddress(consAddr)) - require.False(t, providerKeeper.CanValidateChain(ctx, "consumerId", providerAddr)) + providerKeeper.SetDenylist(ctx, consumerID, types.NewProviderConsAddress(consAddr)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) } func TestCapValidatorSet(t *testing.T) { @@ -820,7 +837,7 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { providerKeeper.SetParams(ctx, params) // Compute the next validators - nextVals := providerKeeper.ComputeNextValidators(ctx, "consumerId", vals) + nextVals := providerKeeper.ComputeNextValidators(ctx, "consumerId", vals, 0) // Check that the length of nextVals is at most maxProviderConsensusVals require.LessOrEqual(r, len(nextVals), int(maxProviderConsensusVals), "The length of nextVals should be at most maxProviderConsensusVals") @@ -843,3 +860,73 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { } }) } + +func TestHasMinPower(t *testing.T) { + pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + providerConsPubKey := ed25519.GenPrivKeyFromSecret([]byte{1}).PubKey() + consAddr := sdk.ConsAddress(providerConsPubKey.Address()) + providerAddr := types.NewProviderConsAddress(consAddr) + + testCases := []struct { + name string + minPower uint64 + expectation func(sdk.ConsAddress, testkeeper.MockedKeepers) + hasMinPower bool + }{ + { + name: "cannot find validator by cons address", + expectation: func(sdk.ConsAddress, testkeeper.MockedKeepers) { + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr). + Return(stakingtypes.Validator{}, fmt.Errorf("validator not found")).Times(1) + }, + hasMinPower: false, + }, { + name: "cannot convert validator operator address", + expectation: func(consAddr sdk.ConsAddress, mocks testkeeper.MockedKeepers) { + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr).Return(stakingtypes.Validator{OperatorAddress: "xxxx"}, nil).Times(1) + }, + hasMinPower: false, + }, { + name: "cannot find last validator power", + expectation: func(consAddr sdk.ConsAddress, mocks testkeeper.MockedKeepers) { + valAddr := sdk.ValAddress(providerAddr.Address.Bytes()) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr). + Return(stakingtypes.Validator{OperatorAddress: valAddr.String()}, nil) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr). + Return(int64(0), fmt.Errorf("last power not found")).Times(1) + }, + hasMinPower: false, + }, { + name: "validator power is LT min power", + expectation: func(consAddr sdk.ConsAddress, mocks testkeeper.MockedKeepers) { + valAddr := sdk.ValAddress(providerAddr.Address.Bytes()) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr). + Return(stakingtypes.Validator{OperatorAddress: valAddr.String()}, nil) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr). + Return(int64(5), nil).Times(1) + }, + hasMinPower: false, + }, { + name: "validator power is GTE min power", + expectation: func(consAddr sdk.ConsAddress, mocks testkeeper.MockedKeepers) { + valAddr := sdk.ValAddress(providerAddr.Address.Bytes()) + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), consAddr). + Return(stakingtypes.Validator{OperatorAddress: valAddr.String()}, nil) + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAddr). + Return(int64(10), nil).Times(1) + }, + hasMinPower: true, + }, + } + + minPower := int64(10) + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tc.expectation(consAddr, mocks) + require.Equal(t, tc.hasMinPower, pk.HasMinPower(ctx, providerAddr, minPower)) + }) + } +} diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index e16ec3ebff..fb1920c453 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -232,6 +232,7 @@ func (k Keeper) MakeConsumerGenesis( return gen, nil, errorsmod.Wrapf(stakingtypes.ErrNoValidatorFound, "error getting last bonded validators: %s", err) } + minPower := int64(0) if powerShapingParameters.Top_N > 0 { // get the consensus active validators // we do not want to base the power calculation for the top N @@ -243,7 +244,7 @@ func (k Keeper) MakeConsumerGenesis( } // in a Top-N chain, we automatically opt in all validators that belong to the top N - minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) + minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) if err != nil { return gen, nil, err } @@ -255,8 +256,9 @@ func (k Keeper) MakeConsumerGenesis( k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) k.SetMinimumPowerInTopN(ctx, consumerId, minPower) } + // need to use the bondedValidators, not activeValidators, here since the chain might be opt-in and allow inactive vals - nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) k.SetConsumerValSet(ctx, consumerId, nextValidators) // get the initial updates with the latest set consumer public keys diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index b0e8bb4e83..cfa8ec5a9f 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -199,6 +199,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { } topN := k.GetTopN(ctx, consumerId) + minPower := int64(0) if topN > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N // of the active validators @@ -208,7 +209,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { panic(fmt.Errorf("failed to get active validators: %w", err)) } - minPower, err := k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) if err != nil { // we panic, since the only way to proceed would be to opt in all validators, which is not the intended behavior panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", consumerId, err)) @@ -220,7 +221,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) } - nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) valUpdates := DiffValidators(currentValidators, nextValidators) k.SetConsumerValSet(ctx, consumerId, nextValidators) From 2ca28cd93a931df68120148baf48dbbf1f348f0f Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Tue, 27 Aug 2024 20:39:33 +0200 Subject: [PATCH 07/43] fix!: ConsumerModificationProposal is needed in Gaia upgrade handler (#2176) ConsumerModificationProposal is needed in Gaia upgrade handler --- x/ccv/provider/types/legacy_proposal.go | 54 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/types/legacy_proposal.go b/x/ccv/provider/types/legacy_proposal.go index f29f3b6c07..3124cc3d87 100644 --- a/x/ccv/provider/types/legacy_proposal.go +++ b/x/ccv/provider/types/legacy_proposal.go @@ -20,8 +20,8 @@ import ( const ( ProposalTypeConsumerAddition = "ConsumerAddition" - ProposalTypeConsumerRemoval = "RemoveConsumer" - ProposalTypeConsumerModification = "UpdateConsumer" + ProposalTypeConsumerRemoval = "ConsumerRemoval" + ProposalTypeConsumerModification = "ConsumerModification" ProposalTypeEquivocation = "Equivocation" ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms" ) @@ -29,6 +29,7 @@ const ( var ( _ govv1beta1.Content = &ConsumerAdditionProposal{} _ govv1beta1.Content = &ConsumerRemovalProposal{} + _ govv1beta1.Content = &ConsumerModificationProposal{} _ govv1beta1.Content = &ChangeRewardDenomsProposal{} _ govv1beta1.Content = &EquivocationProposal{} ) @@ -239,6 +240,55 @@ func (sccp *ConsumerRemovalProposal) ValidateBasic() error { return nil } +// NewConsumerModificationProposal creates a new consumer modification proposal. +func NewConsumerModificationProposal(title, description, chainID string, + topN uint32, + validatorsPowerCap uint32, + validatorSetCap uint32, + allowlist []string, + denylist []string, + minStake uint64, + allowInactiveVals bool, +) govv1beta1.Content { + return &ConsumerModificationProposal{ + Title: title, + Description: description, + ChainId: chainID, + Top_N: topN, + ValidatorsPowerCap: validatorsPowerCap, + ValidatorSetCap: validatorSetCap, + Allowlist: allowlist, + Denylist: denylist, + MinStake: minStake, + AllowInactiveVals: allowInactiveVals, + } +} + +// ProposalRoute returns the routing key of a consumer modification proposal. +func (cccp *ConsumerModificationProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the consumer modification proposal. +func (cccp *ConsumerModificationProposal) ProposalType() string { + return ProposalTypeConsumerModification +} + +// ValidateBasic runs basic stateless validity checks +func (cccp *ConsumerModificationProposal) ValidateBasic() error { + if err := govv1beta1.ValidateAbstract(cccp); err != nil { + return err + } + + if strings.TrimSpace(cccp.ChainId) == "" { + return errorsmod.Wrap(ErrInvalidConsumerModificationProposal, "consumer chain id must not be blank") + } + + err := ValidatePSSFeatures(cccp.Top_N, cccp.ValidatorsPowerCap) + if err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) + } + return nil +} + // NewEquivocationProposal creates a new equivocation proposal. // [DEPRECATED]: do not use because equivocations can be submitted // and verified automatically on the provider. From 8fdfad99afe13104763bd5813d02daa39b816a83 Mon Sep 17 00:00:00 2001 From: insumity Date: Tue, 27 Aug 2024 21:11:48 +0200 Subject: [PATCH 08/43] fix: allow the owner of a chain to remove the chain (#2178) fixed access in RemoveConsumer --- .../ccv/provider/v1/tx.proto | 4 +- x/ccv/provider/keeper/msg_server.go | 16 +- x/ccv/provider/types/msg.go | 4 +- x/ccv/provider/types/tx.pb.go | 281 +++++++++--------- 4 files changed, 154 insertions(+), 151 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 80b4885603..19541025e5 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -224,7 +224,7 @@ message MsgConsumerRemovalResponse {} // MsgRemoveConsumer defines the message used to remove (and stop) a consumer chain. // If it passes, all the consumer chain's state is eventually removed from the provider chain. message MsgRemoveConsumer { - option (cosmos.msg.v1.signer) = "authority"; + option (cosmos.msg.v1.signer) = "signer"; // the consumer id of the consumer chain to be stopped string consumer_id = 1; @@ -233,7 +233,7 @@ message MsgRemoveConsumer { google.protobuf.Timestamp stop_time = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; // signer address - string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgRemoveConsumerResponse defines response type for MsgRemoveConsumer messages diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index fb81b0ef12..aa6b8f9aab 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -87,16 +87,18 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign } // RemoveConsumer defines an RPC handler method for MsgRemoveConsumer -func (k msgServer) RemoveConsumer( - goCtx context.Context, - msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { - if k.GetAuthority() != msg.Authority { - return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) - } - +func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) consumerId := msg.ConsumerId + ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) + if err != nil { + return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) + } + + if msg.Signer != ownerAddress { + return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + } phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId) if !found || phase != Launched { diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 21b9173eca..44466a1a75 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -368,7 +368,7 @@ func (msg MsgUpdateConsumer) GetSigners() []sdk.AccAddress { // NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance func NewMsgRemoveConsumer(signer string, consumerId string, stopTime time.Time) (*MsgRemoveConsumer, error) { return &MsgRemoveConsumer{ - Authority: signer, + Signer: signer, ConsumerId: consumerId, StopTime: stopTime, }, nil @@ -399,7 +399,7 @@ func (msg MsgRemoveConsumer) GetSignBytes() []byte { // GetSigners implements the sdk.Msg interface. It returns the address(es) that // must sign over msg.GetSignBytes(). func (msg MsgRemoveConsumer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Authority) + valAddr, err := sdk.ValAddressFromBech32(msg.Signer) if err != nil { // same behavior as in cosmos-sdk panic(err) diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index b5c78c5e32..447ce8d15c 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -775,7 +775,7 @@ type MsgRemoveConsumer struct { // stop their consumer chain validator node StopTime time.Time `protobuf:"bytes,2,opt,name=stop_time,json=stopTime,proto3,stdtime" json:"stop_time"` // signer address - Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgRemoveConsumer) Reset() { *m = MsgRemoveConsumer{} } @@ -825,9 +825,9 @@ func (m *MsgRemoveConsumer) GetStopTime() time.Time { return time.Time{} } -func (m *MsgRemoveConsumer) GetAuthority() string { +func (m *MsgRemoveConsumer) GetSigner() string { if m != nil { - return m.Authority + return m.Signer } return "" } @@ -1692,137 +1692,138 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 2079 bytes of a gzipped FileDescriptorProto + // 2086 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0x4d, 0x70, 0x1c, 0x47, - 0x15, 0xd6, 0xec, 0xae, 0x94, 0xdd, 0x5e, 0x59, 0x3f, 0x2d, 0x39, 0x1a, 0xad, 0x6d, 0xad, 0x2c, - 0x42, 0xa2, 0x32, 0xd1, 0x6c, 0x2c, 0xb0, 0x03, 0xc2, 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 0xa5, 0x50, 0x70, 0x1f, 0xbc, 0x24, - 0xcf, 0x31, 0x13, 0xce, 0x59, 0x19, 0x26, 0x69, 0xda, 0x23, 0x8c, 0x09, 0x36, 0xb0, 0xac, 0xad, - 0x16, 0xcd, 0xab, 0x11, 0xf6, 0x00, 0x87, 0x3b, 0x29, 0xe4, 0xbd, 0x14, 0x10, 0xae, 0x01, 0xd8, - 0x22, 0x8c, 0xd3, 0x90, 0xd8, 0xa8, 0x6d, 0x61, 0x9f, 0x87, 0x04, 0x33, 0xbd, 0x2a, 0xd5, 0x67, - 0x7b, 0x92, 0xdb, 0x91, 0x00, 0xbe, 0x01, 0xae, 0x9e, 0x68, 0xd4, 0xb2, 0x5b, 0xc8, 0xf7, 0x71, - 0x5b, 0x9f, 0x94, 0xa1, 0xd4, 0x9d, 0x13, 0x6c, 0x6e, 0x47, 0x30, 0x38, 0x07, 0xc6, 0x39, 0x0d, - 0xac, 0xbb, 0xfa, 0x85, 0x65, 0x6d, 0xf5, 0x82, 0x59, 0xe2, 0x34, 0xb8, 0x0b, 0x5f, 0x03, 0xf3, - 0x5d, 0xd4, 0x26, 0x0e, 0xe2, 0x34, 0x64, 0x56, 0x40, 0x8f, 0x70, 0x68, 0xd9, 0x28, 0xd0, 0xa7, - 0x24, 0x06, 0xf6, 0x64, 0x07, 0x42, 0xb4, 0x8d, 0x02, 0x78, 0x0d, 0xcc, 0x26, 0xab, 0x16, 0xc3, - 0x5c, 0xc2, 0xa7, 0x25, 0x7c, 0x3a, 0x11, 0x1c, 0x62, 0x2e, 0xb0, 0x97, 0x41, 0x05, 0xb5, 0xdb, - 0xf4, 0xa8, 0x4d, 0x18, 0xd7, 0x67, 0x96, 0x8b, 0xab, 0x15, 0xb3, 0xb7, 0x00, 0x6b, 0xa0, 0xec, - 0x60, 0xff, 0x58, 0x0a, 0x67, 0xa5, 0x30, 0x79, 0xce, 0x76, 0x1d, 0x98, 0xbf, 0xeb, 0x5c, 0x02, - 0x15, 0x4f, 0xf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0x7a, 0x72, 0x7b, 0xf5, 0xc4, 0x86, 0x76, 0x6e, 0xe8, 0x49, 0xdd, 0x46, 0x0a, 0xa1, 0x37, 0x02, + 0xf9, 0xbe, 0x08, 0xbc, 0x98, 0x8c, 0x40, 0xd7, 0x94, 0xd5, 0x57, 0xc0, 0x17, 0xcf, 0xf4, 0x31, + 0x8e, 0xc6, 0x5f, 0x72, 0x03, 0xa2, 0xb1, 0x4b, 0xdb, 0x8d, 0x16, 0x7e, 0x40, 0x39, 0xf1, 0x9c, + 0x91, 0xa3, 0x61, 0x82, 0x45, 0xbb, 0xed, 0xb7, 0x88, 0x85, 0x38, 0x36, 0x3b, 0x94, 0x63, 0x33, + 0x4a, 0x52, 0x15, 0x98, 0x57, 0x92, 0x71, 0x90, 0x69, 0xac, 0xef, 0x46, 0x02, 0x0f, 0x28, 0xc7, + 0x77, 0x14, 0xbb, 0x71, 0xc9, 0x1e, 0xb4, 0x0c, 0x7f, 0x0c, 0x16, 0x89, 0xf7, 0x30, 0x40, 0x96, + 0x28, 0x02, 0x66, 0xa3, 0x45, 0xad, 0x47, 0x66, 0x13, 0x23, 0x1b, 0x07, 0x32, 0x50, 0xe5, 0x8d, + 0x97, 0xcf, 0x8b, 0xfc, 0x5d, 0xc9, 0x6d, 0x5c, 0xea, 0xc2, 0x6c, 0x0b, 0x94, 0x70, 0xb9, 0x37, + 0xf8, 0x85, 0x0b, 0x05, 0x3f, 0x19, 0xd2, 0x38, 0xf8, 0xbf, 0xd2, 0xc0, 0xcc, 0x3e, 0x73, 0x7e, + 0xe0, 0xdb, 0x88, 0xe3, 0x43, 0x14, 0x20, 0x97, 0x89, 0x70, 0xa3, 0x36, 0x6f, 0x52, 0x51, 0x38, + 0xce, 0x0f, 0x77, 0xcc, 0x0a, 0xf7, 0xc0, 0x84, 0x2f, 0x11, 0x54, 0x74, 0xbf, 0xa4, 0x67, 0x28, + 0xd3, 0x7a, 0xa8, 0x74, 0xbb, 0xf0, 0xe1, 0xd3, 0xda, 0x98, 0xa1, 0x00, 0x36, 0xa7, 0xa5, 0x3f, + 0x31, 0xf4, 0xea, 0x12, 0x58, 0xec, 0xb1, 0x32, 0xf6, 0xe0, 0x93, 0x22, 0x98, 0xdf, 0x67, 0x4e, + 0xe4, 0xe5, 0x96, 0x6d, 0x13, 0x11, 0x46, 0xb8, 0xd4, 0x5b, 0x67, 0xba, 0x35, 0xe6, 0xbb, 0x60, + 0x9a, 0x78, 0x84, 0x13, 0xd4, 0x32, 0x9b, 0x58, 0xec, 0x8d, 0x32, 0xb8, 0x2a, 0x77, 0x4b, 0xd4, + 0x56, 0x5d, 0x55, 0x54, 0xb9, 0x43, 0x82, 0x43, 0xd9, 0x37, 0xa5, 0xe4, 0xc2, 0x45, 0x51, 0x73, + 0x1c, 0xec, 0x61, 0x46, 0x98, 0xd9, 0x44, 0xac, 0x29, 0x37, 0x7d, 0xd2, 0x28, 0xab, 0xb5, 0xbb, + 0x88, 0x35, 0xc5, 0x16, 0x36, 0x88, 0x87, 0x82, 0x93, 0x90, 0xa3, 0x20, 0x39, 0x40, 0xb8, 0x24, + 0x19, 0x76, 0x00, 0x60, 0x3e, 0x3a, 0xf6, 0x4c, 0xd1, 0x6d, 0x64, 0x85, 0x11, 0x86, 0x84, 0x9d, + 0x44, 0x8f, 0x3a, 0x89, 0x7e, 0x3f, 0x6a, 0x45, 0xdb, 0x45, 0x61, 0xc8, 0x93, 0xbf, 0xd5, 0x34, + 0xa3, 0x24, 0xe5, 0x04, 0x05, 0xde, 0x03, 0xb3, 0x6d, 0xaf, 0x41, 0x3d, 0x9b, 0x78, 0x8e, 0xe9, + 0xe3, 0x80, 0x50, 0xbb, 0x32, 0x21, 0xa1, 0x96, 0xfa, 0xa0, 0x76, 0x55, 0xd3, 0x0a, 0x91, 0x7e, + 0x21, 0x90, 0x66, 0x62, 0xe1, 0x43, 0x29, 0x0b, 0xdf, 0x04, 0xd0, 0xb2, 0x3a, 0xd2, 0x24, 0xda, + 0xe6, 0x11, 0xe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, 0x56, 0xb7, 0x47, 0x97, 0x8d, 0x6c, + 0xab, 0x8e, 0xff, 0xf4, 0xd3, 0xf7, 0xaf, 0x6b, 0xdb, 0x6f, 0x7d, 0xf8, 0x6c, 0x59, 0xfb, 0xe8, + 0xd9, 0xb2, 0xf6, 0xf7, 0x67, 0xcb, 0xda, 0x93, 0xe7, 0xcb, 0x63, 0x1f, 0x3d, 0x5f, 0x1e, 0xfb, + 0xeb, 0xf3, 0xe5, 0xb1, 0x1f, 0x7e, 0xc3, 0x21, 0xbc, 0xd9, 0x6e, 0xe8, 0x16, 0x75, 0xd5, 0xaf, + 0xb4, 0xf5, 0xae, 0xd6, 0xf5, 0xf8, 0x47, 0xd6, 0xce, 0xcd, 0xfa, 0xdb, 0xe9, 0x5f, 0x5a, 0xe5, + 0x6f, 0x4a, 0x8d, 0x09, 0xf9, 0xf2, 0xf5, 0xe5, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x96, 0xcd, + 0x06, 0xd7, 0xe5, 0x1e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2962,10 +2963,10 @@ func (m *MsgRemoveConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- dAtA[i] = 0x1a } @@ -3908,7 +3909,7 @@ func (m *MsgRemoveConsumer) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime) n += 1 + l + sovTx(uint64(l)) - l = len(m.Authority) + l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -6028,7 +6029,7 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6056,7 +6057,7 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From 50475e6af41cd7bef8bc49484b56b021472312c3 Mon Sep 17 00:00:00 2001 From: mpoke Date: Wed, 28 Aug 2024 14:32:31 +0200 Subject: [PATCH 09/43] refactor: add proto enum for ConsumerPhase (#2182) --- .../ccv/provider/v1/provider.proto | 17 + tests/integration/setup.go | 4 +- testutil/ibc_testing/generic_setup.go | 6 +- testutil/keeper/unit_test_helpers.go | 2 +- x/ccv/provider/handler_test.go | 10 +- x/ccv/provider/keeper/grpc_query_test.go | 6 +- x/ccv/provider/keeper/hooks_test.go | 10 +- x/ccv/provider/keeper/keeper.go | 6 +- x/ccv/provider/keeper/key_assignment.go | 14 +- x/ccv/provider/keeper/key_assignment_test.go | 18 +- x/ccv/provider/keeper/msg_server.go | 25 +- x/ccv/provider/keeper/msg_server_test.go | 20 +- x/ccv/provider/keeper/partial_set_security.go | 8 +- .../keeper/partial_set_security_test.go | 10 +- x/ccv/provider/keeper/permissionless.go | 46 +-- x/ccv/provider/keeper/permissionless_test.go | 31 +- x/ccv/provider/keeper/proposal.go | 8 +- x/ccv/provider/keeper/proposal_test.go | 55 ++- x/ccv/provider/types/provider.pb.go | 318 ++++++++++-------- 19 files changed, 332 insertions(+), 282 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 7204d5754b..3a4a1108aa 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -464,3 +464,20 @@ message PowerShapingParameters { // ConsumerIds contains consumer ids of chains // Used so we can easily (de)serialize slices of strings message ConsumerIds { repeated string ids = 1; } + +// ConsumerPhase indicates the phases of a consumer chain according to ADR 019 +enum ConsumerPhase { + // UNSPECIFIED defines an empty phase. + CONSUMER_PHASE_UNSPECIFIED = 0; + // REGISTERED defines the phase in which a consumer chain has been assigned a unique consumer id. + // A chain in this phase cannot yet launch. + CONSUMER_PHASE_REGISTERED = 1; + // INITIALIZED defines the phase in which a consumer chain has set all the needed parameters to launch but + // has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached). + CONSUMER_PHASE_INITIALIZED = 2; + // LAUNCHED defines the phase in which a consumer chain is running and consuming a subset of the validator + // set of the provider. + CONSUMER_PHASE_LAUNCHED = 3; + // STOPPED defines the phase in which a previously-launched chain has stopped. + CONSUMER_PHASE_STOPPED = 4; +} diff --git a/tests/integration/setup.go b/tests/integration/setup.go index 20924e9b2e..04f1882113 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -3,7 +3,6 @@ package integration import ( "context" "fmt" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "testing" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" @@ -22,6 +21,7 @@ import ( icstestingutils "github.com/cosmos/interchain-security/v5/testutil/ibc_testing" testutil "github.com/cosmos/interchain-security/v5/testutil/integration" consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -150,7 +150,7 @@ func (suite *CCVTestSuite) SetupTest() { // 2. MakeGenesis is called on the provider chain // 3. ibc/testing sets the tendermint header for the consumer chain app - providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, keeper.Initialized) + providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) preProposalKeyAssignment(suite, icstestingutils.FirstConsumerId) // start consumer chains diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 12fe71a34e..8b0cdfa9f0 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -3,10 +3,10 @@ package ibc_testing import ( "encoding/json" "fmt" - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "testing" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + ibctesting "github.com/cosmos/ibc-go/v8/testing" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" "github.com/stretchr/testify/require" @@ -158,7 +158,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata) providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) - providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, keeper.Initialized) + providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(providerChain.GetContext(), consumerId, coordinator.CurrentTime) // opt-in all validators diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index b27129c543..a7ef6d7563 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -235,7 +235,7 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, providerKeeper.SetConsumerMetadata(ctx, consumerId, GetTestConsumerMetadata()) providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, GetTestInitializationParameters()) providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters()) - providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err := providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) diff --git a/x/ccv/provider/handler_test.go b/x/ccv/provider/handler_test.go index 7ea306f47e..0d06ba7dea 100644 --- a/x/ccv/provider/handler_test.go +++ b/x/ccv/provider/handler_test.go @@ -55,7 +55,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), @@ -88,7 +88,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), @@ -103,7 +103,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // Use the consumer key already used by some other validator k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) @@ -127,7 +127,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // Use the consumer key already k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr) @@ -149,7 +149,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // Use the consumer key already used by some other validator k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index bbc61794d8..bb51e85952 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -83,7 +81,7 @@ func TestQueryConsumerChainOptedInValidators(t *testing.T) { require.Error(t, err) pk.FetchAndIncrementConsumerId(ctx) - pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized) + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) @@ -253,7 +251,7 @@ func TestQueryValidatorConsumerCommissionRate(t *testing.T) { require.Error(t, err) pk.FetchAndIncrementConsumerId(ctx) - pk.SetConsumerPhase(ctx, consumerId, keeper.Initialized) + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // validator with set consumer commission rate expectedCommissionRate := math.LegacyMustNewDecFromStr("0.123") diff --git a/x/ccv/provider/keeper/hooks_test.go b/x/ccv/provider/keeper/hooks_test.go index 8f7f90c948..bc6450923f 100644 --- a/x/ccv/provider/keeper/hooks_test.go +++ b/x/ccv/provider/keeper/hooks_test.go @@ -1,12 +1,14 @@ package keeper_test import ( + "testing" + sdk "github.com/cosmos/cosmos-sdk/types" cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/golang/mock/gomock" - "testing" ) func TestValidatorConsensusKeyInUse(t *testing.T) { @@ -30,7 +32,7 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { name: "in use by another validator", setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) + k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator @@ -47,8 +49,8 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) - k.SetConsumerPhase(ctx, "1", providerkeeper.Initialized) + k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "1", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator, of which there are several, across potentially several chains diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 66df230b09..318fb7c90c 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -752,8 +752,10 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { consumerIds := []string{} for i := uint64(0); i < latestConsumerId; i++ { consumerId := fmt.Sprintf("%d", i) - phase, foundPhase := k.GetConsumerPhase(ctx, consumerId) - if !foundPhase || (phase != Registered && phase != Initialized && phase != Launched) { + phase := k.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && + phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && + phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { continue } consumerIds = append(consumerIds, consumerId) diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index 2e3846feb4..c01a061266 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -403,12 +403,14 @@ func (k Keeper) AssignConsumerKey( validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey, ) error { - phase, found := k.GetConsumerPhase(ctx, consumerId) - if !found || phase == Stopped { - //check that the consumer chain is either registered, initialized, or launched + phase := k.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && + phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && + phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + // check that the consumer chain is either registered, initialized, or launched return errorsmod.Wrapf( - types.ErrUnknownConsumerId, consumerId, - ) + types.ErrInvalidPhase, + "cannot assign a key to a consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) } consAddrTmp, err := ccvtypes.TMCryptoPublicKeyToConsAddr(consumerKey) @@ -460,7 +462,7 @@ func (k Keeper) AssignConsumerKey( oldConsumerAddr := types.NewConsumerConsAddress(oldConsumerAddrTmp) // check whether the consumer chain has already launched (i.e., a client to the consumer was already created) - if phase == Launched { + if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { // mark the old consumer address as prunable once UnbondingPeriod elapses; // note: this state is removed on EndBlock unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index 290b8a6048..9779b727ca 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -393,7 +393,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -420,7 +420,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(sdkCtx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(sdkCtx, consumerId, providerkeeper.Launched) + k.SetConsumerPhase(sdkCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(sdkCtx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -450,7 +450,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -477,7 +477,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), @@ -495,7 +495,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -520,7 +520,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -550,7 +550,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -577,7 +577,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), @@ -613,7 +613,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - providerKeeper.SetConsumerPhase(ctx, "consumerId", providerkeeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // Mock that the validator is validating with the single key, as confirmed by provider's staking keeper gomock.InOrder( diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index aa6b8f9aab..28e0ef24ba 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -2,8 +2,11 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" "fmt" + "strings" + "time" + + errorsmod "cosmossdk.io/errors" tmtypes "github.com/cometbft/cometbft/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,8 +14,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" - "strings" - "time" ) type msgServer struct { @@ -100,8 +101,8 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) } - phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId) - if !found || phase != Launched { + phase := k.Keeper.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { return nil, errorsmod.Wrapf(types.ErrInvalidPhase, "chain with consumer id: %s has to be in its launched phase", consumerId) } @@ -315,7 +316,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) k.Keeper.SetConsumerChainId(ctx, consumerId, msg.ChainId) - k.Keeper.SetConsumerPhase(ctx, consumerId, Registered) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, @@ -343,7 +344,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) @@ -358,10 +359,12 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon ctx := sdk.UnwrapSDKContext(goCtx) consumerId := msg.ConsumerId - phase, found := k.Keeper.GetConsumerPhase(ctx, consumerId) - if found && phase == Stopped { + phase := k.Keeper.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && + phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && + phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPhase, - "cannot update consumer chain that is in the stopped phase: %s", consumerId) + "cannot update consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) } ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) @@ -446,7 +449,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, Initialized) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index b9e1f05b58..fd353e38bf 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -1,13 +1,14 @@ package keeper_test import ( + "testing" + "time" + "github.com/cosmos/cosmos-sdk/codec/address" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/stretchr/testify/require" - "testing" - "time" ) func TestCreateConsumer(t *testing.T) { @@ -31,9 +32,8 @@ func TestCreateConsumer(t *testing.T) { require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "0") require.Equal(t, "signer", ownerAddress) - phase, found := providerKeeper.GetConsumerPhase(ctx, "0") - require.True(t, found) - require.Equal(t, providerkeeper.Registered, phase) + phase := providerKeeper.GetConsumerPhase(ctx, "0") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) consumerMetadata = providertypes.ConsumerMetadata{ Name: "chain name", @@ -51,9 +51,8 @@ func TestCreateConsumer(t *testing.T) { require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "1") require.Equal(t, "signer2", ownerAddress) - phase, found = providerKeeper.GetConsumerPhase(ctx, "1") - require.True(t, found) - require.Equal(t, providerkeeper.Registered, phase) + phase = providerKeeper.GetConsumerPhase(ctx, "1") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) } func TestUpdateConsumer(t *testing.T) { @@ -132,9 +131,8 @@ func TestUpdateConsumer(t *testing.T) { require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) // assert phase - phase, found := providerKeeper.GetConsumerPhase(ctx, consumerId) - require.True(t, found) - require.Equal(t, providerkeeper.Initialized, phase) + phase := providerKeeper.GetConsumerPhase(ctx, consumerId) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) // assert that chain is set to launch consumerIds, err := providerKeeper.GetConsumersToBeLaunched(ctx, expectedInitializationParameters.SpawnTime) diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index 6787429a6f..2a3152a27d 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -16,11 +16,13 @@ import ( // HandleOptIn prepares validator `providerAddr` to opt in to `consumerId` with an optional `consumerKey` consumer public key. // Note that the validator only opts in at the end of an epoch. func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, consumerKey string) error { - phase, found := k.GetConsumerPhase(ctx, consumerId) - if !found || phase == Stopped { + phase := k.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && + phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && + phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { return errorsmod.Wrapf( types.ErrInvalidPhase, - "opting in to an unknown (or stopped) consumer chain, with id: %s", consumerId) + "cannot opt in to a consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) } chainId, err := k.GetConsumerChainId(ctx, consumerId) diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index 671150f865..cbccfe7e9e 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -37,10 +37,10 @@ func TestHandleOptIn(t *testing.T) { require.Error(t, providerKeeper.HandleOptIn(ctx, "unknownConsumerId", providerAddr, "")) // trying to opt in to a stopped consumer chain - providerKeeper.SetConsumerPhase(ctx, "stoppedConsumerId", keeper.Stopped) + providerKeeper.SetConsumerPhase(ctx, "stoppedConsumerId", types.ConsumerPhase_CONSUMER_PHASE_STOPPED) require.Error(t, providerKeeper.HandleOptIn(ctx, "stoppedConsumerId", providerAddr, "")) - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId", "chainId") require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) err := providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, "") @@ -49,7 +49,7 @@ func TestHandleOptIn(t *testing.T) { // validator tries to opt in to another chain with chain id ("chainId") while it is already opted in to // a different chain with the same chain id - providerKeeper.SetConsumerPhase(ctx, "consumerId2", keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId2", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId2", "chainId") err = providerKeeper.HandleOptIn(ctx, "consumerId2", providerAddr, "") require.ErrorContains(t, err, "validator is already opted in to a chain") @@ -89,7 +89,7 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { expectedConsumerPubKey, err := providerKeeper.ParseConsumerKey(consumerKey) require.NoError(t, err) - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId", "consumerId") err = providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, consumerKey) require.NoError(t, err) @@ -198,7 +198,7 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { // setup a pending consumer chain consumerId := "0" providerKeeper.FetchAndIncrementConsumerId(ctx) - providerKeeper.SetConsumerPhase(ctx, consumerId, keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: consumerId}) // check that there's no commission rate set for the validator yet diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index 7353b13f86..e77d152bd2 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -1,35 +1,16 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" - storetypes "cosmossdk.io/store/types" "encoding/binary" "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "strconv" "time" -) -// ConsumerPhase captures the phases of a consumer chain according to `docs/docs/adrs/adr-018-permissionless-ics.md` -type ConsumerPhase byte - -const ( - // Registered phase indicates the phase in which a consumer chain has been assigned a unique consumer id. This consumer - // id can be used to interact with the consumer chain (e.g., when a validator opts in to a chain). A chain in this - // phase cannot yet launch. It has to be initialized first. - Registered ConsumerPhase = iota - // Initialized phase indicates the phase in which a consumer chain has set all the needed parameters to launch but - // has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached). - Initialized - // FailedToLaunch phase indicates that the chain attempted but failed to launch (e.g., due to no validator opting in). - FailedToLaunch - // Launched phase corresponds to the phase in which a consumer chain is running and consuming a subset of the validator - // set of the provider. - Launched - // Stopped phase corresponds to the phase in which a previously-launched chain has stopped. - Stopped + errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) // setConsumerId sets the provided consumerId @@ -198,19 +179,22 @@ func (k Keeper) DeleteConsumerPowerShapingParameters(ctx sdk.Context, consumerId } // GetConsumerPhase returns the phase associated with this consumer id -func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) (ConsumerPhase, bool) { +func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) types.ConsumerPhase { store := ctx.KVStore(k.storeKey) buf := store.Get(types.ConsumerIdToPhaseKey(consumerId)) if buf == nil { - return ConsumerPhase(0), false + return types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED } - return ConsumerPhase(buf[0]), true + phase := types.ConsumerPhase(binary.BigEndian.Uint32(buf)) + return phase } // SetConsumerPhase sets the phase associated with this consumer id -func (k Keeper) SetConsumerPhase(ctx sdk.Context, consumerId string, phase ConsumerPhase) { +func (k Keeper) SetConsumerPhase(ctx sdk.Context, consumerId string, phase types.ConsumerPhase) { store := ctx.KVStore(k.storeKey) - store.Set(types.ConsumerIdToPhaseKey(consumerId), []byte{byte(phase)}) + phaseBytes := make([]byte, 8) + binary.BigEndian.PutUint32(phaseBytes, uint32(phase)) + store.Set(types.ConsumerIdToPhaseKey(consumerId), phaseBytes) } // DeleteConsumerPhase deletes the phase associated with this consumer id @@ -670,8 +654,8 @@ func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, pre // TODO (PERMISSIONLESS): could remove, all fields should be there because we validate the initialization parameters func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { // a chain that is already launched or stopped cannot launch again - phase, found := k.GetConsumerPhase(ctx, consumerId) - if !found || phase == Launched || phase == Stopped { + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED || phase == types.ConsumerPhase_CONSUMER_PHASE_STOPPED { return time.Time{}, false } diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index a18fe738cc..da8412220e 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -1,6 +1,9 @@ package keeper_test import ( + "testing" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -10,8 +13,6 @@ import ( providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "testing" - "time" ) // TestConsumerId tests setters and getters of consumer id (i.e., `FetchAndIncrementConsumerId` and `GetConsumerId`) @@ -231,18 +232,16 @@ func TestConsumerPhase(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - _, found := providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.False(t, found) + phase := providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED, phase) - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) - phase, found := providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.True(t, found) - require.Equal(t, keeper.Initialized, phase) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + phase = providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Launched) - phase, found = providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.True(t, found) - require.Equal(t, keeper.Launched, phase) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + phase = providerKeeper.GetConsumerPhase(ctx, "consumerId") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) } // TestConsumerStopTime tests the getter, setter, and deletion of the consumer id to stop times methods @@ -680,7 +679,7 @@ func TestCanLaunch(t *testing.T) { require.False(t, canLaunch) // cannot launch a chain without initialization parameters - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) @@ -690,17 +689,17 @@ func TestCanLaunch(t *testing.T) { require.NoError(t, err) // cannot launch a launched chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Launched) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) // cannot launch a stopped chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Stopped) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) // initialized chain can launch - providerKeeper.SetConsumerPhase(ctx, "consumerId", keeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.True(t, canLaunch) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index fb1920c453..a175518257 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -42,8 +42,8 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { return err } - phase, found := k.GetConsumerPhase(ctx, consumerId) - if !found || phase != Initialized { + phase := k.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED { return errorsmod.Wrapf(types.ErrInvalidPhase, "cannot create client for consumer chain that is not in the Initialized phase but in phase %d: %s", phase, consumerId) } @@ -357,7 +357,7 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { "error", err) continue } - k.SetConsumerPhase(cachedCtx, consumerId, Launched) + k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // the cached context is created with a new EventManager, so we merge the events into the original context ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) @@ -491,7 +491,7 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { continue } - k.SetConsumerPhase(cachedCtx, consumerId, Stopped) + k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) k.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, stopTime) // The cached context is created with a new EventManager so we merge the event into the original context diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index ee0f8039cd..2386ab65f2 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -4,11 +4,12 @@ import ( "bytes" "encoding/json" "fmt" - cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" "sort" "testing" "time" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "cosmossdk.io/math" @@ -45,7 +46,7 @@ func TestCreateConsumerClient(t *testing.T) { { description: "No state mutation, new client should be created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providerkeeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) // Valid client creation is asserted with mock expectations here testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set @@ -58,7 +59,7 @@ func TestCreateConsumerClient(t *testing.T) { { description: "chain for this consumer id has already launched, and hence client was created, NO new one is created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providerkeeper.Launched) + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // Expect none of the client creation related calls to happen mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Times(0) @@ -804,7 +805,7 @@ func TestBeginBlockInit(t *testing.T) { for i, r := range initializationParameters { providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) // set up the chains in their initialized phase, hence they could launch - providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providerkeeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, fmt.Sprintf("%d", i), r.SpawnTime) } for i, r := range powerShapingParameters { @@ -826,39 +827,34 @@ func TestBeginBlockInit(t *testing.T) { providerKeeper.BeginBlockInit(ctx) // first chain was successfully launched - phase, found := providerKeeper.GetConsumerPhase(ctx, "0") - require.True(t, found) - require.Equal(t, providerkeeper.Launched, phase) - _, found = providerKeeper.GetConsumerGenesis(ctx, "0") + phase := providerKeeper.GetConsumerPhase(ctx, "0") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + _, found := providerKeeper.GetConsumerGenesis(ctx, "0") require.True(t, found) // second chain was successfully launched - phase, found = providerKeeper.GetConsumerPhase(ctx, "1") - require.True(t, found) - require.Equal(t, providerkeeper.Launched, phase) + phase = providerKeeper.GetConsumerPhase(ctx, "1") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "1") require.True(t, found) // third chain was not launched because its spawn time has not passed - phase, found = providerKeeper.GetConsumerPhase(ctx, "2") - require.True(t, found) - require.Equal(t, providerkeeper.Initialized, phase) + phase = providerKeeper.GetConsumerPhase(ctx, "2") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "2") require.False(t, found) // fourth chain corresponds to an Opt-In chain with one opted-in validator and hence the chain gets // successfully executed - phase, found = providerKeeper.GetConsumerPhase(ctx, "3") - require.True(t, found) - require.Equal(t, providerkeeper.Launched, phase) + phase = providerKeeper.GetConsumerPhase(ctx, "3") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "3") require.True(t, found) // fifth chain corresponds to an Opt-In chain with no opted-in validators and hence the // chain launch is NOT successful - phase, found = providerKeeper.GetConsumerPhase(ctx, "4") - require.True(t, found) - require.Equal(t, providerkeeper.Initialized, phase) + phase = providerKeeper.GetConsumerPhase(ctx, "4") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "4") require.False(t, found) } @@ -912,7 +908,7 @@ func TestBeginBlockCCR(t *testing.T) { providerKeeper.SetConsumerMetadata(ctx, consumerId, registrationRecord) providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, initializationRecord) providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, testkeeper.GetTestPowerShapingParameters()) - providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Initialized) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) providerKeeper.SetClientIdToConsumerId(ctx, "clientID", consumerId) err := providerKeeper.CreateConsumerClient(ctx, consumerId) @@ -921,7 +917,7 @@ func TestBeginBlockCCR(t *testing.T) { require.NoError(t, err) // after we have created the consumer client, the chain is considered launched and hence we could later stop the chain - providerKeeper.SetConsumerPhase(ctx, consumerId, providerkeeper.Launched) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) } // @@ -931,14 +927,11 @@ func TestBeginBlockCCR(t *testing.T) { providerKeeper.BeginBlockCCR(ctx) // Only the 3rd (final) proposal is still stored as pending - phase, found := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) - require.True(t, found) - require.Equal(t, providerkeeper.Stopped, phase) - phase, found = providerKeeper.GetConsumerPhase(ctx, consumerIds[1]) - require.True(t, found) - require.Equal(t, providerkeeper.Stopped, phase) + phase := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) + phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[1]) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) // third chain had a stopTime in the future and hence did not stop - phase, found = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) - require.True(t, found) - require.Equal(t, providerkeeper.Launched, phase) + phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) } diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index a0d0fa1dd8..4bd1ce4200 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -37,6 +37,49 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// ConsumerPhase indicates the phases of a consumer chain according to ADR 018 +type ConsumerPhase int32 + +const ( + // UNSPECIFIED defines an empty phase. + ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED ConsumerPhase = 0 + // REGISTERED defines the phase in which a consumer chain has been assigned a unique consumer id. + // A chain in this phase cannot yet launch. + ConsumerPhase_CONSUMER_PHASE_REGISTERED ConsumerPhase = 1 + // INITIALIZED defines the phase in which a consumer chain has set all the needed parameters to launch but + // has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached). + ConsumerPhase_CONSUMER_PHASE_INITIALIZED ConsumerPhase = 2 + // LAUNCHED defines the phase in which a consumer chain is running and consuming a subset of the validator + // set of the provider. + ConsumerPhase_CONSUMER_PHASE_LAUNCHED ConsumerPhase = 3 + // STOPPED defines the phase in which a previously-launched chain has stopped. + ConsumerPhase_CONSUMER_PHASE_STOPPED ConsumerPhase = 4 +) + +var ConsumerPhase_name = map[int32]string{ + 0: "CONSUMER_PHASE_UNSPECIFIED", + 1: "CONSUMER_PHASE_REGISTERED", + 2: "CONSUMER_PHASE_INITIALIZED", + 3: "CONSUMER_PHASE_LAUNCHED", + 4: "CONSUMER_PHASE_STOPPED", +} + +var ConsumerPhase_value = map[string]int32{ + "CONSUMER_PHASE_UNSPECIFIED": 0, + "CONSUMER_PHASE_REGISTERED": 1, + "CONSUMER_PHASE_INITIALIZED": 2, + "CONSUMER_PHASE_LAUNCHED": 3, + "CONSUMER_PHASE_STOPPED": 4, +} + +func (x ConsumerPhase) String() string { + return proto.EnumName(ConsumerPhase_name, int32(x)) +} + +func (ConsumerPhase) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{0} +} + // WARNING: This message is deprecated in favor of `MsgCreateConsumer`. // ConsumerAdditionProposal is a governance proposal on the provider chain to // spawn a new consumer chain. If it passes, then all validators on the provider @@ -1752,6 +1795,7 @@ func (m *ConsumerIds) GetIds() []string { } func init() { + proto.RegisterEnum("interchain_security.ccv.provider.v1.ConsumerPhase", ConsumerPhase_name, ConsumerPhase_value) proto.RegisterType((*ConsumerAdditionProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerAdditionProposal") proto.RegisterType((*ConsumerRemovalProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerRemovalProposal") proto.RegisterType((*ConsumerModificationProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerModificationProposal") @@ -1782,140 +1826,146 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 2119 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0xcf, 0x6f, 0x1b, 0xc7, - 0xf5, 0xd7, 0x8a, 0x94, 0x44, 0x0e, 0xf5, 0x83, 0x1a, 0x3b, 0xf6, 0x4a, 0xd1, 0x97, 0xa4, 0x37, - 0x5f, 0x1b, 0x6c, 0x5c, 0x2f, 0x23, 0x05, 0x05, 0x0c, 0xb7, 0x81, 0x21, 0x51, 0x4e, 0x2c, 0xa9, - 0x71, 0xd8, 0x95, 0xa0, 0x00, 0xe9, 0x61, 0x31, 0xdc, 0x1d, 0x91, 0x53, 0xed, 0xee, 0xac, 0x67, - 0x86, 0x2b, 0xb3, 0x87, 0x9e, 0x8b, 0x02, 0x05, 0xd2, 0x9e, 0x82, 0x5e, 0x9a, 0x63, 0xd1, 0x53, - 0x0f, 0x45, 0xff, 0x80, 0x9e, 0x82, 0x02, 0x45, 0x73, 0xec, 0x29, 0x29, 0xec, 0x43, 0x0f, 0x05, - 0x7a, 0xed, 0xb5, 0x98, 0xd9, 0x1f, 0x5c, 0xea, 0x97, 0x69, 0x58, 0xee, 0x45, 0xda, 0x79, 0xef, - 0xf3, 0xde, 0xbc, 0x99, 0x79, 0xbf, 0x66, 0x08, 0x36, 0x48, 0x20, 0x30, 0x73, 0xfa, 0x88, 0x04, - 0x36, 0xc7, 0xce, 0x80, 0x11, 0x31, 0x6c, 0x39, 0x4e, 0xd4, 0x0a, 0x19, 0x8d, 0x88, 0x8b, 0x59, - 0x2b, 0x5a, 0xcf, 0xbe, 0xcd, 0x90, 0x51, 0x41, 0xe1, 0x3b, 0xe7, 0xc8, 0x98, 0x8e, 0x13, 0x99, - 0x19, 0x2e, 0x5a, 0x5f, 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, 0xde, 0x78, 0x8c, 0x5f, 0x4f, 0x83, 0x1b, 0xea, 0x06, 0xbd, 0xdf, 0x47, - 0xa1, 0x3c, 0xdc, 0x51, 0x08, 0x64, 0xd7, 0x72, 0x6d, 0x82, 0x6b, 0xf9, 0xf4, 0xab, 0x5d, 0xcb, - 0x0b, 0x13, 0x5c, 0xcb, 0x8b, 0x97, 0x5d, 0xcb, 0x67, 0x2e, 0xbb, 0x96, 0xcf, 0x4e, 0x76, 0x2d, - 0x9f, 0xbb, 0xe8, 0x5a, 0x5e, 0x07, 0x95, 0x2c, 0x41, 0xb8, 0x1c, 0x56, 0x41, 0x81, 0xb8, 0x69, - 0x33, 0x29, 0x3f, 0xb7, 0x3e, 0xfd, 0xea, 0x79, 0x4d, 0xfb, 0xfa, 0x79, 0x4d, 0xfb, 0xc7, 0xf3, - 0x9a, 0xf6, 0xf9, 0x8b, 0xda, 0xd4, 0xd7, 0x2f, 0x6a, 0x53, 0x7f, 0x7f, 0x51, 0x9b, 0xfa, 0xec, - 0x83, 0xb3, 0xd9, 0x6f, 0x54, 0x5d, 0xee, 0x65, 0xbf, 0x00, 0x44, 0xdf, 0x6b, 0x3d, 0x1b, 0xff, - 0x7d, 0x41, 0x25, 0xc6, 0xee, 0xac, 0x72, 0xec, 0xf7, 0xff, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x45, - 0xe0, 0x33, 0x4d, 0x90, 0x18, 0x00, 0x00, + // 2220 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0xbd, 0x6f, 0x1b, 0xc9, + 0x15, 0xd7, 0x8a, 0x94, 0x44, 0x3e, 0xea, 0x83, 0x1a, 0xfb, 0x6c, 0x4a, 0xd6, 0x51, 0x34, 0x2f, + 0x36, 0x14, 0x3b, 0x26, 0x4f, 0x3a, 0x04, 0x30, 0x9c, 0x1c, 0x0c, 0x99, 0xa4, 0x6d, 0xfa, 0x43, + 0x66, 0x96, 0xb4, 0x0e, 0x70, 0x8a, 0xc5, 0x70, 0x77, 0x44, 0x4e, 0xb4, 0xbb, 0xb3, 0xde, 0x19, + 0xd2, 0x66, 0x8a, 0xd4, 0x41, 0x80, 0x00, 0x97, 0x54, 0x87, 0x34, 0xb9, 0x2e, 0x41, 0xaa, 0x14, + 0x41, 0xfe, 0x80, 0x54, 0x87, 0x00, 0x41, 0xae, 0x4c, 0x75, 0x17, 0xd8, 0x45, 0x8a, 0x00, 0x69, + 0xd3, 0x06, 0x33, 0xfb, 0xc1, 0xa5, 0x3e, 0x6c, 0x1a, 0xb6, 0xd3, 0x48, 0x3b, 0xef, 0xfd, 0xde, + 0x9b, 0x37, 0x33, 0xef, 0x6b, 0x86, 0xb0, 0x43, 0x5d, 0x41, 0x7c, 0xb3, 0x8f, 0xa9, 0x6b, 0x70, + 0x62, 0x0e, 0x7c, 0x2a, 0x46, 0x55, 0xd3, 0x1c, 0x56, 0x3d, 0x9f, 0x0d, 0xa9, 0x45, 0xfc, 0xea, + 0x70, 0x3b, 0xfe, 0xae, 0x78, 0x3e, 0x13, 0x0c, 0x7d, 0x74, 0x82, 0x4c, 0xc5, 0x34, 0x87, 0x95, + 0x18, 0x37, 0xdc, 0x5e, 0xbf, 0x74, 0x9a, 0xe2, 0xe1, 0x76, 0xf5, 0x19, 0xf5, 0x49, 0xa0, 0x6b, + 0xfd, 0x6c, 0x8f, 0xf5, 0x98, 0xfa, 0xac, 0xca, 0xaf, 0x90, 0xba, 0xd9, 0x63, 0xac, 0x67, 0x93, + 0xaa, 0x1a, 0x75, 0x07, 0x07, 0x55, 0x41, 0x1d, 0xc2, 0x05, 0x76, 0xbc, 0x10, 0x50, 0x3c, 0x0a, + 0xb0, 0x06, 0x3e, 0x16, 0x94, 0xb9, 0x91, 0x02, 0xda, 0x35, 0xab, 0x26, 0xf3, 0x49, 0xd5, 0xb4, + 0x29, 0x71, 0x85, 0x9c, 0x35, 0xf8, 0x0a, 0x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cd, 0xe6, + 0x8c, 0xbe, 0x14, 0xca, 0x05, 0x44, 0x74, 0x11, 0x16, 0x7b, 0xc4, 0x25, 0x9c, 0x72, 0xa3, 0x8f, + 0x79, 0xbf, 0x30, 0x57, 0xd2, 0xb6, 0x16, 0xf5, 0x5c, 0x48, 0xbb, 0x8b, 0x79, 0x1f, 0x6d, 0x42, + 0xae, 0x4b, 0x5d, 0xec, 0x8f, 0x02, 0xc4, 0xbc, 0x42, 0x40, 0x40, 0x52, 0x80, 0x1a, 0x00, 0xf7, + 0xf0, 0x33, 0xd7, 0x90, 0xbe, 0x51, 0x58, 0x08, 0x0d, 0x09, 0xfc, 0xa2, 0x12, 0xf9, 0x45, 0xa5, + 0x13, 0x39, 0xce, 0xad, 0x8c, 0x34, 0xe4, 0xf3, 0x6f, 0x37, 0x35, 0x3d, 0xab, 0xe4, 0x24, 0x07, + 0xed, 0x41, 0x7e, 0xe0, 0x76, 0x99, 0x6b, 0x51, 0xb7, 0x67, 0x78, 0xc4, 0xa7, 0xcc, 0x2a, 0x64, + 0x94, 0xaa, 0xb5, 0x63, 0xaa, 0xea, 0xa1, 0x8b, 0x05, 0x9a, 0xbe, 0x90, 0x9a, 0x56, 0x62, 0xe1, + 0x96, 0x92, 0x45, 0x3f, 0x02, 0x64, 0x9a, 0x43, 0x65, 0x12, 0x1b, 0x88, 0x48, 0x63, 0x76, 0x7a, + 0x8d, 0x79, 0xd3, 0x1c, 0x76, 0x02, 0xe9, 0x50, 0xe5, 0x8f, 0xe1, 0xbc, 0xf0, 0xb1, 0xcb, 0x0f, + 0x88, 0x7f, 0x54, 0x2f, 0x4c, 0xaf, 0xf7, 0x83, 0x48, 0xc7, 0xa4, 0xf2, 0xbb, 0x50, 0x32, 0x43, + 0x07, 0x32, 0x7c, 0x62, 0x51, 0x2e, 0x7c, 0xda, 0x1d, 0x48, 0x59, 0xe3, 0xc0, 0xc7, 0xa6, 0xf2, + 0x91, 0x9c, 0x72, 0x82, 0x62, 0x84, 0xd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0x2d, 0xec, 0x63, 0x87, 0xa3, 0x0e, 0xac, 0x08, + 0xe2, 0x78, 0x36, 0x16, 0xc4, 0x08, 0x5a, 0x92, 0x70, 0xa5, 0x57, 0x55, 0xab, 0x92, 0x6c, 0xfc, + 0x2a, 0x89, 0x56, 0x6f, 0xb8, 0x5d, 0xa9, 0x29, 0x6a, 0x5b, 0x60, 0x41, 0xf4, 0xe5, 0x48, 0x47, + 0x40, 0x44, 0xd7, 0xa1, 0x20, 0xfc, 0x01, 0x17, 0xe3, 0x66, 0x61, 0x5c, 0x25, 0x83, 0xb3, 0x3e, + 0x17, 0xf1, 0x83, 0xfa, 0x1a, 0x57, 0xc7, 0x93, 0xfb, 0x82, 0xd4, 0xdb, 0xf4, 0x05, 0x16, 0x6c, + 0x70, 0x79, 0xa8, 0x86, 0x43, 0x84, 0xaa, 0xde, 0x9e, 0x4d, 0x5c, 0xca, 0xfb, 0x91, 0xf2, 0xf9, + 0xe9, 0x95, 0xaf, 0x29, 0x45, 0x0f, 0xa5, 0x1e, 0x3d, 0x52, 0x13, 0xce, 0x52, 0x83, 0xe2, 0xc9, + 0xb3, 0xc4, 0x0b, 0x5f, 0x50, 0x0b, 0xbf, 0x70, 0x82, 0x8a, 0x78, 0xf5, 0x1c, 0x2e, 0x27, 0xba, + 0x0c, 0x19, 0x4d, 0x86, 0x72, 0x64, 0xc3, 0x27, 0x3d, 0x59, 0x8a, 0x71, 0xd0, 0x70, 0x10, 0x12, + 0x77, 0x4a, 0xa1, 0x4f, 0xcb, 0x36, 0x39, 0xe1, 0xd4, 0xd4, 0x0d, 0xdb, 0xc9, 0xf2, 0xb8, 0x19, + 0x89, 0x63, 0x53, 0x4f, 0xe8, 0xba, 0x4d, 0x88, 0x8c, 0xa2, 0x44, 0x43, 0x42, 0x3c, 0x66, 0xf6, + 0x55, 0x3e, 0x4a, 0xe9, 0xcb, 0x71, 0xf3, 0xd1, 0x90, 0x54, 0xf4, 0x04, 0xae, 0xba, 0x03, 0xa7, +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x9d, 0x06, 0x4b, 0x71, 0x55, 0xef, 0x63, 0x4e, + 0x50, 0x11, 0xd6, 0x6b, 0x8f, 0xf6, 0xda, 0x8f, 0x1f, 0x36, 0x74, 0xa3, 0x75, 0x77, 0xb7, 0xdd, + 0x30, 0x1e, 0xef, 0xb5, 0x5b, 0x8d, 0x5a, 0xf3, 0x76, 0xb3, 0x51, 0xcf, 0xcf, 0xa0, 0x0f, 0x61, + 0xed, 0x08, 0x5f, 0x6f, 0xdc, 0x69, 0xb6, 0x3b, 0x0d, 0xbd, 0x51, 0xcf, 0x6b, 0x27, 0x88, 0x37, + 0xf7, 0x9a, 0x9d, 0xe6, 0xee, 0x83, 0xe6, 0x93, 0x46, 0x3d, 0x3f, 0x8b, 0x2e, 0xc0, 0xf9, 0x23, + 0xfc, 0x07, 0xbb, 0x8f, 0xf7, 0x6a, 0x77, 0x1b, 0xf5, 0x7c, 0x0a, 0xad, 0xc3, 0xb9, 0x23, 0xcc, + 0x76, 0xe7, 0x51, 0xab, 0xd5, 0xa8, 0xe7, 0xd3, 0xb7, 0x3e, 0xfb, 0xea, 0x45, 0x51, 0xfb, 0xfa, + 0x45, 0x51, 0xfb, 0xe7, 0x8b, 0xa2, 0xf6, 0xf9, 0xcb, 0xe2, 0xcc, 0xd7, 0x2f, 0x8b, 0x33, 0xff, + 0x78, 0x59, 0x9c, 0x79, 0xf2, 0xe9, 0xf1, 0x3c, 0x3d, 0xae, 0x83, 0xd7, 0xe2, 0xdf, 0x2a, 0x86, + 0xdf, 0xaf, 0x3e, 0x9f, 0xfc, 0x25, 0x44, 0xa5, 0xf0, 0xee, 0xbc, 0x0a, 0xc1, 0x4f, 0xfe, 0x17, + 0x00, 0x00, 0xff, 0xff, 0x1d, 0xf2, 0xb2, 0x97, 0x3a, 0x19, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { From 3ea292371fc3ac8c182d13ff204189e083af6ade Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 28 Aug 2024 17:48:20 +0200 Subject: [PATCH 10/43] feat: extend `consumer_validators` query to return consumer valset before launch (#2164) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * pre-spawn query * rebase * nits * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * remove panics * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * update logic * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * nits * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * cover stopped phase case * fixed bug on removing previous spawn time & added tests * added some additional tests * added tests on the hooks * removed check that spawn time is in the future * feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity * fix tests --------- Co-authored-by: insumity * nit * nits * nit --------- Co-authored-by: insumity Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> --- x/ccv/provider/keeper/grpc_query.go | 53 +++++++-- x/ccv/provider/keeper/grpc_query_test.go | 135 ++++++++++++++++++++--- x/ccv/provider/types/msg.go | 3 +- x/ccv/provider/types/provider.pb.go | 2 +- 4 files changed, 168 insertions(+), 25 deletions(-) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 4a167599ec..5562bfc2da 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -1,8 +1,10 @@ package keeper import ( + "bytes" "context" "fmt" + "sort" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -333,18 +335,55 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC ctx := sdk.UnwrapSDKContext(goCtx) - if _, found := k.GetConsumerClientId(ctx, consumerId); !found { - // chain has to have started; consumer client id is set for a chain during the chain's spawn time - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("no started consumer chain: %s", consumerId)) + // get the consumer phase + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + return nil, status.Errorf(codes.InvalidArgument, "cannot find a phase for consumer: %s", consumerId) } - var validators []*types.QueryConsumerValidatorsValidator + // query consumer validator set - consumerValSet, err := k.GetConsumerValSet(ctx, consumerId) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) + var consumerValSet []types.ConsensusValidator + var err error + + // if the consumer launched, the consumer valset has been persisted + if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + consumerValSet, err = k.GetConsumerValSet(ctx, consumerId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + // if the consumer hasn't been launched or stopped, compute the consumer validator set + } else if phase != types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + bondedValidators, err := k.GetLastBondedValidators(ctx) + if err != nil { + return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get last validators: %s", err)) + } + minPower := int64(0) + // for TopN chains, compute the minPower that will be automatically opted in + if topN := k.GetTopN(ctx, consumerId); topN > 0 { + activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) + if err != nil { + return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get active validators: %s", err)) + } + + minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + if err != nil { + return nil, status.Error(codes.Internal, fmt.Sprintf("failed to compute min power to opt in for chain %s: %s", consumerId, err)) + } + } + + consumerValSet = k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) + + // sort the address of the validators by ascending lexical order as they were persisted to the store + sort.Slice(consumerValSet, func(i, j int) bool { + return bytes.Compare( + consumerValSet[i].ProviderConsAddr, + consumerValSet[j].ProviderConsAddr, + ) == -1 + }) } + var validators []*types.QueryConsumerValidatorsValidator for _, consumerVal := range consumerValSet { provAddr := types.ProviderConsAddress{Address: consumerVal.ProviderConsAddr} consAddr := provAddr.ToSdkConsAddr() diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index bb51e85952..b44c025dd5 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -1,7 +1,9 @@ package keeper_test import ( + "bytes" "fmt" + "sort" "testing" "github.com/golang/mock/gomock" @@ -101,41 +103,84 @@ func TestQueryConsumerValidators(t *testing.T) { defer ctrl.Finish() consumerId := "0" - req := types.QueryConsumerValidatorsRequest{ ConsumerId: consumerId, } - // error returned from not-started chain + // error returned from not-existing chain _, err := pk.QueryConsumerValidators(ctx, &req) require.Error(t, err) + // set the consumer to the "registered" phase + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + + // expect empty valset + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // -1 to allow the calls "AnyTimes" + res, err := pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Len(t, res.Validators, 0) + + // create bonded validators val1 := createStakingValidator(ctx, mocks, 1, 1, 1) + pk1, _ := val1.CmtConsPublicKey() valConsAddr1, _ := val1.GetConsAddr() providerAddr1 := types.NewProviderConsAddress(valConsAddr1) - pk1, _ := val1.CmtConsPublicKey() consumerValidator1 := types.ConsensusValidator{ProviderConsAddr: providerAddr1.ToSdkConsAddr(), Power: 1, PublicKey: &pk1} val1.Tokens = sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction) val1.Description = stakingtypes.Description{Moniker: "ConsumerValidator1"} val1.Commission.Rate = math.LegacyMustNewDecFromStr("0.123") val2 := createStakingValidator(ctx, mocks, 1, 2, 2) + pk2, _ := val2.CmtConsPublicKey() valConsAddr2, _ := val2.GetConsAddr() providerAddr2 := types.NewProviderConsAddress(valConsAddr2) - pk2, _ := val2.CmtConsPublicKey() consumerValidator2 := types.ConsensusValidator{ProviderConsAddr: providerAddr2.ToSdkConsAddr(), Power: 2, PublicKey: &pk2} val2.Tokens = sdk.TokensFromConsensusPower(2, sdk.DefaultPowerReduction) val2.Description = stakingtypes.Description{Moniker: "ConsumerValidator2"} - val2.Commission.Rate = math.LegacyMustNewDecFromStr("0.123") + val2.Commission.Rate = math.LegacyMustNewDecFromStr("0.456") + + val3 := createStakingValidator(ctx, mocks, 1, 3, 3) + pk3, _ := val3.CmtConsPublicKey() + valConsAddr3, _ := val3.GetConsAddr() + providerAddr3 := types.NewProviderConsAddress(valConsAddr3) + consumerValidator3 := types.ConsensusValidator{ProviderConsAddr: providerAddr3.ToSdkConsAddr(), Power: 3, PublicKey: &pk3} + val3.Tokens = sdk.TokensFromConsensusPower(3, sdk.DefaultPowerReduction) + val3.Description = stakingtypes.Description{Moniker: "ConsumerValidator3"} + + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr1).Return(val1, nil).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr2).Return(val2, nil).AnyTimes() + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr3).Return(val3, nil).AnyTimes() + mocks.MockStakingKeeper.EXPECT().PowerReduction(ctx).Return(sdk.DefaultPowerReduction).AnyTimes() + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{val1, val2}, -1) // -1 to allow the calls "AnyTimes" + + // set max provider consensus vals to include all validators + params := pk.GetParams(ctx) + params.MaxProviderConsensusValidators = 3 + pk.SetParams(ctx, params) + + // expect no validator to be returned since the consumer is Opt-In + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Len(t, res.Validators, 0) + + // opt in one validator + pk.SetOptedIn(ctx, consumerId, providerAddr1) - // set up the client id so the chain looks like it "started" - pk.SetConsumerClientId(ctx, consumerId, "clientID") - pk.SetConsumerValSet(ctx, consumerId, []types.ConsensusValidator{consumerValidator1, consumerValidator2}) // set a consumer commission rate for val1 - val1ConsComRate := math.LegacyMustNewDecFromStr("0.456") + val1ConsComRate := math.LegacyMustNewDecFromStr("0.789") pk.SetConsumerCommissionRate(ctx, consumerId, providerAddr1, val1ConsComRate) - expectedResponse := types.QueryConsumerValidatorsResponse{ + // expect opted-in validator + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Len(t, res.Validators, 1) + require.Equal(t, res.Validators[0].ProviderAddress, providerAddr1.String()) + + // update consumer TopN param + pk.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{Top_N: 50}) + + // expect both opted-in and topN validator + expRes := types.QueryConsumerValidatorsResponse{ Validators: []*types.QueryConsumerValidatorsValidator{ { ProviderAddress: providerAddr1.String(), @@ -168,15 +213,66 @@ func TestQueryConsumerValidators(t *testing.T) { }, } - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr1).Return(val1, nil).AnyTimes() - mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr2).Return(val2, nil).AnyTimes() - mocks.MockStakingKeeper.EXPECT().PowerReduction(ctx).Return(sdk.DefaultPowerReduction).AnyTimes() + // sort the address of the validators by ascending lexical order as they were persisted to the store + sort.Slice(expRes.Validators, func(i, j int) bool { + return bytes.Compare( + expRes.Validators[i].ConsumerKey.GetEd25519(), + expRes.Validators[j].ConsumerKey.GetEd25519(), + ) == -1 + }) - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{val1, val2}, -1) // -1 to allow the calls "AnyTimes" + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Equal(t, &expRes, res) - res, err := pk.QueryConsumerValidators(ctx, &req) + // expect same result when consumer is in "initialized" phase + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + res, err = pk.QueryConsumerValidators(ctx, &req) require.NoError(t, err) - require.Equal(t, &expectedResponse, res) + require.Equal(t, &expRes, res) + + // set consumer to the "launched" phase + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + + // expect an empty consumer valset + // since neither QueueVSCPackets or MakeConsumerGenesis was called at this point + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Empty(t, res) + + // set consumer valset + pk.SetConsumerValSet(ctx, consumerId, []types.ConsensusValidator{ + consumerValidator1, + consumerValidator2, + consumerValidator3, + }) + + expRes.Validators = append(expRes.Validators, &types.QueryConsumerValidatorsValidator{ + ProviderAddress: providerAddr3.String(), + ConsumerKey: &pk3, + ConsumerPower: 3, + ConsumerCommissionRate: val3.Commission.Rate, + Description: val3.Description, + ProviderOperatorAddress: val3.OperatorAddress, + Jailed: val3.Jailed, + Status: val3.Status, + ProviderTokens: val3.Tokens, + ProviderCommissionRate: val3.Commission.Rate, + ProviderPower: 3, + ValidatesCurrentEpoch: true, + }) + + // sort the address of the validators by ascending lexical order as they were persisted to the store + sort.Slice(expRes.Validators, func(i, j int) bool { + return bytes.Compare( + expRes.Validators[i].ConsumerKey.GetEd25519(), + expRes.Validators[j].ConsumerKey.GetEd25519(), + ) == -1 + }) + + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Equal(t, &expRes, res) // validator with no set consumer commission rate pk.DeleteConsumerCommissionRate(ctx, consumerId, providerAddr1) @@ -184,6 +280,13 @@ func TestQueryConsumerValidators(t *testing.T) { res, err = pk.QueryConsumerValidators(ctx, &req) require.NoError(t, err) require.Equal(t, val1.Commission.Rate, res.Validators[0].ConsumerCommissionRate) + + // set consumer to stopped phase + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + // expect empty valset + res, err = pk.QueryConsumerValidators(ctx, &req) + require.NoError(t, err) + require.Empty(t, res) } func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 44466a1a75..08a4b516c9 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -3,11 +3,12 @@ package types import ( "encoding/json" "fmt" - cmttypes "github.com/cometbft/cometbft/types" "strconv" "strings" "time" + cmttypes "github.com/cometbft/cometbft/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 4bd1ce4200..1c0755344d 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -37,7 +37,7 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// ConsumerPhase indicates the phases of a consumer chain according to ADR 018 +// ConsumerPhase indicates the phases of a consumer chain according to ADR 019 type ConsumerPhase int32 const ( From a9b39dda901fdf2ec904dc20028c9ee1ddb52884 Mon Sep 17 00:00:00 2001 From: mpoke Date: Wed, 28 Aug 2024 19:02:54 +0200 Subject: [PATCH 11/43] fix build --- x/ccv/provider/keeper/grpc_query.go | 11 ++++++++--- x/ccv/provider/keeper/grpc_query_test.go | 23 +++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index e33b02b48d..4f2763e0b9 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -65,6 +65,11 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu // GetConsumerChain returns a Chain data structure with all the necessary fields func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chain, error) { + chainID, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return types.Chain{}, fmt.Errorf("cannot find chainID for consumer (%s)", consumerId) + } + clientID, found := k.GetConsumerClientId(ctx, consumerId) if !found { return types.Chain{}, fmt.Errorf("cannot find clientID for consumer (%s)", consumerId) @@ -95,12 +100,12 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai strDenylist[i] = addr.String() } - allowInactiveVals := k.AllowsInactiveValidators(ctx, chainID) + allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) - minStake, _ := k.GetMinStake(ctx, chainID) + minStake := k.GetMinStake(ctx, consumerId) return types.Chain{ - ChainId: consumerId, + ChainId: chainID, ClientId: clientID, Top_N: topN, MinPowerInTop_N: minPowerInTopN, diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 7ab11ad325..a9670fafdd 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -379,6 +379,8 @@ func TestGetConsumerChain(t *testing.T) { pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerIDs := []string{"1", "23", "345", "6789"} + chainIDs := []string{"chain-1", "chain-2", "chain-3", "chain-4"} // mock the validator set @@ -433,23 +435,24 @@ func TestGetConsumerChain(t *testing.T) { } expectedGetAllOrder := []types.Chain{} - for i, chainID := range chainIDs { - clientID := fmt.Sprintf("client-%d", len(chainIDs)-i) + for i, consumerID := range consumerIDs { + pk.SetConsumerChainId(ctx, consumerID, chainIDs[i]) + clientID := fmt.Sprintf("client-%d", len(consumerID)-i) topN := topNs[i] - pk.SetConsumerClientId(ctx, chainID, clientID) - pk.SetConsumerPowerShapingParameters(ctx, chainID, types.PowerShapingParameters{ + pk.SetConsumerClientId(ctx, consumerID, clientID) + pk.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{ Top_N: topN, ValidatorSetCap: validatorSetCaps[i], ValidatorsPowerCap: validatorPowerCaps[i], + AllowInactiveVals: allowInactiveVals[i], + MinStake: minStakes[i].Uint64(), }) - pk.SetMinimumPowerInTopN(ctx, chainID, expectedMinPowerInTopNs[i]) - pk.SetInactiveValidatorsAllowed(ctx, chainID, allowInactiveVals[i]) - pk.SetMinStake(ctx, chainID, minStakes[i].Uint64()) + pk.SetMinimumPowerInTopN(ctx, consumerID, expectedMinPowerInTopNs[i]) for _, addr := range allowlists[i] { - pk.SetAllowlist(ctx, chainID, addr) + pk.SetAllowlist(ctx, consumerID, addr) } for _, addr := range denylists[i] { - pk.SetDenylist(ctx, chainID, addr) + pk.SetDenylist(ctx, consumerID, addr) } strAllowlist := make([]string, len(allowlists[i])) for j, addr := range allowlists[i] { @@ -463,7 +466,7 @@ func TestGetConsumerChain(t *testing.T) { expectedGetAllOrder = append(expectedGetAllOrder, types.Chain{ - ChainId: chainID, + ChainId: chainIDs[i], ClientId: clientID, Top_N: topN, MinPowerInTop_N: expectedMinPowerInTopNs[i], From 289e05c77c8811171ec29d954bf95cd58f29d012 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Wed, 28 Aug 2024 19:51:30 +0200 Subject: [PATCH 12/43] tests: fix integration test setup (#2183) * fix integration test setup * fix integration tests --- tests/integration/common.go | 2 +- tests/integration/provider_gov_hooks.go | 178 ------------------------ tests/integration/setup.go | 7 +- testutil/ibc_testing/generic_setup.go | 18 ++- testutil/keeper/unit_test_helpers.go | 45 +----- 5 files changed, 22 insertions(+), 228 deletions(-) delete mode 100644 tests/integration/provider_gov_hooks.go diff --git a/tests/integration/common.go b/tests/integration/common.go index a2c5cd8d46..97cd3fbf29 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -42,7 +42,7 @@ func (s *CCVTestSuite) getFirstBundle() icstestingutils.ConsumerBundle { } func (s *CCVTestSuite) getBundleByIdx(index int) icstestingutils.ConsumerBundle { - return *s.consumerBundles[fmt.Sprintf("%d", 2+index)] + return *s.consumerBundles[fmt.Sprintf("%d", index)] } func (s *CCVTestSuite) providerCtx() sdk.Context { diff --git a/tests/integration/provider_gov_hooks.go b/tests/integration/provider_gov_hooks.go deleted file mode 100644 index 0890436781..0000000000 --- a/tests/integration/provider_gov_hooks.go +++ /dev/null @@ -1,178 +0,0 @@ -package integration - -import ( - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" -) - -// TestAfterPropSubmissionAndVotingPeriodEnded tests AfterProposalSubmission and AfterProposalVotingPeriodEnded hooks -// require adding a proposal in the gov module and registering a consumer chain with the provider module -func (s *CCVTestSuite) TestAfterPropSubmissionAndVotingPeriodEnded() { - ctx := s.providerChain.GetContext() - providerKeeper := s.providerApp.GetProviderKeeper() - govKeeper := s.providerApp.GetTestGovKeeper() - proposer := s.providerChain.SenderAccount - - msgUpdateConsumer := testkeeper.GetTestMsgUpdateConsumer() - - proposal, err := v1.NewProposal([]sdk.Msg{&msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) - s.Require().NoError(err) - - err = govKeeper.SetProposal(ctx, proposal) - s.Require().NoError(err) - - // the proposal can only be submitted if the owner of the chain is the gov module - providerKeeper.SetConsumerOwnerAddress(ctx, msgUpdateConsumer.ConsumerId, "some bogus address") - - err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) - s.Require().Error(err) - - // the proposal can only be submitted if the owner of the chain is the gov module - govModuleAddress := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" - providerKeeper.SetConsumerOwnerAddress(ctx, msgUpdateConsumer.ConsumerId, govModuleAddress) - - err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) - s.Require().NoError(err) - - // verify that the proposal id is created - consumerIdOnProvider, ok := providerKeeper.GetProposalIdToConsumerId(ctx, proposal.Id) - s.Require().True(ok) - s.Require().NotEmpty(consumerIdOnProvider) - s.Require().Equal(msgUpdateConsumer.ConsumerId, consumerIdOnProvider) - - providerKeeper.Hooks().AfterProposalVotingPeriodEnded(ctx, proposal.Id) - // verify that the proposal id is deleted - s.Require().Empty(providerKeeper.GetProposalIdToConsumerId(ctx, proposal.Id)) - - // assert that a proposal with more than one `MsgUpdateConsumer` messages fails - proposal, err = v1.NewProposal([]sdk.Msg{&msgUpdateConsumer, &msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) - s.Require().NoError(err) - - err = govKeeper.SetProposal(ctx, proposal) - s.Require().NoError(err) - - err = providerKeeper.Hooks().AfterProposalSubmission(ctx, proposal.Id) - s.Require().Error(err) - -} - -func (s *CCVTestSuite) TestGetConsumerAdditionFromProp() { - ctx := s.providerChain.GetContext() - proposer := s.providerChain.SenderAccount - - // create a dummy bank send message - dummyMsg := &banktypes.MsgSend{ - FromAddress: sdk.AccAddress(proposer.GetAddress()).String(), - ToAddress: sdk.AccAddress(proposer.GetAddress()).String(), - Amount: sdk.NewCoins(sdk.NewCoin("stake", math.OneInt())), - } - - // create a legacy proposal - textProp, err := v1.NewLegacyContent( - v1beta1.NewTextProposal("a title", "a legacy text prop"), - authtypes.NewModuleAddress("gov").String(), - ) - s.Require().NoError(err) - - // create a valid consumer addition message - msgConsumerAddition := testkeeper.GetTestMsgConsumerAddition() - - // create a legacy consumer addition proposal content - // (not supported anymore) - addConsumerPropLegacy, err := v1.NewLegacyContent( - testkeeper.GetTestConsumerAdditionProp(), - authtypes.NewModuleAddress("gov").String(), - ) - s.Require().NoError(err) - - testCases := []struct { - name string - propMsg sdk.Msg - expectConsumerPropFound bool - expPanic bool - }{ - { - name: "prop not found", - propMsg: nil, - expectConsumerPropFound: false, - expPanic: false, - }, - { - name: "msgs in prop contain no consumer addition props", - propMsg: dummyMsg, - expectConsumerPropFound: false, - expPanic: false, - }, - { - name: "msgs contain a legacy prop but not of ConsumerAdditionProposal type", - propMsg: textProp, - expectConsumerPropFound: false, - }, - { - name: "msgs contain an invalid legacy prop", - propMsg: &v1.MsgExecLegacyContent{}, - expectConsumerPropFound: false, - expPanic: false, - }, - { - name: "msg contains a prop of legacy ConsumerAdditionProposal type - hook should NOT create a new proposed chain", - propMsg: addConsumerPropLegacy, - expectConsumerPropFound: false, - expPanic: false, - }, - { - name: "msg contains a prop of MsgConsumerAddition type - hook should create a new proposed chain", - propMsg: &msgConsumerAddition, - expectConsumerPropFound: true, - expPanic: false, - }, - } - - for _, tc := range testCases { - s.Run(tc.name, func() { - providerKeeper := s.providerApp.GetProviderKeeper() - govKeeper := s.providerApp.GetTestGovKeeper() - - var proposal v1.Proposal - var err error - - if tc.propMsg == nil { - // cover edgecase where proposal has no messages - proposal, err = v1.NewProposal([]sdk.Msg{}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) - s.Require().NoError(err) - } else { - // cover variolus cases where proposal has messages but only some are consumer addition proposals - proposal, err = v1.NewProposal([]sdk.Msg{tc.propMsg}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", proposer.GetAddress(), false) - s.Require().NoError(err) - } - - err = govKeeper.SetProposal(ctx, proposal) - s.Require().NoError(err) - - if tc.expPanic { - s.Require().Panics(func() { - // this panics with a nil pointer dereference because the proposal is invalid and cannot be unmarshalled - providerKeeper.Hooks().GetConsumerAdditionFromProp(ctx, proposal.Id) - }) - return - } - - savedProp, found := providerKeeper.Hooks().GetConsumerAdditionFromProp(ctx, proposal.Id) - if tc.expectConsumerPropFound { - s.Require().True(found) - s.Require().NotEmpty(savedProp, savedProp) - } else { - s.Require().False(found) - s.Require().Empty(savedProp) - } - }) - } -} diff --git a/tests/integration/setup.go b/tests/integration/setup.go index 04f1882113..5b33a8b191 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -149,9 +149,8 @@ func (suite *CCVTestSuite) SetupTest() { // 1. the consumer chain is added to the coordinator // 2. MakeGenesis is called on the provider chain // 3. ibc/testing sets the tendermint header for the consumer chain app - - providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - preProposalKeyAssignment(suite, icstestingutils.FirstConsumerId) + providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerID, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + preProposalKeyAssignment(suite, icstestingutils.FirstConsumerID) // start consumer chains suite.consumerBundles = make(map[string]*icstestingutils.ConsumerBundle) @@ -284,7 +283,7 @@ func initConsumerChain( err = bundle.Path.EndpointA.UpdateClient() s.Require().NoError(err) - if consumerId == "2" { + if consumerId == "0" { // Support tests that were written before multiple consumers were supported. firstBundle := s.getFirstBundle() s.consumerApp = firstBundle.App diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 8b0cdfa9f0..74bf620080 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -38,7 +38,8 @@ const ( ) var ( - FirstConsumerId string + firstConsumerChainID string + FirstConsumerID string provChainID string democConsumerChainID string consumerTopNParams [NumConsumers]uint32 @@ -47,7 +48,8 @@ var ( func init() { // Disable revision format ibctesting.ChainIDSuffix = "" - FirstConsumerId = "2" + firstConsumerChainID = ibctesting.GetChainID(2) + FirstConsumerID = "" provChainID = ibctesting.GetChainID(1) democConsumerChainID = ibctesting.GetChainID(5000) // TopN parameter values per consumer chain initiated @@ -153,7 +155,10 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( powerShapingParameters := testkeeper.GetTestPowerShapingParameters() powerShapingParameters.Top_N = consumerTopNParams[index] // isn't used in CreateConsumerClient - consumerId := fmt.Sprintf("%d", index+2) + consumerId := providerKeeper.FetchAndIncrementConsumerId(providerChain.GetContext()) + if chainID == firstConsumerChainID { + FirstConsumerID = consumerId + } providerKeeper.SetConsumerChainId(providerChain.GetContext(), consumerId, chainID) providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata) providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) @@ -180,14 +185,13 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerChain.GetContext(), consumerId, ) + s.Require().True(found, "consumer genesis not found in AddConsumer") - foo, found := providerKeeper.GetConsumerClientId( + _, found = providerKeeper.GetConsumerClientId( providerChain.GetContext(), consumerId, ) - _ = foo - - s.Require().True(found, "consumer genesis not found in AddConsumer") + s.Require().True(found, "clientID not found in AddConsumer") // use InitialValSet as the valset on the consumer var valz []*tmtypes.Validator diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index a7ef6d7563..e4b52dbb01 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -282,23 +282,18 @@ func GetTestConsumerMetadata() providertypes.ConsumerMetadata { } func GetTestInitializationParameters() providertypes.ConsumerInitializationParameters { - initialHeight := clienttypes.NewHeight(4, 5) - spawnTime := time.Now().UTC() - ccvTimeoutPeriod := types.DefaultCCVTimeoutPeriod - transferTimeoutPeriod := types.DefaultTransferTimeoutPeriod - unbondingPeriod := types.DefaultConsumerUnbondingPeriod return providertypes.ConsumerInitializationParameters{ - InitialHeight: initialHeight, + InitialHeight: clienttypes.NewHeight(4, 5), GenesisHash: []byte("gen_hash"), BinaryHash: []byte("bin_hash"), - SpawnTime: spawnTime, + SpawnTime: time.Now().UTC(), ConsumerRedistributionFraction: types.DefaultConsumerRedistributeFrac, BlocksPerDistributionTransmission: types.DefaultBlocksPerDistributionTransmission, DistributionTransmissionChannel: "", HistoricalEntries: types.DefaultHistoricalEntries, - CcvTimeoutPeriod: ccvTimeoutPeriod, - TransferTimeoutPeriod: transferTimeoutPeriod, - UnbondingPeriod: unbondingPeriod, + CcvTimeoutPeriod: types.DefaultCCVTimeoutPeriod, + TransferTimeoutPeriod: types.DefaultTransferTimeoutPeriod, + UnbondingPeriod: types.DefaultConsumerUnbondingPeriod, } } @@ -309,37 +304,11 @@ func GetTestPowerShapingParameters() providertypes.PowerShapingParameters { ValidatorSetCap: 0, Allowlist: nil, Denylist: nil, + MinStake: 0, + AllowInactiveVals: false, } } -func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { - prop := providertypes.NewConsumerAdditionProposal( - "chainID", - "description", - "chainID", - clienttypes.NewHeight(4, 5), - []byte("gen_hash"), - []byte("bin_hash"), - time.Now(), - types.DefaultConsumerRedistributeFrac, - types.DefaultBlocksPerDistributionTransmission, - "", - types.DefaultHistoricalEntries, - types.DefaultCCVTimeoutPeriod, - types.DefaultTransferTimeoutPeriod, - types.DefaultConsumerUnbondingPeriod, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ).(*providertypes.ConsumerAdditionProposal) - - return prop -} - func GetTestMsgUpdateConsumer() providertypes.MsgUpdateConsumer { return providertypes.MsgUpdateConsumer{ Signer: "signer", From aec6c93ac296b511bcba34a6cce0a0729392bc7a Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 09:42:45 +0200 Subject: [PATCH 13/43] feat: add consumer chain query (#2179) * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * fixed bug on removing previous spawn time & added tests * added some additional tests * added tests on the hooks * removed check that spawn time is in the future * feat: refactor consumer validator set computation (#2175) * add UT * nits * address comments * Update x/ccv/provider/keeper/partial_set_security.go Co-authored-by: insumity * fix tests --------- Co-authored-by: insumity * add UT * nits * nits * revert legacy prop funcs * fix UT --------- Co-authored-by: insumity Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> --- .../ccv/provider/v1/query.proto | 21 + x/ccv/provider/keeper/grpc_query.go | 46 + x/ccv/provider/keeper/grpc_query_test.go | 79 +- x/ccv/provider/types/query.pb.go | 977 +++++++++++++++--- x/ccv/provider/types/query.pb.gw.go | 101 ++ 5 files changed, 1059 insertions(+), 165 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index e430c9de34..23ca4c6fee 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -178,6 +178,14 @@ service Query { option (google.api.http).get = "/interchain_security/ccv/provider/consumer_id/{client_id}"; } + + // QueryConsumerChain returns the consumer chain + // associated with the provided consumer id + rpc QueryConsumerChain(QueryConsumerChainRequest) + returns (QueryConsumerChainResponse) { + option (google.api.http).get = + "/interchain_security/ccv/provider/consumer_chain/{consumer_id}"; + } } message QueryConsumerGenesisRequest { @@ -431,3 +439,16 @@ message QueryConsumerIdFromClientIdResponse { // the consumer id of the chain associated with this client id string consumer_id = 1; } + +message QueryConsumerChainRequest { + string consumer_id = 1; +} + +message QueryConsumerChainResponse { + string chain_id = 1; + string owner_address = 2; + string phase = 3; + ConsumerMetadata metadata = 4 [ (gogoproto.nullable) = false ]; + ConsumerInitializationParameters init_params = 5; + PowerShapingParameters power_shaping_params = 6; +} diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 4f2763e0b9..63ca301775 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -580,3 +580,49 @@ func (k Keeper) QueryConsumerIdFromClientId(goCtx context.Context, req *types.Qu return &types.QueryConsumerIdFromClientIdResponse{ConsumerId: consumerId}, nil } + +// QueryConsumerChain returns the consumer chain associated with the consumer id +func (k Keeper) QueryConsumerChain(goCtx context.Context, req *types.QueryConsumerChainRequest) (*types.QueryConsumerChainResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + consumerId := req.ConsumerId + if err := types.ValidateConsumerId(consumerId); err != nil { + return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) + } + ctx := sdk.UnwrapSDKContext(goCtx) + + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve chain id for consumer id: %s", consumerId) + } + + ownerAddress, err := k.GetConsumerOwnerAddress(ctx, consumerId) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve owner address for consumer id: %s", consumerId) + } + + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve phase for consumer id: %s", consumerId) + } + + metadata, err := k.GetConsumerMetadata(ctx, consumerId) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve metadata for consumer id: %s", consumerId) + } + + // neither the init nor the power shaping params are mandatory for consumers + initParams, _ := k.GetConsumerInitializationParameters(ctx, consumerId) + powerParams, _ := k.GetConsumerPowerShapingParameters(ctx, consumerId) + + return &types.QueryConsumerChainResponse{ + ChainId: chainId, + OwnerAddress: ownerAddress, + Phase: phase.String(), + Metadata: metadata, + InitParams: &initParams, + PowerShapingParams: &powerParams, + }, nil +} diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index a9670fafdd..7a0e62c3f7 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -280,13 +280,6 @@ func TestQueryConsumerValidators(t *testing.T) { res, err = pk.QueryConsumerValidators(ctx, &req) require.NoError(t, err) require.Equal(t, val1.Commission.Rate, res.Validators[0].ConsumerCommissionRate) - - // set consumer to stopped phase - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) - // expect empty valset - res, err = pk.QueryConsumerValidators(ctx, &req) - require.NoError(t, err) - require.Empty(t, res) } func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { @@ -444,8 +437,6 @@ func TestGetConsumerChain(t *testing.T) { Top_N: topN, ValidatorSetCap: validatorSetCaps[i], ValidatorsPowerCap: validatorPowerCaps[i], - AllowInactiveVals: allowInactiveVals[i], - MinStake: minStakes[i].Uint64(), }) pk.SetMinimumPowerInTopN(ctx, consumerID, expectedMinPowerInTopNs[i]) for _, addr := range allowlists[i] { @@ -486,6 +477,76 @@ func TestGetConsumerChain(t *testing.T) { } } +func TestQueryConsumerChain(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + chainId := "consumer-1" + + req := types.QueryConsumerChainRequest{ + ConsumerId: consumerId, + } + + // expect error when consumer isn't associated with a chain id + _, err := providerKeeper.QueryConsumerChain(ctx, &req) + require.Error(t, err) + + providerKeeper.SetConsumerChainId(ctx, consumerId, chainId) + + // expect error when consumer doesn't have an owner address set + _, err = providerKeeper.QueryConsumerChain(ctx, &req) + require.Error(t, err) + + providerKeeper.SetConsumerOwnerAddress(ctx, consumerId, providerKeeper.GetAuthority()) + + // expect error when consumer doesn't have a valid phase + _, err = providerKeeper.QueryConsumerChain(ctx, &req) + require.Error(t, err) + + providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + + // expect error when consumer doesn't have metadata + _, err = providerKeeper.QueryConsumerChain(ctx, &req) + require.Error(t, err) + + providerKeeper.SetConsumerMetadata(ctx, consumerId, types.ConsumerMetadata{Name: chainId}) + + expRes := types.QueryConsumerChainResponse{ + ChainId: chainId, + OwnerAddress: providerKeeper.GetAuthority(), + Metadata: types.ConsumerMetadata{Name: chainId}, + Phase: types.ConsumerPhase_CONSUMER_PHASE_REGISTERED.String(), + InitParams: &types.ConsumerInitializationParameters{}, + PowerShapingParams: &types.PowerShapingParameters{}, + } + + // expect no error when neither the consumer init and power shaping params are set + res, err := providerKeeper.QueryConsumerChain(ctx, &req) + require.NoError(t, err) + require.Equal(t, &expRes, res) + + providerKeeper.SetConsumerInitializationParameters( + ctx, + consumerId, + types.ConsumerInitializationParameters{SpawnTime: ctx.BlockTime()}, + ) + + providerKeeper.SetConsumerPowerShapingParameters( + ctx, + consumerId, + types.PowerShapingParameters{Top_N: uint32(50)}, + ) + + expRes.InitParams = &types.ConsumerInitializationParameters{SpawnTime: ctx.BlockTime()} + expRes.PowerShapingParams = &types.PowerShapingParameters{Top_N: uint32(50)} + + // expect no error + res, err = providerKeeper.QueryConsumerChain(ctx, &req) + require.NoError(t, err) + require.Equal(t, &expRes, res) +} + func TestQueryConsumerIdFromClientId(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index c20b135ffd..25c51440cc 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -1983,6 +1983,134 @@ func (m *QueryConsumerIdFromClientIdResponse) GetConsumerId() string { return "" } +type QueryConsumerChainRequest struct { + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` +} + +func (m *QueryConsumerChainRequest) Reset() { *m = QueryConsumerChainRequest{} } +func (m *QueryConsumerChainRequest) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerChainRequest) ProtoMessage() {} +func (*QueryConsumerChainRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_422512d7b7586cd7, []int{38} +} +func (m *QueryConsumerChainRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerChainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerChainRequest.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 *QueryConsumerChainRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerChainRequest.Merge(m, src) +} +func (m *QueryConsumerChainRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerChainRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerChainRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerChainRequest proto.InternalMessageInfo + +func (m *QueryConsumerChainRequest) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + +type QueryConsumerChainResponse struct { + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + OwnerAddress string `protobuf:"bytes,2,opt,name=owner_address,json=ownerAddress,proto3" json:"owner_address,omitempty"` + Phase string `protobuf:"bytes,3,opt,name=phase,proto3" json:"phase,omitempty"` + Metadata ConsumerMetadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata"` + InitParams *ConsumerInitializationParameters `protobuf:"bytes,5,opt,name=init_params,json=initParams,proto3" json:"init_params,omitempty"` + PowerShapingParams *PowerShapingParameters `protobuf:"bytes,6,opt,name=power_shaping_params,json=powerShapingParams,proto3" json:"power_shaping_params,omitempty"` +} + +func (m *QueryConsumerChainResponse) Reset() { *m = QueryConsumerChainResponse{} } +func (m *QueryConsumerChainResponse) String() string { return proto.CompactTextString(m) } +func (*QueryConsumerChainResponse) ProtoMessage() {} +func (*QueryConsumerChainResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_422512d7b7586cd7, []int{39} +} +func (m *QueryConsumerChainResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryConsumerChainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryConsumerChainResponse.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 *QueryConsumerChainResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryConsumerChainResponse.Merge(m, src) +} +func (m *QueryConsumerChainResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryConsumerChainResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryConsumerChainResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryConsumerChainResponse proto.InternalMessageInfo + +func (m *QueryConsumerChainResponse) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +func (m *QueryConsumerChainResponse) GetOwnerAddress() string { + if m != nil { + return m.OwnerAddress + } + return "" +} + +func (m *QueryConsumerChainResponse) GetPhase() string { + if m != nil { + return m.Phase + } + return "" +} + +func (m *QueryConsumerChainResponse) GetMetadata() ConsumerMetadata { + if m != nil { + return m.Metadata + } + return ConsumerMetadata{} +} + +func (m *QueryConsumerChainResponse) GetInitParams() *ConsumerInitializationParameters { + if m != nil { + return m.InitParams + } + return nil +} + +func (m *QueryConsumerChainResponse) GetPowerShapingParams() *PowerShapingParameters { + if m != nil { + return m.PowerShapingParams + } + return nil +} + func init() { proto.RegisterType((*QueryConsumerGenesisRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerGenesisRequest") proto.RegisterType((*QueryConsumerGenesisResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerGenesisResponse") @@ -2022,6 +2150,8 @@ func init() { proto.RegisterType((*QueryBlocksUntilNextEpochResponse)(nil), "interchain_security.ccv.provider.v1.QueryBlocksUntilNextEpochResponse") proto.RegisterType((*QueryConsumerIdFromClientIdRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerIdFromClientIdRequest") proto.RegisterType((*QueryConsumerIdFromClientIdResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerIdFromClientIdResponse") + proto.RegisterType((*QueryConsumerChainRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainRequest") + proto.RegisterType((*QueryConsumerChainResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainResponse") } func init() { @@ -2029,162 +2159,172 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x1c, 0x49, - 0x15, 0x76, 0x8f, 0x7f, 0x62, 0x97, 0x13, 0x67, 0x53, 0xf9, 0x9b, 0x8c, 0x1d, 0x8f, 0xd3, 0x49, - 0x60, 0xf2, 0x37, 0x6d, 0x7b, 0xb5, 0xec, 0x26, 0x90, 0x4d, 0x3c, 0xe3, 0x38, 0x19, 0x25, 0x9b, - 0x78, 0x3b, 0x4e, 0x40, 0x5e, 0x4c, 0xa7, 0xdd, 0x5d, 0x8c, 0x1b, 0xf7, 0x74, 0xb7, 0xbb, 0xda, - 0x93, 0x8c, 0xa2, 0x1c, 0x16, 0x24, 0xb4, 0xcb, 0x01, 0x05, 0x21, 0xee, 0x7b, 0x41, 0xe2, 0xc0, - 0x09, 0xad, 0x40, 0xdc, 0xf6, 0xb8, 0x37, 0x96, 0xdd, 0x0b, 0x02, 0x29, 0xa0, 0x04, 0x24, 0x84, - 0x84, 0x84, 0x16, 0xae, 0x48, 0xa8, 0xab, 0x5f, 0xff, 0xba, 0xc7, 0xd3, 0x33, 0xe3, 0x03, 0x37, - 0x77, 0xd5, 0xab, 0xaf, 0xde, 0x7b, 0xf5, 0xea, 0xd5, 0x7b, 0xdf, 0x18, 0x09, 0x9a, 0xe1, 0x10, - 0x5b, 0xd9, 0x90, 0x35, 0x43, 0xa2, 0x44, 0xd9, 0xb6, 0x35, 0xa7, 0x25, 0x28, 0x4a, 0x53, 0xb0, - 0x6c, 0xb3, 0xa9, 0xa9, 0xc4, 0x16, 0x9a, 0x73, 0xc2, 0xd6, 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 0x16, - 0xa4, 0x94, 0x4e, 0xbb, 0x05, 0x55, 0xeb, 0xc9, 0x68, 0x15, 0x92, 0x38, 0x4e, 0xe2, 0x67, 0x9a, - 0xc9, 0x48, 0x39, 0x12, 0x3f, 0x5f, 0x42, 0xf9, 0x47, 0x68, 0x3a, 0xb6, 0xe5, 0xde, 0x1b, 0xf5, - 0x93, 0x7d, 0x68, 0xa6, 0xcd, 0x16, 0xc1, 0x5f, 0xa9, 0x65, 0x02, 0x97, 0xbd, 0x4c, 0x48, 0xc6, - 0x57, 0xae, 0xcb, 0xf8, 0xc2, 0x79, 0x34, 0xcc, 0xaa, 0x38, 0x16, 0x99, 0x83, 0xcc, 0x42, 0x6f, - 0x00, 0x5f, 0x46, 0x43, 0xb6, 0xfb, 0xc0, 0x0c, 0x31, 0x6d, 0xce, 0xba, 0xd1, 0xf1, 0xc7, 0x17, - 0xc5, 0x49, 0xaf, 0xdf, 0xa2, 0xea, 0x66, 0x59, 0x33, 0x85, 0x86, 0xec, 0x6c, 0x94, 0xef, 0x90, - 0xba, 0xac, 0xb4, 0x16, 0x89, 0x92, 0xe7, 0x44, 0xb6, 0x04, 0x9f, 0x45, 0x13, 0x81, 0x56, 0x1e, - 0xfa, 0x30, 0x7b, 0xdc, 0x0e, 0xf8, 0xa3, 0xac, 0x3a, 0xc4, 0x6b, 0x28, 0x1f, 0x88, 0x29, 0x66, - 0xa3, 0xa1, 0x51, 0xaa, 0x99, 0x86, 0xc4, 0x76, 0x1d, 0x61, 0xbb, 0x9e, 0xce, 0xb0, 0xab, 0x78, - 0xcc, 0x07, 0xa9, 0x06, 0x18, 0xa2, 0xab, 0xc5, 0x1a, 0xca, 0x07, 0xae, 0x4d, 0xc2, 0xef, 0xeb, - 0x02, 0xde, 0x07, 0x49, 0xc0, 0xdf, 0x46, 0xe3, 0x2a, 0xa1, 0x8a, 0xad, 0x59, 0x6e, 0x8f, 0x91, - 0x1f, 0x65, 0x9e, 0x3f, 0x5d, 0x86, 0xee, 0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85, 0x4d, 0x63, 0x43, 0x70, 0x17, 0x7c, 0xdc, 0x2e, 0x8c, 0x4b, 0x61, - 0xa9, 0x5f, 0x98, 0xee, 0x0b, 0xe4, 0x36, 0xe4, 0x0d, 0xfe, 0x37, 0x97, 0xf8, 0x4f, 0x9d, 0x38, - 0xbd, 0x82, 0x6f, 0x76, 0x7f, 0xd0, 0xa9, 0x1c, 0x4f, 0xe1, 0x56, 0xff, 0x40, 0xdd, 0x5b, 0x1d, - 0x09, 0x0e, 0xe1, 0x69, 0x40, 0x31, 0x3d, 0xab, 0x7c, 0xf3, 0xd3, 0x97, 0xd3, 0xdc, 0x67, 0x2f, - 0xa7, 0xb9, 0xbf, 0xbc, 0x9c, 0xe6, 0x9e, 0xbf, 0x9a, 0x1e, 0xf8, 0xec, 0xd5, 0xf4, 0xc0, 0x1f, - 0x5e, 0x4d, 0x0f, 0xac, 0x5e, 0xad, 0x6b, 0xce, 0xc6, 0xf6, 0x7a, 0x59, 0x31, 0x1b, 0xf0, 0x1f, - 0x5f, 0x91, 0x5d, 0x2e, 0x05, 0xbb, 0x34, 0xdf, 0x10, 0x9e, 0x24, 0xca, 0xf4, 0x96, 0x45, 0xe8, - 0xfa, 0x08, 0xfb, 0x21, 0xfc, 0xf5, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x42, 0x0b, 0xd3, 0xc7, - 0x91, 0x27, 0x00, 0x00, + // 2637 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6c, 0x1c, 0x49, + 0x19, 0x76, 0x8f, 0x1f, 0xb1, 0xcb, 0xb1, 0xb3, 0xa9, 0x38, 0xc9, 0x64, 0xec, 0x78, 0x9c, 0xce, + 0x06, 0x26, 0xaf, 0x19, 0xdb, 0xab, 0xb0, 0x9b, 0xec, 0xe6, 0xe1, 0x19, 0xc7, 0xc9, 0x28, 0x2f, + 0x6f, 0x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x35, 0xf5, 0xb9, 0x02, 0xd9, 0x40, 0x16, + 0x56, 0x65, 0xc5, 0xd0, 0xc9, 0x76, 0xcd, 0x5b, 0x71, 0x6a, 0x97, 0x15, 0x3b, 0x9a, 0x85, 0xb9, + 0xd8, 0x14, 0xc5, 0xba, 0x8a, 0xad, 0x9a, 0xa6, 0xd3, 0x82, 0x62, 0x35, 0x4c, 0x6a, 0x14, 0x36, + 0x71, 0xc3, 0xf5, 0xf0, 0x98, 0x62, 0x90, 0x9a, 0x41, 0x64, 0xc7, 0x49, 0xe7, 0x83, 0x4f, 0xbd, + 0xea, 0x7c, 0x15, 0x08, 0x45, 0x9b, 0x9a, 0x5e, 0x29, 0xd4, 0xe7, 0xd6, 0x31, 0x45, 0x73, 0xee, + 0xb7, 0x23, 0x25, 0x3e, 0x04, 0x93, 0x6f, 0xdb, 0x41, 0x2f, 0x71, 0xe3, 0x6e, 0x60, 0x1d, 0x13, + 0x8d, 0x48, 0x78, 0x6b, 0x1b, 0x13, 0x0a, 0x8f, 0x83, 0x61, 0xc7, 0x42, 0x4d, 0x4d, 0x0b, 0x33, + 0x42, 0x6e, 0xa4, 0x98, 0x4a, 0x0b, 0xd2, 0x3e, 0x36, 0x56, 0x56, 0x61, 0x16, 0x8c, 0xba, 0x5e, + 0xd9, 0x12, 0x29, 0x5b, 0x42, 0x02, 0xee, 0x50, 0x59, 0x15, 0x9f, 0x80, 0xa9, 0x68, 0x78, 0x62, + 0x1a, 0x3a, 0xc1, 0xf0, 0x5d, 0x30, 0x56, 0x71, 0x86, 0x64, 0x42, 0x11, 0xc5, 0x4c, 0xc9, 0xe8, + 0xfc, 0x6c, 0xbe, 0xdd, 0xe6, 0xd7, 0xe7, 0xf2, 0x21, 0xac, 0x15, 0x7b, 0x5d, 0x71, 0xe0, 0x93, + 0xe7, 0xd9, 0x3e, 0x69, 0x7f, 0xc5, 0x37, 0x26, 0x4e, 0x81, 0x4c, 0x40, 0x79, 0xc9, 0x86, 0x73, + 0x5d, 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 0xe8, 0x53, 0x75, 0xde, 0x53, 0x55, 0xbf, + 0x50, 0x78, 0x1c, 0x7a, 0x86, 0x34, 0x4c, 0x4c, 0xd6, 0x87, 0xd8, 0x6f, 0x39, 0x5e, 0xfb, 0x7f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0xc5, 0x56, 0xdf, 0x54, 0x2a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2248,6 +2388,9 @@ type QueryClient interface { // QueryConsumerIdFromClientId returns the consumer id of the chain // associated with the provided client id QueryConsumerIdFromClientId(ctx context.Context, in *QueryConsumerIdFromClientIdRequest, opts ...grpc.CallOption) (*QueryConsumerIdFromClientIdResponse, error) + // QueryConsumerChain returns the consumer chain + // associated with the provided consumer id + QueryConsumerChain(ctx context.Context, in *QueryConsumerChainRequest, opts ...grpc.CallOption) (*QueryConsumerChainResponse, error) } type queryClient struct { @@ -2411,6 +2554,15 @@ func (c *queryClient) QueryConsumerIdFromClientId(ctx context.Context, in *Query return out, nil } +func (c *queryClient) QueryConsumerChain(ctx context.Context, in *QueryConsumerChainRequest, opts ...grpc.CallOption) (*QueryConsumerChainResponse, error) { + out := new(QueryConsumerChainResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryConsumerChain", 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 @@ -2462,6 +2614,9 @@ type QueryServer interface { // QueryConsumerIdFromClientId returns the consumer id of the chain // associated with the provided client id QueryConsumerIdFromClientId(context.Context, *QueryConsumerIdFromClientIdRequest) (*QueryConsumerIdFromClientIdResponse, error) + // QueryConsumerChain returns the consumer chain + // associated with the provided consumer id + QueryConsumerChain(context.Context, *QueryConsumerChainRequest) (*QueryConsumerChainResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2519,6 +2674,9 @@ func (*UnimplementedQueryServer) QueryBlocksUntilNextEpoch(ctx context.Context, func (*UnimplementedQueryServer) QueryConsumerIdFromClientId(ctx context.Context, req *QueryConsumerIdFromClientIdRequest) (*QueryConsumerIdFromClientIdResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerIdFromClientId not implemented") } +func (*UnimplementedQueryServer) QueryConsumerChain(ctx context.Context, req *QueryConsumerChainRequest) (*QueryConsumerChainResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerChain not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2830,6 +2988,24 @@ func _Query_QueryConsumerIdFromClientId_Handler(srv interface{}, ctx context.Con return interceptor(ctx, in, info, handler) } +func _Query_QueryConsumerChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryConsumerChainRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryConsumerChain(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryConsumerChain", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryConsumerChain(ctx, req.(*QueryConsumerChainRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.provider.v1.Query", HandlerType: (*QueryServer)(nil), @@ -2902,6 +3078,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryConsumerIdFromClientId", Handler: _Query_QueryConsumerIdFromClientId_Handler, }, + { + MethodName: "QueryConsumerChain", + Handler: _Query_QueryConsumerChain_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/provider/v1/query.proto", @@ -4323,6 +4503,114 @@ func (m *QueryConsumerIdFromClientIdResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } +func (m *QueryConsumerChainRequest) 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 *QueryConsumerChainRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsumerChainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryConsumerChainResponse) 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 *QueryConsumerChainResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryConsumerChainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PowerShapingParams != nil { + { + size, err := m.PowerShapingParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.InitParams != nil { + { + size, err := m.InitParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Phase) > 0 { + i -= len(m.Phase) + copy(dAtA[i:], m.Phase) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Phase))) + i-- + dAtA[i] = 0x1a + } + if len(m.OwnerAddress) > 0 { + i -= len(m.OwnerAddress) + copy(dAtA[i:], m.OwnerAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.OwnerAddress))) + i-- + dAtA[i] = 0x12 + } + 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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -4932,6 +5220,50 @@ func (m *QueryConsumerIdFromClientIdResponse) Size() (n int) { return n } +func (m *QueryConsumerChainRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryConsumerChainResponse) 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)) + } + l = len(m.OwnerAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Phase) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovQuery(uint64(l)) + if m.InitParams != nil { + l = m.InitParams.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.PowerShapingParams != nil { + l = m.PowerShapingParams.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -8847,6 +9179,339 @@ func (m *QueryConsumerIdFromClientIdResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryConsumerChainRequest) 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: QueryConsumerChainRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerChainRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = 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 *QueryConsumerChainResponse) 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: QueryConsumerChainResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryConsumerChainResponse: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OwnerAddress", 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.OwnerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Phase", 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.Phase = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitParams", 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.InitParams == nil { + m.InitParams = &ConsumerInitializationParameters{} + } + if err := m.InitParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PowerShapingParams", 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.PowerShapingParams == nil { + m.PowerShapingParams = &PowerShapingParameters{} + } + if err := m.PowerShapingParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index a533712da9..73a7714e22 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -1121,6 +1121,60 @@ func local_request_Query_QueryConsumerIdFromClientId_0(ctx context.Context, mars } +func request_Query_QueryConsumerChain_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerChainRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + msg, err := client.QueryConsumerChain(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryConsumerChain_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryConsumerChainRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + msg, err := server.QueryConsumerChain(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. @@ -1633,6 +1687,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryConsumerChain_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_QueryConsumerChain_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_QueryConsumerChain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2114,6 +2191,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryConsumerChain_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_QueryConsumerChain_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_QueryConsumerChain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2161,6 +2258,8 @@ var ( pattern_Query_QueryBlocksUntilNextEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "blocks_until_next_epoch"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryConsumerIdFromClientId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_id", "client_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryConsumerChain_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_chain", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -2207,4 +2306,6 @@ var ( forward_Query_QueryBlocksUntilNextEpoch_0 = runtime.ForwardResponseMessage forward_Query_QueryConsumerIdFromClientId_0 = runtime.ForwardResponseMessage + + forward_Query_QueryConsumerChain_0 = runtime.ForwardResponseMessage ) From 4ed2723de4c87d3fa3c37f7a5b72c467e2f77f34 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 10:34:02 +0200 Subject: [PATCH 14/43] feat: extend consumer chains query (#2172) * feat: first iteration on Permissionless ICS (#2117) * (partially) renamed chain ids to consumer ids * renamed proposal messages * removed global slash entry * fixed unit tests * added new messages * introduced new state * added functionality for the register and initialize messages * renamed (partially) chainIds to consumerIds * set consumerId to chainId association during registration * added extra check in the initialization so unknokwn, launched, or stopped chains cannot re-initialize * added initial work on traversing initialized chains that are to-be-launched * fixed rebase issues after bringing the VSCMaturedPackets work in * made it so we traverse initialization records instead of addition proposals (+ additional changes so the unit tests pass) * renamed more chainIDs to consumerIds * removed ClientIdToChainId state because chainId already resides on the registration record * nit fixes in go docs * removed MsgConsumerAddition * added CLI commands for new messages * removed consumer modification proposal * removed (partially) consumer removal proposal * rebased to pick up the inactive-validators work (PR #2079) * introduced consumerId in the equivocation messages (and a useful query for Hermes to get the consumerId) * added safeguard so that a validator cannot opt-in to two different chains with the same chain id * renamed some chainIDs to consumerIds * updated based on comments Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * fixed integration tests * rebased to pick up the removal of legacy proposals (#2130) and re-introduced old messages so that existing proposals can deserialize * changes messages to only have MsgCreateConsumer and MsgUpdateConsumer and modified protos so that we are backward-compatible * cleaned up slightly a few things (mostly committing & pushing) so people can pick up the latest changes * fixed the CreateConsumer and UpdateConsumer logic and made most of the fields optional * fixed hooks and the code around proposalId to consumerId * feat: extend consumer validator query to return commission rate (backport #2162) (#2165) * adapt #2162 changes for permissionless ICS * nits --------- Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * renamed some chainIds to consumerIds * took into account comments and also added safeguard to reject new proposals that still use deprecated messages (e.g., MsgConsumerAddition, etc.) * Update x/ccv/provider/types/msg.go Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> * removed double-gas charge on MsgCreateConsumer and imroved the logic of MsgUpdateConsumer * added PopulateMinimumPowerInTopN tested * took into account comments (using protos for marshalling string slice, fixed issues in the UpdateConsumer logic, added extra check to abort spurious proposals) * feat: add fields to consumer validators query (#2167) * extend consumer validators query * nit * nits * fix msg order * deprecate power for consumer_power * modified the way we verify the new owner address, as well as nit refactoring on the ConsumerIds * fixed some rebase issues and changed a proto to be backward-compatible --------- Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: Simon Noetzlin Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> * add phase + metadata * first logic draft * add filter * reformat test * nits * nit * address comments * update tests * nits * update logic * update CLI * revert unwanted changes * remove filter field * nit * fix bad int conversion * update cli --------- Co-authored-by: insumity Co-authored-by: bernd-m <43466467+bermuell@users.noreply.github.com> Co-authored-by: kirdatatjana <116630536+kirdatatjana@users.noreply.github.com> --- .../ccv/provider/v1/query.proto | 18 +- x/ccv/provider/client/cli/query.go | 27 +- x/ccv/provider/keeper/grpc_query.go | 74 ++- x/ccv/provider/keeper/grpc_query_test.go | 131 ++++- x/ccv/provider/keeper/hooks.go | 3 +- x/ccv/provider/types/query.pb.go | 517 ++++++++++++------ x/ccv/provider/types/query.pb.gw.go | 18 + 7 files changed, 587 insertions(+), 201 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 23ca4c6fee..ddd7805c75 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -199,7 +199,14 @@ message QueryConsumerGenesisResponse { [ (gogoproto.nullable) = false ]; } -message QueryConsumerChainsRequest {} +message QueryConsumerChainsRequest { + // The phase of the consumer chains returned (optional) + // Registered=1|Initialized=2|Launched=3|Stopped=4 + ConsumerPhase phase = 1; + // The limit of consumer chains returned (optional) + // default is 100 + int32 limit = 2; +} message QueryConsumerChainsResponse { repeated Chain chains = 1; } @@ -233,11 +240,14 @@ message Chain { repeated string allowlist = 7; // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. repeated string denylist = 8; + // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + ConsumerPhase phase = 9; + // The metadata of the consumer chain + ConsumerMetadata metadata = 10 [(gogoproto.nullable) = false ]; // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. - uint64 min_stake = 9; + uint64 min_stake = 11; // Corresponds to whether inactive validators are allowed to validate the consumer chain. - bool allow_inactive_vals = 10; - + bool allow_inactive_vals = 12; } message QueryValidatorConsumerAddrRequest { diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 34d715583c..53f81a90bf 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "strings" "github.com/spf13/cobra" @@ -75,9 +76,12 @@ func CmdConsumerGenesis() *cobra.Command { func CmdConsumerChains() *cobra.Command { cmd := &cobra.Command{ - Use: "list-consumer-chains", - Short: "Query active consumer chains for provider chain.", - Args: cobra.ExactArgs(0), + Use: "list-consumer-chains [phase] [limit]", + Short: "Query consumer chains for provider chain.", + Long: `Query consumer chains for provider chain. An optional + integer parameter can be passed for phase filtering of consumer chains, + (Registered=1|Initialized=2|Launched=3|Stopped=4).`, + Args: cobra.MaximumNArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -86,6 +90,23 @@ func CmdConsumerChains() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) req := &types.QueryConsumerChainsRequest{} + + if args[0] != "" { + phase, err := strconv.ParseInt(args[0], 10, 32) + if err != nil { + return err + } + req.Phase = types.ConsumerPhase(phase) + } + + if args[1] != "" { + limit, err := strconv.ParseInt(args[1], 10, 32) + if err != nil { + return err + } + req.Limit = int32(limit) + } + res, err := queryClient.QueryConsumerChains(cmd.Context(), req) if err != nil { return err diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 63ca301775..855f66fe5e 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -5,14 +5,15 @@ import ( "context" "fmt" "sort" + "strconv" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -51,13 +52,51 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu ctx := sdk.UnwrapSDKContext(goCtx) - chains := []*types.Chain{} - for _, chainID := range k.GetAllRegisteredConsumerIds(ctx) { - c, err := k.GetConsumerChain(ctx, chainID) + consumerIds := []string{} + phaseFilter := req.Phase + + // if the phase filter is set Launched get consumer from the state directly + if phaseFilter == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + consumerIds = append(consumerIds, k.GetAllRegisteredConsumerIds(ctx)...) + // otherwise iterate over all the consumer using the last unused consumer Id + } else { + firstUnusedConsumerId, ok := k.GetConsumerId(ctx) + if !ok { + return &types.QueryConsumerChainsResponse{}, nil + } + for i := uint64(0); i < firstUnusedConsumerId; i++ { + // if the phase filter is set, verify that the consumer has the same phase + if phaseFilter != types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + p := k.GetConsumerPhase(ctx, strconv.FormatInt(int64(i), 10)) + if p == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + return nil, status.Error(codes.Internal, fmt.Sprintf("cannot retrieve phase for consumer id: %d", i)) + } + if p != phaseFilter { + continue + } + } + + consumerIds = append(consumerIds, strconv.FormatInt(int64(i), 10)) + } + } + + // set limit to default value + limit := 100 + if req.Limit != 0 { + // update limit if specified + limit = int(req.Limit) + } + + chains := make([]*types.Chain, math.Min(len(consumerIds), limit)) + for i, cID := range consumerIds { + if i == limit { + break + } + c, err := k.GetConsumerChain(ctx, cID) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - chains = append(chains, &c) + chains[i] = &c } return &types.QueryConsumerChainsResponse{Chains: chains}, nil @@ -70,11 +109,7 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai return types.Chain{}, fmt.Errorf("cannot find chainID for consumer (%s)", consumerId) } - clientID, found := k.GetConsumerClientId(ctx, consumerId) - if !found { - return types.Chain{}, fmt.Errorf("cannot find clientID for consumer (%s)", consumerId) - } - + clientID, _ := k.GetConsumerClientId(ctx, consumerId) topN := k.GetTopN(ctx, consumerId) // Get the minimal power in the top N for the consumer chain @@ -84,9 +119,10 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai minPowerInTopN = -1 } - validatorSetCap := k.GetValidatorSetCap(ctx, consumerId) - - validatorsPowerCap := k.GetValidatorsPowerCap(ctx, consumerId) + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + return types.Chain{}, fmt.Errorf("cannot find phase for consumer (%s)", consumerId) + } allowlist := k.GetAllowList(ctx, consumerId) strAllowlist := make([]string, len(allowlist)) @@ -100,8 +136,12 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai strDenylist[i] = addr.String() } - allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) + metadata, err := k.GetConsumerMetadata(ctx, consumerId) + if err != nil { + return types.Chain{}, fmt.Errorf("cannot get metadata for consumer (%s): %w", consumerId, err) + } + allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) minStake := k.GetMinStake(ctx, consumerId) return types.Chain{ @@ -109,10 +149,12 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai ClientId: clientID, Top_N: topN, MinPowerInTop_N: minPowerInTopN, - ValidatorSetCap: validatorSetCap, - ValidatorsPowerCap: validatorsPowerCap, + ValidatorSetCap: k.GetValidatorSetCap(ctx, consumerId), + ValidatorsPowerCap: k.GetValidatorsPowerCap(ctx, consumerId), Allowlist: strAllowlist, Denylist: strDenylist, + Phase: phase, + Metadata: metadata, AllowInactiveVals: allowInactiveVals, MinStake: minStake, }, nil diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 7a0e62c3f7..a618a66d84 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -4,7 +4,9 @@ import ( "bytes" "fmt" "sort" + "strconv" "testing" + "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -18,6 +20,7 @@ import ( cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -427,6 +430,8 @@ func TestGetConsumerChain(t *testing.T) { math.NewInt(300), } + metadataLists := []types.ConsumerMetadata{} + expectedGetAllOrder := []types.Chain{} for i, consumerID := range consumerIDs { pk.SetConsumerChainId(ctx, consumerID, chainIDs[i]) @@ -437,6 +442,8 @@ func TestGetConsumerChain(t *testing.T) { Top_N: topN, ValidatorSetCap: validatorSetCaps[i], ValidatorsPowerCap: validatorPowerCaps[i], + MinStake: minStakes[i].Uint64(), + AllowInactiveVals: allowInactiveVals[i], }) pk.SetMinimumPowerInTopN(ctx, consumerID, expectedMinPowerInTopNs[i]) for _, addr := range allowlists[i] { @@ -455,6 +462,12 @@ func TestGetConsumerChain(t *testing.T) { strDenylist[j] = addr.String() } + metadataLists = append(metadataLists, types.ConsumerMetadata{Name: chainIDs[i]}) + pk.SetConsumerMetadata(ctx, consumerID, metadataLists[i]) + + phase := types.ConsumerPhase(int32(i + 1)) + pk.SetConsumerPhase(ctx, consumerID, phase) + expectedGetAllOrder = append(expectedGetAllOrder, types.Chain{ ChainId: chainIDs[i], @@ -465,13 +478,15 @@ func TestGetConsumerChain(t *testing.T) { ValidatorsPowerCap: validatorPowerCaps[i], Allowlist: strAllowlist, Denylist: strDenylist, + Phase: phase, + Metadata: metadataLists[i], AllowInactiveVals: allowInactiveVals[i], MinStake: minStakes[i].Uint64(), }) } - for i, chainID := range pk.GetAllActiveConsumerIds(ctx) { - c, err := pk.GetConsumerChain(ctx, chainID) + for i, cId := range consumerIDs { + c, err := pk.GetConsumerChain(ctx, cId) require.NoError(t, err) require.Equal(t, expectedGetAllOrder[i], c) } @@ -562,3 +577,115 @@ func TestQueryConsumerIdFromClientId(t *testing.T) { require.NoError(t, err) require.Equal(t, expectedConsumerId, res.ConsumerId) } + +func TestQueryConsumerChains(t *testing.T) { + pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerNum := 4 + consumerIds := make([]string, consumerNum) + consumers := make([]*types.Chain, consumerNum) + + // expect no error and returned chains + res, err := pk.QueryConsumerChains(ctx, &types.QueryConsumerChainsRequest{}) + require.NoError(t, err) + require.Len(t, res.Chains, 0) + + // create four consumer chains in different phase + for i := 0; i < consumerNum; i++ { + cID := pk.FetchAndIncrementConsumerId(ctx) + chainID := "consumer-" + strconv.Itoa(i) + c := types.Chain{ + ChainId: chainID, + MinPowerInTop_N: -1, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: []string{}, + Denylist: []string{}, + Phase: types.ConsumerPhase(i + 1), + Metadata: types.ConsumerMetadata{Name: chainID}, + } + pk.SetConsumerPhase(ctx, cID, c.Phase) + pk.SetConsumerMetadata(ctx, cID, c.Metadata) + pk.SetConsumerChainId(ctx, cID, chainID) + + consumerIds[i] = cID + consumers[i] = &c + } + + testCases := []struct { + name string + setup func(ctx sdk.Context, pk keeper.Keeper) + phase_filter types.ConsumerPhase + limit int32 + expConsumers []*types.Chain + }{ + { + name: "expect all consumers when phase filter isn't set", + setup: func(ctx sdk.Context, pk keeper.Keeper) {}, + expConsumers: consumers, + }, + { + name: "expect an amount of consumer equal to the limit", + setup: func(ctx sdk.Context, pk keeper.Keeper) {}, + expConsumers: consumers[:3], + limit: int32(3), + }, + { + name: "expect registered consumers when phase filter is set to Registered", + setup: func(ctx sdk.Context, pk keeper.Keeper) { + consumers[0].Phase = types.ConsumerPhase_CONSUMER_PHASE_REGISTERED + pk.SetConsumerPhase(ctx, consumerIds[0], types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + }, + phase_filter: types.ConsumerPhase_CONSUMER_PHASE_REGISTERED, + expConsumers: consumers[0:1], + }, + { + name: "expect initialized consumers when phase is set to Initialized", + setup: func(ctx sdk.Context, pk keeper.Keeper) { + consumers[1].Phase = types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED + err := pk.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerIds[1], time.Now()) + require.NoError(t, err) + pk.SetConsumerPhase(ctx, consumerIds[1], types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + }, + phase_filter: types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, + expConsumers: consumers[1:2], + }, + { + name: "expect launched consumers when phase is set to Launched", + setup: func(ctx sdk.Context, pk keeper.Keeper) { + consumers[2].Phase = types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED + consumers[2].ClientId = "ClientID" + pk.SetConsumerClientId(ctx, consumerIds[2], consumers[2].ClientId) + pk.SetConsumerPhase(ctx, consumerIds[2], types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + }, + phase_filter: types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, + expConsumers: consumers[2:3], + }, + { + name: "expect stopped consumers when phase is set to Stopped", + setup: func(ctx sdk.Context, pk keeper.Keeper) { + consumers[3].Phase = types.ConsumerPhase_CONSUMER_PHASE_STOPPED + pk.SetConsumerPhase(ctx, consumerIds[3], types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + }, + phase_filter: types.ConsumerPhase_CONSUMER_PHASE_STOPPED, + expConsumers: consumers[3:], + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tc.setup(ctx, pk) + req := types.QueryConsumerChainsRequest{ + Phase: tc.phase_filter, + Limit: tc.limit, + } + expectedResponse := types.QueryConsumerChainsResponse{ + Chains: tc.expConsumers, + } + res, err := pk.QueryConsumerChains(ctx, &req) + require.NoError(t, err) + require.Equal(t, &expectedResponse, res) + }) + } +} diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 68bcbbc399..ffb1b46c15 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -2,8 +2,9 @@ package keeper import ( "context" - "cosmossdk.io/math" "fmt" + + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 25c51440cc..568b8d34ae 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -137,6 +137,12 @@ func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisSt } type QueryConsumerChainsRequest struct { + // The phase of the consumer chains returned (optional) + // Registered=1|Initialized=2|Launched=3|Stopped=4 + Phase ConsumerPhase `protobuf:"varint,1,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` + // The limit of consumer chains returned (optional) + // default is 100 + Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` } func (m *QueryConsumerChainsRequest) Reset() { *m = QueryConsumerChainsRequest{} } @@ -172,6 +178,20 @@ func (m *QueryConsumerChainsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerChainsRequest proto.InternalMessageInfo +func (m *QueryConsumerChainsRequest) GetPhase() ConsumerPhase { + if m != nil { + return m.Phase + } + return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED +} + +func (m *QueryConsumerChainsRequest) GetLimit() int32 { + if m != nil { + return m.Limit + } + return 0 +} + type QueryConsumerChainsResponse struct { Chains []*Chain `protobuf:"bytes,1,rep,name=chains,proto3" json:"chains,omitempty"` } @@ -402,10 +422,14 @@ type Chain struct { Allowlist []string `protobuf:"bytes,7,rep,name=allowlist,proto3" json:"allowlist,omitempty"` // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` + // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + Phase ConsumerPhase `protobuf:"varint,9,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` + // The metadata of the consumer chain + Metadata ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata"` // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. - MinStake uint64 `protobuf:"varint,9,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` + MinStake uint64 `protobuf:"varint,11,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` // Corresponds to whether inactive validators are allowed to validate the consumer chain. - AllowInactiveVals bool `protobuf:"varint,10,opt,name=allow_inactive_vals,json=allowInactiveVals,proto3" json:"allow_inactive_vals,omitempty"` + AllowInactiveVals bool `protobuf:"varint,12,opt,name=allow_inactive_vals,json=allowInactiveVals,proto3" json:"allow_inactive_vals,omitempty"` } func (m *Chain) Reset() { *m = Chain{} } @@ -497,6 +521,20 @@ func (m *Chain) GetDenylist() []string { return nil } +func (m *Chain) GetPhase() ConsumerPhase { + if m != nil { + return m.Phase + } + return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED +} + +func (m *Chain) GetMetadata() ConsumerMetadata { + if m != nil { + return m.Metadata + } + return ConsumerMetadata{} +} + func (m *Chain) GetMinStake() uint64 { if m != nil { return m.MinStake @@ -2159,172 +2197,175 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2637 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6c, 0x1c, 0x49, - 0x19, 0x76, 0x8f, 0x1f, 0xb1, 0xcb, 0xb1, 0xb3, 0xa9, 0x38, 0xc9, 0x64, 0xec, 0x78, 0x9c, 0xce, - 0x06, 0x26, 0xaf, 0x19, 0xdb, 0xab, 0xb0, 0x9b, 0xec, 0xe6, 0xe1, 0x19, 0xc7, 0xc9, 0x28, 0x2f, - 0x6f, 0xdb, 0xc9, 0x22, 0x2f, 0xa1, 0x53, 0xee, 0xae, 0x1d, 0x37, 0x9e, 0xe9, 0x6e, 0x77, 0x95, - 0xc7, 0x19, 0xa2, 0x1c, 0x16, 0x24, 0xb4, 0x70, 0x40, 0x41, 0x88, 0xfb, 0x0a, 0x09, 0x89, 0x03, - 0x27, 0xb4, 0x02, 0x71, 0xdb, 0xe3, 0xde, 0x58, 0x76, 0x2f, 0x08, 0x44, 0x40, 0x09, 0x48, 0x80, - 0x84, 0x84, 0x16, 0xae, 0x48, 0xa8, 0xab, 0xab, 0x7b, 0xba, 0x7b, 0x7a, 0x3c, 0xdd, 0x33, 0x3e, - 0xec, 0xcd, 0x5d, 0xf5, 0xd7, 0xf7, 0x3f, 0xea, 0xaf, 0xbf, 0xfe, 0xfa, 0x3c, 0xa0, 0xa0, 0xe9, - 0x14, 0x5b, 0xca, 0x06, 0xd2, 0x74, 0x99, 0x60, 0x65, 0xdb, 0xd2, 0x68, 0xa3, 0xa0, 0x28, 0xf5, - 0x82, 0x69, 0x19, 0x75, 0x4d, 0xc5, 0x56, 0xa1, 0x3e, 0x57, 0xd8, 0xda, 0xc6, 0x56, 0x23, 0x6f, - 0x5a, 0x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36, 0x56, 0x56, 0x61, 0x16, 0x8c, 0xba, 0x5e, - 0xd9, 0x12, 0x29, 0x5b, 0x42, 0x02, 0xee, 0x50, 0x59, 0x15, 0x9f, 0x80, 0xa9, 0x68, 0x78, 0x62, - 0x1a, 0x3a, 0xc1, 0xf0, 0x5d, 0x30, 0x56, 0x71, 0x86, 0x64, 0x42, 0x11, 0xc5, 0x4c, 0xc9, 0xe8, - 0xfc, 0x6c, 0xbe, 0xdd, 0xe6, 0xd7, 0xe7, 0xf2, 0x21, 0xac, 0x15, 0x7b, 0x5d, 0x71, 0xe0, 0x93, - 0xe7, 0xd9, 0x3e, 0x69, 0x7f, 0xc5, 0x37, 0x26, 0x4e, 0x81, 0x4c, 0x40, 0x79, 0xc9, 0x86, 0x73, - 0x5d, 0x13, 0x51, 0xc8, 0x73, 0x77, 0x96, 0x5b, 0x56, 0x04, 0x43, 0x4c, 0x3d, 0x49, 0x0b, 0x33, - 0xfd, 0xb9, 0xd1, 0xf9, 0x33, 0xf9, 0x18, 0xf9, 0x98, 0x67, 0x20, 0x12, 0x5f, 0x29, 0x9e, 0x06, - 0x5f, 0x6d, 0x55, 0xb1, 0x42, 0x91, 0x45, 0x97, 0x2d, 0xc3, 0x34, 0x08, 0xaa, 0x7a, 0xd6, 0x7c, - 0x20, 0x80, 0x5c, 0x67, 0x59, 0x6e, 0xdb, 0x37, 0xc0, 0x88, 0xe9, 0x0e, 0xf2, 0x88, 0x5d, 0x89, - 0x67, 0x1e, 0x07, 0x5f, 0x50, 0x55, 0xcd, 0x3e, 0x28, 0x4d, 0xe8, 0x26, 0xa0, 0x98, 0x03, 0x5f, - 0x89, 0xb2, 0xc4, 0x30, 0x5b, 0x8c, 0xfe, 0x9e, 0x10, 0xed, 0x60, 0x40, 0xd4, 0xdb, 0xe9, 0x16, - 0x9b, 0x2f, 0x27, 0xb2, 0x59, 0xc2, 0x35, 0xa3, 0x8e, 0xaa, 0x91, 0x26, 0xff, 0x2d, 0x05, 0x06, - 0x99,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 0x4f, 0xee, 0xb3, 0x20, 0x50, 0x42, 0x93, 0x3c, 0x0b, 0xa2, 0x88, 0xc2, 0xcc, - 0xd5, 0xae, 0xd7, 0x73, 0xd7, 0x96, 0x98, 0x6b, 0xd7, 0xe0, 0x95, 0xa4, 0x45, 0x3a, 0x78, 0x0e, - 0x8a, 0xef, 0x7c, 0xf2, 0x62, 0x5a, 0xf8, 0xf4, 0xc5, 0xb4, 0xf0, 0x97, 0x17, 0xd3, 0xc2, 0xb3, - 0x97, 0xd3, 0x7d, 0x9f, 0xbe, 0x9c, 0xee, 0xfb, 0xfd, 0xcb, 0xe9, 0xbe, 0xb5, 0xcb, 0x15, 0x8d, - 0x6e, 0x6c, 0xaf, 0xe7, 0x15, 0xa3, 0xc6, 0x7f, 0xb4, 0xe8, 0x53, 0x75, 0xde, 0x53, 0x55, 0xbf, - 0x50, 0x78, 0x1c, 0x7a, 0x86, 0x34, 0x4c, 0x4c, 0xd6, 0x87, 0xd8, 0x6f, 0x39, 0x5e, 0xfb, 0x7f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0xc5, 0x56, 0xdf, 0x54, 0x2a, 0x00, 0x00, + // 2676 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6c, 0xdc, 0xc6, + 0xf9, 0x17, 0xf5, 0xf2, 0x6a, 0x64, 0x29, 0xc9, 0x58, 0xb6, 0xd7, 0x2b, 0x59, 0x2b, 0xd3, 0xf1, + 0xff, 0x2f, 0xbf, 0x76, 0x25, 0x05, 0x6e, 0x62, 0x27, 0x7e, 0x68, 0x57, 0x96, 0xbd, 0xf0, 0x4b, + 0xa1, 0x64, 0xa7, 0x50, 0xea, 0xd2, 0x14, 0x39, 0x59, 0xb1, 0xe2, 0x92, 0x14, 0x67, 0xb4, 0xf6, + 0xd6, 0xf5, 0x21, 0x2d, 0x50, 0xb8, 0x3d, 0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ae, 0x94, 0x18, 0x00, 0x9c, 0x00, 0x43, 0x86, 0x5e, 0xd3, 0x09, 0xf5, + 0x7f, 0x48, 0x62, 0x1f, 0xa2, 0x12, 0x89, 0xac, 0xa7, 0x9d, 0x7b, 0x5e, 0x02, 0xc3, 0x54, 0x17, + 0xce, 0x0a, 0x33, 0x03, 0xb3, 0xa3, 0x0b, 0xa7, 0x92, 0xe9, 0x77, 0xa7, 0x25, 0xbe, 0x52, 0x3c, + 0x09, 0xfe, 0xbf, 0x55, 0xc5, 0x2a, 0x51, 0x1c, 0xb2, 0xe2, 0x58, 0xb6, 0x85, 0x15, 0xc3, 0xf3, + 0x56, 0x7c, 0x2a, 0x80, 0xd9, 0xce, 0xb2, 0xdc, 0xb6, 0xaf, 0x81, 0x11, 0xdb, 0x1b, 0xe4, 0x3b, + 0x72, 0x29, 0x55, 0x78, 0x16, 0x35, 0x4d, 0x77, 0x0f, 0x62, 0x13, 0xba, 0x09, 0x28, 0xce, 0x82, + 0xff, 0x8b, 0xb3, 0xc4, 0xb2, 0x5b, 0x8c, 0xfe, 0xae, 0x10, 0xef, 0x60, 0x48, 0xd4, 0xcf, 0xa4, + 0x16, 0x9b, 0x2f, 0xa6, 0xb2, 0x59, 0x42, 0x35, 0xab, 0xae, 0x18, 0xb1, 0x26, 0x3f, 0x1d, 0x04, + 0x43, 0x54, 0x37, 0x3c, 0x12, 0x3d, 0x10, 0xcd, 0xc3, 0x30, 0x09, 0x46, 0x54, 0x43, 0x47, 0x26, + 0x69, 0x1e, 0x85, 0x0c, 0x1b, 0xa8, 0x68, 0xf0, 0x00, 0x18, 0x22, 0x96, 0x2d, 0xdf, 0xce, 0x0e, + 0xcc, 0x08, 0xb3, 0x63, 0xd2, 0x20, 0xb1, 0xec, 0xdb, 0xf0, 0x14, 0x80, 0x35, 0xdd, 0x94, 0x6d, + 0xeb, 0xa1, 0x7b, 0x7e, 0x4c, 0x99, 0x49, 0x0c, 0xce, 0x08, 0xb3, 0x03, 0xd2, 0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58, 0xc7, 0x53, 0xf0, 0x3a, + 0x9e, 0xc2, 0x9a, 0xd7, 0xf1, 0x94, 0x32, 0xee, 0x59, 0x79, 0xf6, 0xa7, 0xbc, 0x20, 0x1d, 0x72, + 0x51, 0x24, 0x0f, 0xa4, 0xec, 0x61, 0x88, 0x67, 0xc0, 0x29, 0xea, 0x92, 0x84, 0xaa, 0x3a, 0x26, + 0xc8, 0x41, 0x5a, 0xb3, 0x62, 0x3e, 0x54, 0x1c, 0x6d, 0x09, 0x99, 0x56, 0xcd, 0x2f, 0xd9, 0x57, + 0xc1, 0xe9, 0x44, 0xd2, 0x3c, 0x22, 0x87, 0xc0, 0xb0, 0x46, 0x47, 0xe8, 0x2d, 0x38, 0x22, 0xf1, + 0x2f, 0x71, 0x9a, 0xf7, 0x0d, 0xac, 0x1a, 0x23, 0x8d, 0x16, 0xdf, 0xca, 0x92, 0xaf, 0xe6, 0x43, + 0x01, 0x1c, 0x6d, 0x23, 0xc0, 0x91, 0x1f, 0x80, 0x71, 0x3b, 0x38, 0xe7, 0xdd, 0xb3, 0xc9, 0x0a, + 0x54, 0x08, 0x96, 0x17, 0x94, 0x08, 0x9e, 0x68, 0x82, 0xb1, 0x90, 0x18, 0x9c, 0x02, 0x3c, 0xc1, + 0x97, 0x5a, 0x73, 0x7e, 0x09, 0x4e, 0x03, 0xe0, 0x5d, 0x28, 0x95, 0x25, 0xba, 0xa1, 0x83, 0x52, + 0x60, 0xa4, 0x63, 0x52, 0x8b, 0xdb, 0xa0, 0x48, 0x5d, 0x5e, 0x34, 0x8c, 0x15, 0x45, 0x77, 0xf0, + 0x3d, 0xc5, 0x28, 0x5b, 0xa6, 0x9b, 0x97, 0xa5, 0xf0, 0x05, 0x59, 0x59, 0xda, 0xab, 0xf6, 0xed, + 0xa7, 0x02, 0x98, 0x4b, 0xae, 0x93, 0x47, 0x7e, 0x1b, 0xbc, 0x66, 0x2b, 0xba, 0xe3, 0xd6, 0x51, + 0xb7, 0xe7, 0xa5, 0x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fb, 0xdd, + 0xcb, 0xe9, 0xbe, 0xf5, 0x8b, 0x55, 0x9d, 0x6c, 0xee, 0x6c, 0x14, 0x54, 0xab, 0xc6, 0xff, 0x6f, + 0x33, 0xa0, 0xea, 0xac, 0xaf, 0xaa, 0x7e, 0xae, 0xf8, 0x28, 0xf2, 0x0c, 0x69, 0xd8, 0x08, 0x6f, + 0x0c, 0xd3, 0xff, 0xe5, 0x78, 0xe3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb4, 0xb1, 0x32, 0xd1, + 0x57, 0x2b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3177,6 +3218,16 @@ func (m *QueryConsumerChainsRequest) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l + if m.Limit != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x10 + } + if m.Phase != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Phase)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -3361,11 +3412,26 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x50 + dAtA[i] = 0x60 } if m.MinStake != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.MinStake)) i-- + dAtA[i] = 0x58 + } + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + if m.Phase != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Phase)) + i-- dAtA[i] = 0x48 } if len(m.Denylist) > 0 { @@ -3614,12 +3680,12 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - 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 + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.NextReplenishCandidate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate):]) + if err5 != nil { + return 0, err5 } - i -= n4 - i = encodeVarintQuery(dAtA, i, uint64(n4)) + i -= n5 + i = encodeVarintQuery(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x1a if m.SlashMeterAllowance != 0 { @@ -4656,6 +4722,12 @@ func (m *QueryConsumerChainsRequest) Size() (n int) { } var l int _ = l + if m.Phase != 0 { + n += 1 + sovQuery(uint64(m.Phase)) + } + if m.Limit != 0 { + n += 1 + sovQuery(uint64(m.Limit)) + } return n } @@ -4756,6 +4828,11 @@ func (m *Chain) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } + if m.Phase != 0 { + n += 1 + sovQuery(uint64(m.Phase)) + } + l = m.Metadata.Size() + n += 1 + l + sovQuery(uint64(l)) if m.MinStake != 0 { n += 1 + sovQuery(uint64(m.MinStake)) } @@ -5496,6 +5573,44 @@ func (m *QueryConsumerChainsRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: QueryConsumerChainsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) + } + m.Phase = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Phase |= ConsumerPhase(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6107,6 +6222,58 @@ func (m *Chain) Unmarshal(dAtA []byte) error { m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) + } + m.Phase = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Phase |= ConsumerPhase(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) } @@ -6125,7 +6292,7 @@ func (m *Chain) Unmarshal(dAtA []byte) error { break } } - case 10: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AllowInactiveVals", wireType) } diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 73a7714e22..80e0b6025d 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -177,10 +177,21 @@ func local_request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler r } +var ( + filter_Query_QueryConsumerChains_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_Query_QueryConsumerChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerChainsRequest 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_QueryConsumerChains_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.QueryConsumerChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -190,6 +201,13 @@ func local_request_Query_QueryConsumerChains_0(ctx context.Context, marshaler ru var protoReq QueryConsumerChainsRequest 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_QueryConsumerChains_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.QueryConsumerChains(ctx, &protoReq) return msg, metadata, err From 7aa6db910325aabb527b66fe32e56916e1c42395 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 29 Aug 2024 10:46:49 +0200 Subject: [PATCH 15/43] feat!: migrations for permissionless (#2174) * migrations for permissionless -- wip * feat!: migrations for permissionless (#2177) * initial commit * took into account comments * removed deprecated queries * fix error due to rebase * remove fields from provider genesis * remove commented code --------- Co-authored-by: insumity --- .../ccv/provider/v1/genesis.proto | 12 +- .../ccv/provider/v1/query.proto | 49 - x/ccv/provider/client/cli/query.go | 92 - x/ccv/provider/keeper/genesis.go | 13 +- x/ccv/provider/keeper/genesis_test.go | 12 - x/ccv/provider/keeper/grpc_query.go | 47 - x/ccv/provider/keeper/hooks.go | 89 - x/ccv/provider/keeper/keeper.go | 76 +- x/ccv/provider/keeper/keeper_test.go | 95 - x/ccv/provider/keeper/key_assignment.go | 18 +- x/ccv/provider/keeper/legacy_proposal.go | 24 - x/ccv/provider/keeper/legacy_proposal_test.go | 150 -- x/ccv/provider/keeper/partial_set_security.go | 23 +- .../keeper/partial_set_security_test.go | 2 - x/ccv/provider/keeper/proposal.go | 212 --- x/ccv/provider/keeper/proposal_test.go | 196 +- x/ccv/provider/keeper/validator_set_update.go | 2 +- x/ccv/provider/migrations/migrator.go | 3 + x/ccv/provider/migrations/v8/migrations.go | 285 ++- .../provider/migrations/v8/migrations_test.go | 4 +- x/ccv/provider/module_test.go | 2 - x/ccv/provider/types/genesis.go | 30 +- x/ccv/provider/types/genesis.pb.go | 225 +-- x/ccv/provider/types/genesis_test.go | 40 - x/ccv/provider/types/keys.go | 266 +-- x/ccv/provider/types/keys_test.go | 216 +-- x/ccv/provider/types/query.pb.go | 1690 ++--------------- x/ccv/provider/types/query.pb.gw.go | 195 -- 28 files changed, 746 insertions(+), 3322 deletions(-) delete mode 100644 x/ccv/provider/keeper/legacy_proposal_test.go diff --git a/proto/interchain_security/ccv/provider/v1/genesis.proto b/proto/interchain_security/ccv/provider/v1/genesis.proto index 34c0daf633..8a8a3e4cb8 100644 --- a/proto/interchain_security/ccv/provider/v1/genesis.proto +++ b/proto/interchain_security/ccv/provider/v1/genesis.proto @@ -17,6 +17,12 @@ message GenesisState { // Reserve 4th slot for removed mature_unbonding_ops field reserved 4; + // Reserve 6th slot for removed consumer_addition_proposals field + reserved 6; + + // Reserve 7th slot for removed consumer_removal_proposals field + reserved 7; + // Reserve 11th slot for consumer_addrs_to_prune field reserved 11; @@ -36,12 +42,6 @@ message GenesisState { // empty for a new chain repeated ValsetUpdateIdToHeight valset_update_id_to_height = 5 [ (gogoproto.nullable) = false ]; - // empty for a new chain - repeated ConsumerAdditionProposal consumer_addition_proposals = 6 - [ (gogoproto.nullable) = false ]; - // empty for a new chain - repeated ConsumerRemovalProposal consumer_removal_proposals = 7 - [ (gogoproto.nullable) = false ]; Params params = 8 [ (gogoproto.nullable) = false ]; // empty for a new chain repeated ValidatorConsumerPubKey validator_consumer_pubkeys = 9 diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index ddd7805c75..51d49d1313 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -35,20 +35,6 @@ service Query { "/interchain_security/ccv/provider/consumer_chains"; } - // QueryConsumerChainStarts queries consumer chain start proposals. - rpc QueryConsumerChainStarts(QueryConsumerChainStartProposalsRequest) - returns (QueryConsumerChainStartProposalsResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_chain_start_proposals"; - } - - // QueryConsumerChainStops queries consumer chain stop proposals. - rpc QueryConsumerChainStops(QueryConsumerChainStopProposalsRequest) - returns (QueryConsumerChainStopProposalsResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_chain_stop_proposals"; - } - // QueryValidatorConsumerAddr queries the address // assigned by a validator for a consumer chain. rpc QueryValidatorConsumerAddr(QueryValidatorConsumerAddrRequest) @@ -82,15 +68,6 @@ service Query { "/interchain_security/ccv/provider/registered_consumer_reward_denoms"; } - // QueryProposedConsumerChainIDs returns the chain IDs of the proposed consumer chain addition proposals - // that are still in the voting period - rpc QueryProposedConsumerChainIDs( - QueryProposedChainIDsRequest) - returns (QueryProposedChainIDsResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/proposed_consumer_chains"; - } - // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address // between provider and consumer chain rpc QueryAllPairsValConAddrByConsumerChainID ( @@ -210,18 +187,6 @@ message QueryConsumerChainsRequest { message QueryConsumerChainsResponse { repeated Chain chains = 1; } -message QueryConsumerChainStartProposalsRequest {} - -message QueryConsumerChainStartProposalsResponse { - ConsumerAdditionProposals proposals = 1; -} - -message QueryConsumerChainStopProposalsRequest {} - -message QueryConsumerChainStopProposalsResponse { - ConsumerRemovalProposals proposals = 1; -} - message Chain { string chain_id = 1; string client_id = 2; @@ -302,20 +267,6 @@ message QueryRegisteredConsumerRewardDenomsResponse { repeated string denoms = 1; } -message QueryProposedChainIDsRequest {} - -message QueryProposedChainIDsResponse { - repeated ProposedChain proposedChains = 1 - [ (gogoproto.nullable) = false ]; -} - -message ProposedChain { - // [DEPRECATED] use `consumer_id` instead - string chainID = 1 [deprecated = true]; - uint64 proposalID = 2; - string consumer_id = 3; -} - message QueryAllPairsValConAddrByConsumerChainIDRequest { // [DEPRECATED] use `consumer_id` instead string chain_id = 1 [deprecated = true]; diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 53f81a90bf..fd5d5d7762 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -27,13 +27,10 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdConsumerGenesis()) cmd.AddCommand(CmdConsumerChains()) - cmd.AddCommand(CmdConsumerStartProposals()) - cmd.AddCommand(CmdConsumerStopProposals()) cmd.AddCommand(CmdConsumerValidatorKeyAssignment()) cmd.AddCommand(CmdProviderValidatorKey()) cmd.AddCommand(CmdThrottleState()) cmd.AddCommand(CmdRegisteredConsumerRewardDenoms()) - cmd.AddCommand(CmdProposedConsumerChains()) cmd.AddCommand(CmdAllPairsValConAddrByConsumerChainID()) cmd.AddCommand(CmdProviderParameters()) cmd.AddCommand(CmdConsumerChainOptedInValidators()) @@ -121,95 +118,6 @@ func CmdConsumerChains() *cobra.Command { return cmd } -func CmdProposedConsumerChains() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-proposed-consumer-chains", - Short: "Query chainIDs in consumer addition proposal before voting finishes", - 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.QueryProposedChainIDsRequest{} - res, err := queryClient.QueryProposedConsumerChainIDs(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdConsumerStartProposals() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-start-proposals", - Short: "Query consumer chains start proposals on provider chain.", - Long: `Query mature and pending consumer chains start proposals on provider chain. - Matured proposals will be executed on the next block - their spawn_time has passed - Pending proposals are waiting for their spawn_time to pass. - `, - 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.QueryConsumerChainStartProposalsRequest{} - res, err := queryClient.QueryConsumerChainStarts(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdConsumerStopProposals() *cobra.Command { - cmd := &cobra.Command{ - Use: "list-stop-proposals", - Short: "Query consumer chains stop proposals on provider chain.", - Long: `Query mature and pending consumer chains stop proposals on provider chain. - Matured proposals will be executed on the next block - their stop_time has passed - Pending proposals are waiting for their stop_time to pass. - `, - 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.QueryConsumerChainStopProposalsRequest{} - res, err := queryClient.QueryConsumerChainStops(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - // TODO: fix naming func CmdConsumerValidatorKeyAssignment() *cobra.Command { bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index 0c01cef1e9..127b15c65a 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -32,16 +32,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) []abc k.SetValsetUpdateBlockHeight(ctx, v2h.ValsetUpdateId, v2h.Height) } - for _, prop := range genState.ConsumerAdditionProposals { - // prevent implicit memory aliasing - p := prop - k.SetPendingConsumerAdditionProp(ctx, &p) - } - for _, prop := range genState.ConsumerRemovalProposals { - p := prop - k.SetPendingConsumerRemovalProp(ctx, &p) - } - // Set initial state for each consumer chain for _, cs := range genState.ConsumerStates { chainID := cs.ChainId @@ -173,12 +163,11 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := k.GetParams(ctx) + // TODO (PERMISSIONLESS) return types.NewGenesisState( k.GetValidatorSetUpdateId(ctx), k.GetAllValsetUpdateBlockHeights(ctx), consumerStates, - k.GetAllPendingConsumerAdditionProps(ctx), - k.GetAllPendingConsumerRemovalProps(ctx), params, k.GetAllValidatorConsumerPubKeys(ctx, nil), k.GetAllValidatorsByConsumerAddr(ctx, nil), diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index 8f305f1197..3f3ec2d240 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -62,14 +62,6 @@ func TestInitAndExportGenesis(t *testing.T) { nil, ), }, - []providertypes.ConsumerAdditionProposal{{ - ChainId: cChainIDs[0], - SpawnTime: oneHourFromNow, - }}, - []providertypes.ConsumerRemovalProposal{{ - ChainId: cChainIDs[0], - StopTime: oneHourFromNow, - }}, params, []providertypes.ValidatorConsumerPubKey{ { @@ -139,10 +131,6 @@ func TestInitAndExportGenesis(t *testing.T) { height, found := pk.GetValsetUpdateBlockHeight(ctx, vscID) require.True(t, found) require.Equal(t, initHeight, height) - addProp, found := pk.GetPendingConsumerAdditionProp(ctx, oneHourFromNow, cChainIDs[0]) - require.True(t, found) - require.Equal(t, provGenesis.ConsumerAdditionProposals[0], addProp) - require.True(t, pk.PendingConsumerRemovalPropExists(ctx, cChainIDs[0], oneHourFromNow)) require.Equal(t, provGenesis.Params, pk.GetParams(ctx)) providerConsensusValSet, err := pk.GetLastProviderConsensusValSet(ctx) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 855f66fe5e..d782d650f5 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -160,39 +160,6 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai }, nil } -func (k Keeper) QueryConsumerChainStarts(goCtx context.Context, req *types.QueryConsumerChainStartProposalsRequest) (*types.QueryConsumerChainStartProposalsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - var props []*types.ConsumerAdditionProposal - - for _, prop := range k.GetAllPendingConsumerAdditionProps(ctx) { - // prevent implicit memory aliasing - p := prop - props = append(props, &p) - } - - return &types.QueryConsumerChainStartProposalsResponse{Proposals: &types.ConsumerAdditionProposals{Pending: props}}, nil -} - -func (k Keeper) QueryConsumerChainStops(goCtx context.Context, req *types.QueryConsumerChainStopProposalsRequest) (*types.QueryConsumerChainStopProposalsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - var props []*types.ConsumerRemovalProposal - for _, prop := range k.GetAllPendingConsumerRemovalProps(ctx) { - // prevent implicit memory aliasing - p := prop - props = append(props, &p) - } - - return &types.QueryConsumerChainStopProposalsResponse{Proposals: &types.ConsumerRemovalProposals{Pending: props}}, nil -} - func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.QueryValidatorConsumerAddrRequest) (*types.QueryValidatorConsumerAddrResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") @@ -285,20 +252,6 @@ func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req * }, nil } -func (k Keeper) QueryProposedConsumerChainIDs(goCtx context.Context, req *types.QueryProposedChainIDsRequest) (*types.QueryProposedChainIDsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - chains := k.GetAllProposedConsumerChainIDs(ctx) - - return &types.QueryProposedChainIDsResponse{ - ProposedChains: chains, - }, nil -} - func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, req *types.QueryAllPairsValConAddrByConsumerChainIDRequest) (*types.QueryAllPairsValConAddrByConsumerChainIDResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index ffb1b46c15..f61facac50 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -106,52 +105,11 @@ func (h Hooks) BeforeTokenizeShareRecordRemoved(_ context.Context, _ uint64) err // gov hooks // -// AfterProposalSubmission - call hook if registered -// If an update consumer message exists in the proposal, a record is created that maps the proposal id to the consumer id func (h Hooks) AfterProposalSubmission(goCtx context.Context, proposalId uint64) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) - if err != nil { - return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) - } - - err = DoesNotHaveDeprecatedMessage(&p) - if err != nil { - return err - } - - msgUpdateConsumer, err := h.k.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &p) - if err != nil { - return err - } - - if msgUpdateConsumer != nil { - // a correctly set `MsgUpdateConsumer` was found - h.k.SetProposalIdToConsumerId(ctx, proposalId, msgUpdateConsumer.ConsumerId) - } - return nil } -// AfterProposalVotingPeriodEnded - call hook if registered -// After proposal voting ends, the consumer to proposal id record in store is deleted. func (h Hooks) AfterProposalVotingPeriodEnded(goCtx context.Context, proposalId uint64) error { - ctx := sdk.UnwrapSDKContext(goCtx) - - p, err := h.k.govKeeper.Proposals.Get(ctx, proposalId) - if err != nil { - return fmt.Errorf("cannot retrieve proposal with id: %d", proposalId) - } - - for _, msg := range p.GetMessages() { - _, isUpdateConsumer := msg.GetCachedValue().(*providertypes.MsgUpdateConsumer) - if isUpdateConsumer { - h.k.DeleteProposalIdToConsumerId(ctx, proposalId) - return nil - } - } - return nil } @@ -166,50 +124,3 @@ func (h Hooks) AfterProposalVote(ctx context.Context, proposalID uint64, voterAd func (h Hooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error { return nil } - -// GetConsumerAdditionFromProp extracts a consumer addition proposal from -// the proposal with the given ID -func (h Hooks) GetConsumerAdditionFromProp( - ctx sdk.Context, - proposalID uint64, -) (providertypes.ConsumerAdditionProposal, bool) { - p, err := h.k.govKeeper.Proposals.Get(ctx, proposalID) - if err != nil { - return providertypes.ConsumerAdditionProposal{}, false - } - - // Iterate over the messages in the proposal - // Note that it's assumed that at most ONE message can contain a consumer addition proposal - for _, msg := range p.GetMessages() { - sdkMsg, isConsumerAddition := msg.GetCachedValue().(*providertypes.MsgConsumerAddition) - if !isConsumerAddition { - continue - } - - proposal := providertypes.ConsumerAdditionProposal{ - Title: p.Title, - Description: p.Summary, - ChainId: sdkMsg.ChainId, - InitialHeight: sdkMsg.InitialHeight, - GenesisHash: sdkMsg.GenesisHash, - BinaryHash: sdkMsg.BinaryHash, - SpawnTime: sdkMsg.SpawnTime, - UnbondingPeriod: sdkMsg.UnbondingPeriod, - CcvTimeoutPeriod: sdkMsg.CcvTimeoutPeriod, - TransferTimeoutPeriod: sdkMsg.TransferTimeoutPeriod, - ConsumerRedistributionFraction: sdkMsg.ConsumerRedistributionFraction, - BlocksPerDistributionTransmission: sdkMsg.BlocksPerDistributionTransmission, - HistoricalEntries: sdkMsg.HistoricalEntries, - DistributionTransmissionChannel: sdkMsg.DistributionTransmissionChannel, - Top_N: sdkMsg.Top_N, - ValidatorsPowerCap: sdkMsg.ValidatorsPowerCap, - ValidatorSetCap: sdkMsg.ValidatorSetCap, - Allowlist: sdkMsg.Allowlist, - Denylist: sdkMsg.Denylist, - MinStake: sdkMsg.MinStake, - AllowInactiveVals: sdkMsg.AllowInactiveVals, - } - return proposal, true - } - return providertypes.ConsumerAdditionProposal{}, false -} diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 318fb7c90c..93469af316 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -211,64 +211,6 @@ func (k Keeper) DeleteConsumerIdToChannelId(ctx sdk.Context, consumerId string) store.Delete(types.ConsumerIdToChannelIdKey(consumerId)) } -// SetProposalIdToConsumerId stores a consumer id corresponding to a proposal that contains a `MsgUpdateConsumer` mesage. -// This consumer id is deleted once the voting period for the proposal ends. -func (k Keeper) SetProposalIdToConsumerId(ctx sdk.Context, proposalId uint64, consumerId string) { - store := ctx.KVStore(k.storeKey) - store.Set(types.ProposedConsumerChainKey(proposalId), []byte(consumerId)) -} - -// GetProposalIdToConsumerId returns the proposed consumer id for the given proposal id. -// This method is only used for testing. -func (k Keeper) GetProposalIdToConsumerId(ctx sdk.Context, proposalId uint64) (string, bool) { - store := ctx.KVStore(k.storeKey) - consumerChain := store.Get(types.ProposedConsumerChainKey(proposalId)) - if consumerChain != nil { - return string(consumerChain), true - } - return "", false -} - -// DeleteProposalIdToConsumerId deletes the proposal to consumer id record from store -func (k Keeper) DeleteProposalIdToConsumerId(ctx sdk.Context, proposalId uint64) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ProposedConsumerChainKey(proposalId)) -} - -// GetAllProposedConsumerChainIDs returns the proposed consumer ids of all gov proposals that are still in the voting period -func (k Keeper) GetAllProposedConsumerChainIDs(ctx sdk.Context) []types.ProposedChain { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ProposedConsumerChainKeyPrefix()) - defer iterator.Close() - - proposedChains := []types.ProposedChain{} - for ; iterator.Valid(); iterator.Next() { - proposalID, err := types.ParseProposedConsumerChainKey(iterator.Key()) - if err != nil { - panic(fmt.Errorf("proposed chains cannot be parsed: %w", err)) - } - - proposedChains = append(proposedChains, types.ProposedChain{ - ConsumerId: string(iterator.Value()), - ProposalID: proposalID, - }) - - } - - return proposedChains -} - -// GetAllPendingConsumerChainIDs gets pending consumer chains have not reach spawn time -func (k Keeper) GetAllPendingConsumerChainIDs(ctx sdk.Context) []string { - chainIDs := []string{} - props := k.GetAllPendingConsumerAdditionProps(ctx) - for _, prop := range props { - chainIDs = append(chainIDs, prop.ChainId) - } - - return chainIDs -} - // GetAllRegisteredConsumerIds gets all of the consumer chain IDs, for which the provider module // created IBC clients. Consumer chains with created clients are also referred to as registered. // @@ -820,7 +762,7 @@ func (k Keeper) GetAllOptedIn( consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ConsumerIdWithLenKey(types.OptedInKeyPrefix(), consumerId) + key := types.StringIdWithLenKey(types.OptedInKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -837,7 +779,7 @@ func (k Keeper) DeleteAllOptedIn( consumerId string, ) { store := ctx.KVStore(k.storeKey) - key := types.ConsumerIdWithLenKey(types.OptedInKeyPrefix(), consumerId) + key := types.StringIdWithLenKey(types.OptedInKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) var keysToDel [][]byte @@ -900,7 +842,7 @@ func (k Keeper) GetAllCommissionRateValidators( consumerId string, ) (addresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ConsumerIdWithLenKey(types.ConsumerCommissionRateKeyPrefix(), consumerId) + key := types.StringIdWithLenKey(types.ConsumerCommissionRateKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -963,7 +905,7 @@ func (k Keeper) GetAllowList( consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId) + key := types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -988,7 +930,7 @@ func (k Keeper) IsAllowlisted( // DeleteAllowlist deletes all allowlisted validators func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) defer iterator.Close() keysToDel := [][]byte{} @@ -1004,7 +946,7 @@ func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string) { // IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `consumerId` func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) defer iterator.Close() return !iterator.Valid() @@ -1026,7 +968,7 @@ func (k Keeper) GetDenyList( consumerId string, ) (providerConsAddresses []types.ProviderConsAddress) { store := ctx.KVStore(k.storeKey) - key := types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId) + key := types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId) iterator := storetypes.KVStorePrefixIterator(store, key) defer iterator.Close() @@ -1051,7 +993,7 @@ func (k Keeper) IsDenylisted( // DeleteDenylist deletes all denylisted validators func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) defer iterator.Close() keysToDel := [][]byte{} @@ -1067,7 +1009,7 @@ func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string) { // IsDenylistEmpty returns `true` if no validator is denylisted on chain `consumerId` func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool { store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.ConsumerIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) defer iterator.Close() return !iterator.Valid() diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index d781164e5b..b9b8294955 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -284,101 +284,6 @@ func TestSetSlashLog(t *testing.T) { require.False(t, providerKeeper.GetSlashLog(ctx, addrWithoutDoubleSigns)) } -func TestSetProposedConsumerChains(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - tests := []struct { - consumerId string - proposalId uint64 - }{ - {consumerId: "1", proposalId: 1}, - {consumerId: "some other ID", proposalId: 12}, - {consumerId: "some other other chain ID", proposalId: 123}, - {consumerId: "", proposalId: 1234}, - } - - for _, test := range tests { - providerKeeper.SetProposalIdToConsumerId(ctx, test.proposalId, test.consumerId) - cID, _ := providerKeeper.GetProposalIdToConsumerId(ctx, test.proposalId) - require.Equal(t, cID, test.consumerId) - } -} - -func TestDeleteProposedConsumerChainInStore(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - tests := []struct { - chainId string - proposalId uint64 - deleteProposalId uint64 - ok bool - }{ - {chainId: "1", proposalId: 1, deleteProposalId: 1, ok: true}, - {chainId: "", proposalId: 12, deleteProposalId: 12, ok: true}, - {chainId: "1", proposalId: 0, deleteProposalId: 1, ok: false}, - } - for _, test := range tests { - providerKeeper.SetProposalIdToConsumerId(ctx, test.proposalId, test.chainId) - providerKeeper.DeleteProposalIdToConsumerId(ctx, test.deleteProposalId) - cID, found := providerKeeper.GetProposalIdToConsumerId(ctx, test.proposalId) - if test.ok { - require.False(t, found) - } else { - require.Equal(t, cID, test.chainId) - } - } -} - -func TestGetAllProposedConsumerChainIDs(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - tests := [][]types.ProposedChain{ - {}, - { - { - ConsumerId: "1", - ProposalID: 1, - }, - }, - { - { - ConsumerId: "1", - ProposalID: 1, - }, - { - ConsumerId: "2", - ProposalID: 2, - }, - { - ConsumerId: "", - ProposalID: 3, - }, - }, - } - - for _, test := range tests { - for _, tc := range test { - providerKeeper.SetProposalIdToConsumerId(ctx, tc.ProposalID, tc.ConsumerId) - } - - chains := providerKeeper.GetAllProposedConsumerChainIDs(ctx) - - sort.Slice(chains, func(i, j int) bool { - return chains[i].ProposalID < chains[j].ProposalID - }) - sort.Slice(test, func(i, j int) bool { - return test[i].ProposalID < test[j].ProposalID - }) - require.Equal(t, chains, test) - - for _, tc := range test { - providerKeeper.DeleteProposalIdToConsumerId(ctx, tc.ProposalID) - } - } -} - // TestTopN tests the `SetTopN`, `GetTopN`, `IsTopN`, and `IsOptIn` methods func TestTopN(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index c01a061266..d037fcd648 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -118,13 +118,13 @@ func (k Keeper) GetAllValidatorConsumerPubKeys(ctx sdk.Context, consumerId *stri prefix = []byte{consumerValidatorsKeyPrefix} } else { // iterate over the validators public keys assigned for consumerId - prefix = types.ConsumerIdWithLenKey(consumerValidatorsKeyPrefix, *consumerId) + prefix = types.StringIdWithLenKey(consumerValidatorsKeyPrefix, *consumerId) } iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // TODO: store consumerId and provider cons address in value bytes, marshaled as protobuf type - consumerId, providerAddrTmp, err := types.ParseChainIdAndConsAddrKey(consumerValidatorsKeyPrefix, iterator.Key()) + consumerId, providerAddrTmp, err := types.ParseStringIdAndConsAddrKey(consumerValidatorsKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // the store key is assumed to be correctly serialized in SetValidatorConsumerPubKey. @@ -203,13 +203,13 @@ func (k Keeper) GetAllValidatorsByConsumerAddr(ctx sdk.Context, consumerId *stri prefix = []byte{validatorsByConsumerAddrKeyPrefix} } else { // iterate over the mappings from consensus addresses on consumerId - prefix = types.ConsumerIdWithLenKey(validatorsByConsumerAddrKeyPrefix, *consumerId) + prefix = types.StringIdWithLenKey(validatorsByConsumerAddrKeyPrefix, *consumerId) } iterator := storetypes.KVStorePrefixIterator(store, prefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { // TODO: store consumerId and consumer cons address in value bytes, marshaled as protobuf type - consumerId, consumerAddrTmp, err := types.ParseChainIdAndConsAddrKey(validatorsByConsumerAddrKeyPrefix, iterator.Key()) + consumerId, consumerAddrTmp, err := types.ParseStringIdAndConsAddrKey(validatorsByConsumerAddrKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in SetValidatorByConsumerAddr. @@ -307,7 +307,7 @@ func (k Keeper) ConsumeConsumerAddrsToPrune( ) (consumerAddrsToPrune types.AddressList) { store := ctx.KVStore(k.storeKey) consumerAddrsToPruneKeyPrefix := types.ConsumerAddrsToPruneV2KeyPrefix() - startPrefix := types.ConsumerIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) + startPrefix := types.StringIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) iterator := store.Iterator(startPrefix, storetypes.InclusiveEndBytes(types.ConsumerAddrsToPruneV2Key(consumerId, ts))) defer iterator.Close() @@ -315,10 +315,10 @@ func (k Keeper) ConsumeConsumerAddrsToPrune( var keysToDel [][]byte for ; iterator.Valid(); iterator.Next() { // Sanity check - if _, pruneTs, err := types.ParseConsumerIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()); err != nil { + if _, pruneTs, err := types.ParseStringIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()); err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in AppendConsumerAddrsToPrune. - k.Logger(ctx).Error("ParseConsumerIdAndTsKey failed", + k.Logger(ctx).Error("ParseStringIdAndTsKey failed", "key", string(iterator.Key()), "error", err.Error(), ) @@ -360,11 +360,11 @@ func (k Keeper) ConsumeConsumerAddrsToPrune( func (k Keeper) GetAllConsumerAddrsToPrune(ctx sdk.Context, consumerId string) (consumerAddrsToPrune []types.ConsumerAddrsToPruneV2) { store := ctx.KVStore(k.storeKey) consumerAddrsToPruneKeyPrefix := types.ConsumerAddrsToPruneV2KeyPrefix() - iteratorPrefix := types.ConsumerIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) + iteratorPrefix := types.StringIdWithLenKey(consumerAddrsToPruneKeyPrefix, consumerId) iterator := storetypes.KVStorePrefixIterator(store, iteratorPrefix) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - _, ts, err := types.ParseConsumerIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()) + _, ts, err := types.ParseStringIdAndTsKey(consumerAddrsToPruneKeyPrefix, iterator.Key()) if err != nil { // An error here would indicate something is very wrong, // store keys are assumed to be correctly serialized in AppendConsumerAddrsToPrune. diff --git a/x/ccv/provider/keeper/legacy_proposal.go b/x/ccv/provider/keeper/legacy_proposal.go index 074b611e47..a3e6ed2f30 100644 --- a/x/ccv/provider/keeper/legacy_proposal.go +++ b/x/ccv/provider/keeper/legacy_proposal.go @@ -33,27 +33,3 @@ func (k Keeper) HandleLegacyConsumerRewardDenomProposal(ctx sdk.Context, p *type } return nil } - -// HandleConsumerRemovalProposal stops a consumer chain and released the outstanding unbonding operations. -// If the consumer can be successfully stopped in a cached context, it stores the proposal as a pending proposal. -// -// This method implements StopConsumerChainProposalHandler from spec. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 -// Spec tag: [CCV-PCF-HCRPROP.1] -func (k Keeper) HandleLegacyConsumerRemovalProposal(ctx sdk.Context, p *types.ConsumerRemovalProposal) error { - // verify the consumer removal proposal execution - // in cached context and discard the cached writes - if _, _, err := k.StopConsumerChainInCachedCtx(ctx, *p); err != nil { - return err - } - - k.SetPendingConsumerRemovalProp(ctx, p) - - k.Logger(ctx).Info("consumer removal proposal enqueued", - "chain id", p.ChainId, - "title", p.Title, - "stop time", p.StopTime.UTC(), - ) - - return nil -} diff --git a/x/ccv/provider/keeper/legacy_proposal_test.go b/x/ccv/provider/keeper/legacy_proposal_test.go deleted file mode 100644 index 7f8a08d90b..0000000000 --- a/x/ccv/provider/keeper/legacy_proposal_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package keeper_test - -import ( - "testing" - "time" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" - providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -// -// Initialization sub-protocol related tests of proposal.go -// - -// TestHandleConsumerRemovalProposal tests HandleConsumerRemovalProposal against its corresponding spec method. -// -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-hcrprop1 -// Spec tag: [CCV-PCF-HCRPROP.1] -func TestHandleLegacyConsumerRemovalProposal(t *testing.T) { - type testCase struct { - description string - setupMocks func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) - - // Consumer removal proposal to handle - prop *providertypes.ConsumerRemovalProposal - // Time when prop is handled - blockTime time.Time - // Whether it's expected that the proposal is successfully verified - // and appended to the pending proposals - expAppendProp bool - - // consumerId of the consumer chain - // tests need to check that the CCV channel is not closed prematurely - chainId string - } - - // Snapshot times asserted in tests - now := time.Now().UTC() - hourAfterNow := now.Add(time.Hour).UTC() - hourBeforeNow := now.Add(-time.Hour).UTC() - - tests := []testCase{ - { - description: "valid proposal", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "consumerId", - now, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: true, - chainId: "consumerId", - }, - { - description: "valid proposal - stop_time in the past", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "consumerId", - hourBeforeNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: true, - chainId: "consumerId", - }, - { - description: "valid proposal - before stop_time in the future", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) { - k.SetConsumerClientId(ctx, chainID, "ClientID") - }, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "consumerId", - hourAfterNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: now, - expAppendProp: true, - chainId: "consumerId", - }, - { - description: "rejected valid proposal - consumer chain does not exist", - setupMocks: func(ctx sdk.Context, k providerkeeper.Keeper, chainID string) {}, - prop: providertypes.NewConsumerRemovalProposal( - "title", - "description", - "consumerId-2", - hourAfterNow, - ).(*providertypes.ConsumerRemovalProposal), - blockTime: hourAfterNow, // After stop time. - expAppendProp: false, - chainId: "consumerId-2", - }, - } - - for _, tc := range tests { - - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - ctx = ctx.WithBlockTime(tc.blockTime) - - // Mock expectations and setup for stopping the consumer chain, if applicable - // Note: when expAppendProp is false, no mocks are setup, - // meaning no external keeper methods are allowed to be called. - if tc.expAppendProp { - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, tc.prop.ChainId) - // Valid client creation is asserted with mock expectations here - gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) - } - - tc.setupMocks(ctx, providerKeeper, tc.prop.ChainId) - - err := providerKeeper.HandleLegacyConsumerRemovalProposal(ctx, tc.prop) - - if tc.expAppendProp { - require.NoError(t, err) - - // Proposal should be stored as pending - found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) - require.True(t, found) - - // confirm that the channel was not closed - _, found = providerKeeper.GetConsumerIdToChannelId(ctx, tc.chainId) - require.True(t, found) - } else { - require.Error(t, err) - - // Expect no pending proposal to exist - found := providerKeeper.PendingConsumerRemovalPropExists(ctx, tc.prop.ChainId, tc.prop.StopTime) - require.False(t, found) - } - - // Assert mock calls from setup function - ctrl.Finish() - } -} diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index 2a3152a27d..eccbc5e81a 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -117,27 +117,38 @@ func (k Keeper) OptInTopNValidators(ctx sdk.Context, consumerId string, bondedVa valAddr, err := sdk.ValAddressFromBech32(val.GetOperator()) if err != nil { - k.Logger(ctx).Error("could not retrieve validator address: %s: %s", - val.GetOperator(), err) + k.Logger(ctx).Error("could not retrieve validator address from operator address", + "validator operator address", val.GetOperator(), + "error", err.Error()) continue } power, err := k.stakingKeeper.GetLastValidatorPower(ctx, valAddr) if err != nil { - k.Logger(ctx).Error("could not retrieve last power of validator address: %s: %s", - val.GetOperator(), err) + k.Logger(ctx).Error("could not retrieve last power of validator", + "validator operator address", val.GetOperator(), + "error", err.Error()) continue } if power >= minPowerToOptIn { consAddr, err := val.GetConsAddr() if err != nil { - k.Logger(ctx).Error("could not retrieve validators consensus address: %s: %s", - val, err) + k.Logger(ctx).Error("could not retrieve validator consensus address", + "validator operator address", val.GetOperator(), + "error", err.Error()) continue } k.Logger(ctx).Debug("Opting in validator", "validator", val.GetOperator()) // if validator already exists it gets overwritten + err = k.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(consAddr), consumerId) + if err != nil { + k.Logger(ctx).Error("could not append validator as opted-in validator for this consumer chain", + "validator operator address", val.GetOperator(), + "consumer id", consumerId, + "error", err.Error()) + continue + } k.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(consAddr)) } // else validators that do not belong to the top N validators but were opted in, remain opted in } diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index cbccfe7e9e..357811441f 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -81,7 +81,6 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { } gomock.InOrder(calls...) - providerKeeper.SetProposalIdToConsumerId(ctx, 1, "consumerId") // create a sample consumer key to assign to the `providerAddr` validator // on the consumer chain with `consumerId` @@ -199,7 +198,6 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { consumerId := "0" providerKeeper.FetchAndIncrementConsumerId(ctx) providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: consumerId}) // check that there's no commission rate set for the validator yet _, found := providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index a175518257..03e1293645 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - "time" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -12,7 +11,6 @@ import ( ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" - storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -295,44 +293,6 @@ func (k Keeper) MakeConsumerGenesis( return gen, hash, nil } -// SetPendingConsumerAdditionProp stores a pending consumer addition proposal. -// -// Note that the pending consumer addition proposals are stored under keys with -// the following format: PendingCAPKeyPrefix | spawnTime | consumerId -// Thus, if multiple consumer addition proposal for the same chain will pass at -// the same time, then only the last one will be stored. -func (k Keeper) SetPendingConsumerAdditionProp(ctx sdk.Context, prop *types.ConsumerAdditionProposal) { - store := ctx.KVStore(k.storeKey) - bz, err := prop.Marshal() - if err != nil { - // An error here would indicate something is very wrong - panic(fmt.Errorf("failed to marshal consumer addition proposal: %w", err)) - } - store.Set(types.PendingCAPKey(prop.SpawnTime, prop.ChainId), bz) -} - -// GetPendingConsumerAdditionProp retrieves a pending consumer addition proposal -// by spawn time and chain id. -// -// Note: this method is only used in testing -func (k Keeper) GetPendingConsumerAdditionProp(ctx sdk.Context, spawnTime time.Time, - chainID string, -) (prop types.ConsumerAdditionProposal, found bool) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.PendingCAPKey(spawnTime, chainID)) - if bz == nil { - return prop, false - } - err := prop.Unmarshal(bz) - if err != nil { - // An error here would indicate something is very wrong, - // the ConsumerAdditionProp is assumed to be correctly serialized in SetPendingConsumerAdditionProp. - panic(fmt.Errorf("failed to unmarshal consumer addition proposal: %w", err)) - } - - return prop, true -} - // BeginBlockInit iterates over the initialized consumers chains and creates clients for chains // in which the spawn time has passed func (k Keeper) BeginBlockInit(ctx sdk.Context) { @@ -365,109 +325,6 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { } } -// GetConsumerAdditionPropsToExecute returns the pending consumer addition proposals -// that are ready to be executed, i.e., consumer clients to be created. -// A prop is included in the returned list if its proposed spawn time has passed. -// -// Note: this method is split out from BeginBlockInit to be easily unit tested. -func (k Keeper) GetConsumerAdditionPropsToExecute(ctx sdk.Context) (propsToExecute []types.ConsumerAdditionProposal) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PendingCAPKeyPrefix()) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var prop types.ConsumerAdditionProposal - err := prop.Unmarshal(iterator.Value()) - if err != nil { - // An error here would indicate something is very wrong, - // the ConsumerAdditionProp is assumed to be correctly serialized in SetPendingConsumerAdditionProp. - panic(fmt.Errorf("failed to unmarshal consumer addition proposal: %w", err)) - } - - if !ctx.BlockTime().Before(prop.SpawnTime) { - propsToExecute = append(propsToExecute, prop) - } else { - break - } - } - - return propsToExecute -} - -// GetAllPendingConsumerAdditionProps gets all pending consumer addition proposals. -// -// Note that the pending consumer addition proposals are stored under keys with the following format: -// PendingCAPKeyPrefix | spawnTime.UnixNano() | consumerId -// Thus, the returned array is in spawnTime order. If two proposals have the same spawnTime, -// then they are ordered by consumerId. -func (k Keeper) GetAllPendingConsumerAdditionProps(ctx sdk.Context) (props []types.ConsumerAdditionProposal) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PendingCAPKeyPrefix()) - - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var prop types.ConsumerAdditionProposal - err := prop.Unmarshal(iterator.Value()) - if err != nil { - // An error here would indicate something is very wrong, - // the ConsumerAdditionProp is assumed to be correctly serialized in SetPendingConsumerAdditionProp. - panic(fmt.Errorf("failed to unmarshal consumer addition proposal: %w", err)) - } - - props = append(props, prop) - } - - return props -} - -// DeletePendingConsumerAdditionProps deletes the given consumer addition proposals -func (k Keeper) DeletePendingConsumerAdditionProps(ctx sdk.Context, proposals ...types.ConsumerAdditionProposal) { - store := ctx.KVStore(k.storeKey) - - for _, p := range proposals { - store.Delete(types.PendingCAPKey(p.SpawnTime, p.ChainId)) - } -} - -// SetPendingConsumerRemovalProp stores a pending consumer removal proposal. -// -// Note that the pending removal addition proposals are stored under keys with -// the following format: PendingCRPKeyPrefix | stopTime | consumerId -// Thus, if multiple removal addition proposal for the same chain will pass at -// the same time, then only the last one will be stored. -func (k Keeper) SetPendingConsumerRemovalProp(ctx sdk.Context, prop *types.ConsumerRemovalProposal) { - store := ctx.KVStore(k.storeKey) - bz, err := prop.Marshal() - if err != nil { - // An error here would indicate something is very wrong - panic(fmt.Errorf("failed to marshal consumer removal proposal: %w", err)) - } - store.Set(types.PendingCRPKey(prop.StopTime, prop.ChainId), bz) -} - -// PendingConsumerRemovalPropExists checks whether a pending consumer removal proposal -// exists for the given consumer chain ID and stopTime -// -// Note: this method is only used in testing -func (k Keeper) PendingConsumerRemovalPropExists(ctx sdk.Context, chainID string, timestamp time.Time) bool { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.PendingCRPKey(timestamp, chainID)) - - return bz != nil -} - -// DeletePendingConsumerRemovalProps deletes the given pending consumer removal proposals. -// This method should be called once the proposal has been acted upon. -func (k Keeper) DeletePendingConsumerRemovalProps(ctx sdk.Context, proposals ...types.ConsumerRemovalProposal) { - store := ctx.KVStore(k.storeKey) - - for _, p := range proposals { - store.Delete(types.PendingCRPKey(p.StopTime, p.ChainId)) - } -} - // BeginBlockCCR iterates over the pending consumer proposals and stop/removes the chain if the stop time has passed func (k Keeper) BeginBlockCCR(ctx sdk.Context) { // TODO (PERMISSIONLESS): parameterize the limit @@ -505,72 +362,3 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { ) } } - -// TODO (PERMISSIONLESS): leaving commented out because it might be used for migration -//// GetConsumerRemovalPropsToExecute iterates over the pending consumer removal proposals -//// and returns an ordered list of consumer removal proposals to be executed, -//// ie. consumer chains to be stopped and removed from the provider chain. -//// A prop is included in the returned list if its proposed stop time has passed. -//// -//// Note: this method is split out from BeginBlockCCR to be easily unit tested. -//func (k Keeper) GetConsumerRemovalPropsToExecute(ctx sdk.Context) []types.ConsumerRemovalProposal { -// // store the (to be) executed consumer removal proposals in order -// propsToExecute := []types.ConsumerRemovalProposal{} -// -// store := ctx.KVStore(k.storeKey) -// iterator := storetypes.KVStorePrefixIterator(store, types.PendingCRPKeyPrefix()) -// defer iterator.Close() -// -// for ; iterator.Valid(); iterator.Next() { -// var prop types.ConsumerRemovalProposal -// err := prop.Unmarshal(iterator.Value()) -// if err != nil { -// // An error here would indicate something is very wrong, -// // the ConsumerRemovalProposal is assumed to be correctly serialized in SetPendingConsumerRemovalProp. -// panic(fmt.Errorf("failed to unmarshal consumer removal proposal: %w", err)) -// } -// -// // If current block time is equal to or after stop time, proposal is ready to be executed -// if !ctx.BlockTime().Before(prop.StopTime) { -// propsToExecute = append(propsToExecute, prop) -// } else { -// // No more proposals to check, since they're stored/ordered by timestamp. -// break -// } -// } -// -// return propsToExecute -//} - -// GetAllPendingConsumerRemovalProps iterates through the pending consumer removal proposals. -// -// Note that the pending consumer removal proposals are stored under keys with the following format: -// PendingCRPKeyPrefix | stopTime.UnixNano() | consumerId -// Thus, the returned array is in stopTime order. -func (k Keeper) GetAllPendingConsumerRemovalProps(ctx sdk.Context) (props []types.ConsumerRemovalProposal) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.PendingCRPKeyPrefix()) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var prop types.ConsumerRemovalProposal - err := prop.Unmarshal(iterator.Value()) - if err != nil { - // An error here would indicate something is very wrong, - // the ConsumerRemovalProposal is assumed to be correctly serialized in SetPendingConsumerRemovalProp. - panic(fmt.Errorf("failed to unmarshal consumer removal proposal: %w", err)) - } - - props = append(props, prop) - } - - return props -} - -// StopConsumerChainInCachedCtx stop a consumer chain -// from a given consumer removal proposal in a cached context -func (k Keeper) StopConsumerChainInCachedCtx(ctx sdk.Context, p types.ConsumerRemovalProposal) (cc sdk.Context, writeCache func(), err error) { - cc, writeCache = ctx.CacheContext() - err = k.StopConsumerChain(cc, p.ChainId, true) - return -} diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 2386ab65f2..eaa7d76ec9 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -1,10 +1,9 @@ package keeper_test import ( - "bytes" "encoding/json" "fmt" - "sort" + "testing" "time" @@ -117,162 +116,6 @@ func testCreatedConsumerClient(t *testing.T, require.True(t, ok) } -// TestPendingConsumerAdditionPropDeletion tests the getting/setting -// and deletion keeper methods for pending consumer addition props -func TestPendingConsumerAdditionPropDeletion(t *testing.T) { - testCases := []struct { - providertypes.ConsumerAdditionProposal - ExpDeleted bool - }{ - { - ConsumerAdditionProposal: providertypes.ConsumerAdditionProposal{ChainId: "0", SpawnTime: time.Now().UTC()}, - ExpDeleted: true, - }, - { - ConsumerAdditionProposal: providertypes.ConsumerAdditionProposal{ChainId: "1", SpawnTime: time.Now().UTC().Add(time.Hour)}, - ExpDeleted: false, - }, - } - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - for _, tc := range testCases { - tc := tc - providerKeeper.SetPendingConsumerAdditionProp(ctx, &tc.ConsumerAdditionProposal) - } - - ctx = ctx.WithBlockTime(time.Now().UTC()) - - propsToExecute := providerKeeper.GetConsumerAdditionPropsToExecute(ctx) - // Delete consumer addition proposals, same as what would be done by BeginBlockInit - providerKeeper.DeletePendingConsumerAdditionProps(ctx, propsToExecute...) - numDeleted := 0 - for _, tc := range testCases { - res, found := providerKeeper.GetPendingConsumerAdditionProp(ctx, tc.SpawnTime, tc.ChainId) - if !tc.ExpDeleted { - require.True(t, found) - require.NotEmpty(t, res, "consumer addition proposal was deleted: %s %s", tc.ChainId, tc.SpawnTime.String()) - continue - } - require.Empty(t, res, "consumer addition proposal was not deleted %s %s", tc.ChainId, tc.SpawnTime.String()) - require.Equal(t, propsToExecute[numDeleted].ChainId, tc.ChainId) - numDeleted += 1 - } -} - -// TestGetConsumerAdditionPropsToExecute tests that pending consumer addition proposals -// that are ready to execute are accessed in order by timestamp via the iterator -func TestGetConsumerAdditionPropsToExecute(t *testing.T) { - now := time.Now().UTC() - sampleProp1 := providertypes.ConsumerAdditionProposal{ChainId: "chain-2", SpawnTime: now} - sampleProp2 := providertypes.ConsumerAdditionProposal{ChainId: "chain-1", SpawnTime: now.Add(time.Hour)} - sampleProp3 := providertypes.ConsumerAdditionProposal{ChainId: "chain-4", SpawnTime: now.Add(-time.Hour)} - sampleProp4 := providertypes.ConsumerAdditionProposal{ChainId: "chain-3", SpawnTime: now} - sampleProp5 := providertypes.ConsumerAdditionProposal{ChainId: "chain-1", SpawnTime: now.Add(2 * time.Hour)} - - getExpectedOrder := func(props []providertypes.ConsumerAdditionProposal, accessTime time.Time) []providertypes.ConsumerAdditionProposal { - expectedOrder := []providertypes.ConsumerAdditionProposal{} - for _, prop := range props { - if !accessTime.Before(prop.SpawnTime) { - expectedOrder = append(expectedOrder, prop) - } - } - if len(expectedOrder) == 0 { - return nil - } - // sorting by SpawnTime.UnixNano() - sort.Slice(expectedOrder, func(i, j int) bool { - if expectedOrder[i].SpawnTime.UTC() == expectedOrder[j].SpawnTime.UTC() { - // proposals with same SpawnTime - return expectedOrder[i].ChainId < expectedOrder[j].ChainId - } - return expectedOrder[i].SpawnTime.UTC().Before(expectedOrder[j].SpawnTime.UTC()) - }) - return expectedOrder - } - - testCases := []struct { - propSubmitOrder []providertypes.ConsumerAdditionProposal - accessTime time.Time - }{ - { - propSubmitOrder: []providertypes.ConsumerAdditionProposal{ - sampleProp1, sampleProp2, sampleProp3, sampleProp4, sampleProp5, - }, - accessTime: now, - }, - { - propSubmitOrder: []providertypes.ConsumerAdditionProposal{ - sampleProp3, sampleProp2, sampleProp1, sampleProp5, sampleProp4, - }, - accessTime: now.Add(time.Hour), - }, - { - propSubmitOrder: []providertypes.ConsumerAdditionProposal{ - sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, - }, - accessTime: now.Add(-2 * time.Hour), - }, - { - propSubmitOrder: []providertypes.ConsumerAdditionProposal{ - sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, - }, - accessTime: now.Add(3 * time.Hour), - }, - } - - for _, tc := range testCases { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - expectedOrderedProps := getExpectedOrder(tc.propSubmitOrder, tc.accessTime) - - for _, prop := range tc.propSubmitOrder { - cpProp := prop - providerKeeper.SetPendingConsumerAdditionProp(ctx, &cpProp) - } - propsToExecute := providerKeeper.GetConsumerAdditionPropsToExecute(ctx.WithBlockTime(tc.accessTime)) - require.Equal(t, expectedOrderedProps, propsToExecute) - } -} - -// Test getting both matured and pending consumer addition proposals -func TestGetAllConsumerAdditionProps(t *testing.T) { - pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - now := time.Now().UTC() - props := []providertypes.ConsumerAdditionProposal{ - {ChainId: "chain-2", SpawnTime: now}, - {ChainId: "chain-1", SpawnTime: now.Add(2 * time.Hour)}, - {ChainId: "chain-4", SpawnTime: now.Add(-time.Hour)}, - {ChainId: "chain-3", SpawnTime: now.Add(4 * time.Hour)}, - {ChainId: "chain-1", SpawnTime: now}, - } - expectedGetAllOrder := props - // sorting by SpawnTime.UnixNano() - sort.Slice(expectedGetAllOrder, func(i, j int) bool { - tsi := uint64(expectedGetAllOrder[i].SpawnTime.UTC().UnixNano()) - tsj := uint64(expectedGetAllOrder[j].SpawnTime.UTC().UnixNano()) - cmpTimestamps := bytes.Compare(sdk.Uint64ToBigEndian(tsi), sdk.Uint64ToBigEndian(tsj)) - if cmpTimestamps == 0 { - // proposals with same SpawnTime - return expectedGetAllOrder[i].ChainId < expectedGetAllOrder[j].ChainId - } - return cmpTimestamps == -1 - }) - - for _, prop := range props { - cpProp := prop // bring into loop scope - avoids using iterator pointer instead of value pointer - pk.SetPendingConsumerAdditionProp(ctx, &cpProp) - } - - // iterate and check all results are returned in the expected order - result := pk.GetAllPendingConsumerAdditionProps(ctx.WithBlockTime(now)) - require.Len(t, result, len(props)) - require.Equal(t, expectedGetAllOrder, result) -} - // Tests the StopConsumerChain method against the spec, // with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 @@ -410,43 +253,6 @@ func TestStopConsumerChain(t *testing.T) { // } //} -// Test getting both matured and pending consumer removal proposals -func TestGetAllConsumerRemovalProps(t *testing.T) { - pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - now := time.Now().UTC() - props := []providertypes.ConsumerRemovalProposal{ - {ChainId: "chain-2", StopTime: now}, - {ChainId: "chain-1", StopTime: now.Add(2 * time.Hour)}, - {ChainId: "chain-4", StopTime: now.Add(-time.Hour)}, - {ChainId: "chain-3", StopTime: now.Add(4 * time.Hour)}, - {ChainId: "chain-1", StopTime: now}, - } - expectedGetAllOrder := props - // sorting by StopTime.UnixNano() - sort.Slice(expectedGetAllOrder, func(i, j int) bool { - tsi := uint64(expectedGetAllOrder[i].StopTime.UTC().UnixNano()) - tsj := uint64(expectedGetAllOrder[j].StopTime.UTC().UnixNano()) - cmpTimestamps := bytes.Compare(sdk.Uint64ToBigEndian(tsi), sdk.Uint64ToBigEndian(tsj)) - if cmpTimestamps == 0 { - // proposals with same StopTime - return expectedGetAllOrder[i].ChainId < expectedGetAllOrder[j].ChainId - } - return cmpTimestamps == -1 - }) - - for _, prop := range props { - cpProp := prop // bring into loop scope - avoids using iterator pointer instead of value pointer - pk.SetPendingConsumerRemovalProp(ctx, &cpProp) - } - - // iterate and check all results are returned in the expected order - result := pk.GetAllPendingConsumerRemovalProps(ctx.WithBlockTime(now)) - require.Len(t, result, len(props)) - require.Equal(t, expectedGetAllOrder, result) -} - // TestMakeConsumerGenesis tests the MakeConsumerGenesis keeper method. // An expected genesis state is hardcoded in json, unmarshaled, and compared // against an actual consumer genesis state constructed by a provider keeper. diff --git a/x/ccv/provider/keeper/validator_set_update.go b/x/ccv/provider/keeper/validator_set_update.go index a0afc94ef9..95a8d5c9a7 100644 --- a/x/ccv/provider/keeper/validator_set_update.go +++ b/x/ccv/provider/keeper/validator_set_update.go @@ -14,7 +14,7 @@ import ( // GetConsumerChainConsensusValidatorsKey returns the store key for consumer validators of the consumer chain with `consumerId` func (k Keeper) GetConsumerChainConsensusValidatorsKey(ctx sdk.Context, consumerId string) []byte { - return types.ConsumerIdWithLenKey(types.ConsumerValidatorKeyPrefix(), consumerId) + return types.StringIdWithLenKey(types.ConsumerValidatorKeyPrefix(), consumerId) } // SetConsumerValidator sets provided consumer `validator` on the consumer chain with `consumerId` diff --git a/x/ccv/provider/migrations/migrator.go b/x/ccv/provider/migrations/migrator.go index 4678fe83cd..b2d733de11 100644 --- a/x/ccv/provider/migrations/migrator.go +++ b/x/ccv/provider/migrations/migrator.go @@ -92,6 +92,9 @@ func (m Migrator) Migrate7to8(ctx sdktypes.Context) error { if err := v8.MigrateConsumerAddrsToPrune(ctx, store, m.providerKeeper); err != nil { return err } + if err := v8.MigrateLaunchedConsumerChains(ctx, store, m.providerKeeper); err != nil { + return err + } v8.CleanupState(store) return nil diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index cdf299f91f..916e3d0a22 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -4,11 +4,15 @@ import ( "encoding/binary" "time" + "github.com/cosmos/cosmos-sdk/types/bech32" + + errorsmod "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -19,6 +23,30 @@ const ( LegacyInitTimeoutTimestampBytePrefix = byte(8) LegacyVscSendTimestampBytePrefix = byte(18) LegacyVSCMaturedHandledThisBlockBytePrefix = byte(28) + + LegacyPendingCAPKeyPrefix = byte(9) + LegacyPendingCRPKeyPrefix = byte(10) + LegacyProposedConsumerChainKeyPrefix = byte(30) + + LegacyThrottledPacketDataSizeKeyPrefix = byte(19) + LegacyThrottledPacketDataKeyPrefix = byte(20) + LegacyGlobalSlashEntryKeyPrefix = byte(21) + LegacyTopNKeyPrefix = byte(33) + LegacyValidatorsPowerCapKeyPrefix = byte(34) + LegacyValidatorSetCapKeyPrefix = byte(35) + + LegacyChainToChannelKeyPrefix = byte(5) + LegacyChannelToChainKeyPrefix = byte(6) + LegacyChainToClientKeyPrefix = byte(7) + + // needed for rekeying + ConsumerGenesisKeyPrefix = byte(14) + SlashAcksKeyPrefix = byte(15) + InitChainHeightKeyPrefix = byte(16) + PendingVSCsKeyPrefix = byte(17) + EquivocationEvidenceMinHeightKeyPrefix = byte(29) + ConsumerRewardsAllocationKeyPrefix = byte(38) + MinimumPowerInTopNKeyPrefix = byte(40) ) // CompleteUnbondingOps completes all unbonding operations. @@ -51,7 +79,7 @@ func MigrateConsumerAddrsToPrune(ctx sdk.Context, store storetypes.KVStore, pk p } for ; iterator.Valid(); iterator.Next() { - chainID, vscID, err := providertypes.ParseChainIdAndUintIdKey(LegacyConsumerAddrsToPruneBytePrefix, iterator.Key()) + chainID, vscID, err := providertypes.ParseStringIdAndUintIdKey(LegacyConsumerAddrsToPruneBytePrefix, iterator.Key()) if err != nil { pk.Logger(ctx).Error("ParseChainIdAndUintIdKey failed while migrating ConsumerAddrsToPrune", "key", string(iterator.Key()), @@ -60,7 +88,7 @@ func MigrateConsumerAddrsToPrune(ctx sdk.Context, store storetypes.KVStore, pk p continue } // use the VscSendTimestamp index to compute the timestamp after which this consumer address can be pruned - vscSendTimestampKey := providertypes.ChainIdAndUintIdKey(LegacyVscSendTimestampBytePrefix, chainID, vscID) + vscSendTimestampKey := providertypes.StringIdAndUintIdKey(LegacyVscSendTimestampBytePrefix, chainID, vscID) var sentTime time.Time if timeBz := store.Get(vscSendTimestampKey); timeBz != nil { if ts, err := sdk.ParseTimeBytes(timeBz); err == nil { @@ -95,6 +123,247 @@ func MigrateConsumerAddrsToPrune(ctx sdk.Context, store storetypes.KVStore, pk p return nil } +// MigrateLaunchedConsumerChains migrates all the state for consumer chains with an existing client +// Note that it must be executed before CleanupState. +func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk providerkeeper.Keeper) error { + chainIds := []string{} + iterator := storetypes.KVStorePrefixIterator(store, []byte{LegacyChainToClientKeyPrefix}) + for ; iterator.Valid(); iterator.Next() { + // remove 1 byte prefix from key to retrieve chainId + chainId := string(iterator.Key()[1:]) + chainIds = append(chainIds, chainId) + } + err := iterator.Close() + if err != nil { + return err + } + + for _, chainId := range chainIds { + // create new consumerId + consumerId := pk.FetchAndIncrementConsumerId(ctx) + + // re-key store + + // channelId -> chainId + channelId, found := pk.GetConsumerIdToChannelId(ctx, chainId) + if !found { + return errorsmod.Wrapf(ccv.ErrInvalidConsumerState, "cannot find channel id associated with consumer id: %s", consumerId) + } + pk.SetChannelToConsumerId(ctx, channelId, consumerId) + + // chainId -> channelId + rekeyFromChainIdToConsumerId(store, LegacyChainToChannelKeyPrefix, chainId, consumerId) + + // chainId -> clientId + rekeyFromChainIdToConsumerId(store, LegacyChainToClientKeyPrefix, chainId, consumerId) + + // chainId -> consumer genesis + rekeyFromChainIdToConsumerId(store, ConsumerGenesisKeyPrefix, chainId, consumerId) + + // chainId -> SlashAcks + rekeyFromChainIdToConsumerId(store, SlashAcksKeyPrefix, chainId, consumerId) + + // chainId -> InitChainHeight + rekeyFromChainIdToConsumerId(store, InitChainHeightKeyPrefix, chainId, consumerId) + + // chainId -> PendingVSCs + rekeyFromChainIdToConsumerId(store, PendingVSCsKeyPrefix, chainId, consumerId) + + // chainId -> ConsumerValidators + rekeyChainIdAndConsAddrKey(store, providertypes.ConsumerValidatorsKeyPrefix(), chainId, consumerId) + + // chainId -> ValidatorsByConsumerAddr + rekeyChainIdAndConsAddrKey(store, providertypes.ValidatorsByConsumerAddrKeyPrefix(), chainId, consumerId) + + // chainId -> EquivocationEvidenceMinHeight + rekeyFromChainIdToConsumerId(store, EquivocationEvidenceMinHeightKeyPrefix, chainId, consumerId) + + // chainId -> ConsumerValidator + rekeyChainIdAndConsAddrKey(store, providertypes.ConsumerValidatorKeyPrefix(), chainId, consumerId) + + // chainId -> OptedIn + rekeyChainIdAndConsAddrKey(store, providertypes.OptedInKeyPrefix(), chainId, consumerId) + + // chainId -> Allowlist + rekeyChainIdAndConsAddrKey(store, providertypes.AllowlistKeyPrefix(), chainId, consumerId) + + // chainId -> Denylist + rekeyChainIdAndConsAddrKey(store, providertypes.DenylistKeyPrefix(), chainId, consumerId) + + // chainId -> ConsumerRewardsAllocations + rekeyFromChainIdToConsumerId(store, ConsumerRewardsAllocationKeyPrefix, chainId, consumerId) + + // chainId -> ConsumerCommissionRate + rekeyChainIdAndConsAddrKey(store, providertypes.ConsumerCommissionRateKeyPrefix(), chainId, consumerId) + + // chainId -> MinimumPowerInTopN + rekeyFromChainIdToConsumerId(store, MinimumPowerInTopNKeyPrefix, chainId, consumerId) + + // chainId -> ConsumerAddrsToPruneV2 + rekeyChainIdAndTsKey(store, providertypes.ConsumerAddrsToPruneV2KeyPrefix(), chainId, consumerId) + + pk.SetConsumerChainId(ctx, consumerId, chainId) + + // set ownership -- all existing chains are owned by gov + pk.SetConsumerOwnerAddress(ctx, consumerId, pk.GetAuthority()) + + // Note: ConsumerMetadata will be populated in the upgrade handler + // Note: InitializationParameters is not needed since the chain is already launched + + // migrate power shaping params + topNKey := append([]byte{LegacyTopNKeyPrefix}, []byte(chainId)...) + var topN uint32 = 0 + buf := store.Get(topNKey) + if buf != nil { + topN = binary.BigEndian.Uint32(buf) + } + + validatorsPowerCapKey := append([]byte{LegacyValidatorsPowerCapKeyPrefix}, []byte(chainId)...) + var validatorsPowerCap uint32 = 0 + buf = store.Get(validatorsPowerCapKey) + if buf != nil { + validatorsPowerCap = binary.BigEndian.Uint32(buf) + } + + validatorSetCapKey := append([]byte{LegacyValidatorSetCapKeyPrefix}, []byte(chainId)...) + var validatorSetCap uint32 = 0 + buf = store.Get(validatorSetCapKey) + if buf != nil { + validatorSetCap = binary.BigEndian.Uint32(buf) + } + + bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() + var allowlist []string + for _, addr := range pk.GetAllowList(ctx, consumerId) { + foo, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) + allowlist = append(allowlist, foo) + } + + var denylist []string + for _, addr := range pk.GetDenyList(ctx, consumerId) { + foo, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) + allowlist = append(allowlist, foo) + } + + powerShapingParameters := providertypes.PowerShapingParameters{ + Top_N: topN, + ValidatorsPowerCap: validatorsPowerCap, + ValidatorSetCap: validatorSetCap, + Allowlist: allowlist, + Denylist: denylist, + // do not set those since they do not exist in a previous interchain-security version and hence cannot be set + MinStake: 0, + AllowInactiveVals: false, + } + err := pk.SetConsumerPowerShapingParameters(ctx, consumerId, powerShapingParameters) + if err != nil { + return err + } + + // set phase to launched + pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + + // This is to migrate everything under `ProviderConsAddrToOptedInConsumerIdsKey` + // `OptedIn` was already re-keyed earlier (see above) and hence we can use `consumerId` here. + for _, providerConsAddr := range pk.GetAllOptedIn(ctx, consumerId) { + pk.AppendOptedInConsumerId(ctx, providerConsAddr, consumerId) + } + + // set clientId -> consumerId mapping + clientId, found := pk.GetConsumerClientId(ctx, consumerId) // consumer to client was already re-keyed so we can use `consumerId` here + if !found { + return errorsmod.Wrapf(ccv.ErrInvalidConsumerState, "cannot find client ID associated with consumer ID: %s", consumerId) + } + pk.SetClientIdToConsumerId(ctx, clientId, consumerId) + } + + return nil +} + +// rekeyFromChainIdToConsumerId migrates store keys from `keyPrefix | chainId` +// to `keyPrefix | consumerId` leaving the value unchanged +func rekeyFromChainIdToConsumerId( + store storetypes.KVStore, + keyPrefix byte, + chainId, consumerId string, +) { + oldKey := append([]byte{keyPrefix}, []byte(chainId)...) + value := store.Get(oldKey) + newKey := append([]byte{keyPrefix}, []byte(consumerId)...) + store.Set(newKey, value) + store.Delete(oldKey) +} + +// rekeyChainIdAndConsAddrKey migrates store keys +// from `keyPrefix | len(chainID) | chainID | ConsAddress` +// to `keyPrefix | len(consumerId) | consumerId | ConsAddress“ +// leaving the value unchanged +func rekeyChainIdAndConsAddrKey( + store storetypes.KVStore, + keyPrefix byte, + chainId, consumerId string, +) error { + oldPartialKey := providertypes.StringIdWithLenKey(keyPrefix, chainId) + addrs := []sdk.ConsAddress{} + iterator := storetypes.KVStorePrefixIterator(store, oldPartialKey) + for ; iterator.Valid(); iterator.Next() { + _, addr, err := providertypes.ParseStringIdAndConsAddrKey(keyPrefix, iterator.Key()) + if err != nil { + return err + } + addrs = append(addrs, addr) + } + err := iterator.Close() + if err != nil { + return err + } + + for _, addr := range addrs { + oldKey := providertypes.StringIdAndConsAddrKey(keyPrefix, chainId, addr) + value := store.Get(oldKey) + newKey := providertypes.StringIdAndConsAddrKey(keyPrefix, consumerId, addr) + store.Set(newKey, value) + store.Delete(oldKey) + } + + return nil +} + +// rekeyChainIdAndTsKey migrates store keys +// from `keyPrefix | len(chainID) | chainID | timestamp` +// to `keyPrefix | len(consumerId) | consumerId | timestamp +// leaving the value unchanged +func rekeyChainIdAndTsKey( + store storetypes.KVStore, + keyPrefix byte, + chainId, consumerId string, +) error { + oldPartialKey := providertypes.StringIdWithLenKey(keyPrefix, chainId) + timestamps := []time.Time{} + iterator := storetypes.KVStorePrefixIterator(store, oldPartialKey) + for ; iterator.Valid(); iterator.Next() { + _, ts, err := providertypes.ParseStringIdAndTsKey(keyPrefix, iterator.Key()) + if err != nil { + return err + } + timestamps = append(timestamps, ts) + } + err := iterator.Close() + if err != nil { + return err + } + + for _, ts := range timestamps { + oldKey := providertypes.StringIdAndTsKey(keyPrefix, chainId, ts) + value := store.Get(oldKey) + newKey := providertypes.StringIdAndTsKey(keyPrefix, consumerId, ts) + store.Set(newKey, value) + store.Delete(oldKey) + } + + return nil +} + // CleanupState removes deprecated state func CleanupState(store storetypes.KVStore) { removePrefix(store, LegacyMaturedUnbondingOpsByteKey) @@ -104,6 +373,18 @@ func CleanupState(store storetypes.KVStore) { removePrefix(store, LegacyVscSendTimestampBytePrefix) removePrefix(store, LegacyVSCMaturedHandledThisBlockBytePrefix) removePrefix(store, LegacyConsumerAddrsToPruneBytePrefix) + + removePrefix(store, LegacyPendingCAPKeyPrefix) + removePrefix(store, LegacyPendingCRPKeyPrefix) + removePrefix(store, LegacyProposedConsumerChainKeyPrefix) + + removePrefix(store, LegacyThrottledPacketDataSizeKeyPrefix) + removePrefix(store, LegacyThrottledPacketDataKeyPrefix) + removePrefix(store, LegacyGlobalSlashEntryKeyPrefix) + + removePrefix(store, LegacyTopNKeyPrefix) + removePrefix(store, LegacyValidatorsPowerCapKeyPrefix) + removePrefix(store, LegacyValidatorSetCapKeyPrefix) } func removePrefix(store storetypes.KVStore, prefix byte) { diff --git a/x/ccv/provider/migrations/v8/migrations_test.go b/x/ccv/provider/migrations/v8/migrations_test.go index 8c23fccc64..8f37f84d13 100644 --- a/x/ccv/provider/migrations/v8/migrations_test.go +++ b/x/ccv/provider/migrations/v8/migrations_test.go @@ -14,7 +14,7 @@ import ( ) func legacyConsumerAddrsToPruneKey(chainID string, vscID uint64) []byte { - return providertypes.ChainIdAndUintIdKey(LegacyConsumerAddrsToPruneBytePrefix, chainID, vscID) + return providertypes.StringIdAndUintIdKey(LegacyConsumerAddrsToPruneBytePrefix, chainID, vscID) } func legacyAppendConsumerAddrsToPrune( @@ -44,7 +44,7 @@ func legacyAppendConsumerAddrsToPrune( } func legacyVscSendingTimestampKey(chainID string, vscID uint64) []byte { - return providertypes.ChainIdAndUintIdKey(LegacyVscSendTimestampBytePrefix, chainID, vscID) + return providertypes.StringIdAndUintIdKey(LegacyVscSendTimestampBytePrefix, chainID, vscID) } func legacySetVscSendTimestamp( diff --git a/x/ccv/provider/module_test.go b/x/ccv/provider/module_test.go index a019eb162f..9cbe5d6f4c 100644 --- a/x/ccv/provider/module_test.go +++ b/x/ccv/provider/module_test.go @@ -104,8 +104,6 @@ func TestInitGenesis(t *testing.T) { providerKeeper.GetValidatorSetUpdateId(ctx), nil, tc.consumerStates, - nil, - nil, types.DefaultParams(), nil, nil, diff --git a/x/ccv/provider/types/genesis.go b/x/ccv/provider/types/genesis.go index 5cd60982a6..be4b9d8934 100644 --- a/x/ccv/provider/types/genesis.go +++ b/x/ccv/provider/types/genesis.go @@ -16,23 +16,19 @@ func NewGenesisState( vscID uint64, vscIdToHeights []ValsetUpdateIdToHeight, consumerStates []ConsumerState, - additionProposals []ConsumerAdditionProposal, - removalProposals []ConsumerRemovalProposal, params Params, validatorConsumerPubkeys []ValidatorConsumerPubKey, validatorsByConsumerAddr []ValidatorByConsumerAddr, consumerAddrsToPrune []ConsumerAddrsToPruneV2, ) *GenesisState { return &GenesisState{ - ValsetUpdateId: vscID, - ValsetUpdateIdToHeight: vscIdToHeights, - ConsumerStates: consumerStates, - ConsumerAdditionProposals: additionProposals, - ConsumerRemovalProposals: removalProposals, - Params: params, - ValidatorConsumerPubkeys: validatorConsumerPubkeys, - ValidatorsByConsumerAddr: validatorsByConsumerAddr, - ConsumerAddrsToPruneV2: consumerAddrsToPrune, + ValsetUpdateId: vscID, + ValsetUpdateIdToHeight: vscIdToHeights, + ConsumerStates: consumerStates, + Params: params, + ValidatorConsumerPubkeys: validatorConsumerPubkeys, + ValidatorsByConsumerAddr: validatorsByConsumerAddr, + ConsumerAddrsToPruneV2: consumerAddrsToPrune, } } @@ -49,18 +45,6 @@ func (gs GenesisState) Validate() error { return errorsmod.Wrap(ccv.ErrInvalidGenesis, "valset update ID cannot be equal to zero") } - for _, prop := range gs.ConsumerAdditionProposals { - if err := prop.ValidateBasic(); err != nil { - return errorsmod.Wrap(ccv.ErrInvalidGenesis, err.Error()) - } - } - - for _, prop := range gs.ConsumerRemovalProposals { - if err := prop.ValidateBasic(); err != nil { - return errorsmod.Wrap(ccv.ErrInvalidGenesis, err.Error()) - } - } - if len(gs.ValsetUpdateIdToHeight) > 0 { // check only the first tuple of the list since it is ordered by VSC ID if gs.ValsetUpdateIdToHeight[0].ValsetUpdateId == 0 { diff --git a/x/ccv/provider/types/genesis.pb.go b/x/ccv/provider/types/genesis.pb.go index 7097cd1a2b..5dc5b300c4 100644 --- a/x/ccv/provider/types/genesis.pb.go +++ b/x/ccv/provider/types/genesis.pb.go @@ -32,11 +32,7 @@ type GenesisState struct { ConsumerStates []ConsumerState `protobuf:"bytes,2,rep,name=consumer_states,json=consumerStates,proto3" json:"consumer_states" yaml:"consumer_states"` // empty for a new chain ValsetUpdateIdToHeight []ValsetUpdateIdToHeight `protobuf:"bytes,5,rep,name=valset_update_id_to_height,json=valsetUpdateIdToHeight,proto3" json:"valset_update_id_to_height"` - // empty for a new chain - ConsumerAdditionProposals []ConsumerAdditionProposal `protobuf:"bytes,6,rep,name=consumer_addition_proposals,json=consumerAdditionProposals,proto3" json:"consumer_addition_proposals"` - // empty for a new chain - ConsumerRemovalProposals []ConsumerRemovalProposal `protobuf:"bytes,7,rep,name=consumer_removal_proposals,json=consumerRemovalProposals,proto3" json:"consumer_removal_proposals"` - Params Params `protobuf:"bytes,8,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,8,opt,name=params,proto3" json:"params"` // empty for a new chain ValidatorConsumerPubkeys []ValidatorConsumerPubKey `protobuf:"bytes,9,rep,name=validator_consumer_pubkeys,json=validatorConsumerPubkeys,proto3" json:"validator_consumer_pubkeys"` // empty for a new chain @@ -99,20 +95,6 @@ func (m *GenesisState) GetValsetUpdateIdToHeight() []ValsetUpdateIdToHeight { return nil } -func (m *GenesisState) GetConsumerAdditionProposals() []ConsumerAdditionProposal { - if m != nil { - return m.ConsumerAdditionProposals - } - return nil -} - -func (m *GenesisState) GetConsumerRemovalProposals() []ConsumerRemovalProposal { - if m != nil { - return m.ConsumerRemovalProposals - } - return nil -} - func (m *GenesisState) GetParams() Params { if m != nil { return m.Params @@ -308,56 +290,53 @@ func init() { } var fileDescriptor_48411d9c7900d48e = []byte{ - // 782 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xd1, 0x6e, 0xda, 0x48, - 0x14, 0xc5, 0xc1, 0x21, 0x66, 0x12, 0x58, 0xcb, 0x8a, 0x90, 0x43, 0xb4, 0x24, 0x62, 0x15, 0x09, - 0x69, 0x77, 0x71, 0x60, 0xb5, 0xd2, 0x6a, 0x77, 0xf3, 0x10, 0x12, 0x69, 0x17, 0xfa, 0x82, 0x48, - 0x9a, 0x4a, 0x79, 0xb1, 0x86, 0xf1, 0x08, 0x46, 0x18, 0x8f, 0xe5, 0x19, 0x9c, 0xa2, 0xaa, 0x52, - 0xab, 0xfe, 0x40,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 0xa0, 0xe4, 0x63, 0xcf, 0x21, 0xde, 0xc0, 0x96, 0x1b, - 0x27, 0x4a, 0x61, 0x80, 0x93, 0x21, 0xff, 0xeb, 0xa9, 0x40, 0x69, 0x13, 0x9c, 0x61, 0x7e, 0x22, - 0x68, 0x5d, 0x88, 0x46, 0x98, 0x9f, 0x42, 0x0e, 0x65, 0xc0, 0x6d, 0xa9, 0x1e, 0xef, 0xa1, 0xf8, - 0x12, 0x33, 0x7e, 0x03, 0x06, 0x73, 0x21, 0x1b, 0xda, 0x0e, 0xbd, 0xf2, 0x38, 0x19, 0x63, 0x1b, - 0xa2, 0x91, 0x98, 0xe8, 0x7c, 0x4f, 0x17, 0xc8, 0xa9, 0x04, 0x8e, 0xd1, 0xa8, 0xa3, 0x6a, 0x9a, - 0x9e, 0xaf, 0x5e, 0x82, 0xd2, 0xe2, 0x65, 0xb6, 0xc2, 0x52, 0x2f, 0x81, 0x9c, 0xac, 0xf7, 0x9a, - 0xc0, 0xe5, 0xbf, 0xd6, 0x8b, 0xeb, 0xbb, 0x8a, 0x72, 0x73, 0x57, 0x51, 0x3e, 0xdf, 0x55, 0x94, - 0xf7, 0xf7, 0x95, 0xcc, 0xcd, 0x7d, 0x25, 0xf3, 0xe9, 0xbe, 0x92, 0xb9, 0x3c, 0x1a, 0x10, 0x3e, - 0x9c, 0xf4, 0xeb, 0x88, 0x8e, 0x2d, 0x44, 0xd9, 0x98, 0x32, 0xeb, 0x5b, 0x41, 0x7e, 0x4f, 0xdf, - 0xa1, 0xf0, 0x4f, 0xeb, 0xe5, 0xfc, 0x63, 0xc4, 0xa7, 0x3e, 0x66, 0xfd, 0x9c, 0x78, 0x87, 0xfe, - 0xf8, 0x1a, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x95, 0x75, 0xdb, 0x84, 0x07, 0x00, 0x00, + // 730 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x6e, 0xda, 0x4c, + 0x14, 0xc5, 0xc1, 0x01, 0x33, 0x09, 0x7c, 0x96, 0x15, 0x21, 0x7f, 0x89, 0x4a, 0x10, 0x55, 0x24, + 0xa4, 0xb6, 0x38, 0x50, 0x55, 0xaa, 0xfa, 0xb3, 0x08, 0x89, 0xd4, 0xe2, 0x6e, 0x10, 0x49, 0x53, + 0x29, 0x1b, 0x6b, 0x98, 0x19, 0xc1, 0x08, 0xb0, 0x2d, 0xcf, 0xe0, 0x14, 0x55, 0x95, 0xda, 0x37, + 0xe8, 0xba, 0x2f, 0xd1, 0xd7, 0xc8, 0x32, 0xcb, 0xae, 0xa2, 0x2a, 0x79, 0x83, 0x3e, 0x41, 0xe5, + 0xf1, 0xe0, 0x40, 0x4a, 0x22, 0xd2, 0x9d, 0x7d, 0xcf, 0x9c, 0x7b, 0xcf, 0xfd, 0x05, 0x75, 0xea, + 0x72, 0x12, 0xa0, 0x3e, 0xa4, 0xae, 0xc3, 0x08, 0x1a, 0x07, 0x94, 0x4f, 0x2c, 0x84, 0x42, 0xcb, + 0x0f, 0xbc, 0x90, 0x62, 0x12, 0x58, 0x61, 0xdd, 0xea, 0x11, 0x97, 0x30, 0xca, 0x6a, 0x7e, 0xe0, + 0x71, 0xcf, 0x78, 0xb8, 0x80, 0x52, 0x43, 0x28, 0xac, 0x4d, 0x29, 0xb5, 0xb0, 0xbe, 0xb9, 0xd1, + 0xf3, 0x7a, 0x9e, 0x78, 0x6f, 0x45, 0x5f, 0x31, 0x75, 0x73, 0xf7, 0xb6, 0x68, 0x61, 0xdd, 0x62, + 0x7d, 0x18, 0x10, 0xec, 0x20, 0xcf, 0x65, 0xe3, 0x11, 0x09, 0x24, 0x63, 0xe7, 0x0e, 0xc6, 0x29, + 0x0d, 0x88, 0x7c, 0xd6, 0x58, 0x26, 0x8d, 0x44, 0x9f, 0xe0, 0x54, 0x7e, 0x64, 0xc0, 0xfa, 0x9b, + 0x38, 0xb3, 0x43, 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, 0xc1, 0x41, + 0xd1, 0x27, 0x2e, 0xa6, 0x6e, 0xcf, 0x91, 0x4b, 0x17, 0xa5, 0xd0, 0x23, 0xcc, 0xcc, 0x88, 0xbe, + 0x3c, 0xbf, 0x2b, 0x50, 0x32, 0x10, 0x87, 0x84, 0xef, 0x0b, 0x5a, 0x1b, 0xa2, 0x01, 0xe1, 0x07, + 0x90, 0x43, 0x19, 0x70, 0x43, 0x7a, 0x8f, 0x57, 0x31, 0x7e, 0xc4, 0x8c, 0xc7, 0xc0, 0x60, 0x43, + 0xc8, 0xfa, 0x0e, 0xf6, 0x4e, 0x5d, 0x4e, 0x47, 0xc4, 0x81, 0x68, 0x60, 0x66, 0xcb, 0xe9, 0x6a, + 0xae, 0xa3, 0x0b, 0xe4, 0x40, 0x02, 0x7b, 0x68, 0x60, 0xab, 0x9a, 0xa6, 0xe7, 0x2a, 0x27, 0xa0, + 0xb8, 0x78, 0x9f, 0xef, 0x71, 0xd7, 0x8a, 0x20, 0x23, 0xeb, 0xbd, 0x22, 0x70, 0xf9, 0xd7, 0xfc, + 0x70, 0x76, 0x59, 0x52, 0xce, 0x2f, 0x4b, 0xca, 0xaf, 0xcb, 0x92, 0xf2, 0xed, 0xaa, 0x94, 0x3a, + 0xbf, 0x2a, 0xa5, 0x7e, 0x5e, 0x95, 0x52, 0x27, 0xaf, 0x7b, 0x94, 0xf7, 0xc7, 0xdd, 0x1a, 0xf2, + 0x46, 0x16, 0xf2, 0xd8, 0xc8, 0x63, 0xd6, 0x75, 0x41, 0x9e, 0x24, 0xa7, 0x38, 0x7c, 0x66, 0x7d, + 0x9c, 0xbf, 0xc7, 0x7c, 0xe2, 0x13, 0xd6, 0xcd, 0x88, 0x53, 0xfc, 0xf4, 0x4f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x42, 0x5f, 0xb9, 0x07, 0x87, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -432,34 +411,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x42 - if len(m.ConsumerRemovalProposals) > 0 { - for iNdEx := len(m.ConsumerRemovalProposals) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ConsumerRemovalProposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if len(m.ConsumerAdditionProposals) > 0 { - for iNdEx := len(m.ConsumerAdditionProposals) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ConsumerAdditionProposals[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } if len(m.ValsetUpdateIdToHeight) > 0 { for iNdEx := len(m.ValsetUpdateIdToHeight) - 1; iNdEx >= 0; iNdEx-- { { @@ -643,18 +594,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.ConsumerAdditionProposals) > 0 { - for _, e := range m.ConsumerAdditionProposals { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.ConsumerRemovalProposals) > 0 { - for _, e := range m.ConsumerRemovalProposals { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) if len(m.ValidatorConsumerPubkeys) > 0 { @@ -853,74 +792,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerAdditionProposals", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerAdditionProposals = append(m.ConsumerAdditionProposals, ConsumerAdditionProposal{}) - if err := m.ConsumerAdditionProposals[len(m.ConsumerAdditionProposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRemovalProposals", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConsumerRemovalProposals = append(m.ConsumerRemovalProposals, ConsumerRemovalProposal{}) - if err := m.ConsumerRemovalProposals[len(m.ConsumerRemovalProposals)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index c5472e07d5..09256a3cdd 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -33,8 +33,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1")}}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -53,8 +51,6 @@ func TestValidateGenesisState(t *testing.T) { {ChainId: "chainid-3", ChannelId: "channelid3", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-3")}, {ChainId: "chainid-4", ChannelId: "channelid4", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-4")}, }, - nil, - nil, types.DefaultParams(), nil, nil, @@ -68,8 +64,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1")}}, - nil, - 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, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24, 180), @@ -85,8 +79,6 @@ func TestValidateGenesisState(t *testing.T) { 0, nil, nil, - nil, - 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, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24, 180), @@ -102,8 +94,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, []types.ValsetUpdateIdToHeight{{ValsetUpdateId: 0}}, nil, - nil, - 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, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(10000000)}, 600, 24, 180), @@ -119,8 +109,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}), types.DefaultTrustingPeriodFraction, @@ -140,8 +128,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), "0.0", // 0 trusting period fraction here @@ -161,8 +147,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), types.DefaultTrustingPeriodFraction, @@ -182,8 +166,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), types.DefaultTrustingPeriodFraction, @@ -203,8 +185,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), types.DefaultTrustingPeriodFraction, @@ -224,8 +204,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -239,8 +217,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid", ChannelId: "ivnalidChannel{}", ClientId: "client-id"}}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -254,8 +230,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid", ChannelId: "channel-0", ClientId: ""}}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -269,8 +243,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid", ChannelId: "channel-0", ClientId: "abc", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid")}}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -287,8 +259,6 @@ func TestValidateGenesisState(t *testing.T) { ChainId: "chainid", ChannelId: "channel-0", ClientId: "client-id", ConsumerGenesis: ccv.ConsumerGenesisState{}, }}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -306,8 +276,6 @@ func TestValidateGenesisState(t *testing.T) { ConsumerGenesis: getInitialConsumerGenesis(t, "chainid"), SlashDowntimeAck: []string{"cosmosvaloper1qlmk6r5w5taqrky4ycur4zq6jqxmuzr688htpp"}, }}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -325,8 +293,6 @@ func TestValidateGenesisState(t *testing.T) { ConsumerGenesis: getInitialConsumerGenesis(t, "chainid"), PendingValsetChanges: []ccv.ValidatorSetChangePacketData{{}}, }}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -348,8 +314,6 @@ func TestValidateGenesisState(t *testing.T) { ValidatorUpdates: []abci.ValidatorUpdate{{}}, }}, }}, - nil, - nil, types.DefaultParams(), nil, nil, @@ -363,8 +327,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1")}}, - nil, - 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, "0.1", sdk.Coin{Denom: "st", Amount: math.NewInt(10000000)}, 600, 24, 180), @@ -380,8 +342,6 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultValsetUpdateID, nil, []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id", ConsumerGenesis: getInitialConsumerGenesis(t, "chainid-1")}}, - nil, - 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, "0.1", sdk.Coin{Denom: "stake", Amount: math.NewInt(-1000000)}, 600, 24, 180), diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index b9bf842a43..5f6010d260 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -57,9 +57,9 @@ const ( DeprecatedInitTimeoutTimestampKeyName = "DeprecatedInitTimeoutTimestampKey" - PendingCAPKeyName = "PendingCAPKey" + DeprecatedPendingCAPKeyName = "DeprecatedPendingCAPKey" - PendingCRPKeyName = "PendingCRPKey" + DeprecatedPendingCRPKeyName = "DeprecatedPendingCRPKey" DeprecatedUnbondingOpKeyName = "DeprecatedUnbondingOpKey" @@ -77,9 +77,9 @@ const ( DeprecatedVscSendTimestampKeyName = "DeprecatedVscSendTimestampKey" - ThrottledPacketDataSizeKeyName = "ThrottledPacketDataSizeKey" + DeprecatedThrottledPacketDataSizeKeyName = "DeprecatedThrottledPacketDataSizeKey" - ThrottledPacketDataKeyName = "ThrottledPacketDataKey" + DeprecatedThrottledPacketDataKeyName = "DeprecatedThrottledPacketDataKey" DeprecatedGlobalSlashEntryKeyName = "DeprecatedGlobalSlashEntryKey" @@ -99,7 +99,7 @@ const ( EquivocationEvidenceMinHeightKeyName = "EquivocationEvidenceMinHeightKey" - ProposedConsumerChainKeyName = "ProposedConsumerChainKey" + DeprecatedProposedConsumerChainKeyName = "DeprecatedProposedConsumerChainKey" ConsumerValidatorKeyName = "ConsumerValidatorKey" @@ -123,10 +123,6 @@ const ( LastProviderConsensusValsKeyName = "LastProviderConsensusValsKey" - DeprecatedMinStakeKeyName = "DeprecatedMinStakeKey" - - DeprecatedAllowInactiveValidatorsKeyName = "DeprecatedAllowInactiveValidatorsKey" - ConsumerAddrsToPruneV2KeyName = "ConsumerAddrsToPruneV2Key" ConsumerIdKeyName = "ConsumerIdKey" @@ -200,11 +196,13 @@ func getKeyPrefixes() map[string]byte { // PendingCAPKey is the key for storing pending consumer addition proposals before the spawn time occurs. // The key includes the BigEndian timestamp to allow for efficient chronological iteration - PendingCAPKeyName: 9, + // [DEPRECATED] + DeprecatedPendingCAPKeyName: 9, // PendingCRPKey is the key for storing pending consumer removal proposals before the stop time occurs. // The key includes the BigEndian timestamp to allow for efficient chronological iteration - PendingCRPKeyName: 10, + // [DEPRECATED] + DeprecatedPendingCRPKeyName: 10, // UnbondingOpKey is the key that stores a record of all the ids of consumer chains that // need to unbond before a given unbonding operation can unbond on this chain. @@ -241,10 +239,12 @@ func getKeyPrefixes() map[string]byte { DeprecatedVscSendTimestampKeyName: 18, // ThrottledPacketDataSizeKey is the key for storing the size of chain-specific throttled packet data queues - ThrottledPacketDataSizeKeyName: 19, + // [DEPRECATED] + DeprecatedThrottledPacketDataSizeKeyName: 19, // ThrottledPacketDataKey is the key for storing throttled packet data - ThrottledPacketDataKeyName: 20, + // [DEPRECATED] + DeprecatedThrottledPacketDataKeyName: 20, // GlobalSlashEntryKey is the key for storing global slash queue entries // [DEPRECATED] @@ -286,7 +286,8 @@ func getKeyPrefixes() map[string]byte { EquivocationEvidenceMinHeightKeyName: 29, // ProposedConsumerChainKey is the key for storing the consumer chainId in consumerAddition gov proposal submitted before voting finishes - ProposedConsumerChainKeyName: 30, + // [DEPRECATED] + DeprecatedProposedConsumerChainKeyName: 30, // ConsumerValidatorKey is the key for storing for each consumer chain all the consumer // validators in this epoch that are validating the consumer chain @@ -478,44 +479,6 @@ func ConsumerIdToClientIdKey(consumerId string) []byte { return append(ConsumerIdToClientIdKeyPrefix(), []byte(consumerId)...) } -// PendingCAPKeyPrefix returns the key prefix for storing a pending consumer addition proposal -func PendingCAPKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(PendingCAPKeyName)} -} - -// PendingCAPKey returns the key under which a pending consumer addition proposal is stored. -// The key has the following format: PendingCAPKeyPrefix | timestamp.UnixNano() | chainID -func PendingCAPKey(timestamp time.Time, chainID string) []byte { - ts := uint64(timestamp.UTC().UnixNano()) - return ccvtypes.AppendMany( - // Append the prefix - PendingCAPKeyPrefix(), - // Append the time - sdk.Uint64ToBigEndian(ts), - // Append the chainId - []byte(chainID), - ) -} - -// PendingCRPKeyPrefix returns the key prefix for storing pending consumer removal proposals. -func PendingCRPKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(PendingCRPKeyName)} -} - -// PendingCRPKey returns the key under which pending consumer removal proposals are stored. -// The key has the following format: PendingCRPKeyPrefix | timestamp.UnixNano() | chainID -func PendingCRPKey(timestamp time.Time, chainID string) []byte { - ts := uint64(timestamp.UTC().UnixNano()) - return ccvtypes.AppendMany( - // Append the prefix - PendingCRPKeyPrefix(), - // Append the time - sdk.Uint64ToBigEndian(ts), - // Append the chainId - []byte(chainID), - ) -} - // ValsetUpdateBlockHeightKeyPrefix returns the key prefix that storing the mapping from valset update ID to block height func ValsetUpdateBlockHeightKeyPrefix() []byte { return []byte{mustGetKeyPrefix(ValsetUpdateBlockHeightKeyName)} @@ -550,35 +513,6 @@ func PendingVSCsKey(consumerId string) []byte { return append([]byte{mustGetKeyPrefix(PendingVSCsKeyName)}, []byte(consumerId)...) } -// ThrottledPacketDataSizeKey returns the key storing the size of the throttled packet data queue for a given chain ID -func ThrottledPacketDataSizeKey(consumerChainID string) []byte { - return append([]byte{mustGetKeyPrefix(ThrottledPacketDataSizeKeyName)}, []byte(consumerChainID)...) -} - -// ThrottledPacketDataKeyPrefix returns the key prefix for storing the throttled packet data queue -func ThrottledPacketDataKeyPrefix() byte { - return mustGetKeyPrefix(ThrottledPacketDataKeyName) -} - -// ThrottledPacketDataKey returns the key for storing the throttled packet data queue for a given chain ID and ibc seq num -func ThrottledPacketDataKey(consumerChainID string, ibcSeqNum uint64) []byte { - return ChainIdAndUintIdKey(ThrottledPacketDataKeyPrefix(), consumerChainID, ibcSeqNum) -} - -// MustParseThrottledPacketDataKey parses a throttled packet data key or panics upon failure -func MustParseThrottledPacketDataKey(key []byte) (string, uint64) { - chainId, ibcSeqNum, err := ParseThrottledPacketDataKey(key) - if err != nil { - panic(fmt.Sprintf("failed to parse throttled packet data key: %s", err.Error())) - } - return chainId, ibcSeqNum -} - -// ParseThrottledPacketDataKey parses a throttled packet data key -func ParseThrottledPacketDataKey(key []byte) (chainId string, ibcSeqNum uint64, err error) { - return ParseChainIdAndUintIdKey(ThrottledPacketDataKeyPrefix(), key) -} - // ConsumerValidatorsKey returns the key for storing the validator assigned keys for every consumer chain func ConsumerValidatorsKeyPrefix() byte { return mustGetKeyPrefix(ConsumerValidatorsKeyName) @@ -587,7 +521,7 @@ func ConsumerValidatorsKeyPrefix() byte { // ConsumerValidatorsKey returns the key under which the // validator assigned keys for every consumer chain are stored func ConsumerValidatorsKey(consumerId string, addr ProviderConsAddress) []byte { - return ConsumerIdAndConsAddrKey(ConsumerValidatorsKeyPrefix(), consumerId, addr.ToSdkConsAddr()) + return StringIdAndConsAddrKey(ConsumerValidatorsKeyPrefix(), consumerId, addr.ToSdkConsAddr()) } // ValidatorsByConsumerAddrKeyPrefix returns the key prefix for storing the mapping from validator addresses @@ -599,7 +533,7 @@ func ValidatorsByConsumerAddrKeyPrefix() byte { // ValidatorsByConsumerAddrKey returns the key for storing the mapping from validator addresses // on consumer chains to validator addresses on the provider chain func ValidatorsByConsumerAddrKey(consumerId string, addr ConsumerConsAddress) []byte { - return ConsumerIdAndConsAddrKey(ValidatorsByConsumerAddrKeyPrefix(), consumerId, addr.ToSdkConsAddr()) + return StringIdAndConsAddrKey(ValidatorsByConsumerAddrKeyPrefix(), consumerId, addr.ToSdkConsAddr()) } // SlashLogKey returns the key to a validator's slash log @@ -623,32 +557,6 @@ func EquivocationEvidenceMinHeightKey(consumerId string) []byte { return append([]byte{mustGetKeyPrefix(EquivocationEvidenceMinHeightKeyName)}, []byte(consumerId)...) } -// ProposedConsumerChainKeyPrefix returns the key prefix for storing proposed consumer chainId -// in consumerAddition gov proposal before voting finishes -func ProposedConsumerChainKeyPrefix() []byte { - return []byte{mustGetKeyPrefix(ProposedConsumerChainKeyName)} -} - -// ProposedConsumerChainKey returns the key of proposed consumer chainId in consumerAddition gov proposal before voting finishes, the stored key format is prefix|proposalID, value is chainID -func ProposedConsumerChainKey(proposalID uint64) []byte { - return ccvtypes.AppendMany( - ProposedConsumerChainKeyPrefix(), - sdk.Uint64ToBigEndian(proposalID), - ) -} - -// ParseProposedConsumerChainKey get the proposalID in the key -func ParseProposedConsumerChainKey(bz []byte) (uint64, error) { - expectedPrefix := ProposedConsumerChainKeyPrefix() - prefixL := len(expectedPrefix) - if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { - return 0, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) - } - proposalID := sdk.BigEndianToUint64(bz[prefixL:]) - - return proposalID, nil -} - // ConsumerValidatorKeyPrefix returns the key prefix for storing consumer validators func ConsumerValidatorKeyPrefix() byte { return mustGetKeyPrefix(ConsumerValidatorKeyName) @@ -657,8 +565,7 @@ func ConsumerValidatorKeyPrefix() byte { // ConsumerValidatorKey returns the key for storing consumer validators // for the given consumer chain `consumerId` and validator with `providerAddr` func ConsumerValidatorKey(consumerId string, providerAddr []byte) []byte { - prefix := ConsumerIdWithLenKey(ConsumerValidatorKeyPrefix(), consumerId) - return append(prefix, providerAddr...) + return StringIdAndConsAddrKey(ConsumerValidatorKeyPrefix(), consumerId, sdk.ConsAddress(providerAddr)) } // AllowlistKeyPrefix returns the key prefix for storing consumer chains allowlists @@ -668,10 +575,7 @@ func AllowlistKeyPrefix() byte { // AllowlistKey returns the key for storing consumer chains allowlists func AllowlistKey(consumerId string, providerAddr ProviderConsAddress) []byte { - return append( - ConsumerIdWithLenKey(AllowlistKeyPrefix(), consumerId), - providerAddr.ToSdkConsAddr().Bytes()..., - ) + return StringIdAndConsAddrKey(AllowlistKeyPrefix(), consumerId, providerAddr.ToSdkConsAddr()) } // DenylistKeyPrefix returns the key prefix for storing consumer chains denylists @@ -681,10 +585,7 @@ func DenylistKeyPrefix() byte { // DenylistKey returns the key for storing consumer chains denylists func DenylistKey(consumerId string, providerAddr ProviderConsAddress) []byte { - return append( - ConsumerIdWithLenKey(DenylistKeyPrefix(), consumerId), - providerAddr.ToSdkConsAddr().Bytes()..., - ) + return StringIdAndConsAddrKey(DenylistKeyPrefix(), consumerId, providerAddr.ToSdkConsAddr()) } // OptedInKeyPrefix returns the key prefix for storing whether a validator is opted in on a consumer chain. @@ -694,8 +595,7 @@ func OptedInKeyPrefix() byte { // OptedInKey returns the key used to store whether a validator is opted in on a consumer chain. func OptedInKey(consumerId string, providerAddr ProviderConsAddress) []byte { - prefix := ConsumerIdWithLenKey(OptedInKeyPrefix(), consumerId) - return append(prefix, providerAddr.ToSdkConsAddr().Bytes()...) + return StringIdAndConsAddrKey(OptedInKeyPrefix(), consumerId, providerAddr.ToSdkConsAddr()) } // ConsumerRewardsAllocationKey returns the key used to store the ICS rewards per consumer chain @@ -710,7 +610,7 @@ func ConsumerCommissionRateKeyPrefix() byte { // ConsumerCommissionRateKey returns the key used to store the commission rate per validator per consumer chain. func ConsumerCommissionRateKey(consumerId string, providerAddr ProviderConsAddress) []byte { - return ConsumerIdAndConsAddrKey( + return StringIdAndConsAddrKey( ConsumerCommissionRateKeyPrefix(), consumerId, providerAddr.ToSdkConsAddr(), @@ -718,7 +618,7 @@ func ConsumerCommissionRateKey(consumerId string, providerAddr ProviderConsAddre } func MinimumPowerInTopNKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(MinimumPowerInTopNKeyName), consumerId) + return StringIdWithLenKey(mustGetKeyPrefix(MinimumPowerInTopNKeyName), consumerId) } // ConsumerAddrsToPruneV2KeyPrefix returns the key prefix for storing the consumer validators @@ -732,7 +632,7 @@ func ConsumerAddrsToPruneV2KeyPrefix() byte { // ConsumerAddrsToPruneV2Key returns the key for storing the consumer validators // addresses that need to be pruned. func ConsumerAddrsToPruneV2Key(consumerId string, pruneTs time.Time) []byte { - return ConsumerIdAndTsKey(ConsumerAddrsToPruneV2KeyPrefix(), consumerId, pruneTs) + return StringIdAndTsKey(ConsumerAddrsToPruneV2KeyPrefix(), consumerId, pruneTs) } // LastProviderConsensusValsPrefix returns the key prefix for storing the last validator set sent to the consensus engine of the provider chain @@ -747,12 +647,12 @@ func ConsumerIdKey() []byte { // ConsumerIdToChainIdKey returns the key used to store the chain id of this consumer id func ConsumerIdToChainIdKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToChainIdKeyName), consumerId) + return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToChainIdKeyName), consumerId) } // ConsumerIdToOwnerAddressKey returns the owner address of this consumer id func ConsumerIdToOwnerAddressKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToOwnerAddressKeyName), consumerId) + return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToOwnerAddressKeyName), consumerId) } // ConsumerIdToMetadataKeyPrefix returns the key prefix for storing consumer metadata @@ -762,7 +662,7 @@ func ConsumerIdToMetadataKeyPrefix() byte { // ConsumerIdToMetadataKey returns the key used to store the metadata that corresponds to this consumer id func ConsumerIdToMetadataKey(consumerId string) []byte { - return ConsumerIdWithLenKey(ConsumerIdToMetadataKeyPrefix(), consumerId) + return StringIdWithLenKey(ConsumerIdToMetadataKeyPrefix(), consumerId) } // ConsumerIdToInitializationParametersKeyPrefix returns the key prefix for storing consumer initialization records @@ -772,22 +672,17 @@ func ConsumerIdToInitializationParametersKeyPrefix() byte { // ConsumerIdToInitializationParametersKey returns the key used to store the initialization record that corresponds to this consumer id func ConsumerIdToInitializationParametersKey(consumerId string) []byte { - return ConsumerIdWithLenKey(ConsumerIdToInitializationParametersKeyPrefix(), consumerId) + return StringIdWithLenKey(ConsumerIdToInitializationParametersKeyPrefix(), consumerId) } // ConsumerIdToPowerShapingParametersKey returns the key used to store the update record that corresponds to this consumer id func ConsumerIdToPowerShapingParametersKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPowerShapingParameters), consumerId) + return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPowerShapingParameters), consumerId) } // ConsumerIdToPhaseKey returns the key used to store the phase that corresponds to this consumer id func ConsumerIdToPhaseKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId) -} - -// ConsumerIdToStopTimeKey returns the key used to store the stop time that corresponds to a to-be-stopped chain with consumer id -func ConsumerIdToStopTimeKey(consumerId string) []byte { - return ConsumerIdWithLenKey(mustGetKeyPrefix(ConsumerIdToStopTimeKeyName), consumerId) + return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId) } // ConsumerIdToStopTimeKeyPrefix returns the key prefix for storing the stop times of consumer chains @@ -796,6 +691,11 @@ func ConsumerIdToStopTimeKeyPrefix() byte { return mustGetKeyPrefix(ConsumerIdToStopTimeKeyName) } +// ConsumerIdToStopTimeKey returns the key used to store the stop time that corresponds to a to-be-stopped chain with consumer id +func ConsumerIdToStopTimeKey(consumerId string) []byte { + return StringIdWithLenKey(ConsumerIdToStopTimeKeyPrefix(), consumerId) +} + // SpawnTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be launched func SpawnTimeToConsumerIdsKeyPrefix() byte { return mustGetKeyPrefix(SpawnTimeToConsumerIdsKeyName) @@ -871,108 +771,98 @@ func ClientIdToConsumerIdKey(clientId string) []byte { // Generic helpers section // -// ConsumerIdAndTsKey returns the key with the following format: -// bytePrefix | len(consumerId) | consumerId | timestamp -func ConsumerIdAndTsKey(prefix byte, consumerId string, timestamp time.Time) []byte { - partialKey := ConsumerIdWithLenKey(prefix, consumerId) - timeBz := sdk.FormatTimeBytes(timestamp) +// StringIdAndTsKey returns the key with the following format: +// bytePrefix | len(stringId) | stringId | timestamp +func StringIdAndTsKey(prefix byte, stringId string, timestamp time.Time) []byte { return ccvtypes.AppendMany( - // Append the partialKey - partialKey, - // Append the time bytes - timeBz, + StringIdWithLenKey(prefix, stringId), + sdk.FormatTimeBytes(timestamp), ) } -// ParseConsumerIdAndTsKey returns the consumer id and time for a ConsumerIdIdAndTs key -func ParseConsumerIdAndTsKey(prefix byte, bz []byte) (string, time.Time, error) { +// ParseStringIdAndTsKey returns the string id and time for a StringIdAndTs key +func ParseStringIdAndTsKey(prefix byte, bz []byte) (string, time.Time, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { return "", time.Time{}, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) } - consumerIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) - consumerId := string(bz[prefixL+8 : prefixL+8+int(consumerIdL)]) - timestamp, err := sdk.ParseTimeBytes(bz[prefixL+8+int(consumerIdL):]) + stringIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + stringId := string(bz[prefixL+8 : prefixL+8+int(stringIdL)]) + timestamp, err := sdk.ParseTimeBytes(bz[prefixL+8+int(stringIdL):]) if err != nil { return "", time.Time{}, err } - return consumerId, timestamp, nil + return stringId, timestamp, nil } -// ConsumerIdWithLenKey returns the key with the following format: -// bytePrefix | len(consumerId) | consumerId -func ConsumerIdWithLenKey(prefix byte, consumerId string) []byte { +// StringIdWithLenKey returns the key with the following format: +// bytePrefix | len(stringId) | stringId +func StringIdWithLenKey(prefix byte, stringId string) []byte { return ccvtypes.AppendMany( // Append the prefix []byte{prefix}, - // Append the consumer id length - sdk.Uint64ToBigEndian(uint64(len(consumerId))), - // Append the consumer id - []byte(consumerId), + // Append the string id length + sdk.Uint64ToBigEndian(uint64(len(stringId))), + // Append the string id + []byte(stringId), ) } -// ParseConsumerIdWithLenKey returns the consumer id ConsumerIdWithLen key -func ParseConsumerIdWithLenKey(prefix byte, bz []byte) (string, error) { +// ParseStringIdWithLenKey returns the stringId of a StringIdWithLen key +func ParseStringIdWithLenKey(prefix byte, bz []byte) (string, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { return "", fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) } - consumerIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) - consumerId := string(bz[prefixL+8 : prefixL+8+int(consumerIdL)]) - return consumerId, nil + stringIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + stringId := string(bz[prefixL+8 : prefixL+8+int(stringIdL)]) + return stringId, nil } -// ChainIdAndUintIdKey returns the key with the following format: -// bytePrefix | len(chainID) | chainID | uint64(ID) -func ChainIdAndUintIdKey(prefix byte, chainID string, uintId uint64) []byte { - partialKey := ConsumerIdWithLenKey(prefix, chainID) +// StringIdAndUintIdKey returns the key with the following format: +// bytePrefix | len(stringId) | stringId | uint64(ID) +func StringIdAndUintIdKey(prefix byte, stringId string, uintId uint64) []byte { return ccvtypes.AppendMany( - // Append the partialKey - partialKey, - // Append the uint id bytes + StringIdWithLenKey(prefix, stringId), sdk.Uint64ToBigEndian(uintId), ) } -// ParseChainIdAndUintIdKey returns the chain ID and uint ID for a ChainIdAndUintId key -func ParseChainIdAndUintIdKey(prefix byte, bz []byte) (string, uint64, error) { +// ParseStringIdAndUintIdKey returns the string ID and uint ID for a StringIdAndUintId key +func ParseStringIdAndUintIdKey(prefix byte, bz []byte) (string, uint64, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { return "", 0, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) } - chainIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) - chainID := string(bz[prefixL+8 : prefixL+8+int(chainIdL)]) - uintID := sdk.BigEndianToUint64(bz[prefixL+8+int(chainIdL):]) - return chainID, uintID, nil + stringIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + stringId := string(bz[prefixL+8 : prefixL+8+int(stringIdL)]) + uintID := sdk.BigEndianToUint64(bz[prefixL+8+int(stringIdL):]) + return stringId, uintID, nil } -// ConsumerIdAndConsAddrKey returns the key with the following format: -// bytePrefix | len(consumerId) | consumerId | ConsAddress -func ConsumerIdAndConsAddrKey(prefix byte, consumerId string, addr sdk.ConsAddress) []byte { - partialKey := ConsumerIdWithLenKey(prefix, consumerId) +// StringIdAndConsAddrKey returns the key with the following format: +// bytePrefix | len(stringId) | stringId | ConsAddress +func StringIdAndConsAddrKey(prefix byte, stringId string, addr sdk.ConsAddress) []byte { return ccvtypes.AppendMany( - // Append the partialKey - partialKey, - // Append the addr bytes + StringIdWithLenKey(prefix, stringId), addr, ) } -// ParseChainIdAndConsAddrKey returns the chain ID and ConsAddress for a ConsumerIdAndConsAddrKey key -func ParseChainIdAndConsAddrKey(prefix byte, bz []byte) (string, sdk.ConsAddress, error) { +// ParseStringIdAndConsAddrKey returns the string ID and ConsAddress for a StringIdAndConsAddr key +func ParseStringIdAndConsAddrKey(prefix byte, bz []byte) (string, sdk.ConsAddress, error) { expectedPrefix := []byte{prefix} prefixL := len(expectedPrefix) if prefix := bz[:prefixL]; !bytes.Equal(prefix, expectedPrefix) { return "", nil, fmt.Errorf("invalid prefix; expected: %X, got: %X", expectedPrefix, prefix) } - chainIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) - chainID := string(bz[prefixL+8 : prefixL+8+int(chainIdL)]) - addr := bz[prefixL+8+int(chainIdL):] - return chainID, addr, nil + stringIdL := sdk.BigEndianToUint64(bz[prefixL : prefixL+8]) + stringId := string(bz[prefixL+8 : prefixL+8+int(stringIdL)]) + addr := bz[prefixL+8+int(stringIdL):] + return stringId, addr, nil } // diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index f3ecb4da6c..7f475e0b14 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -41,7 +41,7 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(4), providertypes.SlashMeterReplenishTimeCandidateKey()[0]) i++ - require.Equal(t, byte(5), providertypes.ConsumerIdToChannelIdKey("chainID")[0]) + require.Equal(t, byte(5), providertypes.ConsumerIdToChannelIdKey("13")[0]) i++ require.Equal(t, byte(6), providertypes.ChannelIdToConsumerIdKeyPrefix()[0]) i++ @@ -49,9 +49,9 @@ func TestPreserveBytePrefix(t *testing.T) { i++ // reserve 8 as deprecated i++ - require.Equal(t, byte(9), providertypes.PendingCAPKeyPrefix()[0]) + // reserve 9 as deprecated i++ - require.Equal(t, byte(10), providertypes.PendingCRPKeyPrefix()[0]) + // reserve 10 as deprecated i++ // reserve 11 as deprecated i++ @@ -59,19 +59,19 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(13), providertypes.ValsetUpdateBlockHeightKeyPrefix()[0]) i++ - require.Equal(t, byte(14), providertypes.ConsumerGenesisKey("chainID")[0]) + require.Equal(t, byte(14), providertypes.ConsumerGenesisKey("13")[0]) i++ - require.Equal(t, byte(15), providertypes.SlashAcksKey("chainID")[0]) + require.Equal(t, byte(15), providertypes.SlashAcksKey("13")[0]) i++ - require.Equal(t, byte(16), providertypes.InitChainHeightKey("chainID")[0]) + require.Equal(t, byte(16), providertypes.InitChainHeightKey("13")[0]) i++ - require.Equal(t, byte(17), providertypes.PendingVSCsKey("chainID")[0]) + require.Equal(t, byte(17), providertypes.PendingVSCsKey("13")[0]) i++ // reserve 18 as deprecated i++ - require.Equal(t, byte(19), providertypes.ThrottledPacketDataSizeKey("chainID")[0]) + // reserve 19 as deprecated i++ - require.Equal(t, byte(20), providertypes.ThrottledPacketDataKeyPrefix()) + // reserve 20 as deprecated i++ // DEPRECATED // require.Equal(t, uint8(21), providertypes.GlobalSlashEntryKeyPrefix()[0]) @@ -90,32 +90,32 @@ func TestPreserveBytePrefix(t *testing.T) { i++ // reserve 28 as deprecated i++ - require.Equal(t, byte(29), providertypes.EquivocationEvidenceMinHeightKey("chainID")[0]) + require.Equal(t, byte(29), providertypes.EquivocationEvidenceMinHeightKey("13")[0]) i++ - require.Equal(t, byte(30), providertypes.ProposedConsumerChainKeyPrefix()[0]) + // reserve 30 as deprecated i++ require.Equal(t, byte(31), providertypes.ConsumerValidatorKeyPrefix()) i++ require.Equal(t, byte(32), providertypes.OptedInKeyPrefix()) i++ // DEPRECATED - //require.Equal(t, byte(33), providertypes.TopNKey("chainID")[0]) + //require.Equal(t, byte(33), providertypes.TopNKey("13")[0]) i++ // DEPRECATED - //require.Equal(t, byte(34), providertypes.ValidatorsPowerCapKey("chainID")[0]) + //require.Equal(t, byte(34), providertypes.ValidatorsPowerCapKey("13")[0]) i++ // DEPRECATED - //require.Equal(t, byte(35), providertypes.ValidatorSetCapKey("chainID")[0]) + //require.Equal(t, byte(35), providertypes.ValidatorSetCapKey("13")[0]) i++ require.Equal(t, byte(36), providertypes.AllowlistKeyPrefix()) i++ require.Equal(t, byte(37), providertypes.DenylistKeyPrefix()) i++ - require.Equal(t, byte(38), providertypes.ConsumerRewardsAllocationKey("chainID")[0]) + require.Equal(t, byte(38), providertypes.ConsumerRewardsAllocationKey("13")[0]) i++ require.Equal(t, byte(39), providertypes.ConsumerCommissionRateKeyPrefix()) i++ - require.Equal(t, byte(40), providertypes.MinimumPowerInTopNKey("chainID")[0]) + require.Equal(t, byte(40), providertypes.MinimumPowerInTopNKey("13")[0]) i++ require.Equal(t, byte(41), providertypes.ConsumerAddrsToPruneV2KeyPrefix()) i++ @@ -123,17 +123,17 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(43), providertypes.ConsumerIdKey()[0]) i++ - require.Equal(t, byte(44), providertypes.ConsumerIdToChainIdKey("consumerId")[0]) + require.Equal(t, byte(44), providertypes.ConsumerIdToChainIdKey("13")[0]) i++ - require.Equal(t, byte(45), providertypes.ConsumerIdToOwnerAddressKey("consumerId")[0]) + require.Equal(t, byte(45), providertypes.ConsumerIdToOwnerAddressKey("13")[0]) i++ require.Equal(t, byte(46), providertypes.ConsumerIdToMetadataKeyPrefix()) i++ require.Equal(t, byte(47), providertypes.ConsumerIdToInitializationParametersKeyPrefix()) i++ - require.Equal(t, byte(48), providertypes.ConsumerIdToPowerShapingParametersKey("consumerId")[0]) + require.Equal(t, byte(48), providertypes.ConsumerIdToPowerShapingParametersKey("13")[0]) i++ - require.Equal(t, byte(49), providertypes.ConsumerIdToPhaseKey("consumerId")[0]) + require.Equal(t, byte(49), providertypes.ConsumerIdToPhaseKey("13")[0]) i++ require.Equal(t, byte(50), providertypes.ConsumerIdToStopTimeKeyPrefix()) i++ @@ -180,41 +180,36 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.ValidatorSetUpdateIdKey(), providertypes.SlashMeterKey(), providertypes.SlashMeterReplenishTimeCandidateKey(), - providertypes.ConsumerIdToChannelIdKey("chainID"), + providertypes.ConsumerIdToChannelIdKey("13"), providertypes.ChannelToConsumerIdKey("channelID"), - providertypes.ConsumerIdToClientIdKey("chainID"), - providertypes.PendingCAPKey(time.Time{}, "chainID"), - providertypes.PendingCRPKey(time.Time{}, "chainID"), + providertypes.ConsumerIdToClientIdKey("13"), providertypes.ValsetUpdateBlockHeightKey(7), - providertypes.ConsumerGenesisKey("chainID"), - providertypes.SlashAcksKey("chainID"), - providertypes.InitChainHeightKey("chainID"), - providertypes.PendingVSCsKey("chainID"), - providertypes.ThrottledPacketDataSizeKey("chainID"), - providertypes.ThrottledPacketDataKey("chainID", 88), - providertypes.ConsumerValidatorsKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), - providertypes.ValidatorsByConsumerAddrKey("chainID", providertypes.NewConsumerConsAddress([]byte{0x05})), + providertypes.ConsumerGenesisKey("13"), + providertypes.SlashAcksKey("13"), + providertypes.InitChainHeightKey("13"), + providertypes.PendingVSCsKey("13"), + providertypes.ConsumerValidatorsKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.ValidatorsByConsumerAddrKey("13", providertypes.NewConsumerConsAddress([]byte{0x05})), providertypes.SlashLogKey(providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.ConsumerRewardDenomsKey("uatom"), - providertypes.EquivocationEvidenceMinHeightKey("chainID"), - providertypes.ProposedConsumerChainKey(1), - providertypes.ConsumerValidatorKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05}).Address.Bytes()), - providertypes.AllowlistKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), - providertypes.DenylistKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), - providertypes.OptedInKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), - providertypes.ConsumerRewardsAllocationKey("chainID"), - providertypes.ConsumerCommissionRateKey("chainID", providertypes.NewProviderConsAddress([]byte{0x05})), - providertypes.MinimumPowerInTopNKey("chainID"), - providertypes.ConsumerAddrsToPruneV2Key("chainID", time.Time{}), + providertypes.EquivocationEvidenceMinHeightKey("13"), + providertypes.ConsumerValidatorKey("13", providertypes.NewProviderConsAddress([]byte{0x05}).Address.Bytes()), + providertypes.AllowlistKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.DenylistKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.OptedInKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.ConsumerRewardsAllocationKey("13"), + providertypes.ConsumerCommissionRateKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), + providertypes.MinimumPowerInTopNKey("13"), + providertypes.ConsumerAddrsToPruneV2Key("13", time.Time{}), providerkeeper.GetValidatorKey(types.LastProviderConsensusValsPrefix(), providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.ConsumerIdKey(), - providertypes.ConsumerIdToChainIdKey("consumerId"), - providertypes.ConsumerIdToOwnerAddressKey("consumerId"), - providertypes.ConsumerIdToMetadataKey("consumerId"), - providertypes.ConsumerIdToInitializationParametersKey("consumerId"), - providertypes.ConsumerIdToPowerShapingParametersKey("consumerId"), - providertypes.ConsumerIdToPhaseKey("consumerId"), - providertypes.ConsumerIdToStopTimeKey("consumerId"), + providertypes.ConsumerIdToChainIdKey("13"), + providertypes.ConsumerIdToOwnerAddressKey("13"), + providertypes.ConsumerIdToMetadataKey("13"), + providertypes.ConsumerIdToInitializationParametersKey("13"), + providertypes.ConsumerIdToPowerShapingParametersKey("13"), + providertypes.ConsumerIdToPhaseKey("13"), + providertypes.ConsumerIdToStopTimeKey("13"), providertypes.SpawnTimeToConsumerIdsKey(time.Time{}), providertypes.StopTimeToConsumerIdsKey(time.Time{}), providertypes.ProviderConsAddrToOptedInConsumerIdsKey(providertypes.NewProviderConsAddress([]byte{0x05})), @@ -222,86 +217,59 @@ func getAllFullyDefinedKeys() [][]byte { } } -// Tests the construction and parsing of ChainIdAndTs keys -func TestChainIdAndTsKeyAndParse(t *testing.T) { +// Tests the construction and parsing of StringIdAndTs keys +func TestStringIdAndTsKeyAndParse(t *testing.T) { tests := []struct { - prefix byte - chainID string - timestamp time.Time + prefix byte + consumerID string + timestamp time.Time }{ - {prefix: 0x01, chainID: "1", timestamp: time.Now()}, - {prefix: 0x02, chainID: "some other ID", timestamp: time.Date( + {prefix: 0x01, consumerID: "1", timestamp: time.Now()}, + {prefix: 0x02, consumerID: "111", timestamp: time.Date( 2003, 11, 17, 20, 34, 58, 651387237, time.UTC)}, - {prefix: 0x03, chainID: "some other other chain ID", timestamp: time.Now().Add(5000 * time.Hour)}, + {prefix: 0x03, consumerID: "2000", timestamp: time.Now().Add(5000 * time.Hour)}, } for _, test := range tests { - key := providertypes.ConsumerIdAndTsKey(test.prefix, test.chainID, test.timestamp) + key := providertypes.StringIdAndTsKey(test.prefix, test.consumerID, test.timestamp) require.NotEmpty(t, key) - // Expected bytes = prefix + chainID length + chainID + time bytes - expectedLen := 1 + 8 + len(test.chainID) + len(sdk.FormatTimeBytes(time.Time{})) + // Expected bytes = prefix + consumerID length + consumerID + time bytes + expectedLen := 1 + 8 + len(test.consumerID) + len(sdk.FormatTimeBytes(time.Time{})) require.Equal(t, expectedLen, len(key)) - parsedID, parsedTime, err := providertypes.ParseConsumerIdAndTsKey(test.prefix, key) - require.Equal(t, test.chainID, parsedID) + parsedID, parsedTime, err := providertypes.ParseStringIdAndTsKey(test.prefix, key) + require.Equal(t, test.consumerID, parsedID) require.Equal(t, test.timestamp.UTC(), parsedTime.UTC()) require.NoError(t, err) } } -// Tests the construction and parsing of ChainIdAndUintId keys -func TestChainIdAndUintIdAndParse(t *testing.T) { +// Tests the construction and parsing of StringIdAndUintId keys +func TestStringIdAndUintIdAndParse(t *testing.T) { tests := []struct { - prefix byte - chainID string - uintID uint64 + prefix byte + consumerID string + uintID uint64 }{ - {prefix: 0x01, chainID: "1", uintID: 1}, - {prefix: 0x02, chainID: "some other ID", uintID: 2}, - {prefix: 0x03, chainID: "some other other chain ID", uintID: 3}, + {prefix: 0x01, consumerID: "1", uintID: 1}, + {prefix: 0x02, consumerID: "13", uintID: 2}, + {prefix: 0x03, consumerID: "245", uintID: 3}, } for _, test := range tests { - key := providertypes.ChainIdAndUintIdKey(test.prefix, test.chainID, test.uintID) + key := providertypes.StringIdAndUintIdKey(test.prefix, test.consumerID, test.uintID) require.NotEmpty(t, key) - // Expected bytes = prefix + chainID length + chainID + vscId bytes - expectedLen := 1 + 8 + len(test.chainID) + 8 + // Expected bytes = prefix + consumerID length + consumerID + vscId bytes + expectedLen := 1 + 8 + len(test.consumerID) + 8 require.Equal(t, expectedLen, len(key)) - parsedChainID, parsedUintID, err := providertypes.ParseChainIdAndUintIdKey(test.prefix, key) - require.Equal(t, test.chainID, parsedChainID) + parsedChainID, parsedUintID, err := providertypes.ParseStringIdAndUintIdKey(test.prefix, key) + require.Equal(t, test.consumerID, parsedChainID) require.Equal(t, test.uintID, parsedUintID) require.NoError(t, err) } } -// Tests the construction and parsing of keys for throttled packet data -func TestThrottledPacketDataKeyAndParse(t *testing.T) { - tests := []struct { - consumerChainID string - ibcSeqNum uint64 - }{ - {consumerChainID: "some chain id", ibcSeqNum: 45}, - {consumerChainID: "some chain id that is longer", ibcSeqNum: 54038}, - {consumerChainID: "some chain id that is longer-er ", ibcSeqNum: 9999999999999999999}, - } - - for _, test := range tests { - key := providertypes.ThrottledPacketDataKey(test.consumerChainID, test.ibcSeqNum) - require.NotEmpty(t, key) - // This key should be of len: prefix + chainID length + chainID + ibcSeqNum - require.Equal(t, 1+8+len(test.consumerChainID)+8, len(key)) - parsedChainID, parsedSeqNum := providertypes.MustParseThrottledPacketDataKey(key) - require.Equal(t, test.consumerChainID, parsedChainID) - require.Equal(t, test.ibcSeqNum, parsedSeqNum) - } - - // Sanity check that two keys with different chain ids but same seq num are different - key1 := providertypes.ThrottledPacketDataKey("chain-7", 45) - key2 := providertypes.ThrottledPacketDataKey("chain-8", 45) - require.NotEqual(t, key1, key2) -} - -// Tests the construction and parsing of ChainIdAndConsAddr keys -func TestChainIdAndConsAddrAndParse(t *testing.T) { +// Tests the construction and parsing of StringIdAndConsAddr keys +func TestStringIdAndConsAddrAndParse(t *testing.T) { cIds := []*cryptoutil.CryptoIdentity{ cryptoutil.NewCryptoIdentityFromIntSeed(99998), cryptoutil.NewCryptoIdentityFromIntSeed(99999), @@ -312,23 +280,23 @@ func TestChainIdAndConsAddrAndParse(t *testing.T) { pubKey3 := cIds[2].TMCryptoPubKey() tests := []struct { - prefix byte - chainID string - addr sdk.ConsAddress + prefix byte + consumerId string + addr sdk.ConsAddress }{ - {prefix: 0x01, chainID: "1", addr: sdk.ConsAddress(pubKey1.Address())}, - {prefix: 0x02, chainID: "some other ID", addr: sdk.ConsAddress(pubKey2.Address())}, - {prefix: 0x03, chainID: "some other other chain ID", addr: sdk.ConsAddress(pubKey3.Address())}, + {prefix: 0x01, consumerId: "1", addr: sdk.ConsAddress(pubKey1.Address())}, + {prefix: 0x02, consumerId: "23", addr: sdk.ConsAddress(pubKey2.Address())}, + {prefix: 0x03, consumerId: "456", addr: sdk.ConsAddress(pubKey3.Address())}, } for _, test := range tests { - key := providertypes.ConsumerIdAndConsAddrKey(test.prefix, test.chainID, test.addr) + key := providertypes.StringIdAndConsAddrKey(test.prefix, test.consumerId, test.addr) require.NotEmpty(t, key) - // Expected bytes = prefix + chainID length + chainID + consAddr bytes - expectedLen := 1 + 8 + len(test.chainID) + len(test.addr) + // Expected bytes = prefix + consumerID length + consumerID + consAddr bytes + expectedLen := 1 + 8 + len(test.consumerId) + len(test.addr) require.Equal(t, expectedLen, len(key)) - parsedID, parsedConsAddr, err := providertypes.ParseChainIdAndConsAddrKey(test.prefix, key) - require.Equal(t, test.chainID, parsedID) + parsedID, parsedConsAddr, err := providertypes.ParseStringIdAndConsAddrKey(test.prefix, key) + require.Equal(t, test.consumerId, parsedID) require.Equal(t, test.addr, parsedConsAddr) require.NoError(t, err) } @@ -383,21 +351,3 @@ func TestKeysWithUint64Payload(t *testing.T) { } } } - -func TestParseProposedConsumerChainKey(t *testing.T) { - tests := []struct { - chainID string - proposalID uint64 - }{ - {chainID: "1", proposalID: 1}, - {chainID: "some other ID", proposalID: 12}, - {chainID: "some other other chain ID", proposalID: 123}, - } - - for _, test := range tests { - key := providertypes.ProposedConsumerChainKey(test.proposalID) - pID, err := providertypes.ParseProposedConsumerChainKey(key) - require.NoError(t, err) - require.Equal(t, pID, test.proposalID) - } -} diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 568b8d34ae..5a1a2a4e15 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -236,174 +236,6 @@ func (m *QueryConsumerChainsResponse) GetChains() []*Chain { return nil } -type QueryConsumerChainStartProposalsRequest struct { -} - -func (m *QueryConsumerChainStartProposalsRequest) Reset() { - *m = QueryConsumerChainStartProposalsRequest{} -} -func (m *QueryConsumerChainStartProposalsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryConsumerChainStartProposalsRequest) ProtoMessage() {} -func (*QueryConsumerChainStartProposalsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{4} -} -func (m *QueryConsumerChainStartProposalsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryConsumerChainStartProposalsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryConsumerChainStartProposalsRequest.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 *QueryConsumerChainStartProposalsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryConsumerChainStartProposalsRequest.Merge(m, src) -} -func (m *QueryConsumerChainStartProposalsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryConsumerChainStartProposalsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryConsumerChainStartProposalsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryConsumerChainStartProposalsRequest proto.InternalMessageInfo - -type QueryConsumerChainStartProposalsResponse struct { - Proposals *ConsumerAdditionProposals `protobuf:"bytes,1,opt,name=proposals,proto3" json:"proposals,omitempty"` -} - -func (m *QueryConsumerChainStartProposalsResponse) Reset() { - *m = QueryConsumerChainStartProposalsResponse{} -} -func (m *QueryConsumerChainStartProposalsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryConsumerChainStartProposalsResponse) ProtoMessage() {} -func (*QueryConsumerChainStartProposalsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{5} -} -func (m *QueryConsumerChainStartProposalsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryConsumerChainStartProposalsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryConsumerChainStartProposalsResponse.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 *QueryConsumerChainStartProposalsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryConsumerChainStartProposalsResponse.Merge(m, src) -} -func (m *QueryConsumerChainStartProposalsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryConsumerChainStartProposalsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryConsumerChainStartProposalsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryConsumerChainStartProposalsResponse proto.InternalMessageInfo - -func (m *QueryConsumerChainStartProposalsResponse) GetProposals() *ConsumerAdditionProposals { - if m != nil { - return m.Proposals - } - return nil -} - -type QueryConsumerChainStopProposalsRequest struct { -} - -func (m *QueryConsumerChainStopProposalsRequest) Reset() { - *m = QueryConsumerChainStopProposalsRequest{} -} -func (m *QueryConsumerChainStopProposalsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryConsumerChainStopProposalsRequest) ProtoMessage() {} -func (*QueryConsumerChainStopProposalsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{6} -} -func (m *QueryConsumerChainStopProposalsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryConsumerChainStopProposalsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryConsumerChainStopProposalsRequest.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 *QueryConsumerChainStopProposalsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryConsumerChainStopProposalsRequest.Merge(m, src) -} -func (m *QueryConsumerChainStopProposalsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryConsumerChainStopProposalsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryConsumerChainStopProposalsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryConsumerChainStopProposalsRequest proto.InternalMessageInfo - -type QueryConsumerChainStopProposalsResponse struct { - Proposals *ConsumerRemovalProposals `protobuf:"bytes,1,opt,name=proposals,proto3" json:"proposals,omitempty"` -} - -func (m *QueryConsumerChainStopProposalsResponse) Reset() { - *m = QueryConsumerChainStopProposalsResponse{} -} -func (m *QueryConsumerChainStopProposalsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryConsumerChainStopProposalsResponse) ProtoMessage() {} -func (*QueryConsumerChainStopProposalsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{7} -} -func (m *QueryConsumerChainStopProposalsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryConsumerChainStopProposalsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryConsumerChainStopProposalsResponse.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 *QueryConsumerChainStopProposalsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryConsumerChainStopProposalsResponse.Merge(m, src) -} -func (m *QueryConsumerChainStopProposalsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryConsumerChainStopProposalsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryConsumerChainStopProposalsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryConsumerChainStopProposalsResponse proto.InternalMessageInfo - -func (m *QueryConsumerChainStopProposalsResponse) GetProposals() *ConsumerRemovalProposals { - if m != nil { - return m.Proposals - } - return nil -} - type Chain struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` @@ -436,7 +268,7 @@ func (m *Chain) Reset() { *m = Chain{} } func (m *Chain) String() string { return proto.CompactTextString(m) } func (*Chain) ProtoMessage() {} func (*Chain) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{8} + return fileDescriptor_422512d7b7586cd7, []int{4} } func (m *Chain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -562,7 +394,7 @@ func (m *QueryValidatorConsumerAddrRequest) Reset() { *m = QueryValidato func (m *QueryValidatorConsumerAddrRequest) String() string { return proto.CompactTextString(m) } func (*QueryValidatorConsumerAddrRequest) ProtoMessage() {} func (*QueryValidatorConsumerAddrRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{9} + return fileDescriptor_422512d7b7586cd7, []int{5} } func (m *QueryValidatorConsumerAddrRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -600,7 +432,7 @@ func (m *QueryValidatorConsumerAddrResponse) Reset() { *m = QueryValidat func (m *QueryValidatorConsumerAddrResponse) String() string { return proto.CompactTextString(m) } func (*QueryValidatorConsumerAddrResponse) ProtoMessage() {} func (*QueryValidatorConsumerAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{10} + return fileDescriptor_422512d7b7586cd7, []int{6} } func (m *QueryValidatorConsumerAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -649,7 +481,7 @@ func (m *QueryValidatorProviderAddrRequest) Reset() { *m = QueryValidato func (m *QueryValidatorProviderAddrRequest) String() string { return proto.CompactTextString(m) } func (*QueryValidatorProviderAddrRequest) ProtoMessage() {} func (*QueryValidatorProviderAddrRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{11} + return fileDescriptor_422512d7b7586cd7, []int{7} } func (m *QueryValidatorProviderAddrRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -687,7 +519,7 @@ func (m *QueryValidatorProviderAddrResponse) Reset() { *m = QueryValidat func (m *QueryValidatorProviderAddrResponse) String() string { return proto.CompactTextString(m) } func (*QueryValidatorProviderAddrResponse) ProtoMessage() {} func (*QueryValidatorProviderAddrResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{12} + return fileDescriptor_422512d7b7586cd7, []int{8} } func (m *QueryValidatorProviderAddrResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -730,7 +562,7 @@ func (m *QueryThrottleStateRequest) Reset() { *m = QueryThrottleStateReq func (m *QueryThrottleStateRequest) String() string { return proto.CompactTextString(m) } func (*QueryThrottleStateRequest) ProtoMessage() {} func (*QueryThrottleStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{13} + return fileDescriptor_422512d7b7586cd7, []int{9} } func (m *QueryThrottleStateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -774,7 +606,7 @@ func (m *QueryThrottleStateResponse) Reset() { *m = QueryThrottleStateRe func (m *QueryThrottleStateResponse) String() string { return proto.CompactTextString(m) } func (*QueryThrottleStateResponse) ProtoMessage() {} func (*QueryThrottleStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{14} + return fileDescriptor_422512d7b7586cd7, []int{10} } func (m *QueryThrottleStateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -835,7 +667,7 @@ func (m *QueryRegisteredConsumerRewardDenomsRequest) String() string { } func (*QueryRegisteredConsumerRewardDenomsRequest) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{15} + return fileDescriptor_422512d7b7586cd7, []int{11} } func (m *QueryRegisteredConsumerRewardDenomsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -876,7 +708,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) String() string { } func (*QueryRegisteredConsumerRewardDenomsResponse) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{16} + return fileDescriptor_422512d7b7586cd7, []int{12} } func (m *QueryRegisteredConsumerRewardDenomsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -912,148 +744,6 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) GetDenoms() []string { return nil } -type QueryProposedChainIDsRequest struct { -} - -func (m *QueryProposedChainIDsRequest) Reset() { *m = QueryProposedChainIDsRequest{} } -func (m *QueryProposedChainIDsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryProposedChainIDsRequest) ProtoMessage() {} -func (*QueryProposedChainIDsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{17} -} -func (m *QueryProposedChainIDsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProposedChainIDsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProposedChainIDsRequest.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 *QueryProposedChainIDsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProposedChainIDsRequest.Merge(m, src) -} -func (m *QueryProposedChainIDsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryProposedChainIDsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProposedChainIDsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProposedChainIDsRequest proto.InternalMessageInfo - -type QueryProposedChainIDsResponse struct { - ProposedChains []ProposedChain `protobuf:"bytes,1,rep,name=proposedChains,proto3" json:"proposedChains"` -} - -func (m *QueryProposedChainIDsResponse) Reset() { *m = QueryProposedChainIDsResponse{} } -func (m *QueryProposedChainIDsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryProposedChainIDsResponse) ProtoMessage() {} -func (*QueryProposedChainIDsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{18} -} -func (m *QueryProposedChainIDsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProposedChainIDsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProposedChainIDsResponse.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 *QueryProposedChainIDsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProposedChainIDsResponse.Merge(m, src) -} -func (m *QueryProposedChainIDsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryProposedChainIDsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProposedChainIDsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProposedChainIDsResponse proto.InternalMessageInfo - -func (m *QueryProposedChainIDsResponse) GetProposedChains() []ProposedChain { - if m != nil { - return m.ProposedChains - } - return nil -} - -type ProposedChain struct { - // [DEPRECATED] use `consumer_id` instead - ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"` // Deprecated: Do not use. - ProposalID uint64 `protobuf:"varint,2,opt,name=proposalID,proto3" json:"proposalID,omitempty"` - ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` -} - -func (m *ProposedChain) Reset() { *m = ProposedChain{} } -func (m *ProposedChain) String() string { return proto.CompactTextString(m) } -func (*ProposedChain) ProtoMessage() {} -func (*ProposedChain) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{19} -} -func (m *ProposedChain) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ProposedChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ProposedChain.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 *ProposedChain) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProposedChain.Merge(m, src) -} -func (m *ProposedChain) XXX_Size() int { - return m.Size() -} -func (m *ProposedChain) XXX_DiscardUnknown() { - xxx_messageInfo_ProposedChain.DiscardUnknown(m) -} - -var xxx_messageInfo_ProposedChain proto.InternalMessageInfo - -// Deprecated: Do not use. -func (m *ProposedChain) GetChainID() string { - if m != nil { - return m.ChainID - } - return "" -} - -func (m *ProposedChain) GetProposalID() uint64 { - if m != nil { - return m.ProposalID - } - return 0 -} - -func (m *ProposedChain) GetConsumerId() string { - if m != nil { - return m.ConsumerId - } - return "" -} - type QueryAllPairsValConAddrByConsumerChainIDRequest struct { // [DEPRECATED] use `consumer_id` instead ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. @@ -1069,7 +759,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) String() string { } func (*QueryAllPairsValConAddrByConsumerChainIDRequest) ProtoMessage() {} func (*QueryAllPairsValConAddrByConsumerChainIDRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{20} + return fileDescriptor_422512d7b7586cd7, []int{13} } func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1125,7 +815,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) String() string { } func (*QueryAllPairsValConAddrByConsumerChainIDResponse) ProtoMessage() {} func (*QueryAllPairsValConAddrByConsumerChainIDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{21} + return fileDescriptor_422512d7b7586cd7, []int{14} } func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1173,7 +863,7 @@ func (m *PairValConAddrProviderAndConsumer) Reset() { *m = PairValConAdd func (m *PairValConAddrProviderAndConsumer) String() string { return proto.CompactTextString(m) } func (*PairValConAddrProviderAndConsumer) ProtoMessage() {} func (*PairValConAddrProviderAndConsumer) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{22} + return fileDescriptor_422512d7b7586cd7, []int{15} } func (m *PairValConAddrProviderAndConsumer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1230,7 +920,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{23} + return fileDescriptor_422512d7b7586cd7, []int{16} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1267,7 +957,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{24} + return fileDescriptor_422512d7b7586cd7, []int{17} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1317,7 +1007,7 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) String() string { } func (*QueryConsumerChainOptedInValidatorsRequest) ProtoMessage() {} func (*QueryConsumerChainOptedInValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{25} + return fileDescriptor_422512d7b7586cd7, []int{18} } func (m *QueryConsumerChainOptedInValidatorsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1374,7 +1064,7 @@ func (m *QueryConsumerChainOptedInValidatorsResponse) String() string { } func (*QueryConsumerChainOptedInValidatorsResponse) ProtoMessage() {} func (*QueryConsumerChainOptedInValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{26} + return fileDescriptor_422512d7b7586cd7, []int{19} } func (m *QueryConsumerChainOptedInValidatorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1420,7 +1110,7 @@ func (m *QueryConsumerValidatorsRequest) Reset() { *m = QueryConsumerVal func (m *QueryConsumerValidatorsRequest) String() string { return proto.CompactTextString(m) } func (*QueryConsumerValidatorsRequest) ProtoMessage() {} func (*QueryConsumerValidatorsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{27} + return fileDescriptor_422512d7b7586cd7, []int{20} } func (m *QueryConsumerValidatorsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1499,7 +1189,7 @@ func (m *QueryConsumerValidatorsValidator) Reset() { *m = QueryConsumerV func (m *QueryConsumerValidatorsValidator) String() string { return proto.CompactTextString(m) } func (*QueryConsumerValidatorsValidator) ProtoMessage() {} func (*QueryConsumerValidatorsValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{28} + return fileDescriptor_422512d7b7586cd7, []int{21} } func (m *QueryConsumerValidatorsValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1607,7 +1297,7 @@ func (m *QueryConsumerValidatorsResponse) Reset() { *m = QueryConsumerVa func (m *QueryConsumerValidatorsResponse) String() string { return proto.CompactTextString(m) } func (*QueryConsumerValidatorsResponse) ProtoMessage() {} func (*QueryConsumerValidatorsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{29} + return fileDescriptor_422512d7b7586cd7, []int{22} } func (m *QueryConsumerValidatorsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1656,7 +1346,7 @@ func (m *QueryConsumerChainsValidatorHasToValidateRequest) String() string { } func (*QueryConsumerChainsValidatorHasToValidateRequest) ProtoMessage() {} func (*QueryConsumerChainsValidatorHasToValidateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{30} + return fileDescriptor_422512d7b7586cd7, []int{23} } func (m *QueryConsumerChainsValidatorHasToValidateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1704,7 +1394,7 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) String() string { } func (*QueryConsumerChainsValidatorHasToValidateResponse) ProtoMessage() {} func (*QueryConsumerChainsValidatorHasToValidateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{31} + return fileDescriptor_422512d7b7586cd7, []int{24} } func (m *QueryConsumerChainsValidatorHasToValidateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1756,7 +1446,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) String() string { } func (*QueryValidatorConsumerCommissionRateRequest) ProtoMessage() {} func (*QueryValidatorConsumerCommissionRateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{32} + return fileDescriptor_422512d7b7586cd7, []int{25} } func (m *QueryValidatorConsumerCommissionRateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1820,7 +1510,7 @@ func (m *QueryValidatorConsumerCommissionRateResponse) String() string { } func (*QueryValidatorConsumerCommissionRateResponse) ProtoMessage() {} func (*QueryValidatorConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{33} + return fileDescriptor_422512d7b7586cd7, []int{26} } func (m *QueryValidatorConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1856,7 +1546,7 @@ func (m *QueryBlocksUntilNextEpochRequest) Reset() { *m = QueryBlocksUnt func (m *QueryBlocksUntilNextEpochRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlocksUntilNextEpochRequest) ProtoMessage() {} func (*QueryBlocksUntilNextEpochRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{34} + return fileDescriptor_422512d7b7586cd7, []int{27} } func (m *QueryBlocksUntilNextEpochRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1894,7 +1584,7 @@ func (m *QueryBlocksUntilNextEpochResponse) Reset() { *m = QueryBlocksUn func (m *QueryBlocksUntilNextEpochResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlocksUntilNextEpochResponse) ProtoMessage() {} func (*QueryBlocksUntilNextEpochResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{35} + return fileDescriptor_422512d7b7586cd7, []int{28} } func (m *QueryBlocksUntilNextEpochResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1940,7 +1630,7 @@ func (m *QueryConsumerIdFromClientIdRequest) Reset() { *m = QueryConsume func (m *QueryConsumerIdFromClientIdRequest) String() string { return proto.CompactTextString(m) } func (*QueryConsumerIdFromClientIdRequest) ProtoMessage() {} func (*QueryConsumerIdFromClientIdRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{36} + return fileDescriptor_422512d7b7586cd7, []int{29} } func (m *QueryConsumerIdFromClientIdRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1985,7 +1675,7 @@ func (m *QueryConsumerIdFromClientIdResponse) Reset() { *m = QueryConsum func (m *QueryConsumerIdFromClientIdResponse) String() string { return proto.CompactTextString(m) } func (*QueryConsumerIdFromClientIdResponse) ProtoMessage() {} func (*QueryConsumerIdFromClientIdResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{37} + return fileDescriptor_422512d7b7586cd7, []int{30} } func (m *QueryConsumerIdFromClientIdResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2029,7 +1719,7 @@ func (m *QueryConsumerChainRequest) Reset() { *m = QueryConsumerChainReq func (m *QueryConsumerChainRequest) String() string { return proto.CompactTextString(m) } func (*QueryConsumerChainRequest) ProtoMessage() {} func (*QueryConsumerChainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{38} + return fileDescriptor_422512d7b7586cd7, []int{31} } func (m *QueryConsumerChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2078,7 +1768,7 @@ func (m *QueryConsumerChainResponse) Reset() { *m = QueryConsumerChainRe func (m *QueryConsumerChainResponse) String() string { return proto.CompactTextString(m) } func (*QueryConsumerChainResponse) ProtoMessage() {} func (*QueryConsumerChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{39} + return fileDescriptor_422512d7b7586cd7, []int{32} } func (m *QueryConsumerChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2154,10 +1844,6 @@ func init() { proto.RegisterType((*QueryConsumerGenesisResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerGenesisResponse") proto.RegisterType((*QueryConsumerChainsRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainsRequest") proto.RegisterType((*QueryConsumerChainsResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainsResponse") - proto.RegisterType((*QueryConsumerChainStartProposalsRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainStartProposalsRequest") - proto.RegisterType((*QueryConsumerChainStartProposalsResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainStartProposalsResponse") - proto.RegisterType((*QueryConsumerChainStopProposalsRequest)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainStopProposalsRequest") - proto.RegisterType((*QueryConsumerChainStopProposalsResponse)(nil), "interchain_security.ccv.provider.v1.QueryConsumerChainStopProposalsResponse") proto.RegisterType((*Chain)(nil), "interchain_security.ccv.provider.v1.Chain") proto.RegisterType((*QueryValidatorConsumerAddrRequest)(nil), "interchain_security.ccv.provider.v1.QueryValidatorConsumerAddrRequest") proto.RegisterType((*QueryValidatorConsumerAddrResponse)(nil), "interchain_security.ccv.provider.v1.QueryValidatorConsumerAddrResponse") @@ -2167,9 +1853,6 @@ func init() { proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateResponse") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsRequest)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsRequest") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsResponse") - proto.RegisterType((*QueryProposedChainIDsRequest)(nil), "interchain_security.ccv.provider.v1.QueryProposedChainIDsRequest") - proto.RegisterType((*QueryProposedChainIDsResponse)(nil), "interchain_security.ccv.provider.v1.QueryProposedChainIDsResponse") - proto.RegisterType((*ProposedChain)(nil), "interchain_security.ccv.provider.v1.ProposedChain") proto.RegisterType((*QueryAllPairsValConAddrByConsumerChainIDRequest)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDRequest") proto.RegisterType((*QueryAllPairsValConAddrByConsumerChainIDResponse)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDResponse") proto.RegisterType((*PairValConAddrProviderAndConsumer)(nil), "interchain_security.ccv.provider.v1.PairValConAddrProviderAndConsumer") @@ -2197,175 +1880,159 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4b, 0x6c, 0xdc, 0xc6, - 0xf9, 0x17, 0xf5, 0xf2, 0x6a, 0x64, 0x29, 0xc9, 0x58, 0xb6, 0xd7, 0x2b, 0x59, 0x2b, 0xd3, 0xf1, - 0xff, 0x2f, 0xbf, 0x76, 0x25, 0x05, 0x6e, 0x62, 0x27, 0x7e, 0x68, 0x57, 0x96, 0xbd, 0xf0, 0x4b, - 0xa1, 0x64, 0xa7, 0x50, 0xea, 0xd2, 0x14, 0x39, 0x59, 0xb1, 0xe2, 0x92, 0x14, 0x67, 0xb4, 0xf6, - 0xd6, 0xf5, 0x21, 0x2d, 0x50, 0xb8, 0x3d, 0x14, 0x2e, 0x8a, 0xde, 0x83, 0x02, 0x05, 0x7a, 0xe8, - 0xa9, 0x08, 0x5a, 0xf4, 0x96, 0x63, 0x6e, 0x4d, 0x93, 0x4b, 0xd1, 0xa2, 0x6e, 0x61, 0xf7, 0xd0, - 0x16, 0x28, 0x50, 0xa4, 0xbd, 0x16, 0x28, 0x38, 0x33, 0xe4, 0x92, 0x5c, 0xae, 0x96, 0xdc, 0xd5, - 0xa1, 0x37, 0x71, 0xe6, 0x9b, 0xdf, 0xf7, 0x98, 0x6f, 0xbe, 0xf9, 0xe6, 0xb7, 0x02, 0x45, 0xdd, - 0x24, 0xc8, 0x51, 0x37, 0x15, 0xdd, 0x94, 0x31, 0x52, 0x77, 0x1c, 0x9d, 0x34, 0x8a, 0xaa, 0x5a, - 0x2f, 0xda, 0x8e, 0x55, 0xd7, 0x35, 0xe4, 0x14, 0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, 0x4d, 0x77, 0x0f, 0x62, 0x13, 0xba, 0x09, 0x28, 0xce, 0x82, - 0xff, 0x8b, 0xb3, 0xc4, 0xb2, 0x5b, 0x8c, 0xfe, 0xae, 0x10, 0xef, 0x60, 0x48, 0xd4, 0xcf, 0xa4, - 0x16, 0x9b, 0x2f, 0xa6, 0xb2, 0x59, 0x42, 0x35, 0xab, 0xae, 0x18, 0xb1, 0x26, 0x3f, 0x1d, 0x04, - 0x43, 0x54, 0x37, 0x3c, 0x12, 0x3d, 0x10, 0xcd, 0xc3, 0x30, 0x09, 0x46, 0x54, 0x43, 0x47, 0x26, - 0x69, 0x1e, 0x85, 0x0c, 0x1b, 0xa8, 0x68, 0xf0, 0x00, 0x18, 0x22, 0x96, 0x2d, 0xdf, 0xce, 0x0e, - 0xcc, 0x08, 0xb3, 0x63, 0xd2, 0x20, 0xb1, 0xec, 0xdb, 0xf0, 0x14, 0x80, 0x35, 0xdd, 0x94, 0x6d, - 0xeb, 0xa1, 0x7b, 0x7e, 0x4c, 0x99, 0x49, 0x0c, 0xce, 0x08, 0xb3, 0x03, 0xd2, 0x78, 0x4d, 0x37, - 0x57, 0xdc, 0x89, 0x8a, 0xb9, 0xe6, 0xca, 0xce, 0x81, 0x89, 0xba, 0x62, 0xe8, 0x9a, 0x42, 0x2c, - 0x07, 0xf3, 0x25, 0xaa, 0x62, 0x67, 0x87, 0x28, 0x1e, 0x6c, 0xce, 0xd1, 0x45, 0x65, 0xc5, 0x86, - 0xa7, 0xc0, 0x6b, 0xfe, 0xa8, 0x8c, 0x11, 0xa1, 0xe2, 0xc3, 0x54, 0xfc, 0x15, 0x7f, 0x62, 0x15, - 0x11, 0x57, 0x76, 0x0a, 0x8c, 0x28, 0x86, 0x61, 0x3d, 0x34, 0x74, 0x4c, 0xb2, 0xfb, 0x66, 0x06, - 0x66, 0x47, 0xa4, 0xe6, 0x00, 0xcc, 0x81, 0x8c, 0x86, 0xcc, 0x06, 0x9d, 0xcc, 0xd0, 0x49, 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, 0x0a, 0xca, 0x75, 0x17, 0x52, - 0x2d, 0xb7, 0xdc, 0x2b, 0x4c, 0xfa, 0x06, 0xb9, 0x0d, 0x3f, 0x07, 0xff, 0x25, 0x44, 0xfe, 0x5f, - 0x2c, 0xcc, 0xa0, 0xc1, 0x6b, 0xe9, 0x37, 0x3a, 0x96, 0xc6, 0xcb, 0x5d, 0xef, 0x1d, 0x28, 0xbd, - 0xd7, 0x81, 0xe4, 0x28, 0x3e, 0xf6, 0x59, 0xc4, 0x27, 0xf0, 0x8f, 0xde, 0xb3, 0x20, 0x54, 0x42, - 0xd3, 0x3c, 0x0b, 0xe2, 0x88, 0xc2, 0xdc, 0xe5, 0xae, 0xd7, 0x73, 0xd7, 0x96, 0xa9, 0x6b, 0x57, - 0xe0, 0xa5, 0xb4, 0x45, 0x3a, 0x7c, 0x0e, 0x4a, 0xef, 0x7d, 0xfa, 0x62, 0x5a, 0xf8, 0xec, 0xc5, - 0xb4, 0xf0, 0xe7, 0x17, 0xd3, 0xc2, 0xb3, 0x97, 0xd3, 0x7d, 0x9f, 0xbd, 0x9c, 0xee, 0xfb, 0xdd, - 0xcb, 0xe9, 0xbe, 0xf5, 0x8b, 0x55, 0x9d, 0x6c, 0xee, 0x6c, 0x14, 0x54, 0xab, 0xc6, 0xff, 0x6f, - 0x33, 0xa0, 0xea, 0xac, 0xaf, 0xaa, 0x7e, 0xae, 0xf8, 0x28, 0xf2, 0x0c, 0x69, 0xd8, 0x08, 0x6f, - 0x0c, 0xd3, 0xff, 0xe5, 0x78, 0xe3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb4, 0xb1, 0x32, 0xd1, - 0x57, 0x2b, 0x00, 0x00, + // 2428 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x14, 0xc9, + 0xf5, 0x77, 0xfb, 0x8b, 0x71, 0x19, 0xcc,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, 0x5d, 0x88, 0x44, 0x35, 0x2f, + 0x6a, 0x8f, 0x12, 0x95, 0x79, 0xcb, 0xc3, 0x74, 0x7d, 0x94, 0xff, 0x8c, 0xfb, 0xe6, 0x7f, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x94, 0xed, 0x31, 0x2a, 0xe9, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2386,10 +2053,6 @@ type QueryClient interface { // ConsumerChains queries active consumer chains supported by the provider // chain QueryConsumerChains(ctx context.Context, in *QueryConsumerChainsRequest, opts ...grpc.CallOption) (*QueryConsumerChainsResponse, error) - // QueryConsumerChainStarts queries consumer chain start proposals. - QueryConsumerChainStarts(ctx context.Context, in *QueryConsumerChainStartProposalsRequest, opts ...grpc.CallOption) (*QueryConsumerChainStartProposalsResponse, error) - // QueryConsumerChainStops queries consumer chain stop proposals. - QueryConsumerChainStops(ctx context.Context, in *QueryConsumerChainStopProposalsRequest, opts ...grpc.CallOption) (*QueryConsumerChainStopProposalsResponse, error) // QueryValidatorConsumerAddr queries the address // assigned by a validator for a consumer chain. QueryValidatorConsumerAddr(ctx context.Context, in *QueryValidatorConsumerAddrRequest, opts ...grpc.CallOption) (*QueryValidatorConsumerAddrResponse, error) @@ -2402,9 +2065,6 @@ type QueryClient interface { // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) - // QueryProposedConsumerChainIDs returns the chain IDs of the proposed consumer chain addition proposals - // that are still in the voting period - QueryProposedConsumerChainIDs(ctx context.Context, in *QueryProposedChainIDsRequest, opts ...grpc.CallOption) (*QueryProposedChainIDsResponse, error) // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address // between provider and consumer chain QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, in *QueryAllPairsValConAddrByConsumerChainIDRequest, opts ...grpc.CallOption) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) @@ -2460,24 +2120,6 @@ func (c *queryClient) QueryConsumerChains(ctx context.Context, in *QueryConsumer return out, nil } -func (c *queryClient) QueryConsumerChainStarts(ctx context.Context, in *QueryConsumerChainStartProposalsRequest, opts ...grpc.CallOption) (*QueryConsumerChainStartProposalsResponse, error) { - out := new(QueryConsumerChainStartProposalsResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryConsumerChainStarts", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryConsumerChainStops(ctx context.Context, in *QueryConsumerChainStopProposalsRequest, opts ...grpc.CallOption) (*QueryConsumerChainStopProposalsResponse, error) { - out := new(QueryConsumerChainStopProposalsResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryConsumerChainStops", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) QueryValidatorConsumerAddr(ctx context.Context, in *QueryValidatorConsumerAddrRequest, opts ...grpc.CallOption) (*QueryValidatorConsumerAddrResponse, error) { out := new(QueryValidatorConsumerAddrResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryValidatorConsumerAddr", in, out, opts...) @@ -2514,15 +2156,6 @@ func (c *queryClient) QueryRegisteredConsumerRewardDenoms(ctx context.Context, i return out, nil } -func (c *queryClient) QueryProposedConsumerChainIDs(ctx context.Context, in *QueryProposedChainIDsRequest, opts ...grpc.CallOption) (*QueryProposedChainIDsResponse, error) { - out := new(QueryProposedChainIDsResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryProposedConsumerChainIDs", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, in *QueryAllPairsValConAddrByConsumerChainIDRequest, opts ...grpc.CallOption) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) { out := new(QueryAllPairsValConAddrByConsumerChainIDResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryAllPairsValConAddrByConsumerChainID", in, out, opts...) @@ -2612,10 +2245,6 @@ type QueryServer interface { // ConsumerChains queries active consumer chains supported by the provider // chain QueryConsumerChains(context.Context, *QueryConsumerChainsRequest) (*QueryConsumerChainsResponse, error) - // QueryConsumerChainStarts queries consumer chain start proposals. - QueryConsumerChainStarts(context.Context, *QueryConsumerChainStartProposalsRequest) (*QueryConsumerChainStartProposalsResponse, error) - // QueryConsumerChainStops queries consumer chain stop proposals. - QueryConsumerChainStops(context.Context, *QueryConsumerChainStopProposalsRequest) (*QueryConsumerChainStopProposalsResponse, error) // QueryValidatorConsumerAddr queries the address // assigned by a validator for a consumer chain. QueryValidatorConsumerAddr(context.Context, *QueryValidatorConsumerAddrRequest) (*QueryValidatorConsumerAddrResponse, error) @@ -2628,9 +2257,6 @@ type QueryServer interface { // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(context.Context, *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) - // QueryProposedConsumerChainIDs returns the chain IDs of the proposed consumer chain addition proposals - // that are still in the voting period - QueryProposedConsumerChainIDs(context.Context, *QueryProposedChainIDsRequest) (*QueryProposedChainIDsResponse, error) // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address // between provider and consumer chain QueryAllPairsValConAddrByConsumerChainID(context.Context, *QueryAllPairsValConAddrByConsumerChainIDRequest) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) @@ -2670,12 +2296,6 @@ func (*UnimplementedQueryServer) QueryConsumerGenesis(ctx context.Context, req * func (*UnimplementedQueryServer) QueryConsumerChains(ctx context.Context, req *QueryConsumerChainsRequest) (*QueryConsumerChainsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerChains not implemented") } -func (*UnimplementedQueryServer) QueryConsumerChainStarts(ctx context.Context, req *QueryConsumerChainStartProposalsRequest) (*QueryConsumerChainStartProposalsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerChainStarts not implemented") -} -func (*UnimplementedQueryServer) QueryConsumerChainStops(ctx context.Context, req *QueryConsumerChainStopProposalsRequest) (*QueryConsumerChainStopProposalsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryConsumerChainStops not implemented") -} func (*UnimplementedQueryServer) QueryValidatorConsumerAddr(ctx context.Context, req *QueryValidatorConsumerAddrRequest) (*QueryValidatorConsumerAddrResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryValidatorConsumerAddr not implemented") } @@ -2688,9 +2308,6 @@ func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *Qu func (*UnimplementedQueryServer) QueryRegisteredConsumerRewardDenoms(ctx context.Context, req *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryRegisteredConsumerRewardDenoms not implemented") } -func (*UnimplementedQueryServer) QueryProposedConsumerChainIDs(ctx context.Context, req *QueryProposedChainIDsRequest) (*QueryProposedChainIDsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryProposedConsumerChainIDs not implemented") -} func (*UnimplementedQueryServer) QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, req *QueryAllPairsValConAddrByConsumerChainIDRequest) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAllPairsValConAddrByConsumerChainID not implemented") } @@ -2759,42 +2376,6 @@ func _Query_QueryConsumerChains_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } -func _Query_QueryConsumerChainStarts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryConsumerChainStartProposalsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryConsumerChainStarts(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryConsumerChainStarts", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryConsumerChainStarts(ctx, req.(*QueryConsumerChainStartProposalsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryConsumerChainStops_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryConsumerChainStopProposalsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryConsumerChainStops(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryConsumerChainStops", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryConsumerChainStops(ctx, req.(*QueryConsumerChainStopProposalsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_QueryValidatorConsumerAddr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryValidatorConsumerAddrRequest) if err := dec(in); err != nil { @@ -2867,24 +2448,6 @@ func _Query_QueryRegisteredConsumerRewardDenoms_Handler(srv interface{}, ctx con return interceptor(ctx, in, info, handler) } -func _Query_QueryProposedConsumerChainIDs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProposedChainIDsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryProposedConsumerChainIDs(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryProposedConsumerChainIDs", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryProposedConsumerChainIDs(ctx, req.(*QueryProposedChainIDsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_QueryAllPairsValConAddrByConsumerChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryAllPairsValConAddrByConsumerChainIDRequest) if err := dec(in); err != nil { @@ -3059,14 +2622,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryConsumerChains", Handler: _Query_QueryConsumerChains_Handler, }, - { - MethodName: "QueryConsumerChainStarts", - Handler: _Query_QueryConsumerChainStarts_Handler, - }, - { - MethodName: "QueryConsumerChainStops", - Handler: _Query_QueryConsumerChainStops_Handler, - }, { MethodName: "QueryValidatorConsumerAddr", Handler: _Query_QueryValidatorConsumerAddr_Handler, @@ -3083,10 +2638,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryRegisteredConsumerRewardDenoms", Handler: _Query_QueryRegisteredConsumerRewardDenoms_Handler, }, - { - MethodName: "QueryProposedConsumerChainIDs", - Handler: _Query_QueryProposedConsumerChainIDs_Handler, - }, { MethodName: "QueryAllPairsValConAddrByConsumerChainID", Handler: _Query_QueryAllPairsValConAddrByConsumerChainID_Handler, @@ -3268,122 +2819,6 @@ func (m *QueryConsumerChainsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryConsumerChainStartProposalsRequest) 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 *QueryConsumerChainStartProposalsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryConsumerChainStartProposalsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryConsumerChainStartProposalsResponse) 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 *QueryConsumerChainStartProposalsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryConsumerChainStartProposalsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proposals != nil { - { - size, err := m.Proposals.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 *QueryConsumerChainStopProposalsRequest) 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 *QueryConsumerChainStopProposalsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryConsumerChainStopProposalsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryConsumerChainStopProposalsResponse) 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 *QueryConsumerChainStopProposalsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryConsumerChainStopProposalsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Proposals != nil { - { - size, err := m.Proposals.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 *Chain) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3680,12 +3115,12 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.NextReplenishCandidate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate):]) - if err5 != nil { - return 0, err5 + n3, err3 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.NextReplenishCandidate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate):]) + if err3 != nil { + return 0, err3 } - i -= n5 - i = encodeVarintQuery(dAtA, i, uint64(n5)) + i -= n3 + i = encodeVarintQuery(dAtA, i, uint64(n3)) i-- dAtA[i] = 0x1a if m.SlashMeterAllowance != 0 { @@ -3756,108 +3191,6 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA return len(dAtA) - i, nil } -func (m *QueryProposedChainIDsRequest) 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 *QueryProposedChainIDsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryProposedChainIDsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryProposedChainIDsResponse) 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 *QueryProposedChainIDsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryProposedChainIDsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ProposedChains) > 0 { - for iNdEx := len(m.ProposedChains) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ProposedChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ProposedChain) 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 *ProposedChain) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ProposedChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) - i-- - dAtA[i] = 0x1a - } - if m.ProposalID != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProposalID)) - 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 *QueryAllPairsValConAddrByConsumerChainIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -4746,63 +4079,19 @@ func (m *QueryConsumerChainsResponse) Size() (n int) { return n } -func (m *QueryConsumerChainStartProposalsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryConsumerChainStartProposalsResponse) Size() (n int) { +func (m *Chain) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Proposals != nil { - l = m.Proposals.Size() + l = len(m.ChainId) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - return n -} - -func (m *QueryConsumerChainStopProposalsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryConsumerChainStopProposalsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Proposals != nil { - l = m.Proposals.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *Chain) 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)) - } - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } if m.Top_N != 0 { n += 1 + sovQuery(uint64(m.Top_N)) @@ -4960,50 +4249,6 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) Size() (n int) { return n } -func (m *QueryProposedChainIDsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryProposedChainIDsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ProposedChains) > 0 { - for _, e := range m.ProposedChains { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *ProposedChain) 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.ProposalID != 0 { - n += 1 + sovQuery(uint64(m.ProposalID)) - } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Size() (n int) { if m == nil { return 0 @@ -5655,285 +4900,15 @@ func (m *QueryConsumerChainsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryConsumerChainsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Chains", 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.Chains = append(m.Chains, &Chain{}) - if err := m.Chains[len(m.Chains)-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 *QueryConsumerChainStartProposalsRequest) 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: QueryConsumerChainStartProposalsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainStartProposalsRequest: 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 *QueryConsumerChainStartProposalsResponse) 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: QueryConsumerChainStartProposalsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainStartProposalsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposals", 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.Proposals == nil { - m.Proposals = &ConsumerAdditionProposals{} - } - if err := m.Proposals.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 *QueryConsumerChainStopProposalsRequest) 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: QueryConsumerChainStopProposalsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainStopProposalsRequest: 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 *QueryConsumerChainStopProposalsResponse) 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: QueryConsumerChainStopProposalsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryConsumerChainsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryConsumerChainStopProposalsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryConsumerChainsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proposals", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Chains", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5960,10 +4935,8 @@ func (m *QueryConsumerChainStopProposalsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Proposals == nil { - m.Proposals = &ConsumerRemovalProposals{} - } - if err := m.Proposals.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Chains = append(m.Chains, &Chain{}) + if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7092,273 +6065,6 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) Unmarshal(dAtA []byte) err } return nil } -func (m *QueryProposedChainIDsRequest) 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: QueryProposedChainIDsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposedChainIDsRequest: 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 *QueryProposedChainIDsResponse) 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: QueryProposedChainIDsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProposedChainIDsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposedChains", 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.ProposedChains = append(m.ProposedChains, ProposedChain{}) - if err := m.ProposedChains[len(m.ProposedChains)-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 *ProposedChain) 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: ProposedChain: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ProposedChain: 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 ProposalID", wireType) - } - m.ProposalID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProposalID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = 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 *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 80e0b6025d..543fc6e8bc 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -213,42 +213,6 @@ func local_request_Query_QueryConsumerChains_0(ctx context.Context, marshaler ru } -func request_Query_QueryConsumerChainStarts_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainStartProposalsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryConsumerChainStarts(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryConsumerChainStarts_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainStartProposalsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryConsumerChainStarts(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryConsumerChainStops_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainStopProposalsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryConsumerChainStops(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryConsumerChainStops_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainStopProposalsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryConsumerChainStops(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_QueryValidatorConsumerAddr_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -357,24 +321,6 @@ func local_request_Query_QueryRegisteredConsumerRewardDenoms_0(ctx context.Conte } -func request_Query_QueryProposedConsumerChainIDs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProposedChainIDsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryProposedConsumerChainIDs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryProposedConsumerChainIDs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProposedChainIDsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryProposedConsumerChainIDs(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_QueryAllPairsValConAddrByConsumerChainID_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -1268,52 +1214,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryConsumerChainStarts_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_QueryConsumerChainStarts_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_QueryConsumerChainStarts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryConsumerChainStops_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_QueryConsumerChainStops_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_QueryConsumerChainStops_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryValidatorConsumerAddr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1406,29 +1306,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryProposedConsumerChainIDs_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_QueryProposedConsumerChainIDs_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_QueryProposedConsumerChainIDs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1829,46 +1706,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryConsumerChainStarts_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_QueryConsumerChainStarts_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_QueryConsumerChainStarts_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryConsumerChainStops_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_QueryConsumerChainStops_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_QueryConsumerChainStops_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryValidatorConsumerAddr_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1949,26 +1786,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryProposedConsumerChainIDs_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_QueryProposedConsumerChainIDs_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_QueryProposedConsumerChainIDs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -2239,10 +2056,6 @@ var ( pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chains"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryConsumerChainStarts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chain_start_proposals"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryConsumerChainStops_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chain_stop_proposals"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryValidatorConsumerAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "validator_consumer_addr"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryValidatorProviderAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "validator_provider_addr"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2251,8 +2064,6 @@ var ( 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))) - pattern_Query_QueryProposedConsumerChainIDs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "proposed_consumer_chains"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2287,10 +2098,6 @@ var ( forward_Query_QueryConsumerChains_0 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerChainStarts_0 = runtime.ForwardResponseMessage - - forward_Query_QueryConsumerChainStops_0 = runtime.ForwardResponseMessage - forward_Query_QueryValidatorConsumerAddr_0 = runtime.ForwardResponseMessage forward_Query_QueryValidatorProviderAddr_0 = runtime.ForwardResponseMessage @@ -2299,8 +2106,6 @@ var ( forward_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.ForwardResponseMessage - forward_Query_QueryProposedConsumerChainIDs_0 = runtime.ForwardResponseMessage - forward_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.ForwardResponseMessage forward_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.ForwardResponseMessage From 43ecf100aa0ef662987e5642c079c1260e8cfeb7 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 10:58:30 +0200 Subject: [PATCH 16/43] feat: update `consumer_chains` REST endpoint (#2188) update consumer chains REST endpoint --- .../ccv/provider/v1/query.proto | 2 +- x/ccv/provider/types/query.pb.go | 307 +++++++++--------- x/ccv/provider/types/query.pb.gw.go | 72 +++- 3 files changed, 214 insertions(+), 167 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 51d49d1313..b9226cb5f5 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -32,7 +32,7 @@ service Query { rpc QueryConsumerChains(QueryConsumerChainsRequest) returns (QueryConsumerChainsResponse) { option (google.api.http).get = - "/interchain_security/ccv/provider/consumer_chains"; + "/interchain_security/ccv/provider/consumer_chains/{phase}/{limit}"; } // QueryValidatorConsumerAddr queries the address diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 5a1a2a4e15..be3b8b2313 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -1880,159 +1880,160 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2428 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x14, 0xc9, - 0xf5, 0x77, 0xfb, 0x8b, 0x71, 0x19, 0xcc, 0x52, 0x18, 0x18, 0xc6, 0xe0, 0x31, 0xcd, 0x22, 0x79, - 0xf9, 0x98, 0xb6, 0xbd, 0xe2, 0xbf, 0x0b, 0xfb, 0x67, 0xc1, 0x33, 0x60, 0x18, 0x91, 0x05, 0x6f, - 0xdb, 0xb0, 0x91, 0x57, 0xa4, 0xb7, 0xdc, 0x5d, 0x3b, 0xae, 0xb8, 0xa7, 0xbb, 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 0x9f, 0x0d, 0xa5, 0x4d, 0x5d, 0x22, 0xe9, 0x3b, 0x0c, - 0x2a, 0x4e, 0x83, 0x03, 0xee, 0x43, 0x27, 0x19, 0x48, 0xfa, 0x7e, 0xbe, 0x18, 0x46, 0xcc, 0x64, - 0xd8, 0xd7, 0x8b, 0x58, 0x49, 0xe9, 0xd1, 0x87, 0xf7, 0xb2, 0x47, 0xff, 0x18, 0x8c, 0x13, 0x87, - 0x30, 0x43, 0x96, 0x6d, 0x23, 0x1c, 0xfb, 0x46, 0x57, 0xd8, 0x55, 0x87, 0x30, 0x82, 0x6c, 0xf2, - 0x1d, 0x3e, 0x9a, 0xe4, 0xc5, 0x5c, 0xd0, 0x29, 0x51, 0x1d, 0x04, 0xc8, 0xa2, 0xb8, 0x83, 0x75, - 0x30, 0x29, 0x66, 0x27, 0x74, 0x03, 0x79, 0xc4, 0xa9, 0x85, 0x02, 0x47, 0xb9, 0xc0, 0x77, 0xb2, - 0xd5, 0x89, 0x01, 0xc0, 0x8a, 0xe0, 0xef, 0x10, 0x03, 0xbd, 0xe4, 0x3a, 0x5d, 0xf8, 0x4f, 0x11, - 0x8c, 0xf0, 0x43, 0x82, 0xbf, 0x18, 0x04, 0x93, 0x69, 0x13, 0x3a, 0x78, 0xad, 0xfb, 0x8c, 0x1a, - 0x9f, 0x1d, 0x16, 0x16, 0xfb, 0x40, 0x10, 0xd1, 0xa2, 0xfe, 0x50, 0xf9, 0xde, 0x57, 0x7f, 0xfb, - 0xc9, 0xe0, 0xf7, 0x95, 0xb5, 0x32, 0xbc, 0xb6, 0xfb, 0x04, 0x39, 0x8a, 0x4c, 0x39, 0x06, 0xd4, - 0x1e, 0x77, 0xc4, 0xea, 0x13, 0x78, 0xa5, 0x27, 0x04, 0x19, 0xad, 0x4f, 0xe0, 0x57, 0x8a, 0xac, - 0xea, 0xe3, 0xe9, 0x19, 0x5e, 0xed, 0xde, 0xce, 0xd8, 0x24, 0xb2, 0x70, 0xad, 0x77, 0x00, 0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7e, 0xbd, 0x3f, 0x90, 0xde, 0x72, - 0x40, 0xe4, 0x8c, 0x7e, 0x72, 0x40, 0x3a, 0x48, 0x94, 0x03, 0xfe, 0xa1, 0xc8, 0xc6, 0x38, 0xad, - 0xff, 0x87, 0x5d, 0x4c, 0xa0, 0x76, 0x98, 0x31, 0x14, 0x96, 0xfa, 0x85, 0xe9, 0xbe, 0x66, 0xdc, - 0x66, 0x5c, 0x01, 0xff, 0xa5, 0x24, 0xfe, 0x83, 0x21, 0x3e, 0x50, 0x80, 0x37, 0xbb, 0x3f, 0xe8, - 0xd4, 0xa9, 0x46, 0xe1, 0x56, 0xff, 0x40, 0xdd, 0x5b, 0xdd, 0x11, 0x1c, 0xda, 0xe3, 0x68, 0xa8, - 0xf2, 0x04, 0xfe, 0x39, 0xac, 0x94, 0x63, 0x29, 0xb4, 0x9b, 0x4a, 0x39, 0x6d, 0x6e, 0x52, 0xb8, - 0xda, 0x33, 0xbf, 0x34, 0x6d, 0x89, 0x9b, 0x76, 0x0d, 0xbe, 0xdb, 0x6d, 0x92, 0x8e, 0xdf, 0x83, - 0xf2, 0x07, 0x9f, 0xbf, 0x98, 0x56, 0xbe, 0x78, 0x31, 0xad, 0xfc, 0xf5, 0xc5, 0xb4, 0xf2, 0xec, - 0xe5, 0xf4, 0xc0, 0x17, 0x2f, 0xa7, 0x07, 0xfe, 0xf0, 0x72, 0x7a, 0x60, 0xed, 0x4a, 0x8d, 0xb0, - 0x8d, 0xc6, 0x7a, 0xc9, 0x74, 0xeb, 0xf2, 0x3f, 0x89, 0x3a, 0x44, 0x5d, 0x88, 0x44, 0x35, 0x2f, - 0x6a, 0x8f, 0x12, 0x95, 0x79, 0xcb, 0xc3, 0x74, 0x7d, 0x94, 0xff, 0x8c, 0xfb, 0xe6, 0x7f, 0x03, - 0x00, 0x00, 0xff, 0xff, 0x94, 0xed, 0x31, 0x2a, 0xe9, 0x25, 0x00, 0x00, + // 2436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x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75, 0x98, 0x3e, 0x16, 0x62, 0x2c, 0x73, 0x88, 0x20, 0x74, 0x22, 0x54, + 0x11, 0x3a, 0x47, 0x44, 0xe8, 0x84, 0xab, 0x22, 0x74, 0xbe, 0x0e, 0x4e, 0xc9, 0xcb, 0x8d, 0xa9, + 0x61, 0x6e, 0xfa, 0x7e, 0xd0, 0x7f, 0x60, 0xcf, 0x35, 0xd7, 0xf2, 0x63, 0xdc, 0xc2, 0x13, 0xd1, + 0x76, 0x45, 0xec, 0xde, 0x0e, 0x36, 0xd5, 0x67, 0x0a, 0x28, 0xee, 0x7a, 0xed, 0x65, 0x76, 0xc1, + 0x00, 0xb4, 0x12, 0x87, 0x7c, 0xd5, 0x6e, 0x67, 0xca, 0xa4, 0xfb, 0xdd, 0x76, 0xbd, 0x0d, 0x58, + 0xdd, 0x90, 0xef, 0x6e, 0xbc, 0x7f, 0x8b, 0x68, 0xef, 0x22, 0xba, 0xec, 0xca, 0xaf, 0xb0, 0xd0, + 0xea, 0x31, 0x5b, 0xa8, 0x08, 0xcc, 0x76, 0x20, 0x52, 0xba, 0xe3, 0x32, 0x80, 0xad, 0x5b, 0x2a, + 0xf3, 0x61, 0x98, 0x61, 0xa3, 0x47, 0x52, 0x14, 0x08, 0x16, 0xaf, 0x93, 0x2f, 0xa5, 0x57, 0xde, + 0xf1, 0xeb, 0xf3, 0xff, 0xd1, 0x31, 0xa8, 0x35, 0x70, 0x39, 0x9b, 0xb6, 0xd2, 0x19, 0x6f, 0xca, + 0xa4, 0xa8, 0x64, 0xcf, 0x1f, 0x9c, 0x41, 0x55, 0xe5, 0x5b, 0x50, 0xb6, 0x5d, 0x73, 0x9d, 0x3e, + 0x74, 0x18, 0xb1, 0xef, 0xe3, 0xa7, 0x22, 0x2a, 0xc3, 0x57, 0x7d, 0x45, 0xb6, 0x18, 0xe9, 0x34, + 0x52, 0x83, 0xab, 0xe0, 0xd4, 0x2a, 0xdf, 0x37, 0x36, 0x03, 0x02, 0x83, 0x17, 0xc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, 0x9e, 0xbf, 0x9a, 0xec, 0xfb, 0xe2, 0xd5, 0x64, 0xdf, 0x9f, + 0x5e, 0x4d, 0xf6, 0xad, 0x5c, 0xaf, 0x11, 0xb6, 0xb6, 0xb9, 0x5a, 0x32, 0xdd, 0xba, 0xfc, 0xcf, + 0xa2, 0x36, 0x51, 0x57, 0x22, 0x51, 0x8d, 0xab, 0xda, 0xd3, 0x44, 0x65, 0xde, 0xf4, 0x30, 0x5d, + 0x1d, 0xe6, 0x3f, 0xeb, 0x7e, 0xed, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x6f, 0x00, 0x0a, + 0xf9, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 543fc6e8bc..3c09d0caac 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -177,19 +177,40 @@ func local_request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler r } -var ( - filter_Query_QueryConsumerChains_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Query_QueryConsumerChains_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerChainsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["phase"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "phase") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChains_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + e, err = runtime.Enum(val, ConsumerPhase_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "phase", err) + } + + protoReq.Phase = ConsumerPhase(e) + + val, ok = pathParams["limit"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "limit") + } + + protoReq.Limit, err = runtime.Int32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "limit", err) } msg, err := client.QueryConsumerChains(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -201,11 +222,36 @@ func local_request_Query_QueryConsumerChains_0(ctx context.Context, marshaler ru var protoReq QueryConsumerChainsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + e int32 + ok bool + err error + _ = err + ) + + val, ok = pathParams["phase"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "phase") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChains_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + e, err = runtime.Enum(val, ConsumerPhase_value) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "phase", err) + } + + protoReq.Phase = ConsumerPhase(e) + + val, ok = pathParams["limit"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "limit") + } + + protoReq.Limit, err = runtime.Int32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "limit", err) } msg, err := server.QueryConsumerChains(ctx, &protoReq) @@ -2054,7 +2100,7 @@ var ( pattern_Query_QueryConsumerGenesis_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "consumer_chains"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_chains", "phase", "limit"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryValidatorConsumerAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "validator_consumer_addr"}, "", runtime.AssumeColonVerbOpt(false))) From 29b1bf4d694081d9ee8a29b880c5c61aaebb55b4 Mon Sep 17 00:00:00 2001 From: bernd-m <43466467+bermuell@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:11:39 +0200 Subject: [PATCH 17/43] fix: permissionless added event + cli changes (#2185) * add consumer registration event * fix some queries, CLI and permissionless logic * cli changes * addressed review comments --- x/ccv/provider/client/cli/query.go | 12 ++--- x/ccv/provider/client/cli/tx.go | 80 ++++++++--------------------- x/ccv/provider/keeper/grpc_query.go | 2 +- x/ccv/provider/keeper/msg_server.go | 6 +++ x/ccv/types/events.go | 2 + 5 files changed, 37 insertions(+), 65 deletions(-) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index fd5d5d7762..1d6e26350b 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -46,8 +46,8 @@ func NewQueryCmd() *cobra.Command { // parameters managed by the x/params module. func CmdConsumerGenesis() *cobra.Command { cmd := &cobra.Command{ - Use: "consumer-genesis [chainid]", - Short: "Query for consumer chain genesis state by chain id", + Use: "consumer-genesis [consumer-id]", + Short: "Query for consumer chain genesis state by consumer id", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -170,12 +170,12 @@ $ %s query provider validator-consumer-key foochain %s1gghjut3ccd8ay0zduzj64hwre func CmdProviderValidatorKey() *cobra.Command { bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() cmd := &cobra.Command{ - Use: "validator-provider-key [chainid] [consumer-validator-address]", + Use: "validator-provider-key [consumer-id] [consumer-validator-address]", Short: "Query validator consensus public key for the provider chain", Long: strings.TrimSpace( fmt.Sprintf(`Returns the currently assigned validator consensus public key for the provider chain. Example: -$ %s query provider validator-provider-key foochain %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj +$ %s query provider validator-provider-key 333 %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj `, version.AppName, bech32PrefixConsAddr, ), @@ -188,7 +188,7 @@ $ %s query provider validator-provider-key foochain %s1gghjut3ccd8ay0zduzj64hwre } queryClient := types.NewQueryClient(clientCtx) - consumerChainID := args[0] + consumerID := args[0] addr, err := sdk.ConsAddressFromBech32(args[1]) if err != nil { @@ -196,7 +196,7 @@ $ %s query provider validator-provider-key foochain %s1gghjut3ccd8ay0zduzj64hwre } req := &types.QueryValidatorProviderAddrRequest{ - ChainId: consumerChainID, + ConsumerId: consumerID, ConsumerAddress: addr.String(), } res, err := queryClient.QueryValidatorProviderAddr(cmd.Context(), req) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 4a7cef864f..4251ef50e1 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -215,7 +215,7 @@ Example: func NewCreateConsumerCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-consumer [chain-id] [metadata] [initialization-parameters] [power-shaping-parameters]", + Use: "create-consumer [consumer-parameters]", Short: "create a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Create a consumer chain and get the assigned consumer id of this chain. @@ -223,9 +223,9 @@ Note that the one that signs this message is the owner of this consumer chain. T changed by updating the consumer chain. Example: -%s tx provider create-consumer [chain-id] [path/to/metadata.json] [path/to/initialization-parameters.json] [path/to/power-shaping-parameters.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider create-consumer [path/to/create_consumer.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -240,37 +240,16 @@ Example: signer := clientCtx.GetFromAddress().String() - chainId := args[0] - - metadata := types.ConsumerMetadata{} - metadataJson, err := os.ReadFile(args[1]) - if err != nil { - return err - } - if err = json.Unmarshal(metadataJson, &metadata); err != nil { - return fmt.Errorf("metadata unmarshalling failed: %w", err) - } - - initializationParameters := types.ConsumerInitializationParameters{} - initializationParametersJson, err := os.ReadFile(args[2]) - if err != nil { - return err - } - if err = json.Unmarshal(initializationParametersJson, &initializationParameters); err != nil { - return fmt.Errorf("initialization parameters unmarshalling failed: %w", err) - } - - powerShapingParameters := types.PowerShapingParameters{} - - powerShapingParametersJson, err := os.ReadFile(args[3]) + consCreateJson, err := os.ReadFile(args[0]) if err != nil { return err } - if err = json.Unmarshal(powerShapingParametersJson, &powerShapingParameters); err != nil { - return fmt.Errorf("power-shaping parameters unmarshalling failed: %w", err) + consCreate := types.MsgCreateConsumer{} + if err = json.Unmarshal(consCreateJson, &consCreate); err != nil { + return fmt.Errorf("consumer data unmarshalling failed: %w", err) } - msg, err := types.NewMsgCreateConsumer(signer, chainId, metadata, &initializationParameters, &powerShapingParameters) + msg, err := types.NewMsgCreateConsumer(signer, consCreate.ChainId, consCreate.Metadata, consCreate.InitializationParameters, consCreate.PowerShapingParameters) if err != nil { return err } @@ -291,16 +270,16 @@ Example: func NewUpdateConsumerCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "update-consumer [consumer-id] [owner-address] [metadata] [initialization-parameters] [power-shaping-parameters]", + Use: "update-consumer [consumer-parameters]", Short: "update a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Update a consumer chain to change its parameters (e.g., spawn time, allow list, etc.). Note that only the owner of the chain can initialize it. Example: -%s tx provider update-consumer [consumer-id] [owner-address] [path/to/metadata.json] [path/to/initialization-parameters.json] [path/to/power-shaping-parameters.json] --from node0 --home ../node0 --chain-id $CID + %s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(5), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -314,37 +293,22 @@ Example: txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) signer := clientCtx.GetFromAddress().String() - consumerId := args[0] - ownerAddress := args[1] - metadata := types.ConsumerMetadata{} - metadataJson, err := os.ReadFile(args[2]) + consUpdateJson, err := os.ReadFile(args[0]) if err != nil { return err } - if err = json.Unmarshal(metadataJson, &metadata); err != nil { - return fmt.Errorf("metadata unmarshalling failed: %w", err) - } - initializationParameters := types.ConsumerInitializationParameters{} - initializationParametersJson, err := os.ReadFile(args[3]) - if err != nil { - return err - } - if err = json.Unmarshal(initializationParametersJson, &initializationParameters); err != nil { - return fmt.Errorf("initialization parameters unmarshalling failed: %w", err) + consUpdate := types.MsgUpdateConsumer{} + if err = json.Unmarshal(consUpdateJson, &consUpdate); err != nil { + return fmt.Errorf("consumer data unmarshalling failed: %w", err) } - powerShapingParameters := types.PowerShapingParameters{} - powerShapingParametersJson, err := os.ReadFile(args[4]) - if err != nil { - return err - } - if err = json.Unmarshal(powerShapingParametersJson, &powerShapingParameters); err != nil { - return fmt.Errorf("power-shaping parameters unmarshalling failed: %w", err) + if strings.TrimSpace(consUpdate.ConsumerId) == "" { + return fmt.Errorf("consumer_id can't be empty") } - msg, err := types.NewMsgUpdateConsumer(signer, consumerId, ownerAddress, &metadata, &initializationParameters, &powerShapingParameters) + msg, err := types.NewMsgUpdateConsumer(signer, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters) if err != nil { return err } @@ -418,7 +382,7 @@ Example: func NewOptInCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "opt-in [consumer-chain-id] [consumer-pubkey]", + Use: "opt-in [consumer-id] [consumer-pubkey]", Short: "opts in validator to the consumer chain, and if given uses the " + "provided consensus public key for this consumer chain", Args: cobra.RangeArgs(1, 2), @@ -466,7 +430,7 @@ func NewOptInCmd() *cobra.Command { func NewOptOutCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "opt-out [consumer-chain-id]", + Use: "opt-out [consumer-id]", Short: "opts out validator from this consumer chain", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -505,12 +469,12 @@ func NewOptOutCmd() *cobra.Command { func NewSetConsumerCommissionRateCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "set-consumer-commission-rate [consumer-chain-id] [commission-rate]", + Use: "set-consumer-commission-rate [consumer-id] [commission-rate]", Short: "set a per-consumer chain commission", Long: strings.TrimSpace( fmt.Sprintf(`Note that the "commission-rate" argument is a fraction and should be in the range [0,1]. Example: - %s set-consumer-commission-rate consumer-1 0.5 --from node0 --home ../node0`, + %s set-consumer-commission-rate 123 0.5 --from node0 --home ../node0`, version.AppName), ), Args: cobra.ExactArgs(2), diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index d782d650f5..d47fd8fec9 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -210,7 +210,7 @@ func (k Keeper) QueryValidatorProviderAddr(goCtx context.Context, req *types.Que } consumerAddr := types.NewConsumerConsAddress(consumerAddrTmp) - providerAddr, found := k.GetValidatorByConsumerAddr(ctx, req.ChainId, consumerAddr) + providerAddr, found := k.GetValidatorByConsumerAddr(ctx, req.ConsumerId, consumerAddr) if !found { return &types.QueryValidatorProviderAddrResponse{}, nil } diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 28e0ef24ba..e78e8f8c9b 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -351,6 +351,12 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon } } + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent(ccvtypes.EventTypeConsumerCreation, + sdk.NewAttribute(ccvtypes.AttributeConsumerID, consumerId), + ), + }) + return &types.MsgCreateConsumerResponse{ConsumerId: consumerId}, nil } diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index 3c63fd7954..0be5b1a7d8 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -15,6 +15,7 @@ const ( EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" EventTypeFeeDistribution = "fee_distribution" EventTypeConsumerSlashRequest = "consumer_slash_request" + EventTypeConsumerCreation = "consumer_creation" AttributeKeyAckSuccess = "success" AttributeKeyAck = "acknowledgement" @@ -34,6 +35,7 @@ const ( AttributeMisbehaviourHeight1 = "misbehaviour_height_1" AttributeMisbehaviourHeight2 = "misbehaviour_height_2" AttributeConsumerDoubleVoting = "consumer_double_voting" + AttributeConsumerID = "consumer_id" AttributeChainID = "chain_id" AttributeValidatorAddress = "validator_address" AttributeInfractionType = "infraction_type" From 113577014701f9dbabd3a6d9ae3fbe9d7b93f8b5 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 29 Aug 2024 15:12:30 +0200 Subject: [PATCH 18/43] fix!: several permissionless changes (#2189) * minor fixes in tests * replace IsConsumerProposedOrRegistered with IsConsumerActive * remove param from createStakingValidator * handle error in GetTopN * remove aux methods for getting PowerShapingParameters * remove default PowerShapingParameters * fix tests * handle error messages --- tests/integration/setup.go | 7 +- testutil/ibc_testing/generic_setup.go | 2 +- testutil/keeper/unit_test_helpers.go | 4 +- x/ccv/provider/keeper/distribution.go | 6 +- x/ccv/provider/keeper/grpc_query.go | 42 +++--- x/ccv/provider/keeper/grpc_query_test.go | 46 +++--- x/ccv/provider/keeper/keeper.go | 78 +--------- x/ccv/provider/keeper/keeper_test.go | 106 ------------- x/ccv/provider/keeper/key_assignment.go | 19 +-- x/ccv/provider/keeper/msg_server.go | 113 ++++++++------ x/ccv/provider/keeper/msg_server_test.go | 2 + x/ccv/provider/keeper/partial_set_security.go | 85 +++++++---- .../keeper/partial_set_security_test.go | 141 +++++++++++------- x/ccv/provider/keeper/permissionless.go | 28 ++-- x/ccv/provider/keeper/permissionless_test.go | 59 ++++---- x/ccv/provider/keeper/proposal.go | 24 +-- x/ccv/provider/keeper/proposal_test.go | 11 +- x/ccv/provider/keeper/relay.go | 20 +-- x/ccv/provider/keeper/relay_test.go | 28 ++-- .../keeper/staking_keeper_interface_test.go | 3 +- .../keeper/validator_set_update_test.go | 16 +- .../provider/migrations/v5/migration_test.go | 9 +- x/ccv/provider/migrations/v6/migrations.go | 12 +- x/ccv/provider/types/errors.go | 1 + 24 files changed, 396 insertions(+), 466 deletions(-) diff --git a/tests/integration/setup.go b/tests/integration/setup.go index 5b33a8b191..1a61cbd706 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -160,8 +160,9 @@ func (suite *CCVTestSuite) SetupTest() { suite.registerPacketSniffer(bundle.Chain) // check that TopN is correctly set for the consumer - topN := providerKeeper.GetTopN(suite.providerCtx(), bundle.ConsumerId) - suite.Require().Equal(bundle.TopN, topN) + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(suite.providerCtx(), bundle.ConsumerId) + suite.Require().NoError(err) + suite.Require().Equal(bundle.TopN, powerShapingParameters.Top_N) } // initialize each consumer chain with it's corresponding genesis state @@ -283,7 +284,7 @@ func initConsumerChain( err = bundle.Path.EndpointA.UpdateClient() s.Require().NoError(err) - if consumerId == "0" { + if consumerId == icstestingutils.FirstConsumerID { // Support tests that were written before multiple consumers were supported. firstBundle := s.getFirstBundle() s.consumerApp = firstBundle.App diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 74bf620080..ca46aff6b4 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -164,7 +164,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(providerChain.GetContext(), consumerId, coordinator.CurrentTime) + providerKeeper.AppendConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) // opt-in all validators lastVals, err := providerApp.GetProviderKeeper().GetLastBondedValidators(providerChain.GetContext()) diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index e4b52dbb01..95c5de2380 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -262,8 +262,8 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, acks) // in case the chain was successfully stopped, it should not contain a Top N associated to it - topN := providerKeeper.GetTopN(ctx, consumerId) - require.Zero(t, topN) + _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + require.Error(t, err) // test key assignment state is cleaned require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId)) diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 9291e57a76..9d67181158 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -335,10 +335,10 @@ func (k Keeper) IdentifyConsumerIdFromIBCPacket(ctx sdk.Context, packet channelt // HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address // on the condition that the given consumer chain exists. func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, commissionRate math.LegacyDec) error { - // check that the consumer chain exists - if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { + // check that the consumer chain is active -- registered, initialized, or launched + if !k.IsConsumerActive(ctx, consumerId) { return errorsmod.Wrapf( - types.ErrUnknownConsumerId, + types.ErrInvalidPhase, "unknown consumer chain, with id: %s", consumerId) } diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index d47fd8fec9..14410324fa 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -110,7 +110,10 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai } clientID, _ := k.GetConsumerClientId(ctx, consumerId) - topN := k.GetTopN(ctx, consumerId) + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return types.Chain{}, fmt.Errorf("cannot find power shaping parameters for consumer (%s): %s", consumerId, err.Error()) + } // Get the minimal power in the top N for the consumer chain minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, consumerId) @@ -141,22 +144,19 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai return types.Chain{}, fmt.Errorf("cannot get metadata for consumer (%s): %w", consumerId, err) } - allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) - minStake := k.GetMinStake(ctx, consumerId) - return types.Chain{ ChainId: chainID, ClientId: clientID, - Top_N: topN, + Top_N: powerShapingParameters.Top_N, MinPowerInTop_N: minPowerInTopN, - ValidatorSetCap: k.GetValidatorSetCap(ctx, consumerId), - ValidatorsPowerCap: k.GetValidatorsPowerCap(ctx, consumerId), + ValidatorSetCap: powerShapingParameters.ValidatorSetCap, + ValidatorsPowerCap: powerShapingParameters.ValidatorsPowerCap, Allowlist: strAllowlist, Denylist: strDenylist, Phase: phase, Metadata: metadata, - AllowInactiveVals: allowInactiveVals, - MinStake: minStake, + AllowInactiveVals: powerShapingParameters.AllowInactiveVals, + MinStake: powerShapingParameters.MinStake, }, nil } @@ -314,7 +314,7 @@ func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req * optedInVals := []string{} ctx := sdk.UnwrapSDKContext(goCtx) - if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { + if !k.IsConsumerActive(ctx, consumerId) { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerId)) } @@ -366,19 +366,23 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC } minPower := int64(0) // for TopN chains, compute the minPower that will be automatically opted in - if topN := k.GetTopN(ctx, consumerId); topN > 0 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get power shaping params: %s", err)) + } + if powerShapingParameters.Top_N > 0 { activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get active validators: %s", err)) } - minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("failed to compute min power to opt in for chain %s: %s", consumerId, err)) } } - consumerValSet = k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) + consumerValSet = k.ComputeNextValidators(ctx, consumerId, bondedValidators, powerShapingParameters, minPower) // sort the address of the validators by ascending lexical order as they were persisted to the store sort.Slice(consumerValSet, func(i, j int) bool { @@ -485,10 +489,14 @@ func (k Keeper) hasToValidate( minPowerToOptIn := int64(0) // If the consumer is TopN compute the minimum power - if topN := k.GetTopN(ctx, consumerId); topN > 0 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return false, err + } + if powerShapingParameters.Top_N > 0 { // compute the minimum power to opt-in since the one in the state is stale // Note that the effective min power will be computed at the end of the epoch - minPowerToOptIn, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + minPowerToOptIn, err = k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) if err != nil { return false, err } @@ -500,7 +508,7 @@ func (k Keeper) hasToValidate( if err != nil { return false, err } - nextValidators := k.ComputeNextValidators(ctx, consumerId, lastVals, minPowerToOptIn) + nextValidators := k.ComputeNextValidators(ctx, consumerId, lastVals, powerShapingParameters, minPowerToOptIn) for _, v := range nextValidators { consAddr := sdk.ConsAddress(v.ProviderConsAddr) if provAddr.ToSdkConsAddr().Equals(consAddr) { @@ -532,7 +540,7 @@ func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req ctx := sdk.UnwrapSDKContext(goCtx) - if !k.IsConsumerProposedOrRegistered(ctx, consumerId) { + if !k.IsConsumerActive(ctx, consumerId) { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unknown consumer chain: %s", consumerId)) } diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index a618a66d84..9063e1cdd0 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -55,11 +55,11 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { require.Error(t, err) // Request with invalid consumer id - response, err := pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: "invalidConsumerId"}) + _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: "invalidConsumerId"}) require.Error(t, err) // Request is valid - response, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: consumerId}) + response, err := pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: consumerId}) require.NoError(t, err) expectedResult := types.PairValConAddrProviderAndConsumer{ @@ -117,6 +117,10 @@ func TestQueryConsumerValidators(t *testing.T) { // set the consumer to the "registered" phase pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + // set power shaping params + err = pk.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{}) + require.NoError(t, err) + // expect empty valset testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // -1 to allow the calls "AnyTimes" res, err := pk.QueryConsumerValidators(ctx, &req) @@ -124,7 +128,7 @@ func TestQueryConsumerValidators(t *testing.T) { require.Len(t, res.Validators, 0) // create bonded validators - val1 := createStakingValidator(ctx, mocks, 1, 1, 1) + val1 := createStakingValidator(ctx, mocks, 1, 1) pk1, _ := val1.CmtConsPublicKey() valConsAddr1, _ := val1.GetConsAddr() providerAddr1 := types.NewProviderConsAddress(valConsAddr1) @@ -133,7 +137,7 @@ func TestQueryConsumerValidators(t *testing.T) { val1.Description = stakingtypes.Description{Moniker: "ConsumerValidator1"} val1.Commission.Rate = math.LegacyMustNewDecFromStr("0.123") - val2 := createStakingValidator(ctx, mocks, 1, 2, 2) + val2 := createStakingValidator(ctx, mocks, 2, 2) pk2, _ := val2.CmtConsPublicKey() valConsAddr2, _ := val2.GetConsAddr() providerAddr2 := types.NewProviderConsAddress(valConsAddr2) @@ -142,7 +146,7 @@ func TestQueryConsumerValidators(t *testing.T) { val2.Description = stakingtypes.Description{Moniker: "ConsumerValidator2"} val2.Commission.Rate = math.LegacyMustNewDecFromStr("0.456") - val3 := createStakingValidator(ctx, mocks, 1, 3, 3) + val3 := createStakingValidator(ctx, mocks, 3, 3) pk3, _ := val3.CmtConsPublicKey() valConsAddr3, _ := val3.GetConsAddr() providerAddr3 := types.NewProviderConsAddress(valConsAddr3) @@ -289,7 +293,7 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { pk, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - val := createStakingValidator(ctx, mocks, 1, 1, 1) + val := createStakingValidator(ctx, mocks, 1, 1) valConsAddr, _ := val.GetConsAddr() providerAddr := types.NewProviderConsAddress(valConsAddr) mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valConsAddr).Return(val, nil).AnyTimes() @@ -300,13 +304,15 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { } // set up some consumer chains - consumerChains := []string{"chain1", "chain2", "chain3", "chain4"} - for _, cc := range consumerChains { - pk.SetConsumerClientId(ctx, cc, "clientID") + consumerIDs := []string{"1", "23", "456", "6789"} + for _, cID := range consumerIDs { + pk.SetConsumerClientId(ctx, cID, "clientID") + err := pk.SetConsumerPowerShapingParameters(ctx, cID, types.PowerShapingParameters{}) + require.NoError(t, err) } - // set `providerAddr` as a consumer validator on "chain1" - pk.SetConsumerValidator(ctx, "chain1", types.ConsensusValidator{ + // set `providerAddr` as a consumer validator on first consumer chain + pk.SetConsumerValidator(ctx, consumerIDs[0], types.ConsensusValidator{ ProviderConsAddr: providerAddr.ToSdkConsAddr(), Power: 1, PublicKey: &crypto.PublicKey{ @@ -316,17 +322,18 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { }, }) - // set `providerAddr` as an opted-in validator on "chain3" - pk.SetOptedIn(ctx, "chain3", providerAddr) + // set `providerAddr` as an opted-in validator on third consumer chain + pk.SetOptedIn(ctx, consumerIDs[2], providerAddr) // set max provider consensus vals to include all validators params := pk.GetParams(ctx) params.MaxProviderConsensusValidators = 3 pk.SetParams(ctx, params) - // `providerAddr` has to validate "chain1" because it is a consumer validator in this chain, as well as "chain3" - // because it opted in, in "chain3" and `providerAddr` belongs to the bonded validators - expectedChains := []string{"chain1", "chain3"} + // `providerAddr` has to validate + // - first consumer because it is a consumer validator in this chain, + // - third consumer because it opted in + expectedChains := []string{consumerIDs[0], consumerIDs[2]} res, err := pk.QueryConsumerChainsValidatorHasToValidate(ctx, &req) require.NoError(t, err) @@ -606,7 +613,10 @@ func TestQueryConsumerChains(t *testing.T) { Metadata: types.ConsumerMetadata{Name: chainID}, } pk.SetConsumerPhase(ctx, cID, c.Phase) - pk.SetConsumerMetadata(ctx, cID, c.Metadata) + err := pk.SetConsumerMetadata(ctx, cID, c.Metadata) + require.NoError(t, err) + err = pk.SetConsumerPowerShapingParameters(ctx, cID, types.PowerShapingParameters{}) + require.NoError(t, err) pk.SetConsumerChainId(ctx, cID, chainID) consumerIds[i] = cID @@ -644,7 +654,7 @@ func TestQueryConsumerChains(t *testing.T) { name: "expect initialized consumers when phase is set to Initialized", setup: func(ctx sdk.Context, pk keeper.Keeper) { consumers[1].Phase = types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED - err := pk.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerIds[1], time.Now()) + err := pk.AppendConsumerToBeLaunched(ctx, consumerIds[1], time.Now()) require.NoError(t, err) pk.SetConsumerPhase(ctx, consumerIds[1], types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) }, diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 93469af316..4598ff30c1 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -694,10 +694,7 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { consumerIds := []string{} for i := uint64(0); i < latestConsumerId; i++ { consumerId := fmt.Sprintf("%d", i) - phase := k.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && - phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && - phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if !k.IsConsumerActive(ctx, consumerId) { continue } consumerIds = append(consumerIds, consumerId) @@ -706,29 +703,6 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { return consumerIds } -// GetTopN returns N if chain `consumerId` has a top N associated, and 0 otherwise. -func (k Keeper) GetTopN( - ctx sdk.Context, - consumerId string, -) uint32 { - powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) - if err != nil { - k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) - } - - return powerShapingParameters.Top_N -} - -// IsTopN returns true if chain with `consumerId` is a Top-N chain (i.e., enforces at least one validator to validate chain `consumerId`) -func (k Keeper) IsTopN(ctx sdk.Context, consumerId string) bool { - return k.GetTopN(ctx, consumerId) > 0 -} - -// IsOptIn returns true if chain with `consumerId` is an Opt-In chain (i.e., no validator is forced to validate chain `consumerId`) -func (k Keeper) IsOptIn(ctx sdk.Context, consumerId string) bool { - return k.GetTopN(ctx, consumerId) == 0 -} - func (k Keeper) SetOptedIn( ctx sdk.Context, consumerId string, @@ -865,30 +839,6 @@ func (k Keeper) DeleteConsumerCommissionRate( store.Delete(types.ConsumerCommissionRateKey(consumerId, providerAddr)) } -// GetValidatorsPowerCap returns the associated power cap of chain with `consumerId` and 0 if no power cap association is found -func (k Keeper) GetValidatorsPowerCap( - ctx sdk.Context, - consumerId string, -) uint32 { - powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) - if err != nil { - k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) - } - return powerShapingParameters.ValidatorsPowerCap -} - -// GetValidatorSetCap returns the associated validator set cap of chain with `consumerId` and 0 if no set cap association is found -func (k Keeper) GetValidatorSetCap( - ctx sdk.Context, - consumerId string, -) uint32 { - powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) - if err != nil { - k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) - } - return powerShapingParameters.ValidatorSetCap -} - // SetAllowlist allowlists validator with `providerAddr` address on chain `consumerId` func (k Keeper) SetAllowlist( ctx sdk.Context, @@ -1054,32 +1004,6 @@ func (k Keeper) DeleteMinimumPowerInTopN( store.Delete(types.MinimumPowerInTopNKey(consumerId)) } -// GetMinStake returns the minimum stake required for a validator to validate -// a given consumer chain. Returns 0 if min stake is not found for this consumer id. -func (k Keeper) GetMinStake( - ctx sdk.Context, - consumerId string, -) uint64 { - powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) - if err != nil { - k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) - } - return powerShapingParameters.MinStake -} - -// AllowsInactiveValidators returns whether inactive validators are allowed to validate -// a given consumer chain. Returns false if flag on inactive validators is not found for this consumer id. -func (k Keeper) AllowsInactiveValidators( - ctx sdk.Context, - consumerId string, -) bool { - powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) - if err != nil { - k.Logger(ctx).Error("could not retrieve power shaping parameters", "error", err) - } - return powerShapingParameters.AllowInactiveVals -} - func (k Keeper) UnbondingCanComplete(ctx sdk.Context, id uint64) error { return k.stakingKeeper.UnbondingCanComplete(ctx, id) } diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index b9b8294955..1794c2fba5 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -284,38 +284,6 @@ func TestSetSlashLog(t *testing.T) { require.False(t, providerKeeper.GetSlashLog(ctx, addrWithoutDoubleSigns)) } -// TestTopN tests the `SetTopN`, `GetTopN`, `IsTopN`, and `IsOptIn` methods -func TestTopN(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - tests := []struct { - consumerId string - N uint32 - isOptIn bool - }{ - {consumerId: "TopNChain1", N: 50, isOptIn: false}, - {consumerId: "TopNChain2", N: 100, isOptIn: false}, - {consumerId: "OptInChain", N: 0, isOptIn: true}, - } - - for _, test := range tests { - providerKeeper.SetConsumerPowerShapingParameters(ctx, test.consumerId, types.PowerShapingParameters{ - Top_N: test.N, - }) - topN := providerKeeper.GetTopN(ctx, test.consumerId) - require.Equal(t, test.N, topN) - - if test.isOptIn { - require.True(t, providerKeeper.IsOptIn(ctx, test.consumerId)) - require.False(t, providerKeeper.IsTopN(ctx, test.consumerId)) - } else { - require.False(t, providerKeeper.IsOptIn(ctx, test.consumerId)) - require.True(t, providerKeeper.IsTopN(ctx, test.consumerId)) - } - } -} - func TestGetAllOptedIn(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -458,37 +426,9 @@ func TestDenylist(t *testing.T) { require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) } -// TestAllowInactiveValidators tests the `SetAllowInactiveValidators` and `AllowsInactiveValidators` methods -func TestAllowInactiveValidators(t *testing.T) { - k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - - consumerId := "consumerId" - - // check that by default, AllowsInactiveValidators returns false - require.False(t, k.AllowsInactiveValidators(ctx, consumerId)) - - // set the chain to allow inactive validators - k.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ - AllowInactiveVals: true, - }) - // check that AllowsInactiveValidators returns true - require.True(t, k.AllowsInactiveValidators(ctx, consumerId)) - - // set the chain to not allow inactive validators - k.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ - AllowInactiveVals: false, - }) - - // check that AllowsInactiveValidators returns false - require.False(t, k.AllowsInactiveValidators(ctx, consumerId)) -} - // Tests setting, getting and deleting parameters that are stored per-consumer chain. // The tests cover the following parameters: // - MinimumPowerInTopN -// - MinStake -// - ValidatorSetCap -// - ValidatorPowersCap func TestKeeperConsumerParams(t *testing.T) { k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) @@ -511,52 +451,6 @@ func TestKeeperConsumerParams(t *testing.T) { initialValue: 1000, updatedValue: 2000, }, - { - name: "Minimum Stake", - settingFunc: func(ctx sdk.Context, id string, val int64) { - k.SetConsumerPowerShapingParameters(ctx, id, - types.PowerShapingParameters{ - MinStake: uint64(val), - }) - }, - getFunc: func(ctx sdk.Context, id string) int64 { - return int64(k.GetMinStake(ctx, id)) - }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, - initialValue: 1000, - updatedValue: 2000, - }, - { - name: "Validator Set Cap", - settingFunc: func(ctx sdk.Context, id string, val int64) { - k.SetConsumerPowerShapingParameters(ctx, id, - types.PowerShapingParameters{ - ValidatorSetCap: uint32(val), - }) - }, - getFunc: func(ctx sdk.Context, id string) int64 { - return int64(k.GetValidatorSetCap(ctx, id)) - }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, - initialValue: 10, - updatedValue: 200, - }, - { - name: "Validator Powers Cap", - settingFunc: func(ctx sdk.Context, id string, val int64) { - k.SetConsumerPowerShapingParameters(ctx, id, - types.PowerShapingParameters{ - ValidatorsPowerCap: uint32(val), - }) - }, - getFunc: func(ctx sdk.Context, id string) int64 { - val := k.GetValidatorsPowerCap(ctx, id) - return int64(val) - }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteConsumerPowerShapingParameters(ctx, id) }, - initialValue: 10, - updatedValue: 11, - }, } for _, tt := range tests { diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index d037fcd648..47a890098a 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -403,10 +403,7 @@ func (k Keeper) AssignConsumerKey( validator stakingtypes.Validator, consumerKey tmprotocrypto.PublicKey, ) error { - phase := k.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && - phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && - phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if !k.IsConsumerActive(ctx, consumerId) { // check that the consumer chain is either registered, initialized, or launched return errorsmod.Wrapf( types.ErrInvalidPhase, @@ -462,6 +459,7 @@ func (k Keeper) AssignConsumerKey( oldConsumerAddr := types.NewConsumerConsAddress(oldConsumerAddrTmp) // check whether the consumer chain has already launched (i.e., a client to the consumer was already created) + phase := k.GetConsumerPhase(ctx, consumerId) if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { // mark the old consumer address as prunable once UnbondingPeriod elapses; // note: this state is removed on EndBlock @@ -547,19 +545,6 @@ func (k Keeper) DeleteKeyAssignments(ctx sdk.Context, consumerId string) { } } -// IsConsumerProposedOrRegistered checks if a consumer chain is either registered, meaning either already running -// or will run soon, or proposed its ConsumerAdditionProposal was submitted but the chain was not yet added to ICS yet. -func (k Keeper) IsConsumerProposedOrRegistered(ctx sdk.Context, consumerId string) bool { - allConsumerChains := k.GetAllActiveConsumerIds(ctx) - for _, c := range allConsumerChains { - if c == consumerId { - return true - } - } - - return false -} - // ValidatorConsensusKeyInUse checks if the given consensus key is already // used by validator in a consumer chain. // Note that this method is called when a new validator is created in the x/staking module of cosmos-sdk. diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index e78e8f8c9b..b10cb883c6 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -91,14 +91,16 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + resp := types.MsgRemoveConsumerResponse{} + consumerId := msg.ConsumerId ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { - return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) + return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) } if msg.Signer != ownerAddress { - return &types.MsgRemoveConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) } phase := k.Keeper.GetConsumerPhase(ctx, consumerId) @@ -109,13 +111,19 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) if err == nil { - k.Keeper.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, previousStopTime) + if err := k.Keeper.RemoveConsumerToBeStopped(ctx, consumerId, previousStopTime); err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot remove previous stop time: %s", err.Error()) + } } - k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime) - k.Keeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerId, msg.StopTime) + if err := k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime); err != nil { + return &resp, errorsmod.Wrapf(types.ErrInvalidStopTime, "cannot set stop time: %s", err.Error()) + } + if err := k.Keeper.AppendConsumerToBeStopped(ctx, consumerId, msg.StopTime); err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot set consumer to be stop: %s", err.Error()) + } - return &types.MsgRemoveConsumerResponse{}, nil + return &resp, nil } // ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms @@ -311,6 +319,7 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M // CreateConsumer creates a consumer chain func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateConsumer) (*types.MsgCreateConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + resp := types.MsgCreateConsumerResponse{} consumerId := k.Keeper.FetchAndIncrementConsumerId(ctx) @@ -319,34 +328,43 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { - return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, + return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, "cannot set consumer metadata: %s", err.Error()) } - // initialization parameters are optional and hence could be nil + // initialization parameters are optional and hence could be nil; + // in that case, set the default + initializationParameters := types.ConsumerInitializationParameters{} // default params if msg.InitializationParameters != nil { - if err := k.Keeper.SetConsumerInitializationParameters(ctx, consumerId, *msg.InitializationParameters); err != nil { - return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, - "cannot set consumer initialization parameters: %s", err.Error()) - } + initializationParameters = *msg.InitializationParameters + } + if err := k.Keeper.SetConsumerInitializationParameters(ctx, consumerId, initializationParameters); err != nil { + return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, + "cannot set consumer initialization parameters: %s", err.Error()) } - // power-shaping parameters are optional and hence could be null + // power-shaping parameters are optional and hence could be nil; + // in that case, set the default + powerShapingParameters := types.PowerShapingParameters{} // default params if msg.PowerShapingParameters != nil { - if msg.PowerShapingParameters.Top_N != 0 { - return &types.MsgCreateConsumerResponse{}, errorsmod.Wrap(types.ErrCannotCreateTopNChain, + powerShapingParameters = *msg.PowerShapingParameters + + if powerShapingParameters.Top_N != 0 { + return &resp, errorsmod.Wrap(types.ErrCannotCreateTopNChain, "cannot create a Top N chain using the `MsgCreateConsumer` message; use `MsgUpdateConsumer` instead") } - if err := k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { - return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, - "cannot set power shaping parameters") - } + + // TODO UpdateAllowlist & UpdateDenylist + } + if err := k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, powerShapingParameters); err != nil { + return &resp, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, + "cannot set power shaping parameters") } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { - return &types.MsgCreateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) } } @@ -357,36 +375,36 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon ), }) - return &types.MsgCreateConsumerResponse{ConsumerId: consumerId}, nil + resp.ConsumerId = consumerId + return &resp, nil } // UpdateConsumer updates the record of a consumer chain func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateConsumer) (*types.MsgUpdateConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + resp := types.MsgUpdateConsumerResponse{} + consumerId := msg.ConsumerId - phase := k.Keeper.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && - phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && - phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPhase, + if !k.Keeper.IsConsumerActive(ctx, consumerId) { + return &resp, errorsmod.Wrapf(types.ErrInvalidPhase, "cannot update consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) } ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) + return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) } if msg.Signer != ownerAddress { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) } // The new owner address can be empty, in which case the consumer chain does not change its owner. // However, if the new owner address is not empty, we verify that it's a valid account address. if strings.TrimSpace(msg.NewOwnerAddress) != "" { if _, err := k.accountKeeper.AddressCodec().StringToBytes(msg.NewOwnerAddress); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidNewOwnerAddress, "invalid new owner address %s", msg.NewOwnerAddress) + return &resp, errorsmod.Wrapf(types.ErrInvalidNewOwnerAddress, "invalid new owner address %s", msg.NewOwnerAddress) } k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.NewOwnerAddress) @@ -394,21 +412,22 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon if msg.Metadata != nil { if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, *msg.Metadata); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, + return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, "cannot set consumer metadata: %s", err.Error()) } } // get the previous spawn time so that we can use it in `PrepareConsumerForLaunch` - var previousSpawnTime time.Time - previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, msg.ConsumerId) - if err == nil { - previousSpawnTime = previousInitializationParameters.SpawnTime + previousInitializationParameters, err := k.Keeper.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, + "cannot get consumer initialized parameters, consumerId(%s): %s", consumerId, err.Error()) } + previousSpawnTime := previousInitializationParameters.SpawnTime if msg.InitializationParameters != nil { if err = k.Keeper.SetConsumerInitializationParameters(ctx, msg.ConsumerId, *msg.InitializationParameters); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, + return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, "cannot set consumer initialization parameters: %s", err.Error()) } } @@ -418,13 +437,19 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon // Top N chain, we need two `MsgUpdateConsumer` messages: i) one that would set the `ownerAddress` to the gov module // and ii) one that would set the `Top_N` to something greater than 0. if msg.PowerShapingParameters.Top_N > 0 && ownerAddress != k.GetAuthority() { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidTransformToTopN, + return &resp, errorsmod.Wrapf(types.ErrInvalidTransformToTopN, "an update to a Top N chain can only be done if chain is owner is the gov module") } - oldTopN := k.Keeper.GetTopN(ctx, consumerId) + oldPowerShapingParameters, err := k.Keeper.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, + "cannot get consumer previous power shaping parameters: %s", err.Error()) + } + oldTopN := oldPowerShapingParameters.Top_N + if err = k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, *msg.PowerShapingParameters); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, + return &resp, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot set power shaping parameters") } @@ -432,7 +457,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon k.Keeper.UpdateDenylist(ctx, consumerId, msg.PowerShapingParameters.Denylist) err = k.Keeper.UpdateMinimumPowerInTopN(ctx, consumerId, oldTopN, msg.PowerShapingParameters.Top_N) if err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotUpdateMinimumPowerInTopN, + return &resp, errorsmod.Wrapf(types.ErrCannotUpdateMinimumPowerInTopN, "could not update minimum power in top N, oldTopN: %d, newTopN: %d, error: %s", oldTopN, msg.PowerShapingParameters.Top_N, err.Error()) } } @@ -441,28 +466,28 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon // remains a Top N chain. currentOwnerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) if err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s: %s", ownerAddress, err.Error()) + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot retrieve owner address %s: %s", ownerAddress, err.Error()) } currentPowerShapingParameters, err := k.Keeper.GetConsumerPowerShapingParameters(ctx, consumerId) if err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot retrieve power shaping parameters: %s", err.Error()) + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot retrieve power shaping parameters: %s", err.Error()) } if currentPowerShapingParameters.Top_N != 0 && currentOwnerAddress != k.GetAuthority() { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrInvalidTransformToOptIn, + return &resp, errorsmod.Wrapf(types.ErrInvalidTransformToOptIn, "a move to a new owner address that is not the gov module can only be done if `Top N` is set to 0") } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { - return &types.MsgUpdateConsumerResponse{}, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) } } - return &types.MsgUpdateConsumerResponse{}, nil + return &resp, nil } func (k msgServer) ConsumerAddition(_ context.Context, _ *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index fd353e38bf..b6f9bb1f71 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -31,6 +31,7 @@ func TestCreateConsumer(t *testing.T) { require.NoError(t, err) require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "0") + require.NoError(t, err) require.Equal(t, "signer", ownerAddress) phase := providerKeeper.GetConsumerPhase(ctx, "0") require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) @@ -50,6 +51,7 @@ func TestCreateConsumer(t *testing.T) { require.NoError(t, err) require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "1") + require.NoError(t, err) require.Equal(t, "signer2", ownerAddress) phase = providerKeeper.GetConsumerPhase(ctx, "1") require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index eccbc5e81a..95667a1d4c 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -11,15 +11,13 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) // HandleOptIn prepares validator `providerAddr` to opt in to `consumerId` with an optional `consumerKey` consumer public key. // Note that the validator only opts in at the end of an epoch. func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, consumerKey string) error { - phase := k.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_REGISTERED && - phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED && - phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if !k.IsConsumerActive(ctx, consumerId) { return errorsmod.Wrapf( types.ErrInvalidPhase, "cannot opt in to a consumer chain that is not in the registered, initialized, or launched phase: %s", consumerId) @@ -68,15 +66,28 @@ func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr typ // HandleOptOut prepares validator `providerAddr` to opt out from running `consumerId`. // Note that the validator only opts out at the end of an epoch. func (k Keeper) HandleOptOut(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) error { - if _, found := k.GetConsumerClientId(ctx, consumerId); !found { - // A validator can only opt out from a running chain. We check this by checking the consumer client id, because - // `SetConsumerClientId` is set when the chain starts in `CreateConsumerClientInCachedCtx` of `BeginBlockInit`. + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { return errorsmod.Wrapf( types.ErrUnknownConsumerId, - "opting out of an unknown or not running consumer chain, with id: %s", consumerId) + "opting out of an unknown consumer chain, consumerId(%s)", consumerId, + ) + } + if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + // A validator can only opt out from a running chain + return errorsmod.Wrapf( + types.ErrInvalidPhase, + "opting out of a consumer chain not yet launched, consumerId(%s)", consumerId, + ) } - if topN := k.GetTopN(ctx, consumerId); topN > 0 { + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + return errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, + "cannot get consumer power shaping parameters: %s", err.Error(), + ) + } + if powerShapingParameters.Top_N > 0 { // a validator cannot opt out from a Top N chain if the validator is in the Top N validators validator, err := k.stakingKeeper.GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()) if err != nil { @@ -202,13 +213,18 @@ func (k Keeper) ComputeMinPowerInTopN(ctx sdk.Context, bondedValidators []stakin // CapValidatorSet caps the provided `validators` if chain with `consumerId` is an Opt In chain with a validator-set cap. // If cap is `k`, `CapValidatorSet` returns the first `k` validators from `validators` with the highest power. -func (k Keeper) CapValidatorSet(ctx sdk.Context, consumerId string, validators []types.ConsensusValidator) []types.ConsensusValidator { - if k.GetTopN(ctx, consumerId) > 0 { +func (k Keeper) CapValidatorSet( + ctx sdk.Context, + powerShapingParameters types.PowerShapingParameters, + validators []types.ConsensusValidator, +) []types.ConsensusValidator { + if powerShapingParameters.Top_N > 0 { // is a no-op if the chain is a Top N chain return validators } - if validatorSetCap := k.GetValidatorSetCap(ctx, consumerId); validatorSetCap != 0 && int(validatorSetCap) < len(validators) { + validatorSetCap := powerShapingParameters.ValidatorSetCap + if validatorSetCap != 0 && int(validatorSetCap) < len(validators) { sort.Slice(validators, func(i, j int) bool { return validators[i].Power > validators[j].Power }) @@ -223,9 +239,13 @@ func (k Keeper) CapValidatorSet(ctx sdk.Context, consumerId string, validators [ // with their new powers. Works on a best-basis effort because there are cases where we cannot guarantee that all validators // on the consumer chain have less power than the set validators-power cap. For example, if we have 10 validators and // the power cap is set to 5%, we need at least one validator to have more than 10% of the voting power on the consumer chain. -func (k Keeper) CapValidatorsPower(ctx sdk.Context, consumerId string, validators []types.ConsensusValidator) []types.ConsensusValidator { - if p := k.GetValidatorsPowerCap(ctx, consumerId); p > 0 { - return NoMoreThanPercentOfTheSum(validators, p) +func (k Keeper) CapValidatorsPower( + ctx sdk.Context, + validatorsPowerCap uint32, + validators []types.ConsensusValidator, +) []types.ConsensusValidator { + if validatorsPowerCap > 0 { + return NoMoreThanPercentOfTheSum(validators, validatorsPowerCap) } else { // is a no-op if power cap is not set for `consumerId` return validators @@ -334,12 +354,18 @@ func NoMoreThanPercentOfTheSum(validators []types.ConsensusValidator, percent ui // CanValidateChain returns true if the validator `providerAddr` is opted-in to chain with `consumerId` and the allowlist // and denylist do not prevent the validator from validating the chain. -func (k Keeper) CanValidateChain(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress, minPowerToOptIn int64) bool { +func (k Keeper) CanValidateChain( + ctx sdk.Context, + consumerId string, + providerAddr types.ProviderConsAddress, + topN uint32, + minPowerToOptIn int64, +) bool { // check if the validator is already opted-in optedIn := k.IsOptedIn(ctx, consumerId, providerAddr) // check if the validator is automatically opted-in for a topN chain - if !optedIn && k.GetTopN(ctx, consumerId) > 0 { + if !optedIn && topN > 0 { optedIn = k.HasMinPower(ctx, providerAddr, minPowerToOptIn) } @@ -355,8 +381,11 @@ func (k Keeper) CanValidateChain(ctx sdk.Context, consumerId string, providerAdd // FulfillsMinStake returns true if the validator `providerAddr` has enough stake to validate chain with `consumerId` // by checking its staked tokens against the minimum stake required to validate the chain. -func (k Keeper) FulfillsMinStake(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) bool { - minStake := k.GetMinStake(ctx, consumerId) +func (k Keeper) FulfillsMinStake( + ctx sdk.Context, + minStake uint64, + providerAddr types.ProviderConsAddress, +) bool { if minStake == 0 { return true } @@ -372,7 +401,13 @@ func (k Keeper) FulfillsMinStake(ctx sdk.Context, consumerId string, providerAdd } // ComputeNextValidators computes the validators for the upcoming epoch based on the currently `bondedValidators`. -func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bondedValidators []stakingtypes.Validator, minPowerToOptIn int64) []types.ConsensusValidator { +func (k Keeper) ComputeNextValidators( + ctx sdk.Context, + consumerId string, + bondedValidators []stakingtypes.Validator, + powerShapingParameters types.PowerShapingParameters, + minPowerToOptIn int64, +) []types.ConsensusValidator { // sort the bonded validators by number of staked tokens in descending order sort.Slice(bondedValidators, func(i, j int) bool { return bondedValidators[i].GetBondedTokens().GT(bondedValidators[j].GetBondedTokens()) @@ -380,8 +415,7 @@ func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bonded // if inactive validators are not allowed, only consider the first `MaxProviderConsensusValidators` validators // since those are the ones that participate in consensus - allowInactiveVals := k.AllowsInactiveValidators(ctx, consumerId) - if !allowInactiveVals { + if !powerShapingParameters.AllowInactiveVals { // only leave the first MaxProviderConsensusValidators bonded validators maxProviderConsensusVals := k.GetMaxProviderConsensusValidators(ctx) if len(bondedValidators) > int(maxProviderConsensusVals) { @@ -391,11 +425,12 @@ func (k Keeper) ComputeNextValidators(ctx sdk.Context, consumerId string, bonded nextValidators := k.FilterValidators(ctx, consumerId, bondedValidators, func(providerAddr types.ProviderConsAddress) bool { - return k.CanValidateChain(ctx, consumerId, providerAddr, minPowerToOptIn) && k.FulfillsMinStake(ctx, consumerId, providerAddr) + return k.CanValidateChain(ctx, consumerId, providerAddr, powerShapingParameters.Top_N, minPowerToOptIn) && + k.FulfillsMinStake(ctx, powerShapingParameters.MinStake, providerAddr) }) - nextValidators = k.CapValidatorSet(ctx, consumerId, nextValidators) - return k.CapValidatorsPower(ctx, consumerId, nextValidators) + nextValidators = k.CapValidatorSet(ctx, powerShapingParameters, nextValidators) + return k.CapValidatorsPower(ctx, powerShapingParameters.ValidatorsPowerCap, nextValidators) } // HasMinPower returns true if the `providerAddr` voting power is GTE than the given minimum power diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index 357811441f..f760599907 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -109,19 +109,26 @@ func TestHandleOptOut(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerId := "consumerId" + providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) // trying to opt out from a not running chain returns an error require.Error(t, providerKeeper.HandleOptOut(ctx, "unknownChainID", providerAddr)) - // set a consumer client so that the chain is considered running - providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") + // set the phase and power shaping params + providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{}) + require.NoError(t, err) // if validator (`providerAddr`) is already opted in, then an opt-out would remove this validator - providerKeeper.SetOptedIn(ctx, "consumerId", providerAddr) - require.True(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) - providerKeeper.HandleOptOut(ctx, "consumerId", providerAddr) - require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) + providerKeeper.SetOptedIn(ctx, consumerId, providerAddr) + require.True(t, providerKeeper.IsOptedIn(ctx, consumerId, providerAddr)) + err = providerKeeper.AppendOptedInConsumerId(ctx, providerAddr, consumerId) + require.NoError(t, err) + err = providerKeeper.HandleOptOut(ctx, consumerId, providerAddr) + require.NoError(t, err) + require.False(t, providerKeeper.IsOptedIn(ctx, consumerId, providerAddr)) } func TestHandleOptOutFromTopNChain(t *testing.T) { @@ -130,24 +137,25 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { consumerId := "consumerId" - // set a consumer client so that the chain is considered running - providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") + // set the phase + providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // set the chain as Top 50 and create 4 validators with 10%, 20%, 30%, and 40% of the total voting power // respectively - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ Top_N: 50, }) - valA := createStakingValidator(ctx, mocks, 1, 1, 1) // 10% of the total voting power (can opt out) + require.NoError(t, err) + valA := createStakingValidator(ctx, mocks, 1, 1) // 10% of the total voting power (can opt out) valAConsAddr, _ := valA.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 2, 2) // 20% of the total voting power (can opt out) + valB := createStakingValidator(ctx, mocks, 2, 2) // 20% of the total voting power (can opt out) valBConsAddr, _ := valB.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() - valC := createStakingValidator(ctx, mocks, 3, 3, 3) // 30% of the total voting power (cannot opt out) + valC := createStakingValidator(ctx, mocks, 3, 3) // 30% of the total voting power (cannot opt out) valCConsAddr, _ := valC.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, nil).AnyTimes() - valD := createStakingValidator(ctx, mocks, 4, 4, 4) // 40% of the total voting power (cannot opt out) + valD := createStakingValidator(ctx, mocks, 4, 4) // 40% of the total voting power (cannot opt out) valDConsAddr, _ := valD.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, nil).AnyTimes() @@ -160,13 +168,17 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { // opt in all validators providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valAConsAddr)) - providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valAConsAddr), consumerId) + err = providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valAConsAddr), consumerId) + require.NoError(t, err) providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valBConsAddr)) - providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valBConsAddr), consumerId) + err = providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valBConsAddr), consumerId) + require.NoError(t, err) providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valCConsAddr)) - providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valCConsAddr), consumerId) + err = providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valCConsAddr), consumerId) + require.NoError(t, err) providerKeeper.SetOptedIn(ctx, consumerId, types.NewProviderConsAddress(valDConsAddr)) - providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valDConsAddr), consumerId) + err = providerKeeper.AppendOptedInConsumerId(ctx, types.NewProviderConsAddress(valDConsAddr), consumerId) + require.NoError(t, err) // validators A and B can opt out because they belong the bottom 30% of validators require.NoError(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valAConsAddr))) @@ -178,8 +190,9 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { require.Error(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(valDConsAddr))) // opting out a validator that cannot be found from a Top N chain should also return an error - notFoundValidator := createStakingValidator(ctx, mocks, 5, 5, 5) - notFoundValidatorConsAddr, _ := notFoundValidator.GetConsAddr() + notFoundValidator := createStakingValidator(ctx, mocks, 5, 5) + notFoundValidatorConsAddr, err := notFoundValidator.GetConsAddr() + require.NoError(t, err) mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, notFoundValidatorConsAddr). Return(stakingtypes.Validator{}, stakingtypes.ErrNoValidatorFound) require.Error(t, providerKeeper.HandleOptOut(ctx, consumerId, types.NewProviderConsAddress(notFoundValidatorConsAddr))) @@ -237,13 +250,13 @@ func TestOptInTopNValidators(t *testing.T) { defer ctrl.Finish() // create 4 validators with powers 1, 2, 3, and 1 respectively - valA := createStakingValidator(ctx, mocks, 1, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1) valAConsAddr, _ := valA.GetConsAddr() - valB := createStakingValidator(ctx, mocks, 2, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2) valBConsAddr, _ := valB.GetConsAddr() - valC := createStakingValidator(ctx, mocks, 3, 3, 3) + valC := createStakingValidator(ctx, mocks, 3, 3) valCConsAddr, _ := valC.GetConsAddr() - valD := createStakingValidator(ctx, mocks, 4, 1, 4) + valD := createStakingValidator(ctx, mocks, 1, 4) valDConsAddr, _ := valD.GetConsAddr() // Start Test 1: opt in all validators with power >= 0 @@ -324,11 +337,11 @@ func TestComputeMinPowerInTopN(t *testing.T) { // 1 => 100% bondedValidators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, 1, 5, 1), - createStakingValidator(ctx, mocks, 2, 10, 2), - createStakingValidator(ctx, mocks, 3, 3, 3), - createStakingValidator(ctx, mocks, 4, 1, 4), - createStakingValidator(ctx, mocks, 5, 6, 5), + createStakingValidator(ctx, mocks, 5, 1), + createStakingValidator(ctx, mocks, 10, 2), + createStakingValidator(ctx, mocks, 3, 3), + createStakingValidator(ctx, mocks, 1, 4), + createStakingValidator(ctx, mocks, 6, 5), } m, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, 100) @@ -385,43 +398,49 @@ func TestCanValidateChain(t *testing.T) { consumerID := "0" - validator := createStakingValidator(ctx, mocks, 0, 1, 1) // adds GetLastValidatorPower expectation to mocks + validator := createStakingValidator(ctx, mocks, 1, 1) // adds GetLastValidatorPower expectation to mocks consAddr, _ := validator.GetConsAddr() providerAddr := types.NewProviderConsAddress(consAddr) // with no allowlist or denylist, the validator has to be opted in, in order to consider it - require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 0)) + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerID) + require.Error(t, err) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 0)) // with TopN chains, the validator can be considered, mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), providerAddr.Address).Return(validator, nil).Times(2) providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 50}) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerID) + require.NoError(t, err) // validator's power is LT the min power - require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 2)) // validator's power is GTE the min power - require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 1)) // when validator is opted-in it can validate regardless of its min power providerKeeper.SetOptedIn(ctx, consumerID, types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 2)) // With OptIn chains, validator can validate only if it has already opted-in providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 0}) - require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 2)) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerID) + require.NoError(t, err) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 2)) // create an allow list but do not add the validator `providerAddr` to it - validatorA := createStakingValidator(ctx, mocks, 1, 1, 2) + validatorA := createStakingValidator(ctx, mocks, 1, 2) consAddrA, _ := validatorA.GetConsAddr() providerKeeper.SetAllowlist(ctx, consumerID, types.NewProviderConsAddress(consAddrA)) - require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 1)) providerKeeper.SetAllowlist(ctx, consumerID, types.NewProviderConsAddress(consAddr)) - require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 1)) // create a denylist but do not add validator `providerAddr` to it providerKeeper.SetDenylist(ctx, consumerID, types.NewProviderConsAddress(consAddrA)) - require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 1)) // add validator `providerAddr` to the denylist providerKeeper.SetDenylist(ctx, consumerID, types.NewProviderConsAddress(consAddr)) - require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, 1)) + require.False(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 1)) } func TestCapValidatorSet(t *testing.T) { @@ -447,37 +466,49 @@ func TestCapValidatorSet(t *testing.T) { } validators := []types.ConsensusValidator{validatorA, validatorB, validatorC} - consumerValidators := providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.Error(t, err) + consumerValidators := providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 0, }) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 100, }) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 1, }) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, []types.ConsensusValidator{validatorC}, consumerValidators) providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 2, }) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, []types.ConsensusValidator{validatorC, validatorB}, consumerValidators) providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 3, }) - consumerValidators = providerKeeper.CapValidatorSet(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, []types.ConsensusValidator{validatorC, validatorB, validatorA}, consumerValidators) } @@ -525,7 +556,9 @@ func TestCapValidatorsPower(t *testing.T) { } // no capping takes place because validators power-cap is not set - cappedValidators := providerKeeper.CapValidatorsPower(ctx, "consumerId", validators) + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.Error(t, err) + cappedValidators := providerKeeper.CapValidatorsPower(ctx, powerShapingParameters.ValidatorsPowerCap, validators) sortValidators(validators) sortValidators(cappedValidators) require.Equal(t, validators, cappedValidators) @@ -533,7 +566,9 @@ func TestCapValidatorsPower(t *testing.T) { providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorsPowerCap: 33, }) - cappedValidators = providerKeeper.CapValidatorsPower(ctx, "consumerId", validators) + powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + cappedValidators = providerKeeper.CapValidatorsPower(ctx, powerShapingParameters.ValidatorsPowerCap, validators) sortValidators(expectedValidators) sortValidators(cappedValidators) require.Equal(t, expectedValidators, cappedValidators) @@ -737,7 +772,7 @@ func findConsumerValidator(t *testing.T, v types.ConsensusValidator, valsAfter [ func createStakingValidatorsAndMocks(ctx sdk.Context, mocks testkeeper.MockedKeepers, powers ...int64) ([]stakingtypes.Validator, []types.ProviderConsAddress) { var validators []stakingtypes.Validator for i, power := range powers { - val := createStakingValidator(ctx, mocks, i, power, i) + val := createStakingValidator(ctx, mocks, power, i) val.Tokens = math.NewInt(power) val.Status = stakingtypes.Bonded validators = append(validators, val) @@ -792,11 +827,8 @@ func TestFulfillsMinStake(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ - MinStake: tc.minStake, - }) for i, valAddr := range consAddrs { - result := providerKeeper.FulfillsMinStake(ctx, "consumerId", valAddr) + result := providerKeeper.FulfillsMinStake(ctx, tc.minStake, valAddr) require.Equal(t, tc.expectedFulfill[i], result) } }) @@ -834,8 +866,11 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { params.MaxProviderConsensusValidators = int64(maxProviderConsensusVals) providerKeeper.SetParams(ctx, params) + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") + require.NoError(t, err) + // Compute the next validators - nextVals := providerKeeper.ComputeNextValidators(ctx, "consumerId", vals, 0) + nextVals := providerKeeper.ComputeNextValidators(ctx, "consumerId", vals, powerShapingParameters, 0) // Check that the length of nextVals is at most maxProviderConsensusVals require.LessOrEqual(r, len(nextVals), int(maxProviderConsensusVals), "The length of nextVals should be at most maxProviderConsensusVals") diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index e77d152bd2..f684f8b80d 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -203,6 +203,14 @@ func (k Keeper) DeleteConsumerPhase(ctx sdk.Context, consumerId string) { store.Delete(types.ConsumerIdToPhaseKey(consumerId)) } +// IsConsumerActive checks if a consumer chain is either registered, initialized, or launched. +func (k Keeper) IsConsumerActive(ctx sdk.Context, consumerId string) bool { + phase := k.GetConsumerPhase(ctx, consumerId) + return phase == types.ConsumerPhase_CONSUMER_PHASE_REGISTERED || + phase == types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED || + phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED +} + // GetConsumerStopTime returns the stop time associated with the to-be-stopped chain with consumer id func (k Keeper) GetConsumerStopTime(ctx sdk.Context, consumerId string) (time.Time, error) { store := ctx.KVStore(k.storeKey) @@ -321,13 +329,13 @@ func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) ( return k.getConsumerIdsBasedOnTime(ctx, types.SpawnTimeToConsumerIdsKey, spawnTime) } -// AppendConsumerToBeLaunchedOnSpawnTime appends the provider consumer id for the given spawn time -func (k Keeper) AppendConsumerToBeLaunchedOnSpawnTime(ctx sdk.Context, consumerId string, spawnTime time.Time) error { +// AppendConsumerToBeLaunched appends the provider consumer id for the given spawn time +func (k Keeper) AppendConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { return k.appendConsumerIdOnTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) } -// RemoveConsumerToBeLaunchedFromSpawnTime removes consumer id from if stored for this specific spawn time -func (k Keeper) RemoveConsumerToBeLaunchedFromSpawnTime(ctx sdk.Context, consumerId string, spawnTime time.Time) error { +// RemoveConsumerToBeLaunched removes consumer id from if stored for this specific spawn time +func (k Keeper) RemoveConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { return k.removeConsumerIdFromTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) } @@ -336,13 +344,13 @@ func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (ty return k.getConsumerIdsBasedOnTime(ctx, types.StopTimeToConsumerIdsKey, stopTime) } -// AppendConsumerToBeStoppedOnStopTime appends the provider consumer id for the given stop time -func (k Keeper) AppendConsumerToBeStoppedOnStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { +// AppendConsumerToBeStopped appends the provider consumer id for the given stop time +func (k Keeper) AppendConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { return k.appendConsumerIdOnTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) } -// RemoveConsumerToBeStoppedFromStopTime removes consumer id from if stored for this specific stop time -func (k Keeper) RemoveConsumerToBeStoppedFromStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { +// RemoveConsumerToBeStopped removes consumer id from if stored for this specific stop time +func (k Keeper) RemoveConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { return k.removeConsumerIdFromTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) } @@ -641,12 +649,12 @@ func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, pre if !previousSpawnTime.Equal(time.Time{}) { // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` // remove the consumer id from the previous spawn time - err := k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, previousSpawnTime) + err := k.RemoveConsumerToBeLaunched(ctx, consumerId, previousSpawnTime) if err != nil { return err } } - return k.AppendConsumerToBeLaunchedOnSpawnTime(ctx, consumerId, spawnTime) + return k.AppendConsumerToBeLaunched(ctx, consumerId, spawnTime) } // CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index da8412220e..f4eb4922c1 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -263,28 +263,28 @@ func TestConsumerStopTime(t *testing.T) { require.Error(t, err) } -// TestConsumersToBeLaunched tests `AppendConsumerToBeLaunchedOnSpawnTime`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunchedFromSpawnTime` +// TestConsumersToBeLaunched tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` func TestConsumersToBeLaunched(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() spawnTime := time.Now() - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", spawnTime) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", spawnTime) consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1"}, consumers.Ids) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", spawnTime) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", spawnTime) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", spawnTime) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", spawnTime) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) - err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId2", spawnTime) + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId2", spawnTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) @@ -292,7 +292,7 @@ func TestConsumersToBeLaunched(t *testing.T) { // also add consumer ids under a different spawn time and verify everything under the original spawn time is still there spawnTimePlusOneHour := spawnTime.Add(time.Hour) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId4", spawnTimePlusOneHour) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) require.NoError(t, err) require.Equal(t, []string{"consumerId4"}, consumers.Ids) @@ -302,51 +302,51 @@ func TestConsumersToBeLaunched(t *testing.T) { require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) // start removing all consumers from `spawnTime` - err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId3", spawnTime) + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId3", spawnTime) require.NoError(t, err) - err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId1", spawnTime) + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId1", spawnTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) require.Empty(t, consumers.Ids) // remove from `spawnTimePlusOneHour` - err = providerKeeper.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, "consumerId4", spawnTimePlusOneHour) + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) require.NoError(t, err) require.Empty(t, consumers.Ids) // add another consumer for `spawnTime` - err = providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId5", spawnTime) + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId5", spawnTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) require.NoError(t, err) require.Equal(t, []string{"consumerId5"}, consumers.Ids) } -// TestConsumersToBeStopped tests `AppendConsumerToBeLaunchedOnSpawnTime`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunchedFromSpawnTime` +// TestConsumersToBeStopped tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` func TestConsumersToBeStopped(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() stopTime := time.Now() - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId1", stopTime) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", stopTime) consumers, err := providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1"}, consumers.Ids) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId2", stopTime) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", stopTime) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId3", stopTime) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", stopTime) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) - err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId2", stopTime) + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId2", stopTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) @@ -354,7 +354,7 @@ func TestConsumersToBeStopped(t *testing.T) { // also add consumer ids under a different stop time and verify everything under the original stop time is still there stopTimePlusOneHour := stopTime.Add(time.Hour) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId4", stopTimePlusOneHour) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) require.NoError(t, err) require.Equal(t, []string{"consumerId4"}, consumers.Ids) @@ -364,23 +364,23 @@ func TestConsumersToBeStopped(t *testing.T) { require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) // start removing all consumers from `stopTime` - err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId3", stopTime) + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId3", stopTime) require.NoError(t, err) - err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId1", stopTime) + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId1", stopTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) require.Empty(t, consumers.Ids) // remove from `stopTimePlusOneHour` - err = providerKeeper.RemoveConsumerToBeStoppedFromStopTime(ctx, "consumerId4", stopTimePlusOneHour) + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) require.NoError(t, err) require.Empty(t, consumers.Ids) // add another consumer for `stopTime` - err = providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId5", stopTime) + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId5", stopTime) require.NoError(t, err) consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) require.NoError(t, err) @@ -474,9 +474,9 @@ func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { // no chains to-be-launched exist require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, "consumerId3", time.Unix(30, 0)) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", time.Unix(30, 0)) // time has not yet reached the spawn time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) @@ -507,9 +507,9 @@ func TestGetLaunchedConsumersReadyToStop(t *testing.T) { // no chains to-be-stopped exist require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, "consumerId3", time.Unix(30, 0)) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) + providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) // time has not yet reached the stop time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) @@ -585,9 +585,9 @@ func TestUpdateMinimumPowerInTopN(t *testing.T) { // test cases where Top N > 0 and for this we mock some validators powers := []int64{10, 20, 30} validators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, 1, powers[0], 1), // this validator has ~16 of the total voting power - createStakingValidator(ctx, mocks, 2, powers[1], 2), // this validator has ~33% of the total voting gpower - createStakingValidator(ctx, mocks, 3, powers[2], 3), // this validator has 50% of the total voting power + createStakingValidator(ctx, mocks, powers[0], 1), // this validator has ~16 of the total voting power + createStakingValidator(ctx, mocks, powers[1], 2), // this validator has ~33% of the total voting gpower + createStakingValidator(ctx, mocks, powers[2], 3), // this validator has 50% of the total voting power } mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() @@ -736,6 +736,7 @@ func TestHasAtMostOnceCorrectMsgUpdateConsumer(t *testing.T) { // a proposal with 2 `MsgUpdateConsumer` messages invalidProposal, err := govv1.NewProposal([]sdk.Msg{&expectedMsgUpdateConsumer, &expectedMsgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) + require.NoError(t, err) actualMsgUpdateConsumer, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &invalidProposal) require.ErrorContains(t, err, "proposal can contain at most one") require.Nil(t, actualMsgUpdateConsumer) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 03e1293645..6d95a1679f 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -183,21 +183,13 @@ func (k Keeper) MakeConsumerGenesis( ) (gen ccv.ConsumerGenesisState, nextValidatorsHash []byte, err error) { initializationRecord, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { - return gen, nil, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, - "initialization record for consumer id: %s is missing", consumerId) - + return gen, nil, errorsmod.Wrapf(ccv.ErrInvalidConsumerState, + "cannot retrieve initialization parameters: %s", err.Error()) } powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) if err != nil { - powerShapingParameters = types.PowerShapingParameters{ - Top_N: 0, - ValidatorsPowerCap: 0, - ValidatorSetCap: 0, - Allowlist: []string{}, - Denylist: []string{}, - MinStake: 0, - AllowInactiveVals: false, - } + return gen, nil, errorsmod.Wrapf(ccv.ErrInvalidConsumerState, + "cannot retrieve power shaping parameters: %s", err.Error()) } providerUnbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) @@ -256,7 +248,7 @@ func (k Keeper) MakeConsumerGenesis( } // need to use the bondedValidators, not activeValidators, here since the chain might be opt-in and allow inactive vals - nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, powerShapingParameters, minPower) k.SetConsumerValSet(ctx, consumerId, nextValidators) // get the initial updates with the latest set consumer public keys @@ -307,7 +299,7 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) { } // Remove consumer to prevent re-trying launching this chain. // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. - k.RemoveConsumerToBeLaunchedFromSpawnTime(ctx, consumerId, record.SpawnTime) + k.RemoveConsumerToBeLaunched(ctx, consumerId, record.SpawnTime) cachedCtx, writeFn := ctx.CacheContext() err = k.LaunchConsumer(cachedCtx, consumerId) @@ -334,7 +326,7 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { stopTime, err := k.GetConsumerStopTime(ctx, consumerId) if err != nil { - k.Logger(ctx).Info("chain could not be stopped", + k.Logger(ctx).Error("chain could not be stopped", "consumerId", consumerId, "err", err.Error()) continue @@ -349,7 +341,7 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { } k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) - k.RemoveConsumerToBeStoppedFromStopTime(ctx, consumerId, stopTime) + k.RemoveConsumerToBeStopped(ctx, consumerId, stopTime) // The cached context is created with a new EventManager so we merge the event into the original context ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index eaa7d76ec9..9e5e094eb2 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -348,6 +348,7 @@ func TestMakeConsumerGenesis(t *testing.T) { providerKeeper.SetConsumerChainId(ctx, "0", "testchain1") providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", providertypes.PowerShapingParameters{}) actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, "0") require.NoError(t, err) @@ -612,7 +613,7 @@ func TestBeginBlockInit(t *testing.T) { providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) // set up the chains in their initialized phase, hence they could launch providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.AppendConsumerToBeLaunchedOnSpawnTime(ctx, fmt.Sprintf("%d", i), r.SpawnTime) + providerKeeper.AppendConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) } for i, r := range powerShapingParameters { providerKeeper.SetConsumerPowerShapingParameters(ctx, fmt.Sprintf("%d", i), r) @@ -677,17 +678,17 @@ func TestBeginBlockCCR(t *testing.T) { chainIds := []string{"chain1", "chain2", "chain3"} consumerIds := []string{"consumerId1", "consumerId2", "consumerId3"} providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) + providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[1], now) + providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[1], now) providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) - providerKeeper.AppendConsumerToBeStoppedOnStopTime(ctx, consumerIds[2], now.Add(time.Hour)) + providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) // // Mock expectations // expectations := []*gomock.Call{} - for i, _ := range consumerIds { + for i := range consumerIds { chainId := chainIds[i] // A consumer chain is setup corresponding to each consumerId, making these mocks necessary testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index cfa8ec5a9f..88369568ff 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -15,7 +15,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -95,7 +94,7 @@ func (k Keeper) ProviderValidatorUpdates(ctx sdk.Context) []abci.ValidatorUpdate panic(fmt.Errorf("failed to get last provider consensus validator set: %w", err)) } - nextValidators := []types.ConsensusValidator{} + nextValidators := []providertypes.ConsensusValidator{} maxValidators := k.GetMaxProviderConsensusValidators(ctx) // avoid out of range errors by bounding the max validators to the number of bonded validators if maxValidators > int64(len(bondedValidators)) { @@ -195,24 +194,27 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { currentValidators, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { - panic(fmt.Errorf("failed to get consumer validators: %w", err)) + panic(fmt.Errorf("failed to get consumer validators, consumerId(%s): %w", consumerId, err)) + } + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + if err != nil { + panic(fmt.Errorf("failed to get consumer power shaping parameters: %w", err)) } - topN := k.GetTopN(ctx, consumerId) minPower := int64(0) - if topN > 0 { + if powerShapingParameters.Top_N > 0 { // in a Top-N chain, we automatically opt in all validators that belong to the top N // of the active validators activeValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) if err != nil { // something must be broken in the bonded validators, so we have to panic since there is no realistic way to proceed - panic(fmt.Errorf("failed to get active validators: %w", err)) + panic(fmt.Errorf("failed to get active validators, consumerId(%s): %w", consumerId, err)) } - minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, topN) + minPower, err = k.ComputeMinPowerInTopN(ctx, activeValidators, powerShapingParameters.Top_N) if err != nil { // we panic, since the only way to proceed would be to opt in all validators, which is not the intended behavior - panic(fmt.Errorf("failed to compute min power to opt in for chain %v: %w", consumerId, err)) + panic(fmt.Errorf("failed to compute min power to opt in, consumerId(%s): %w", consumerId, err)) } // set the minimal power of validators in the top N in the store @@ -221,7 +223,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { k.OptInTopNValidators(ctx, consumerId, activeValidators, minPower) } - nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, minPower) + nextValidators := k.ComputeNextValidators(ctx, consumerId, bondedValidators, powerShapingParameters, minPower) valUpdates := DiffValidators(currentValidators, nextValidators) k.SetConsumerValSet(ctx, consumerId, nextValidators) diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index db8c991d7f..fb27247263 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -94,11 +94,11 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { providerKeeper.SetParams(ctx, providertypes.DefaultParams()) // mock 2 bonded validators - valA := createStakingValidator(ctx, mocks, 1, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1) valAConsAddr, _ := valA.GetConsAddr() valAPubKey, _ := valA.TmConsPublicKey() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2) valBConsAddr, _ := valB.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{valA, valB}, -1) @@ -120,6 +120,10 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { // validator for the first time after the `QueueVSCPackets` call. providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valBConsAddr)) + // set power shaping params + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{}) + require.NoError(t, err) + providerKeeper.QueueVSCPackets(ctx) // the height of consumer validator A should not be modified because A was already a consumer validator @@ -596,14 +600,12 @@ func TestEndBlockVSU(t *testing.T) { // create 4 sample lastValidators var lastValidators []stakingtypes.Validator - var powers []int64 for i := 0; i < 4; i++ { validator := cryptotestutil.NewCryptoIdentityFromIntSeed(i).SDKStakingValidator() lastValidators = append(lastValidators, validator) valAdrr, err := sdk.ValAddressFromBech32(validator.GetOperator()) require.NoError(t, err) mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(gomock.Any(), valAdrr).Return(int64(i+1), nil).AnyTimes() - powers = append(powers, int64(i+1)) } testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 5, lastValidators, -1) @@ -649,14 +651,14 @@ func TestProviderValidatorUpdates(t *testing.T) { // Mocking bonded validators in the staking keeper. // be aware that the powers need to be in descending order validators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, 3, 30, 3), - createStakingValidator(ctx, mocks, 2, 20, 2), - createStakingValidator(ctx, mocks, 1, 10, 1), + createStakingValidator(ctx, mocks, 30, 3), + createStakingValidator(ctx, mocks, 20, 2), + createStakingValidator(ctx, mocks, 10, 1), } mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(ctx).Return(validators, nil).Times(1) // set up a validator that we will only use for the last provider consensus validator set - removedValidator := createStakingValidator(ctx, mocks, 4, 40, 4) + removedValidator := createStakingValidator(ctx, mocks, 40, 4) // Set up the last provider consensus validators consensusVals := make([]providertypes.ConsensusValidator, 0, len(validators)) @@ -715,22 +717,22 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { providerKeeper.SetValidatorSetUpdateId(ctx, 1) - valA := createStakingValidator(ctx, mocks, 1, 1, 1) // 3.125% of the total voting power + valA := createStakingValidator(ctx, mocks, 1, 1) // 3.125% of the total voting power valAConsAddr, _ := valA.GetConsAddr() valAPubKey, _ := valA.TmConsPublicKey() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valAConsAddr).Return(valA, nil).AnyTimes() - valB := createStakingValidator(ctx, mocks, 2, 3, 2) // 9.375% of the total voting power + valB := createStakingValidator(ctx, mocks, 3, 2) // 9.375% of the total voting power valBConsAddr, _ := valB.GetConsAddr() valBPubKey, _ := valB.TmConsPublicKey() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() - valC := createStakingValidator(ctx, mocks, 3, 4, 3) // 12.5% of the total voting power + valC := createStakingValidator(ctx, mocks, 4, 3) // 12.5% of the total voting power valCConsAddr, _ := valC.GetConsAddr() valCPubKey, _ := valC.TmConsPublicKey() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valCConsAddr).Return(valC, nil).AnyTimes() - valD := createStakingValidator(ctx, mocks, 4, 8, 4) // 25% of the total voting power + valD := createStakingValidator(ctx, mocks, 8, 4) // 25% of the total voting power valDConsAddr, _ := valD.GetConsAddr() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valDConsAddr).Return(valD, nil).AnyTimes() - valE := createStakingValidator(ctx, mocks, 5, 16, 5) // 50% of the total voting power + valE := createStakingValidator(ctx, mocks, 16, 5) // 50% of the total voting power valEConsAddr, _ := valE.GetConsAddr() valEPubKey, _ := valE.TmConsPublicKey() mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valEConsAddr).Return(valE, nil).AnyTimes() diff --git a/x/ccv/provider/keeper/staking_keeper_interface_test.go b/x/ccv/provider/keeper/staking_keeper_interface_test.go index 2eb9c9f1bd..40cfb5c0d7 100644 --- a/x/ccv/provider/keeper/staking_keeper_interface_test.go +++ b/x/ccv/provider/keeper/staking_keeper_interface_test.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" "github.com/golang/mock/gomock" @@ -107,7 +106,7 @@ func TestStakingKeeperInterface(t *testing.T) { return nil }).AnyTimes() actualValPowers := []int64{} - err := providerKeeper.IterateBondedValidatorsByPower(ctx, func(index int64, validator types.ValidatorI) (stop bool) { + err := providerKeeper.IterateBondedValidatorsByPower(ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) { counter++ actualValPowers = append(actualValPowers, validator.GetTokens().Int64()) return false diff --git a/x/ccv/provider/keeper/validator_set_update_test.go b/x/ccv/provider/keeper/validator_set_update_test.go index 58ef556aec..aa9ae6abba 100644 --- a/x/ccv/provider/keeper/validator_set_update_test.go +++ b/x/ccv/provider/keeper/validator_set_update_test.go @@ -111,7 +111,7 @@ func createConsumerValidator(index int, power int64, seed int) (types.ConsensusV } // createStakingValidator helper function to generate a validator with the given power and with a provider address based on index -func createStakingValidator(ctx sdk.Context, mocks testkeeper.MockedKeepers, index int, power int64, seed int) stakingtypes.Validator { +func createStakingValidator(ctx sdk.Context, mocks testkeeper.MockedKeepers, power int64, seed int) stakingtypes.Validator { providerConsPubKey := cryptotestutil.NewCryptoIdentityFromIntSeed(seed).TMProtoCryptoPublicKey() pk, _ := cryptocodec.FromCmtProtoPublicKey(providerConsPubKey) @@ -348,7 +348,7 @@ func TestFilterValidatorsConsiderAll(t *testing.T) { var expectedValidators []types.ConsensusValidator // create a staking validator A that has not set a consumer public key - valA := createStakingValidator(ctx, mocks, 1, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1) // because validator A has no consumer key set, the `PublicKey` we expect is the key on the provider chain valAConsAddr, _ := valA.GetConsAddr() valAPublicKey, _ := valA.TmConsPublicKey() @@ -359,7 +359,7 @@ func TestFilterValidatorsConsiderAll(t *testing.T) { }) // create a staking validator B that has set a consumer public key - valB := createStakingValidator(ctx, mocks, 2, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2) // validator B has set a consumer key, the `PublicKey` we expect is the key set by `SetValidatorConsumerPubKey` valBConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valBConsAddr, _ := valB.GetConsAddr() @@ -390,7 +390,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { var expectedValidators []types.ConsensusValidator // create a staking validator A that has not set a consumer public key - valA := createStakingValidator(ctx, mocks, 1, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1) // because validator A has no consumer key set, the `PublicKey` we expect is the key on the provider chain valAConsAddr, _ := valA.GetConsAddr() valAPublicKey, _ := valA.TmConsPublicKey() @@ -402,7 +402,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { expectedValidators = append(expectedValidators, expectedValAConsumerValidator) // create a staking validator B that has set a consumer public key - valB := createStakingValidator(ctx, mocks, 2, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2) // validator B has set a consumer key, the `PublicKey` we expect is the key set by `SetValidatorConsumerPubKey` valBConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valBConsAddr, _ := valB.GetConsAddr() @@ -437,7 +437,7 @@ func TestFilterValidatorsConsiderOnlyOptIn(t *testing.T) { require.Equal(t, expectedValidators, actualValidators) // create a staking validator C that is not opted in, hence `expectedValidators` remains the same - valC := createStakingValidator(ctx, mocks, 3, 3, 3) + valC := createStakingValidator(ctx, mocks, 3, 3) bondedValidators = []stakingtypes.Validator{valA, valB, valC} actualValidators = providerKeeper.FilterValidators(ctx, "consumerId", bondedValidators, func(providerAddr types.ProviderConsAddress) bool { @@ -456,7 +456,7 @@ func TestCreateConsumerValidator(t *testing.T) { chainID := "consumerId" // create a validator which has set a consumer public key - valA := createStakingValidator(ctx, mocks, 0, 1, 1) + valA := createStakingValidator(ctx, mocks, 1, 1) valAConsumerKey := cryptotestutil.NewCryptoIdentityFromIntSeed(1).TMProtoCryptoPublicKey() valAConsAddr, _ := valA.GetConsAddr() valAProviderConsAddr := types.NewProviderConsAddress(valAConsAddr) @@ -471,7 +471,7 @@ func TestCreateConsumerValidator(t *testing.T) { require.NoError(t, err) // create a validator which has not set a consumer public key - valB := createStakingValidator(ctx, mocks, 1, 2, 2) + valB := createStakingValidator(ctx, mocks, 2, 2) valBConsAddr, _ := valB.GetConsAddr() valBProviderConsAddr := types.NewProviderConsAddress(valBConsAddr) valBPublicKey, _ := valB.TmConsPublicKey() diff --git a/x/ccv/provider/migrations/v5/migration_test.go b/x/ccv/provider/migrations/v5/migration_test.go index dce390ad71..1ae0e98a20 100644 --- a/x/ccv/provider/migrations/v5/migration_test.go +++ b/x/ccv/provider/migrations/v5/migration_test.go @@ -16,13 +16,14 @@ func TestMigrateParams(t *testing.T) { provKeeper.SetConsumerClientId(ctx, "chainID", "clientID") // initially top N should not exist - topN := provKeeper.GetTopN(ctx, "chainID") - require.Zero(t, topN) + _, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "chainID") + require.Error(t, err) // migrate MigrateTopNForRegisteredChains(ctx, provKeeper) // after migration, top N should be 95 - topN = provKeeper.GetTopN(ctx, "chainID") - require.Equal(t, uint32(95), topN) + powerShapingParameters, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "chainID") + require.NoError(t, err) + require.Equal(t, uint32(95), powerShapingParameters.Top_N) } diff --git a/x/ccv/provider/migrations/v6/migrations.go b/x/ccv/provider/migrations/v6/migrations.go index 933c5b9853..efbded3d02 100644 --- a/x/ccv/provider/migrations/v6/migrations.go +++ b/x/ccv/provider/migrations/v6/migrations.go @@ -23,8 +23,12 @@ func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper for _, chain := range registeredConsumerChains { // get the top N - topN := providerKeeper.GetTopN(ctx, chain) - if topN == 0 { + powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, chain) + if err != nil { + providerKeeper.Logger(ctx).Error("failed to get power shaping parameters", "chain", chain, "error", err) + continue + } + if powerShapingParameters.Top_N == 0 { providerKeeper.Logger(ctx).Info("top N is 0, not setting minimal power", "chain", chain) } else { // set the minimal power in the top N @@ -33,9 +37,9 @@ func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper providerKeeper.Logger(ctx).Error("failed to get last bonded validators", "chain", chain, "error", err) continue } - minPower, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, topN) + minPower, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, powerShapingParameters.Top_N) if err != nil { - providerKeeper.Logger(ctx).Error("failed to compute min power in top N", "chain", chain, "topN", topN, "error", err) + providerKeeper.Logger(ctx).Error("failed to compute min power in top N", "chain", chain, "topN", powerShapingParameters.Top_N, "error", err) continue } providerKeeper.SetMinimumPowerInTopN(ctx, chain, minPower) diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index b7ab44d029..57ab5c2a99 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -48,4 +48,5 @@ var ( ErrInvalidTransformToOptIn = errorsmod.Register(ModuleName, 40, "invalid transform to Opt In chain") ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") ErrCannotPrepareForLaunch = errorsmod.Register(ModuleName, 42, "cannot prepare chain for launch") + ErrInvalidStopTime = errorsmod.Register(ModuleName, 43, "invalid stop time") ) From 1c63e3e40d2cc8824d52267d8889a82d99a5913f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 29 Aug 2024 15:55:07 +0200 Subject: [PATCH 19/43] fix: fix consumer chain query CLI (#2190) * fix consumer chains query cli * add consumer-chain cli command * fix consumer chains cli bug --- x/ccv/provider/client/cli/query.go | 32 ++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 1d6e26350b..be516d584f 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -39,6 +39,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdValidatorConsumerCommissionRate()) cmd.AddCommand(CmdBlocksUntilNextEpoch()) cmd.AddCommand(CmdConsumerIdFromClientId()) + cmd.AddCommand(CmdConsumerChain()) return cmd } @@ -88,7 +89,7 @@ func CmdConsumerChains() *cobra.Command { req := &types.QueryConsumerChainsRequest{} - if args[0] != "" { + if len(args) >= 1 && args[0] != "" { phase, err := strconv.ParseInt(args[0], 10, 32) if err != nil { return err @@ -96,7 +97,7 @@ func CmdConsumerChains() *cobra.Command { req.Phase = types.ConsumerPhase(phase) } - if args[1] != "" { + if len(args) == 2 && args[1] != "" { limit, err := strconv.ParseInt(args[1], 10, 32) if err != nil { return err @@ -553,3 +554,30 @@ func CmdConsumerIdFromClientId() *cobra.Command { return cmd } + +func CmdConsumerChain() *cobra.Command { + cmd := &cobra.Command{ + Use: "consumer-chain [consumer-id]", + Short: "Query the consumer chain associated with the consumer id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryConsumerChainRequest{ConsumerId: args[0]} + res, err := queryClient.QueryConsumerChain(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From 4c30f6bef967af2fe1b454f4f304b45d1ab87d64 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 29 Aug 2024 19:34:46 +0200 Subject: [PATCH 20/43] fix!: fix store.set nil values (#2193) fix store.set nil values --- x/ccv/provider/migrations/v8/migrations.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index 916e3d0a22..7ed39ad5b6 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -289,9 +289,11 @@ func rekeyFromChainIdToConsumerId( ) { oldKey := append([]byte{keyPrefix}, []byte(chainId)...) value := store.Get(oldKey) - newKey := append([]byte{keyPrefix}, []byte(consumerId)...) - store.Set(newKey, value) - store.Delete(oldKey) + if value != nil { + newKey := append([]byte{keyPrefix}, []byte(consumerId)...) + store.Set(newKey, value) + store.Delete(oldKey) + } } // rekeyChainIdAndConsAddrKey migrates store keys @@ -321,6 +323,10 @@ func rekeyChainIdAndConsAddrKey( for _, addr := range addrs { oldKey := providertypes.StringIdAndConsAddrKey(keyPrefix, chainId, addr) value := store.Get(oldKey) + if value == nil { + // this should not happen, but just in case as Set will fail if value is nil + continue + } newKey := providertypes.StringIdAndConsAddrKey(keyPrefix, consumerId, addr) store.Set(newKey, value) store.Delete(oldKey) @@ -356,6 +362,10 @@ func rekeyChainIdAndTsKey( for _, ts := range timestamps { oldKey := providertypes.StringIdAndTsKey(keyPrefix, chainId, ts) value := store.Get(oldKey) + if value == nil { + // this should not happen, but just in case as Set will fail if value is nil + continue + } newKey := providertypes.StringIdAndTsKey(keyPrefix, consumerId, ts) store.Set(newKey, value) store.Delete(oldKey) From 45c5fceeaba3d2696a07a6dc2420c29e2345cfa9 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Fri, 30 Aug 2024 14:08:52 +0200 Subject: [PATCH 21/43] fix!: msgs validation (#2195) * add testing for ValidateStringField * ValidateInitializationParameters * ValidatePowerShapingParameters * validate NewOwnerAddress * apply review suggestions --- x/ccv/provider/types/errors.go | 2 + x/ccv/provider/types/msg.go | 150 ++++++++------ x/ccv/provider/types/msg_test.go | 345 ++++++++++++++++++++++++++++++- x/ccv/types/shared_params.go | 2 +- 4 files changed, 438 insertions(+), 61 deletions(-) diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 57ab5c2a99..90bb46ccaf 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -49,4 +49,6 @@ var ( ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") ErrCannotPrepareForLaunch = errorsmod.Register(ModuleName, 42, "cannot prepare chain for launch") ErrInvalidStopTime = errorsmod.Register(ModuleName, 43, "invalid stop time") + ErrInvalidMsgCreateConsumer = errorsmod.Register(ModuleName, 44, "invalid create consumer message") + ErrInvalidMsgUpdateConsumer = errorsmod.Register(ModuleName, 45, "invalid update consumer message") ) diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 08a4b516c9..9bca3f996f 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -33,6 +33,17 @@ const ( TypeMsgOptIn = "opt_in" TypeMsgOptOut = "opt_out" TypeMsgSetConsumerCommissionRate = "set_consumer_commission_rate" + + // MaxNameLength defines the maximum consumer name length + MaxNameLength = 50 + // MaxDescriptionLength defines the maximum consumer description length + MaxDescriptionLength = 10000 + // MaxMetadataLength defines the maximum consumer metadata length + MaxMetadataLength = 255 + // MaxHashLength defines the maximum length of a hash + MaxHashLength = 64 + // MaxValidatorCount defines the maximum number of validators + MaxValidatorCount = 1000 ) var ( @@ -257,17 +268,17 @@ func (msg MsgCreateConsumer) Route() string { return RouterKey } // ValidateBasic implements the sdk.Msg interface. func (msg MsgCreateConsumer) ValidateBasic() error { - if err := ValidateField("chain id", msg.ChainId, cmttypes.MaxChainIDLen); err != nil { - return err + if err := ValidateStringField("ChainId", msg.ChainId, cmttypes.MaxChainIDLen); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgCreateConsumer, "ChainId: %s", err.Error()) } if err := ValidateConsumerMetadata(msg.Metadata); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgCreateConsumer, "Metadata: %s", err.Error()) } if msg.InitializationParameters != nil { if err := ValidateInitializationParameters(*msg.InitializationParameters); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgCreateConsumer, "InitializationParameters: %s", err.Error()) } } @@ -277,7 +288,7 @@ func (msg MsgCreateConsumer) ValidateBasic() error { "first create the chain and then use `MsgUpdateConsumer` to make the chain Top N") } if err := ValidatePowerShapingParameters(*msg.PowerShapingParameters); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgCreateConsumer, "PowerShapingParameters: %s", err.Error()) } } @@ -325,24 +336,26 @@ func (msg MsgUpdateConsumer) Route() string { return RouterKey } // ValidateBasic implements the sdk.Msg interface. func (msg MsgUpdateConsumer) ValidateBasic() error { if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "ConsumerId: %s", err.Error()) } + // Note that NewOwnerAddress is validated when handling the message in UpdateConsumer + if msg.Metadata != nil { if err := ValidateConsumerMetadata(*msg.Metadata); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "Metadata: %s", err.Error()) } } if msg.InitializationParameters != nil { if err := ValidateInitializationParameters(*msg.InitializationParameters); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "InitializationParameters: %s", err.Error()) } } if msg.PowerShapingParameters != nil { if err := ValidatePowerShapingParameters(*msg.PowerShapingParameters); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "PowerShapingParameters: %s", err.Error()) } } @@ -736,8 +749,10 @@ func ValidateConsumerId(consumerId string) error { return nil } -// ValidateField validates that `field` is not empty and has at most `maxLength` characters -func ValidateField(nameOfTheField string, field string, maxLength int) error { +// ValidateStringField validates that a string `field` satisfies the following properties: +// - is not empty +// - has at most `maxLength` characters +func ValidateStringField(nameOfTheField string, field string, maxLength int) error { if strings.TrimSpace(field) == "" { return fmt.Errorf("%s cannot be empty", nameOfTheField) } else if len(field) > maxLength { @@ -746,48 +761,72 @@ func ValidateField(nameOfTheField string, field string, maxLength int) error { return nil } +// TruncateString truncates a string to maximum length characters +func TruncateString(str string, maxLength int) string { + if maxLength <= 0 { + return "" + } + + truncated := "" + count := 0 + for _, char := range str { + truncated += string(char) + count++ + if count >= maxLength { + break + } + } + return truncated +} + // ValidateConsumerMetadata validates that all the provided metadata are in the expected range func ValidateConsumerMetadata(metadata ConsumerMetadata) error { - const maxNameLength = 100 - const maxDescriptionLength = 50000 - const maxMetadataLength = 1000 - - if err := ValidateField("name", metadata.Name, maxNameLength); err != nil { - return err + if err := ValidateStringField("name", metadata.Name, MaxNameLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerMetadata, "Name: %s", err.Error()) } - if err := ValidateField("description", metadata.Description, maxDescriptionLength); err != nil { - return err + if err := ValidateStringField("description", metadata.Description, MaxDescriptionLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerMetadata, "Description: %s", err.Error()) } - if err := ValidateField("metadata", metadata.Metadata, maxMetadataLength); err != nil { - return err + if err := ValidateStringField("metadata", metadata.Metadata, MaxMetadataLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerMetadata, "Metadata: %s", err.Error()) } return nil } +// ValidateConsAddressList validates a list of consensus addresses +func ValidateConsAddressList(list []string, maxLength int) error { + if len(list) > maxLength { + return fmt.Errorf("consensus address list too long; got: %d, max: %d", len(list), maxLength) + } + for _, address := range list { + _, err := sdk.ConsAddressFromBech32(address) + if err != nil { + return fmt.Errorf("invalid address %s: %s", address, err.Error()) + } + } + return nil +} + // ValidatePowerShapingParameters validates that all the provided power-shaping parameters are in the expected range func ValidatePowerShapingParameters(powerShapingParameters PowerShapingParameters) error { - const maxAllowlistLength = 500 - const maxDenylistLength = 500 - // Top N corresponds to the top N% of validators that have to validate the consumer chain and can only be 0 (for an // Opt In chain) or in the range [50, 100] (for a Top N chain). if powerShapingParameters.Top_N != 0 && (powerShapingParameters.Top_N < 50 || powerShapingParameters.Top_N > 100) { - return fmt.Errorf("parameter Top N can either be 0 or in the range [50, 100]") + return errorsmod.Wrap(ErrInvalidPowerShapingParameters, "Top N can either be 0 or in the range [50, 100]") } - if powerShapingParameters.ValidatorsPowerCap != 0 && powerShapingParameters.ValidatorsPowerCap > 100 { - return fmt.Errorf("validators' power cap has to be in the range [1, 100]") + if powerShapingParameters.ValidatorsPowerCap > 100 { + return errorsmod.Wrap(ErrInvalidPowerShapingParameters, "ValidatorsPowerCap has to be in the range [0, 100]") } - if len(powerShapingParameters.Allowlist) > maxAllowlistLength { - return fmt.Errorf("allowlist cannot exceed length: %d", maxAllowlistLength) + if err := ValidateConsAddressList(powerShapingParameters.Allowlist, MaxValidatorCount); err != nil { + return errorsmod.Wrapf(ErrInvalidPowerShapingParameters, "Allowlist: %s", err.Error()) } - - if len(powerShapingParameters.Denylist) > maxDenylistLength { - return fmt.Errorf("denylist cannot exceed length: %d", maxDenylistLength) + if err := ValidateConsAddressList(powerShapingParameters.Denylist, MaxValidatorCount); err != nil { + return errorsmod.Wrapf(ErrInvalidPowerShapingParameters, "Denylist: %s", err.Error()) } return nil @@ -795,63 +834,56 @@ func ValidatePowerShapingParameters(powerShapingParameters PowerShapingParameter // ValidateInitializationParameters validates that all the provided parameters are in the expected range func ValidateInitializationParameters(initializationParameters ConsumerInitializationParameters) error { - const maxGenesisHashLength = 1000 - const maxBinaryHashLength = 1000 - const maxConsumerRedistributionFractionLength = 50 - const maxDistributionTransmissionChannelLength = 1000 - if initializationParameters.InitialHeight.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "initial height cannot be zero") + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "InitialHeight cannot be zero") } - if len(initializationParameters.GenesisHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "genesis hash cannot be empty") - } else if len(initializationParameters.GenesisHash) > maxGenesisHashLength { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "genesis hash cannot exceed %d bytes", maxGenesisHashLength) + if err := ValidateByteSlice(initializationParameters.GenesisHash, MaxHashLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "GenesisHash: %s", err.Error()) } - if len(initializationParameters.BinaryHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "binary hash cannot be empty") - } else if len(initializationParameters.BinaryHash) > maxBinaryHashLength { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "binary hash cannot exceed %d bytes", maxBinaryHashLength) + if err := ValidateByteSlice(initializationParameters.BinaryHash, MaxHashLength); err != nil { + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "BinaryHash: %s", err.Error()) } if initializationParameters.SpawnTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "spawn time cannot be zero") + return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "SpawnTime cannot be zero") } if err := ccvtypes.ValidateStringFraction(initializationParameters.ConsumerRedistributionFraction); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "consumer redistribution fraction is invalid: %s", err.Error()) - } else if err := ValidateField("consumer redistribution fraction", initializationParameters.ConsumerRedistributionFraction, maxConsumerRedistributionFractionLength); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "consumer redistribution fraction is invalid: %s", err.Error()) + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "ConsumerRedistributionFraction: %s", err.Error()) } if err := ccvtypes.ValidatePositiveInt64(initializationParameters.BlocksPerDistributionTransmission); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "blocks per distribution transmission has to be positive") + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "BlocksPerDistributionTransmission: %s", err.Error()) } if err := ccvtypes.ValidateDistributionTransmissionChannel(initializationParameters.DistributionTransmissionChannel); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "distribution transmission channel is invalid: %s", err.Error()) - } else if len(initializationParameters.DistributionTransmissionChannel) > maxDistributionTransmissionChannelLength { - // note that the distribution transmission channel can be the empty string (i.e., "") and hence we only check its max length here - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "distribution transmission channel exceeds %d length", maxDistributionTransmissionChannelLength) + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "DistributionTransmissionChannel: %s", err.Error()) } if err := ccvtypes.ValidatePositiveInt64(initializationParameters.HistoricalEntries); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "historical entries has to be positive") + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "HistoricalEntries: %s", err.Error()) } if err := ccvtypes.ValidateDuration(initializationParameters.CcvTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "ccv timeout period cannot be zero") + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "CcvTimeoutPeriod: %s", err.Error()) } if err := ccvtypes.ValidateDuration(initializationParameters.TransferTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "transfer timeout period cannot be zero") + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "TransferTimeoutPeriod: %s", err.Error()) } if err := ccvtypes.ValidateDuration(initializationParameters.UnbondingPeriod); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "invalid unbonding period: %s", err.Error()) + return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "UnbondingPeriod: %s", err.Error()) } return nil } + +func ValidateByteSlice(hash []byte, maxLength int) error { + if len(hash) > maxLength { + return fmt.Errorf("hash is too long; got: %d, max: %d", len(hash), MaxHashLength) + } + return nil +} diff --git a/x/ccv/provider/types/msg_test.go b/x/ccv/provider/types/msg_test.go index da6d24d793..60f7d31675 100644 --- a/x/ccv/provider/types/msg_test.go +++ b/x/ccv/provider/types/msg_test.go @@ -1,9 +1,12 @@ package types_test import ( + "testing" + "time" + + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/stretchr/testify/require" - "testing" ) func TestValidateConsumerId(t *testing.T) { @@ -19,3 +22,343 @@ func TestValidateConsumerId(t *testing.T) { require.NoError(t, types.ValidateConsumerId("0")) require.NoError(t, types.ValidateConsumerId("18446744073709551615")) // 2^64 - 1 } + +func TestValidateStringField(t *testing.T) { + testCases := []struct { + name string + field string + maxLength int + valid bool + }{ + { + name: "invalid: empty", + field: "", + maxLength: 5, + valid: false, + }, + { + name: "invalid: too long", + field: "this field is too long", + maxLength: 5, + valid: false, + }, + { + name: "valid", + field: "valid", + maxLength: 5, + valid: true, + }, + } + + for _, tc := range testCases { + err := types.ValidateStringField(tc.name, tc.field, tc.maxLength) + if tc.valid { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} + +func TestTruncateString(t *testing.T) { + testCases := []struct { + str string + maxLength int + expStr string + }{ + {"drink", 3, "dri"}, + {"drink", 6, "drink"}, + {"drink", 0, ""}, + {"drink", -1, ""}, + {"drink", 100, "drink"}, + {"pub", 100, "pub"}, + {"こんにちは", 3, "こんに"}, + } + + for _, tc := range testCases { + truncated := types.TruncateString(tc.str, tc.maxLength) + require.Equal(t, tc.expStr, truncated) + } +} + +func TestValidateInitializationParameters(t *testing.T) { + now := time.Now().UTC() + coolStr := "Cosmos Hub is the best place to launch a chain. Interchain Security is awesome." + tooLongHash := []byte(coolStr) + + testCases := []struct { + name string + params types.ConsumerInitializationParameters + valid bool + }{ + { + name: "valid", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: true, + }, + { + name: "invalid - zero height", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.ZeroHeight(), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - hash too long", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: tooLongHash, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - zero spawn time", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: time.Time{}, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - zero duration", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: 0, + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid -- ConsumerRedistributionFraction > 1", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "1.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid -- ConsumerRedistributionFraction wrong format", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: coolStr, + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - BlocksPerDistributionTransmission zero", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 0, + HistoricalEntries: 10000, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - HistoricalEntries zero", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 0, + DistributionTransmissionChannel: "", + }, + valid: false, + }, + { + name: "invalid - DistributionTransmissionChannel too long", + params: types.ConsumerInitializationParameters{ + InitialHeight: clienttypes.NewHeight(3, 4), + GenesisHash: []byte{0x01}, + BinaryHash: []byte{0x01}, + SpawnTime: now, + UnbondingPeriod: time.Duration(100000000000), + CcvTimeoutPeriod: time.Duration(100000000000), + TransferTimeoutPeriod: time.Duration(100000000000), + ConsumerRedistributionFraction: "0.75", + BlocksPerDistributionTransmission: 10, + HistoricalEntries: 10000, + DistributionTransmissionChannel: coolStr, + }, + valid: false, + }, + } + + for _, tc := range testCases { + err := types.ValidateInitializationParameters(tc.params) + if tc.valid { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} + +func TestValidateConsAddressList(t *testing.T) { + consAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + invalidConsAddr := "cosmosvalcons1nx7n5uh0ztxsynn4sje6ey" + + testCases := []struct { + name string + list []string + maxLength int + valid bool + }{ + { + name: "valid - empty list", + list: []string{}, + maxLength: 10, + valid: true, + }, + { + name: "valid - non-empty list", + list: []string{consAddr1, consAddr2}, + maxLength: 10, + valid: true, + }, + { + name: "invalid - address with wrong format", + list: []string{invalidConsAddr}, + maxLength: 10, + valid: false, + }, + { + name: "invalid - empty address", + list: []string{""}, + maxLength: 10, + valid: false, + }, + { + name: "invalid - list length", + list: []string{consAddr1, consAddr2}, + maxLength: 1, + valid: false, + }, + } + + for _, tc := range testCases { + err := types.ValidateConsAddressList(tc.list, tc.maxLength) + if tc.valid { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} + +func TestValidateByteSlice(t *testing.T) { + testCases := []struct { + name string + slice []byte + maxLength int + valid bool + }{ + { + name: "valid: empty", + slice: []byte{}, + maxLength: 5, + valid: true, + }, + { + name: "invalid: too long", + slice: []byte{0x01, 0x02}, + maxLength: 1, + valid: false, + }, + { + name: "valid", + slice: []byte{0x01, 0x02}, + maxLength: 5, + valid: true, + }, + } + + for _, tc := range testCases { + err := types.ValidateByteSlice(tc.slice, tc.maxLength) + if tc.valid { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} diff --git a/x/ccv/types/shared_params.go b/x/ccv/types/shared_params.go index fa2e28c81c..d1a82df576 100644 --- a/x/ccv/types/shared_params.go +++ b/x/ccv/types/shared_params.go @@ -77,7 +77,7 @@ func ValidateChannelIdentifier(i interface{}) error { return ibchost.ChannelIdentifierValidator(value) } -func ValidateBech32(i interface{}) error { +func ValidateAccAddress(i interface{}) error { value, ok := i.(string) if !ok { return fmt.Errorf("invalid parameter type: %T", i) From b87451028c5aab29930959a401babd7254d64eed Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 30 Aug 2024 16:08:56 +0200 Subject: [PATCH 22/43] fix: fix queries' API REST endpoint path (#2196) * clean uw files * doc * Revert "doc" This reverts commit efc27181ee85499793d115ed28094abecf91474d. * Revert "clean uw files" This reverts commit 5773cf3b6ef0c98937c9aa03535f3eaf834cbe1f. * remove deprecated REST endpoints * update REST endpoint * fix broken UT by previous PR (#2195) --- .../ccv/provider/v1/query.proto | 58 +- x/ccv/provider/keeper/grpc_query.go | 15 +- x/ccv/provider/types/legacy_proposal_test.go | 6 +- x/ccv/provider/types/query.pb.go | 702 ++++------------ x/ccv/provider/types/query.pb.gw.go | 791 +----------------- 5 files changed, 229 insertions(+), 1343 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index b9226cb5f5..f6d2f406aa 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -19,11 +19,7 @@ service Query { rpc QueryConsumerGenesis(QueryConsumerGenesisRequest) returns (QueryConsumerGenesisResponse) { option (google.api.http) = { - // [DEPRECATED] use the {consumer_id} endpoint instead. - get: "/interchain_security/ccv/provider/consumer_genesis/{chain_id}"; - additional_bindings { - get: "/interchain_security/ccv/provider/consumer_genesis/{consumer_id}"; - } + get: "/interchain_security/ccv/provider/consumer_genesis/{consumer_id}"; }; } @@ -74,11 +70,7 @@ service Query { QueryAllPairsValConAddrByConsumerChainIDRequest) returns (QueryAllPairsValConAddrByConsumerChainIDResponse) { option (google.api.http) = { - // [DEPRECATED] use the {consumer_id} endpoint instead. - get: "/interchain_security/ccv/provider/{chain_id}"; - additional_bindings { - get: "/interchain_security/ccv/provider/{consumer_id}"; - } + get: "/interchain_security/ccv/provider/address_pairs/{consumer_id}"; }; } @@ -95,11 +87,7 @@ service Query { QueryConsumerChainOptedInValidatorsRequest) returns (QueryConsumerChainOptedInValidatorsResponse) { option (google.api.http) = { - // [DEPRECATED] use the {consumer_id} endpoint instead. - get: "/interchain_security/ccv/provider/opted_in_validators/{chain_id}"; - additional_bindings { - get: "/interchain_security/ccv/provider/opted_in_validators/{consumer_id}"; - } + get: "/interchain_security/ccv/provider/opted_in_validators/{consumer_id}"; }; } @@ -118,11 +106,7 @@ service Query { QueryValidatorConsumerCommissionRateRequest) returns (QueryValidatorConsumerCommissionRateResponse) { option (google.api.http) = { - // [DEPRECATED] use the {consumer_id} endpoint instead. - get: "/interchain_security/ccv/provider/consumer_commission_rate/{chain_id}/{provider_address}"; - additional_bindings { get: "/interchain_security/ccv/provider/consumer_commission_rate/{consumer_id}/{provider_address}"; - } }; } @@ -132,11 +116,7 @@ service Query { rpc QueryConsumerValidators(QueryConsumerValidatorsRequest) returns (QueryConsumerValidatorsResponse) { option (google.api.http) = { - // [DEPRECATED] use the {consumer_id} endpoint instead. - get: "/interchain_security/ccv/provider/consumer_validators/{chain_id}"; - additional_bindings { get: "/interchain_security/ccv/provider/consumer_validators/{consumer_id}"; - } }; } @@ -166,9 +146,7 @@ service Query { } message QueryConsumerGenesisRequest { - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; - string consumer_id = 2; + string consumer_id = 1; } message QueryConsumerGenesisResponse { @@ -218,12 +196,10 @@ message Chain { message QueryValidatorConsumerAddrRequest { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; // The consensus address of the validator on the provider chain - string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The id of the consumer chain - string consumer_id = 3; + string consumer_id = 2; } message QueryValidatorConsumerAddrResponse { @@ -234,12 +210,10 @@ message QueryValidatorConsumerAddrResponse { message QueryValidatorProviderAddrRequest { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; // The consensus address of the validator on the consumer chain - string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + string consumer_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; // The id of the consumer chain - string consumer_id = 3; + string consumer_id = 2; } message QueryValidatorProviderAddrResponse { @@ -268,10 +242,8 @@ message QueryRegisteredConsumerRewardDenomsResponse { } message QueryAllPairsValConAddrByConsumerChainIDRequest { - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; // The id of the consumer chain - string consumer_id = 2; + string consumer_id = 1; } message QueryAllPairsValConAddrByConsumerChainIDResponse { @@ -293,9 +265,7 @@ message QueryParamsResponse { } message QueryConsumerChainOptedInValidatorsRequest { - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; - string consumer_id = 2; + string consumer_id = 1; } message QueryConsumerChainOptedInValidatorsResponse { @@ -304,9 +274,7 @@ message QueryConsumerChainOptedInValidatorsResponse { } message QueryConsumerValidatorsRequest { - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; - string consumer_id = 2; + string consumer_id = 1; } message QueryConsumerValidatorsValidator { @@ -368,11 +336,9 @@ message QueryConsumerChainsValidatorHasToValidateResponse { } message QueryValidatorConsumerCommissionRateRequest { - // [DEPRECATED] use `consumer_id` instead - string chain_id = 1 [deprecated = true]; + string consumer_id = 1; // The consensus address of the validator on the provider chain string provider_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; - string consumer_id = 3; } message QueryValidatorConsumerCommissionRateResponse { diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 14410324fa..8968a8604b 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -25,8 +25,6 @@ func (k Keeper) QueryConsumerGenesis(c context.Context, req *types.QueryConsumer if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } consumerId := req.ConsumerId @@ -163,8 +161,6 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.QueryValidatorConsumerAddrRequest) (*types.QueryValidatorConsumerAddrResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -198,8 +194,6 @@ func (k Keeper) QueryValidatorConsumerAddr(goCtx context.Context, req *types.Que func (k Keeper) QueryValidatorProviderAddr(goCtx context.Context, req *types.QueryValidatorProviderAddrRequest) (*types.QueryValidatorProviderAddrResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -255,8 +249,6 @@ func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req * func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, req *types.QueryAllPairsValConAddrByConsumerChainIDRequest) (*types.QueryAllPairsValConAddrByConsumerChainIDResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } consumerId := req.ConsumerId @@ -302,8 +294,6 @@ func (k Keeper) QueryParams(goCtx context.Context, req *types.QueryParamsRequest func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req *types.QueryConsumerChainOptedInValidatorsRequest) (*types.QueryConsumerChainOptedInValidatorsResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } consumerId := req.ConsumerId @@ -331,9 +321,8 @@ func (k Keeper) QueryConsumerChainOptedInValidators(goCtx context.Context, req * func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryConsumerValidatorsRequest) (*types.QueryConsumerValidatorsResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } + consumerId := req.ConsumerId if err := types.ValidateConsumerId(consumerId); err != nil { return nil, status.Error(codes.InvalidArgument, errorsmod.Wrap(types.ErrInvalidConsumerId, consumerId).Error()) @@ -524,8 +513,6 @@ func (k Keeper) hasToValidate( func (k Keeper) QueryValidatorConsumerCommissionRate(goCtx context.Context, req *types.QueryValidatorConsumerCommissionRateRequest) (*types.QueryValidatorConsumerCommissionRateResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") - } else if req.ChainId != "" { - return nil, status.Errorf(codes.InvalidArgument, "ChainId has been deprecated. Use ConsumerId instead.") } consumerId := req.ConsumerId diff --git a/x/ccv/provider/types/legacy_proposal_test.go b/x/ccv/provider/types/legacy_proposal_test.go index 180a4978bd..4a13a4290b 100644 --- a/x/ccv/provider/types/legacy_proposal_test.go +++ b/x/ccv/provider/types/legacy_proposal_test.go @@ -554,7 +554,7 @@ func TestMsgUpdateConsumerValidateBasic(t *testing.T) { Top_N: 50, ValidatorsPowerCap: 100, ValidatorSetCap: 34, - Allowlist: []string{"addr1"}, + Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, Denylist: nil, MinStake: 0, AllowInactiveVals: false, @@ -591,8 +591,8 @@ func TestMsgUpdateConsumerValidateBasic(t *testing.T) { Top_N: 54, ValidatorsPowerCap: 92, ValidatorSetCap: 0, - Allowlist: []string{"addr1"}, - Denylist: []string{"addr2", "addr3"}, + Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, + Denylist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j", "cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, MinStake: 0, AllowInactiveVals: false, }, diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index be3b8b2313..161c4e70f9 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -39,9 +39,7 @@ var _ = time.Kitchen const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type QueryConsumerGenesisRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerGenesisRequest) Reset() { *m = QueryConsumerGenesisRequest{} } @@ -77,14 +75,6 @@ func (m *QueryConsumerGenesisRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerGenesisRequest proto.InternalMessageInfo -// Deprecated: Do not use. -func (m *QueryConsumerGenesisRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - func (m *QueryConsumerGenesisRequest) GetConsumerId() string { if m != nil { return m.ConsumerId @@ -382,12 +372,10 @@ func (m *Chain) GetAllowInactiveVals() bool { } type QueryValidatorConsumerAddrRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The consensus address of the validator on the provider chain - ProviderAddress string `protobuf:"bytes,2,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` + ProviderAddress string `protobuf:"bytes,1,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` // The id of the consumer chain - ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorConsumerAddrRequest) Reset() { *m = QueryValidatorConsumerAddrRequest{} } @@ -469,12 +457,10 @@ func (m *QueryValidatorConsumerAddrResponse) GetConsumerAddress() string { } type QueryValidatorProviderAddrRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The consensus address of the validator on the consumer chain - ConsumerAddress string `protobuf:"bytes,2,opt,name=consumer_address,json=consumerAddress,proto3" json:"consumer_address,omitempty" yaml:"address"` + ConsumerAddress string `protobuf:"bytes,1,opt,name=consumer_address,json=consumerAddress,proto3" json:"consumer_address,omitempty" yaml:"address"` // The id of the consumer chain - ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorProviderAddrRequest) Reset() { *m = QueryValidatorProviderAddrRequest{} } @@ -745,10 +731,8 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) GetDenoms() []string { } type QueryAllPairsValConAddrByConsumerChainIDRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // The id of the consumer chain - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Reset() { @@ -788,14 +772,6 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest proto.InternalMessageInfo -// Deprecated: Do not use. -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetConsumerId() string { if m != nil { return m.ConsumerId @@ -994,9 +970,7 @@ func (m *QueryParamsResponse) GetParams() Params { } type QueryConsumerChainOptedInValidatorsRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerChainOptedInValidatorsRequest) Reset() { @@ -1036,14 +1010,6 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerChainOptedInValidatorsRequest proto.InternalMessageInfo -// Deprecated: Do not use. -func (m *QueryConsumerChainOptedInValidatorsRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - func (m *QueryConsumerChainOptedInValidatorsRequest) GetConsumerId() string { if m != nil { return m.ConsumerId @@ -1101,9 +1067,7 @@ func (m *QueryConsumerChainOptedInValidatorsResponse) GetValidatorsProviderAddre } type QueryConsumerValidatorsRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. - ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryConsumerValidatorsRequest) Reset() { *m = QueryConsumerValidatorsRequest{} } @@ -1139,14 +1103,6 @@ func (m *QueryConsumerValidatorsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerValidatorsRequest proto.InternalMessageInfo -// Deprecated: Do not use. -func (m *QueryConsumerValidatorsRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - func (m *QueryConsumerValidatorsRequest) GetConsumerId() string { if m != nil { return m.ConsumerId @@ -1431,11 +1387,9 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) GetConsumerChainIds( } type QueryValidatorConsumerCommissionRateRequest struct { - // [DEPRECATED] use `consumer_id` instead - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. + ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,2,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` - ConsumerId string `protobuf:"bytes,3,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *QueryValidatorConsumerCommissionRateRequest) Reset() { @@ -1475,10 +1429,9 @@ func (m *QueryValidatorConsumerCommissionRateRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryValidatorConsumerCommissionRateRequest proto.InternalMessageInfo -// Deprecated: Do not use. -func (m *QueryValidatorConsumerCommissionRateRequest) GetChainId() string { +func (m *QueryValidatorConsumerCommissionRateRequest) GetConsumerId() string { if m != nil { - return m.ChainId + return m.ConsumerId } return "" } @@ -1490,13 +1443,6 @@ func (m *QueryValidatorConsumerCommissionRateRequest) GetProviderAddress() strin return "" } -func (m *QueryValidatorConsumerCommissionRateRequest) GetConsumerId() string { - if m != nil { - return m.ConsumerId - } - return "" -} - type QueryValidatorConsumerCommissionRateResponse struct { // The rate to charge delegators on the consumer chain, as a fraction Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` @@ -1880,160 +1826,155 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0xcd, 0x6f, 0x1c, 0x49, - 0x15, 0x77, 0xfb, 0x2b, 0xe3, 0x72, 0xe2, 0x6c, 0x2a, 0x4e, 0x32, 0x19, 0x27, 0x1e, 0xa7, 0xb3, - 0x91, 0xbc, 0xf9, 0x98, 0xb6, 0x8d, 0xc2, 0xee, 0x66, 0xc9, 0x26, 0x9e, 0x49, 0x9c, 0x8c, 0xc2, - 0x26, 0xde, 0xb6, 0x93, 0x45, 0x5e, 0x85, 0xde, 0x72, 0x77, 0xed, 0xb8, 0x70, 0x4f, 0x77, 0xbb, - 0xab, 0x3c, 0xc9, 0x60, 0x7c, 0x81, 0x4b, 0xe0, 0x80, 0x82, 0x10, 0xf7, 0x15, 0x12, 0x12, 0x07, - 0x4e, 0x68, 0x05, 0xe2, 0xb6, 0xc7, 0xbd, 0xb1, 0x2c, 0x17, 0x04, 0x22, 0xa0, 0x84, 0x03, 0x17, -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0x2f, 0x3f, 0xbd, 0x72, 0x56, - 0xa2, 0x47, 0xf1, 0x23, 0xe3, 0x60, 0x89, 0xf9, 0xc4, 0xa9, 0xe9, 0xa7, 0x42, 0x8c, 0x07, 0x12, - 0x22, 0x0c, 0x93, 0x93, 0x60, 0xf8, 0x3b, 0x88, 0xd8, 0xd8, 0xe2, 0x15, 0x66, 0x4e, 0x97, 0x5f, - 0xf0, 0x1a, 0x18, 0x0e, 0xda, 0xa2, 0x4d, 0xca, 0xeb, 0xc3, 0xb1, 0x39, 0x75, 0x37, 0xf5, 0xcb, - 0xae, 0x63, 0x2d, 0x71, 0x4a, 0x5d, 0x72, 0xc0, 0x65, 0x10, 0x45, 0xa3, 0xc1, 0xdc, 0x75, 0xec, - 0x88, 0xea, 0x71, 0xa4, 0x7c, 0x49, 0x7a, 0xf5, 0xc4, 0x4e, 0xaf, 0x56, 0x1d, 0xf6, 0xe5, 0xa7, - 0x57, 0x80, 0x14, 0x52, 0x75, 0x98, 0x3e, 0x16, 0x62, 0x2c, 0x73, 0x88, 0x20, 0x74, 0x22, 0x54, - 0x11, 0x3a, 0x47, 0x44, 0xe8, 0x84, 0xab, 0x22, 0x74, 0xbe, 0x0e, 0x4e, 0xc9, 0xcb, 0x8d, 0xa9, - 0x61, 0x6e, 0xfa, 0x7e, 0xd0, 0x7f, 0x60, 0xcf, 0x35, 0xd7, 0xf2, 0x63, 0xdc, 0xc2, 0x13, 0xd1, - 0x76, 0x45, 0xec, 0xde, 0x0e, 0x36, 0xd5, 0x67, 0x0a, 0x28, 0xee, 0x7a, 0xed, 0x65, 0x76, 0xc1, - 0x00, 0xb4, 0x12, 0x87, 0x7c, 0xd5, 0x6e, 0x67, 0xca, 0xa4, 0xfb, 0xdd, 0x76, 0xbd, 0x0d, 0x58, - 0xdd, 0x90, 0xef, 0x6e, 0xbc, 0x7f, 0x8b, 0x68, 0xef, 0x22, 0xba, 0xec, 0xca, 0xaf, 0xb0, 0xd0, - 0xea, 0x31, 0x5b,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, 0x7b, 0xcc, 0x1c, - 0x0a, 0x0b, 0xbd, 0xc2, 0x74, 0x5e, 0x33, 0xee, 0x32, 0xbe, 0x80, 0xff, 0x51, 0x12, 0xff, 0xd1, - 0x10, 0x1f, 0x30, 0xc0, 0x3b, 0x9d, 0x1f, 0x74, 0xea, 0x94, 0xa3, 0x70, 0xb7, 0x77, 0xa0, 0xce, - 0xad, 0x6e, 0x0b, 0x0e, 0x6d, 0x2b, 0x1a, 0xb2, 0x6c, 0xc3, 0xbf, 0x86, 0x95, 0x72, 0x2c, 0x85, - 0x76, 0x52, 0x29, 0xa7, 0xcd, 0x51, 0x0a, 0x37, 0xba, 0xe6, 0x97, 0xa6, 0x2d, 0x70, 0xd3, 0x6e, - 0xc2, 0x77, 0x3b, 0x4d, 0xd2, 0xf1, 0x7b, 0x50, 0xfe, 0xe0, 0xf3, 0x97, 0x93, 0xca, 0x17, 0x2f, - 0x27, 0x95, 0xbf, 0xbf, 0x9c, 0x54, 0x9e, 0xbf, 0x9a, 0xec, 0xfb, 0xe2, 0xd5, 0x64, 0xdf, 0x9f, - 0x5e, 0x4d, 0xf6, 0xad, 0x5c, 0xaf, 0x11, 0xb6, 0xb6, 0xb9, 0x5a, 0x32, 0xdd, 0xba, 0xfc, 0xcf, - 0xa2, 0x36, 0x51, 0x57, 0x22, 0x51, 0x8d, 0xab, 0xda, 0xd3, 0x44, 0x65, 0xde, 0xf4, 0x30, 0x5d, - 0x1d, 0xe6, 0x3f, 0xeb, 0x7e, 0xed, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x6f, 0x00, 0x0a, - 0xf9, 0x25, 0x00, 0x00, + // 2368 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0xcd, 0x6f, 0xdb, 0xc8, + 0x15, 0x37, 0xe5, 0x8f, 0xc8, 0xe3, 0xc4, 0xbb, 0x99, 0x38, 0x89, 0x22, 0x27, 0x96, 0xc3, 0x6c, + 0x00, 0x6f, 0x3e, 0x44, 0x5b, 0x45, 0xba, 0xbb, 0xd9, 0xe6, 0xc3, 0x52, 0xec, 0x44, 0x48, 0x93, + 0x78, 0x69, 0x27, 0x0b, 0x64, 0x91, 0xb2, 0x63, 0x72, 0x56, 0x9a, 0x9a, 0x22, 0x19, 0xce, 0x48, + 0x89, 0xea, 0xfa, 0xd2, 0x53, 0x2e, 0x05, 0xb6, 0x28, 0x7a, 0x2d, 0x16, 0x05, 0x7a, 0x2f, 0x8a, + 0x45, 0x81, 0xfe, 0x07, 0x7b, 0xeb, 0x76, 0x7b, 0x29, 0x0a, 0x34, 0x2d, 0x92, 0x16, 0xe8, 0xa5, + 0x40, 0xbb, 0xed, 0x1f, 0x50, 0x70, 0x38, 0xa4, 0x44, 0x86, 0x96, 0x49, 0xcb, 0x37, 0x71, 0xe6, + 0xbd, 0xdf, 0xfb, 0x98, 0x37, 0x6f, 0xde, 0x7b, 0x36, 0x50, 0x88, 0xc5, 0xb0, 0xab, 0x37, 0x11, + 0xb1, 0x34, 0x8a, 0xf5, 0xb6, 0x4b, 0x58, 0x57, 0xd1, 0xf5, 0x8e, 0xe2, 0xb8, 0x76, 0x87, 0x18, + 0xd8, 0x55, 0x3a, 0x4b, 0xca, 0xd3, 0x36, 0x76, 0xbb, 0x65, 0xc7, 0xb5, 0x99, 0x0d, 0xcf, 0x25, + 0x30, 0x94, 0x75, 0xbd, 0x53, 0x0e, 0x18, 0xca, 0x9d, 0xa5, 0xe2, 0xe9, 0x86, 0x6d, 0x37, 0x4c, + 0xac, 0x20, 0x87, 0x28, 0xc8, 0xb2, 0x6c, 0x86, 0x18, 0xb1, 0x2d, 0xea, 0x43, 0x14, 0x67, 0x1a, + 0x76, 0xc3, 0xe6, 0x3f, 0x15, 0xef, 0x97, 0x58, 0x2d, 0x09, 0x1e, 0xfe, 0xb5, 0xd9, 0xfe, 0x54, + 0x61, 0xa4, 0x85, 0x29, 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3, 0x4e, 0x13, 0x51, 0x5f, 0xe4, 0x74, + 0xa5, 0x52, 0x4e, 0x11, 0x50, 0xa1, 0xec, 0x35, 0x8f, 0x53, 0xf5, 0x01, 0xe0, 0x0c, 0x18, 0x37, + 0x49, 0x8b, 0xb0, 0x42, 0x6e, 0x5e, 0x5a, 0x18, 0x57, 0xfd, 0x0f, 0x19, 0xc5, 0x5c, 0x17, 0x48, + 0x17, 0x96, 0x57, 0xc1, 0x04, 0x97, 0x45, 0x0b, 0xd2, 0xfc, 0xe8, 0xc2, 0x54, 0xe5, 0x42, 0x3a, + 0xf9, 0xde, 0xb6, 0x2a, 0x38, 0xe5, 0x17, 0x63, 0x60, 0x9c, 0xaf, 0xc0, 0x53, 0x20, 0xef, 0x73, + 0x86, 0xa7, 0x70, 0x88, 0x7f, 0xd7, 0x0d, 0x38, 0x0b, 0x26, 0x75, 0x93, 0x60, 0x8b, 0x79, 0x7b, + 0x39, 0xbe, 0x97, 0xf7, 0x17, 0xea, 0x06, 0x3c, 0x06, 0xc6, 0x99, 0xed, 0x68, 0xf7, 0x0b, 0xa3, + 0xf3, 0xd2, 0xc2, 0x11, 0x75, 0x8c, 0xd9, 0xce, 0x7d, 0x78, 0x01, 0xc0, 0x16, 0xb1, 0x34, 0xc7, + 0x7e, 0xe6, 0x1d, 0xab, 0xa5, 0xf9, 0x14, 0x63, 0xf3, 0xd2, 0xc2, 0xa8, 0x3a, 0xdd, 0x22, 0xd6, + 0x9a, 0xb7, 0x51, 0xb7, 0x36, 0x3c, 0xda, 0x45, 0x30, 0xd3, 0x41, 0x26, 0x31, 0x10, 0xb3, 0x5d, + 0x2a, 0x58, 0x74, 0xe4, 0x14, 0xc6, 0x39, 0x1e, 0xec, 0xed, 0x71, 0xa6, 0x1a, 0x72, 0xe0, 0x05, + 0x70, 0x34, 0x5c, 0xd5, 0x28, 0x66, 0x9c, 0x7c, 0x82, 0x93, 0xbf, 0x15, 0x6e, 0xac, 0x63, 0xe6, + 0xd1, 0x9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 0x7d, 0x47, 0x94, 0xf3, 0x91, 0x30, 0x4b, + 0xfd, 0x6c, 0xfe, 0x72, 0x34, 0x69, 0x76, 0x11, 0x4a, 0x1f, 0xd0, 0xee, 0x9f, 0x03, 0x47, 0xec, + 0x67, 0x56, 0x3c, 0x4e, 0xd4, 0xc3, 0x7c, 0x31, 0x48, 0x85, 0x33, 0x41, 0x77, 0x3c, 0xca, 0x37, + 0x13, 0x3a, 0xdd, 0xb1, 0x83, 0xec, 0x74, 0x3f, 0x05, 0x53, 0xc4, 0x22, 0x4c, 0x13, 0x95, 0xd5, + 0x38, 0xc7, 0x5e, 0xc9, 0x84, 0x5d, 0xb7, 0x08, 0x23, 0xc8, 0x24, 0x3f, 0xe4, 0x13, 0x3c, 0x5e, + 0x6f, 0x79, 0xdd, 0x0a, 0x55, 0x81, 0x87, 0xec, 0xd7, 0x5f, 0xb0, 0x05, 0x66, 0xfc, 0x09, 0x04, + 0x6d, 0x22, 0x87, 0x58, 0x8d, 0x40, 0xe0, 0x04, 0x17, 0xf8, 0x61, 0xba, 0x52, 0xce, 0x03, 0x58, + 0xf7, 0xf9, 0xfb, 0xc4, 0x40, 0x27, 0xbe, 0x4e, 0x2b, 0xbf, 0x3b, 0x03, 0xc6, 0xf9, 0x21, 0xc1, + 0x7f, 0x48, 0x60, 0x26, 0x69, 0xce, 0x05, 0x6f, 0x66, 0x4f, 0x99, 0xd1, 0x11, 0x5b, 0x71, 0x79, + 0x08, 0x04, 0x3f, 0x5a, 0xe4, 0x3b, 0x3f, 0xfe, 0xe3, 0xdf, 0x7f, 0x96, 0xab, 0xc2, 0x9b, 0x7b, + 0x0f, 0x59, 0xc3, 0xa8, 0x14, 0x83, 0x34, 0x65, 0xbb, 0x2f, 0x4e, 0x77, 0xe0, 0x6b, 0x49, 0x54, + 0xcd, 0xd1, 0xe4, 0x09, 0x6f, 0x64, 0x57, 0x32, 0x32, 0x8c, 0x2b, 0xde, 0xdc, 0x3f, 0x80, 0x30, + 0xb2, 0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 0x17, 0x57, 0x87, + 0x85, 0xc9, 0x5e, 0x27, 0xed, 0xd2, 0x6f, 0xc3, 0xff, 0x4a, 0xb1, 0x3f, 0x64, 0x47, 0x3b, 0x62, + 0x78, 0x3b, 0xfb, 0x11, 0x25, 0xb6, 0xe5, 0xc5, 0x3b, 0xc3, 0x03, 0x65, 0xb7, 0xba, 0xef, 0x68, + 0x95, 0xed, 0x70, 0x2a, 0xb0, 0x03, 0xff, 0x12, 0x54, 0x87, 0x91, 0xf4, 0x94, 0xa5, 0x3a, 0x4c, + 0x6a, 0xfc, 0x8b, 0x37, 0xf6, 0xcd, 0x2f, 0x4c, 0x5b, 0xe5, 0xa6, 0xdd, 0x84, 0xd7, 0xb3, 0x26, + 0xc0, 0x68, 0x14, 0x57, 0x3f, 0xfe, 0xf2, 0xd5, 0x9c, 0xf4, 0xd5, 0xab, 0x39, 0xe9, 0x6f, 0xaf, + 0xe6, 0xa4, 0xcf, 0x5e, 0xcf, 0x8d, 0x7c, 0xf5, 0x7a, 0x6e, 0xe4, 0x4f, 0xaf, 0xe7, 0x46, 0x1e, + 0x5f, 0x6b, 0x10, 0xd6, 0x6c, 0x6f, 0x96, 0x75, 0xbb, 0x25, 0xfe, 0x63, 0xa4, 0x4f, 0xd4, 0xe5, + 0x50, 0x54, 0xe7, 0x8a, 0xf2, 0x3c, 0x56, 0x8d, 0x76, 0x1d, 0x4c, 0x37, 0x27, 0xf8, 0xdf, 0x02, + 0xbf, 0xf5, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0xad, 0x83, 0x18, 0xd1, 0x23, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2705,13 +2646,6 @@ func (m *QueryConsumerGenesisRequest) MarshalToSizedBuffer(dAtA []byte) (int, er copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x12 - } - 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 @@ -2950,20 +2884,13 @@ func (m *QueryValidatorConsumerAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.ProviderAddress) > 0 { i -= len(m.ProviderAddress) copy(dAtA[i:], m.ProviderAddress) i = encodeVarintQuery(dAtA, i, uint64(len(m.ProviderAddress))) i-- - dAtA[i] = 0x12 - } - 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 @@ -3024,20 +2951,13 @@ func (m *QueryValidatorProviderAddrRequest) MarshalToSizedBuffer(dAtA []byte) (i copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if len(m.ConsumerAddress) > 0 { i -= len(m.ConsumerAddress) copy(dAtA[i:], m.ConsumerAddress) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerAddress))) i-- - dAtA[i] = 0x12 - } - 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 @@ -3217,13 +3137,6 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) MarshalToSizedBuffer(d copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x12 - } - 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 @@ -3396,13 +3309,6 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) MarshalToSizedBuffer(dAtA [ copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x12 - } - 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 @@ -3465,13 +3371,6 @@ func (m *QueryConsumerValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, copy(dAtA[i:], m.ConsumerId) i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- - dAtA[i] = 0x12 - } - 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 @@ -3735,13 +3634,6 @@ func (m *QueryValidatorConsumerCommissionRateRequest) MarshalToSizedBuffer(dAtA _ = i var l int _ = l - if len(m.ConsumerId) > 0 { - i -= len(m.ConsumerId) - copy(dAtA[i:], m.ConsumerId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) - i-- - dAtA[i] = 0x1a - } if len(m.ProviderAddress) > 0 { i -= len(m.ProviderAddress) copy(dAtA[i:], m.ProviderAddress) @@ -3749,10 +3641,10 @@ func (m *QueryValidatorConsumerCommissionRateRequest) MarshalToSizedBuffer(dAtA i-- dAtA[i] = 0x12 } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) i-- dAtA[i] = 0xa } @@ -4028,10 +3920,6 @@ func (m *QueryConsumerGenesisRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ConsumerId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4138,10 +4026,6 @@ func (m *QueryValidatorConsumerAddrRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ProviderAddress) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4172,10 +4056,6 @@ func (m *QueryValidatorProviderAddrRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ConsumerAddress) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4256,10 +4136,6 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ConsumerId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4329,10 +4205,6 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ConsumerId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4361,10 +4233,6 @@ func (m *QueryConsumerValidatorsRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } l = len(m.ConsumerId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) @@ -4470,7 +4338,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Size() (n int) { } var l int _ = l - l = len(m.ChainId) + l = len(m.ConsumerId) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -4478,10 +4346,6 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.ConsumerId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } return n } @@ -4623,38 +4487,6 @@ func (m *QueryConsumerGenesisRequest) Unmarshal(dAtA []byte) error { } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -5337,38 +5169,6 @@ func (m *QueryValidatorConsumerAddrRequest) Unmarshal(dAtA []byte) error { } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddress", wireType) } @@ -5400,7 +5200,7 @@ func (m *QueryValidatorConsumerAddrRequest) Unmarshal(dAtA []byte) error { } m.ProviderAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -5565,38 +5365,6 @@ func (m *QueryValidatorProviderAddrRequest) Unmarshal(dAtA []byte) error { } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerAddress", wireType) } @@ -5628,7 +5396,7 @@ func (m *QueryValidatorProviderAddrRequest) Unmarshal(dAtA []byte) error { } m.ConsumerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -6096,38 +5864,6 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -6577,38 +6313,6 @@ func (m *QueryConsumerChainOptedInValidatorsRequest) Unmarshal(dAtA []byte) erro } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -6773,38 +6477,6 @@ func (m *QueryConsumerValidatorsRequest) Unmarshal(dAtA []byte) error { } 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 != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } @@ -7571,7 +7243,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Unmarshal(dAtA []byte) err switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7599,7 +7271,7 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Unmarshal(dAtA []byte) err if postIndex > l { return io.ErrUnexpectedEOF } - m.ChainId = string(dAtA[iNdEx:postIndex]) + m.ConsumerId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -7633,38 +7305,6 @@ func (m *QueryValidatorConsumerCommissionRateRequest) Unmarshal(dAtA []byte) err } m.ProviderAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) - 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 3c09d0caac..8d1a7ad91e 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -33,10 +33,6 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -var ( - filter_Query_QueryConsumerGenesis_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - func request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerGenesisRequest var metadata runtime.ServerMetadata @@ -48,78 +44,6 @@ func request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime _ = err ) - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryConsumerGenesis(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerGenesisRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryConsumerGenesis(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryConsumerGenesis_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerGenesisRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - val, ok = pathParams["consumer_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") @@ -131,19 +55,12 @@ func request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.QueryConsumerGenesis(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryConsumerGenesis_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerGenesisRequest var metadata runtime.ServerMetadata @@ -165,13 +82,6 @@ func local_request_Query_QueryConsumerGenesis_1(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerGenesis_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.QueryConsumerGenesis(ctx, &protoReq) return msg, metadata, err @@ -367,10 +277,6 @@ func local_request_Query_QueryRegisteredConsumerRewardDenoms_0(ctx context.Conte } -var ( - filter_Query_QueryAllPairsValConAddrByConsumerChainID_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - func request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest var metadata runtime.ServerMetadata @@ -382,78 +288,6 @@ func request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Contex _ = err ) - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryAllPairsValConAddrByConsumerChainID_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - val, ok = pathParams["consumer_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") @@ -465,19 +299,12 @@ func request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context.Contex return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest var metadata runtime.ServerMetadata @@ -499,13 +326,6 @@ func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx context. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllPairsValConAddrByConsumerChainID_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq) return msg, metadata, err @@ -529,10 +349,6 @@ func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Ma } -var ( - filter_Query_QueryConsumerChainOptedInValidators_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - func request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerChainOptedInValidatorsRequest var metadata runtime.ServerMetadata @@ -544,78 +360,6 @@ func request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, ma _ = err ) - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryConsumerChainOptedInValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainOptedInValidatorsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryConsumerChainOptedInValidators(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryConsumerChainOptedInValidators_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerChainOptedInValidatorsRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - val, ok = pathParams["consumer_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") @@ -627,19 +371,12 @@ func request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Context, ma return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.QueryConsumerChainOptedInValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryConsumerChainOptedInValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerChainOptedInValidatorsRequest var metadata runtime.ServerMetadata @@ -661,13 +398,6 @@ func local_request_Query_QueryConsumerChainOptedInValidators_1(ctx context.Conte return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerChainOptedInValidators_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.QueryConsumerChainOptedInValidators(ctx, &protoReq) return msg, metadata, err @@ -725,202 +455,10 @@ func local_request_Query_QueryConsumerChainsValidatorHasToValidate_0(ctx context msg, err := server.QueryConsumerChainsValidatorHasToValidate(ctx, &protoReq) return msg, metadata, err -} - -var ( - filter_Query_QueryValidatorConsumerCommissionRate_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0, "provider_address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} -) - -func request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorConsumerCommissionRateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - val, ok = pathParams["provider_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") - } - - protoReq.ProviderAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryValidatorConsumerCommissionRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorConsumerCommissionRateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - val, ok = pathParams["provider_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") - } - - protoReq.ProviderAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryValidatorConsumerCommissionRate(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryValidatorConsumerCommissionRate_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0, "provider_address": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} -) - -func request_Query_QueryValidatorConsumerCommissionRate_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorConsumerCommissionRateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["consumer_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") - } - - protoReq.ConsumerId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) - } - - val, ok = pathParams["provider_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") - } - - protoReq.ProviderAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryValidatorConsumerCommissionRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryValidatorConsumerCommissionRate_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorConsumerCommissionRateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["consumer_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") - } - - protoReq.ConsumerId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) - } - - val, ok = pathParams["provider_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") - } - - protoReq.ProviderAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerCommissionRate_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryValidatorConsumerCommissionRate(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_QueryConsumerValidators_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerValidatorsRequest +} + +func request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorConsumerCommissionRateRequest var metadata runtime.ServerMetadata var ( @@ -930,31 +468,35 @@ func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runt _ = err ) - val, ok = pathParams["chain_id"] + val, ok = pathParams["consumer_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ChainId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } - msg, err := client.QueryConsumerValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryValidatorConsumerCommissionRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryConsumerValidatorsRequest +func local_request_Query_QueryValidatorConsumerCommissionRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryValidatorConsumerCommissionRateRequest var metadata runtime.ServerMetadata var ( @@ -964,34 +506,34 @@ func local_request_Query_QueryConsumerValidators_0(ctx context.Context, marshale _ = err ) - val, ok = pathParams["chain_id"] + val, ok = pathParams["consumer_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - protoReq.ChainId, err = runtime.String(val) + protoReq.ConsumerId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } - msg, err := server.QueryConsumerValidators(ctx, &protoReq) + msg, err := server.QueryValidatorConsumerCommissionRate(ctx, &protoReq) return msg, metadata, err } -var ( - filter_Query_QueryConsumerValidators_1 = &utilities.DoubleArray{Encoding: map[string]int{"consumer_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_QueryConsumerValidators_1(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerValidatorsRequest var metadata runtime.ServerMetadata @@ -1013,19 +555,12 @@ func request_Query_QueryConsumerValidators_1(ctx context.Context, marshaler runt return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.QueryConsumerValidators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryConsumerValidators_1(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryConsumerValidators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryConsumerValidatorsRequest var metadata runtime.ServerMetadata @@ -1047,13 +582,6 @@ func local_request_Query_QueryConsumerValidators_1(ctx context.Context, marshale return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryConsumerValidators_1); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.QueryConsumerValidators(ctx, &protoReq) return msg, metadata, err @@ -1214,29 +742,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryConsumerGenesis_1, 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_QueryConsumerGenesis_1(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_QueryConsumerGenesis_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1375,29 +880,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1, 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_QueryAllPairsValConAddrByConsumerChainID_1(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_QueryAllPairsValConAddrByConsumerChainID_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1444,29 +926,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryConsumerChainOptedInValidators_1, 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_QueryConsumerChainOptedInValidators_1(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_QueryConsumerChainOptedInValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerChainsValidatorHasToValidate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1513,29 +972,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryValidatorConsumerCommissionRate_1, 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_QueryValidatorConsumerCommissionRate_1(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_QueryValidatorConsumerCommissionRate_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerValidators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1559,29 +995,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryConsumerValidators_1, 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_QueryConsumerValidators_1(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_QueryConsumerValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryBlocksUntilNextEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1712,26 +1125,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryConsumerGenesis_1, 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_QueryConsumerGenesis_1(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryConsumerGenesis_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerChains_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1852,26 +1245,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1, 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_QueryAllPairsValConAddrByConsumerChainID_1(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryAllPairsValConAddrByConsumerChainID_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1912,26 +1285,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryConsumerChainOptedInValidators_1, 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_QueryConsumerChainOptedInValidators_1(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryConsumerChainOptedInValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerChainsValidatorHasToValidate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1972,26 +1325,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryValidatorConsumerCommissionRate_1, 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_QueryValidatorConsumerCommissionRate_1(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryValidatorConsumerCommissionRate_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryConsumerValidators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -2012,26 +1345,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryConsumerValidators_1, 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_QueryConsumerValidators_1(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryConsumerValidators_1(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryBlocksUntilNextEpoch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -2096,9 +1409,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueryConsumerGenesis_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryConsumerGenesis_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerGenesis_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_genesis", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_chains", "phase", "limit"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2110,25 +1421,17 @@ var ( 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))) - pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"interchain_security", "ccv", "provider", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "address_pairs", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryConsumerChainOptedInValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "opted_in_validators", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryConsumerChainOptedInValidators_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "opted_in_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerChainOptedInValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "opted_in_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryConsumerChainsValidatorHasToValidate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_chains_per_validator", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryValidatorConsumerCommissionRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_commission_rate", "chain_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryValidatorConsumerCommissionRate_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_commission_rate", "consumer_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryValidatorConsumerCommissionRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_commission_rate", "consumer_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryConsumerValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_validators", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryConsumerValidators_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryConsumerValidators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "consumer_validators", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryBlocksUntilNextEpoch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "blocks_until_next_epoch"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2140,8 +1443,6 @@ var ( var ( forward_Query_QueryConsumerGenesis_0 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerGenesis_1 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerChains_0 = runtime.ForwardResponseMessage forward_Query_QueryValidatorConsumerAddr_0 = runtime.ForwardResponseMessage @@ -2154,24 +1455,16 @@ var ( forward_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.ForwardResponseMessage - forward_Query_QueryAllPairsValConAddrByConsumerChainID_1 = runtime.ForwardResponseMessage - forward_Query_QueryParams_0 = runtime.ForwardResponseMessage forward_Query_QueryConsumerChainOptedInValidators_0 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerChainOptedInValidators_1 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerChainsValidatorHasToValidate_0 = runtime.ForwardResponseMessage forward_Query_QueryValidatorConsumerCommissionRate_0 = runtime.ForwardResponseMessage - forward_Query_QueryValidatorConsumerCommissionRate_1 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerValidators_0 = runtime.ForwardResponseMessage - forward_Query_QueryConsumerValidators_1 = runtime.ForwardResponseMessage - forward_Query_QueryBlocksUntilNextEpoch_0 = runtime.ForwardResponseMessage forward_Query_QueryConsumerIdFromClientId_0 = runtime.ForwardResponseMessage From 9bbd27435d68481c8b5c7914aea94c6259c9ffe4 Mon Sep 17 00:00:00 2001 From: bernd-m <43466467+bermuell@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:26:24 +0200 Subject: [PATCH 23/43] fix: permissionless query (#2191) * fix implementation * addressed comments * cleanup * keep metadata and powershaping data for stopped consumer chains * addressed comments * adapt unit-tests --- testutil/keeper/unit_test_helpers.go | 11 ++-- x/ccv/provider/client/cli/tx.go | 73 ++++++++++++++++++++++++++ x/ccv/provider/keeper/grpc_query.go | 5 +- x/ccv/provider/keeper/proposal.go | 3 -- x/ccv/provider/keeper/proposal_test.go | 2 +- x/ccv/provider/keeper/relay_test.go | 4 +- 6 files changed, 85 insertions(+), 13 deletions(-) diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 95c5de2380..584c6a0633 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -247,7 +247,7 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, // TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned // after a stopped consumer chain. func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, - consumerId, expectedChannelID string, + consumerId, expectedChannelID string, expErr bool, ) { t.Helper() _, found := providerKeeper.GetConsumerClientId(ctx, consumerId) @@ -262,8 +262,13 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, acks) // in case the chain was successfully stopped, it should not contain a Top N associated to it - _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) - require.Error(t, err) + ps, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + if expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + require.Empty(t, ps) // test key assignment state is cleaned require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId)) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 4251ef50e1..00826278b0 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -224,6 +224,42 @@ changed by updating the consumer chain. Example: %s tx provider create-consumer [path/to/create_consumer.json] --from node0 --home ../node0 --chain-id $CID + +where create_consumer.json content: +{ + "chain_id": "consu", + "metadata": { + "name": "chain consumer", + "description": "no description", + "metadata": "no metadata" + }, + "initialization_parameters": { + "initial_height": { + "revision_number": "0", + "revision_height": "1" + }, + "genesis_hash": "Z2VuX2hhc2g=", + "binary_hash": "YmluX2hhc2g=", + "spawn_time": "2024-08-29T12:26:16.529913Z", + "unbonding_period": "1209600s", + "ccv_timeout_period": "2419200s", + "transfer_timeout_period": "3600s", + "consumer_redistribution_fraction": "0.75", + "blocks_per_distribution_transmission": "1000", + "historical_entries": "10000", + "distribution_transmission_channel": "" + }, + "power_shaping_parameters": { + "top_N": 100, + "validators_power_cap": 0, + "validator_set_cap": 0, + "allowlist": [], + "denylist": [], + "min_stake": "0", + "allow_inactive_vals": false + } +} + `, version.AppName)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -278,6 +314,43 @@ Note that only the owner of the chain can initialize it. Example: %s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID + + where consumer-update.json contains parameters for 'power_shaping', 'initialization' and 'metadata': + +{ + "consumer_id": "0", + "new_owner_address": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", + "metadata": { + "name": "chain consumer", + "description": "no description", + "metadata": "no metadata" + }, + "initialization_parameters": { + "initial_height": { + "revision_number": "0", + "revision_height": "1" + }, + "genesis_hash": "Z2VuX2hhc2g=", + "binary_hash": "YmluX2hhc2g=", + "spawn_time": "2024-08-29T12:26:16.529913Z", + "unbonding_period": "1209600s", + "ccv_timeout_period": "2419200s", + "transfer_timeout_period": "3600s", + "consumer_redistribution_fraction": "0.75", + "blocks_per_distribution_transmission": "1000", + "historical_entries": "10000", + "distribution_transmission_channel": "" + }, + "power_shaping_parameters": { + "top_N": 100, + "validators_power_cap": 0, + "validator_set_cap": 0, + "allowlist": [], + "denylist": [], + "min_stake": "0", + "allow_inactive_vals": false + } +} `, version.AppName)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 8968a8604b..57dd6ce317 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -137,10 +137,7 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai strDenylist[i] = addr.String() } - metadata, err := k.GetConsumerMetadata(ctx, consumerId) - if err != nil { - return types.Chain{}, fmt.Errorf("cannot get metadata for consumer (%s): %w", consumerId, err) - } + metadata, _ := k.GetConsumerMetadata(ctx, consumerId) return types.Chain{ ChainId: chainID, diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 6d95a1679f..6c6dcc2ac2 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -160,9 +160,6 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan k.DeleteSlashAcks(ctx, consumerId) k.DeletePendingVSCPackets(ctx, consumerId) - k.DeleteConsumerMetadata(ctx, consumerId) - k.DeleteConsumerPowerShapingParameters(ctx, consumerId) - k.DeleteConsumerPowerShapingParameters(ctx, consumerId) k.DeleteAllowlist(ctx, consumerId) k.DeleteDenylist(ctx, consumerId) k.DeleteAllOptedIn(ctx, consumerId) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 9e5e094eb2..f33978a8d5 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -172,7 +172,7 @@ func TestStopConsumerChain(t *testing.T) { require.NoError(t, err) } - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) ctrl.Finish() } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index fb27247263..9367a944a6 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -542,7 +542,7 @@ func TestOnTimeoutPacketStopsChain(t *testing.T) { } err := providerKeeper.OnTimeoutPacket(ctx, packet) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) require.NoError(t, err) } @@ -578,7 +578,7 @@ func TestOnAcknowledgementPacketWithAckError(t *testing.T) { err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) require.NoError(t, err) } From 6262e42539b0446bc2a6504173a9bb067bb5fad8 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Fri, 30 Aug 2024 16:30:40 +0200 Subject: [PATCH 24/43] refactor: mostly refactors (#2194) * handle errors * set the reverse index in SetConsumerClientId * rename method * create consumer_lifecycle.go with launch/stop logic * move methods around * move methods around * handle ChangeRewardDenoms * add TODOs * remove proposal_test * remove todos * apply review suggestions * apply review suggestions * fix UTs --- testutil/ibc_testing/generic_setup.go | 15 +- testutil/keeper/unit_test_helpers.go | 4 +- x/ccv/provider/ibc_module_test.go | 3 +- .../{proposal.go => consumer_lifecycle.go} | 519 ++++++-- ...sal_test.go => consumer_lifecycle_test.go} | 1150 ++++++++++------- x/ccv/provider/keeper/distribution.go | 37 + x/ccv/provider/keeper/distribution_test.go | 32 + x/ccv/provider/keeper/grpc_query_test.go | 2 +- x/ccv/provider/keeper/keeper.go | 84 +- x/ccv/provider/keeper/keeper_test.go | 176 ++- x/ccv/provider/keeper/legacy_proposal.go | 35 - x/ccv/provider/keeper/msg_server.go | 17 +- x/ccv/provider/keeper/permissionless.go | 419 +----- x/ccv/provider/keeper/permissionless_test.go | 458 ------- x/ccv/provider/keeper/relay_test.go | 3 +- x/ccv/provider/migrations/v8/migrations.go | 11 +- x/ccv/provider/module.go | 4 +- x/ccv/provider/proposal_handler.go | 2 +- x/ccv/provider/types/events.go | 6 +- x/ccv/provider/types/legacy_proposal_test.go | 70 - x/ccv/provider/types/msg_test.go | 74 ++ 21 files changed, 1520 insertions(+), 1601 deletions(-) rename x/ccv/provider/keeper/{proposal.go => consumer_lifecycle.go} (50%) rename x/ccv/provider/keeper/{proposal_test.go => consumer_lifecycle_test.go} (62%) delete mode 100644 x/ccv/provider/keeper/legacy_proposal.go diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index ca46aff6b4..10a5d6abae 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -160,11 +160,15 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( FirstConsumerID = consumerId } providerKeeper.SetConsumerChainId(providerChain.GetContext(), consumerId, chainID) - providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata) - providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) - providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) + err := providerKeeper.SetConsumerMetadata(providerChain.GetContext(), consumerId, consumerMetadata) + s.Require().NoError(err) + err = providerKeeper.SetConsumerInitializationParameters(providerChain.GetContext(), consumerId, initializationParameters) + s.Require().NoError(err) + err = providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) + s.Require().NoError(err) providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.AppendConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) + err = providerKeeper.AppendConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) + s.Require().NoError(err) // opt-in all validators lastVals, err := providerApp.GetProviderKeeper().GetLastBondedValidators(providerChain.GetContext()) @@ -173,7 +177,8 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( for _, v := range lastVals { consAddr, _ := v.GetConsAddr() providerKeeper.SetOptedIn(providerChain.GetContext(), consumerId, providertypes.NewProviderConsAddress(consAddr)) - providerKeeper.AppendOptedInConsumerId(providerChain.GetContext(), providertypes.NewProviderConsAddress(consAddr), consumerId) + err = providerKeeper.AppendOptedInConsumerId(providerChain.GetContext(), providertypes.NewProviderConsAddress(consAddr), consumerId) + s.Require().NoError(err) } // commit the state on the provider chain diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 584c6a0633..6249227e00 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -239,7 +239,9 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, err := providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) - providerKeeper.SetClientIdToConsumerId(ctx, "clientID", consumerId) + // set the mapping consumer ID <> client ID for the consumer chain + providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") + // set the channel ID for the consumer chain err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) } diff --git a/x/ccv/provider/ibc_module_test.go b/x/ccv/provider/ibc_module_test.go index 2d778daf00..0a06bf6091 100644 --- a/x/ccv/provider/ibc_module_test.go +++ b/x/ccv/provider/ibc_module_test.go @@ -123,7 +123,6 @@ func TestOnChanOpenTry(t *testing.T) { providerKeeper.SetPort(ctx, ccv.ProviderPortID) providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientIdToConsumer") - providerKeeper.SetClientIdToConsumerId(ctx, "clientIdToConsumer", "consumerId") // Instantiate valid params as default. Individual test cases mutate these as needed. params := params{ @@ -313,7 +312,7 @@ func TestOnChanOpenConfirm(t *testing.T) { providerKeeper.SetConsumerIdToChannelId(ctx, "consumerChainID", "existingChannelID") } - providerKeeper.SetClientIdToConsumerId(ctx, "clientID", "consumerChainID") + providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientID") providerModule := provider.NewAppModule(&providerKeeper, *keeperParams.ParamsSubspace, keeperParams.StoreKey) diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/consumer_lifecycle.go similarity index 50% rename from x/ccv/provider/keeper/proposal.go rename to x/ccv/provider/keeper/consumer_lifecycle.go index 6c6dcc2ac2..58c83be9cf 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/consumer_lifecycle.go @@ -2,34 +2,166 @@ package keeper import ( "fmt" + "time" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" - ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + tmtypes "github.com/cometbft/cometbft/types" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - tmtypes "github.com/cometbft/cometbft/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// Wrapper for the new proposal message MsgChangeRewardDenoms -// Will replace legacy handler HandleLegacyConsumerRewardDenomProposal -func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, proposal *types.MsgChangeRewardDenoms) error { - p := types.ChangeRewardDenomsProposal{ - DenomsToAdd: proposal.DenomsToAdd, - DenomsToRemove: proposal.DenomsToRemove, +// PrepareConsumerForLaunch prepares to move the launch of a consumer chain from the previous spawn time to spawn time. +// Previous spawn time can correspond to its zero value if the validator was not previously set for launch. +func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) error { + if !previousSpawnTime.Equal(time.Time{}) { + // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` + // remove the consumer id from the previous spawn time + err := k.RemoveConsumerToBeLaunched(ctx, consumerId, previousSpawnTime) + if err != nil { + return err + } + } + return k.AppendConsumerToBeLaunched(ctx, consumerId, spawnTime) +} + +// CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence +// is ready to launch and at what spawn time +// TODO (PERMISSIONLESS): could remove, all fields should be there because we validate the initialization parameters +func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { + // a chain that is already launched or stopped cannot launch again + phase := k.GetConsumerPhase(ctx, consumerId) + if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED || phase == types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + return time.Time{}, false + } + + initializationParameters, err := k.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + return time.Time{}, false + } + + spawnTimeIsNotZero := !initializationParameters.SpawnTime.Equal(time.Time{}) + + genesisHashSet := initializationParameters.GenesisHash != nil + binaryHashSet := initializationParameters.BinaryHash != nil + + consumerRedistributionFractionSet := initializationParameters.ConsumerRedistributionFraction != "" + blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0 + historicalEntriesSet := initializationParameters.HistoricalEntries > 0 + + return initializationParameters.SpawnTime, spawnTimeIsNotZero && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && + blocksPerDistributionTransmissionSet && historicalEntriesSet +} + +// BeginBlockLaunchConsumers launches initialized consumers that are ready to launch +func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) { + // TODO (PERMISSIONLESS): we can parameterize the limit + for _, consumerId := range k.GetConsumersReadyToLaunch(ctx, 200) { + record, err := k.GetConsumerInitializationParameters(ctx, consumerId) + if err != nil { + ctx.Logger().Error("could not retrieve initialization record", + "consumerId", consumerId, + "error", err) + continue + } + // Remove consumer to prevent re-trying launching this chain. + // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. + err = k.RemoveConsumerToBeLaunched(ctx, consumerId, record.SpawnTime) + if err != nil { + ctx.Logger().Error("could not remove consumer from to-be-launched queue", + "consumerId", consumerId, + "error", err) + continue + } + + cachedCtx, writeFn := ctx.CacheContext() + err = k.LaunchConsumer(cachedCtx, consumerId) + if err != nil { + ctx.Logger().Error("could not launch chain", + "consumerId", consumerId, + "error", err) + continue + } + k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + + // the cached context is created with a new EventManager, so we merge the events into the original context + ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) + writeFn() + } +} + +// GetConsumersReadyToLaunch returns the consumer ids of the pending initialized consumer chains +// that are ready to launch, i.e., consumer clients to be created. +func (k Keeper) GetConsumersReadyToLaunch(ctx sdk.Context, limit uint32) []string { + store := ctx.KVStore(k.storeKey) + + spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix}) + defer iterator.Close() + + result := []string{} + for ; iterator.Valid(); iterator.Next() { + spawnTime, err := types.ParseTime(spawnTimeToConsumerIdsKeyPrefix, iterator.Key()) + if err != nil { + k.Logger(ctx).Error("failed to parse spawn time", + "error", err) + continue + } + if spawnTime.After(ctx.BlockTime()) { + return result + } + + // if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain + consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) + if err != nil { + k.Logger(ctx).Error("failed to retrieve consumers to launch", + "spawn time", spawnTime, + "error", err) + continue + } + if len(result)+len(consumerIds.Ids) >= int(limit) { + remainingConsumerIds := len(result) + len(consumerIds.Ids) - int(limit) + if len(consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]) == 0 { + return result + } + return append(result, consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]...) + } else { + result = append(result, consumerIds.Ids...) + } + } + + return result +} + +// LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective +// consumer genesis file +func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { + err := k.CreateConsumerClient(ctx, consumerId) + if err != nil { + return err + } + + consumerGenesis, found := k.GetConsumerGenesis(ctx, consumerId) + if !found { + return errorsmod.Wrapf(types.ErrNoConsumerGenesis, "consumer genesis could not be found for consumer id: %s", consumerId) + } + + if len(consumerGenesis.Provider.InitialValSet) == 0 { + return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in consumer id: %s", consumerId) } - return k.HandleLegacyConsumerRewardDenomProposal(ctx, &p) + return nil } // CreateConsumerClient will create the CCV client for the given consumer chain. The CCV channel must be built @@ -90,7 +222,6 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { return err } k.SetConsumerClientId(ctx, consumerId, clientID) - k.SetClientIdToConsumerId(ctx, clientID, consumerId) k.Logger(ctx).Info("consumer chain launched (client created)", "consumer id", consumerId, @@ -112,66 +243,6 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { return nil } -// StopConsumerChain cleans up the states for the given consumer id -func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan bool) (err error) { - // check that a client for consumerId exists - // TODO (PERMISSIONLESS): change to use phases instead - if _, found := k.GetConsumerClientId(ctx, consumerId); !found { - return errorsmod.Wrap(types.ErrConsumerChainNotFound, - fmt.Sprintf("cannot stop non-existent consumer chain: %s", consumerId)) - } - - // clean up states - k.DeleteConsumerClientId(ctx, consumerId) - k.DeleteConsumerGenesis(ctx, consumerId) - // Note: this call panics if the key assignment state is invalid - k.DeleteKeyAssignments(ctx, consumerId) - k.DeleteMinimumPowerInTopN(ctx, consumerId) - k.DeleteEquivocationEvidenceMinHeight(ctx, consumerId) - - // close channel and delete the mappings between chain ID and channel ID - if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { - if closeChan { - // Close the channel for the given channel ID on the condition - // that the channel exists and isn't already in the CLOSED state - channel, found := k.channelKeeper.GetChannel(ctx, ccv.ProviderPortID, channelID) - if found && channel.State != channeltypes.CLOSED { - err := k.chanCloseInit(ctx, channelID) - if err != nil { - k.Logger(ctx).Error("channel to consumer chain could not be closed", - "consumerId", consumerId, - "channelID", channelID, - "error", err.Error(), - ) - } - } - } - k.DeleteConsumerIdToChannelId(ctx, consumerId) - k.DeleteChannelIdToConsumerId(ctx, channelID) - } - - // delete consumer commission rate - provAddrs := k.GetAllCommissionRateValidators(ctx, consumerId) - for _, addr := range provAddrs { - k.DeleteConsumerCommissionRate(ctx, consumerId, addr) - } - - k.DeleteInitChainHeight(ctx, consumerId) - k.DeleteSlashAcks(ctx, consumerId) - k.DeletePendingVSCPackets(ctx, consumerId) - - k.DeleteAllowlist(ctx, consumerId) - k.DeleteDenylist(ctx, consumerId) - k.DeleteAllOptedIn(ctx, consumerId) - k.DeleteConsumerValSet(ctx, consumerId) - - // TODO (PERMISSIONLESS) add newly-added state to be deleted - - k.Logger(ctx).Info("consumer chain removed from provider", "consumerId", consumerId) - - return nil -} - // MakeConsumerGenesis returns the created consumer genesis state for consumer chain `consumerId`, // as well as the validator hash of the initial validator set of the consumer chain func (k Keeper) MakeConsumerGenesis( @@ -282,42 +353,10 @@ func (k Keeper) MakeConsumerGenesis( return gen, hash, nil } -// BeginBlockInit iterates over the initialized consumers chains and creates clients for chains -// in which the spawn time has passed -func (k Keeper) BeginBlockInit(ctx sdk.Context) { - // TODO (PERMISSIONLESS): we can parameterize the limit - for _, consumerId := range k.GetInitializedConsumersReadyToLaunch(ctx, 200) { - record, err := k.GetConsumerInitializationParameters(ctx, consumerId) - if err != nil { - ctx.Logger().Error("could not retrieve initialization record", - "consumerId", consumerId, - "error", err) - continue - } - // Remove consumer to prevent re-trying launching this chain. - // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. - k.RemoveConsumerToBeLaunched(ctx, consumerId, record.SpawnTime) - - cachedCtx, writeFn := ctx.CacheContext() - err = k.LaunchConsumer(cachedCtx, consumerId) - if err != nil { - ctx.Logger().Error("could not launch chain", - "consumerId", consumerId, - "error", err) - continue - } - k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) - - // the cached context is created with a new EventManager, so we merge the events into the original context - ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) - writeFn() - } -} - -// BeginBlockCCR iterates over the pending consumer proposals and stop/removes the chain if the stop time has passed -func (k Keeper) BeginBlockCCR(ctx sdk.Context) { +// BeginBlockStopConsumers iterates over the pending consumer proposals and stop/removes the chain if the stop time has passed +func (k Keeper) BeginBlockStopConsumers(ctx sdk.Context) { // TODO (PERMISSIONLESS): parameterize the limit - for _, consumerId := range k.GetLaunchedConsumersReadyToStop(ctx, 200) { + for _, consumerId := range k.GetConsumersReadyToStop(ctx, 200) { // stop consumer chain in a cached context to handle errors cachedCtx, writeFn := ctx.CacheContext() @@ -331,14 +370,21 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { err = k.StopConsumerChain(cachedCtx, consumerId, true) if err != nil { - k.Logger(ctx).Info("consumer chain could not be stopped", + k.Logger(ctx).Error("consumer chain could not be stopped", "consumerId", consumerId, "err", err.Error()) continue } k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) - k.RemoveConsumerToBeStopped(ctx, consumerId, stopTime) + + err = k.RemoveConsumerToBeStopped(ctx, consumerId, stopTime) + if err != nil { + ctx.Logger().Error("could not remove consumer from to-be-stopped queue", + "consumerId", consumerId, + "error", err) + continue + } // The cached context is created with a new EventManager so we merge the event into the original context ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) @@ -351,3 +397,252 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) { ) } } + +// GetConsumersReadyToStop returns the consumer ids of the pending launched consumer chains +// that are ready to stop +func (k Keeper) GetConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { + store := ctx.KVStore(k.storeKey) + + stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) + defer iterator.Close() + + result := []string{} + for ; iterator.Valid(); iterator.Next() { + stopTime, err := types.ParseTime(stopTimeToConsumerIdsKeyPrefix, iterator.Key()) + if err != nil { + k.Logger(ctx).Error("failed to parse stop time", + "error", err) + continue + } + if stopTime.After(ctx.BlockTime()) { + return result + } + + consumers, err := k.GetConsumersToBeStopped(ctx, stopTime) + if err != nil { + k.Logger(ctx).Error("failed to retrieve consumers to stop", + "stop time", stopTime, + "error", err) + continue + } + if len(result)+len(consumers.Ids) >= int(limit) { + remainingConsumerIds := len(result) + len(consumers.Ids) - int(limit) + if len(consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]) == 0 { + return result + } + return append(result, consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]...) + } else { + result = append(result, consumers.Ids...) + } + } + + return result +} + +// StopConsumerChain cleans up the states for the given consumer id +func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan bool) (err error) { + // check that a client for consumerId exists + // TODO (PERMISSIONLESS): change to use phases instead + if _, found := k.GetConsumerClientId(ctx, consumerId); !found { + return errorsmod.Wrap(types.ErrConsumerChainNotFound, + fmt.Sprintf("cannot stop non-existent consumer chain: %s", consumerId)) + } + + // clean up states + k.DeleteConsumerClientId(ctx, consumerId) + k.DeleteConsumerGenesis(ctx, consumerId) + // Note: this call panics if the key assignment state is invalid + k.DeleteKeyAssignments(ctx, consumerId) + k.DeleteMinimumPowerInTopN(ctx, consumerId) + k.DeleteEquivocationEvidenceMinHeight(ctx, consumerId) + + // close channel and delete the mappings between chain ID and channel ID + if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { + if closeChan { + // Close the channel for the given channel ID on the condition + // that the channel exists and isn't already in the CLOSED state + channel, found := k.channelKeeper.GetChannel(ctx, ccv.ProviderPortID, channelID) + if found && channel.State != channeltypes.CLOSED { + err := k.chanCloseInit(ctx, channelID) + if err != nil { + k.Logger(ctx).Error("channel to consumer chain could not be closed", + "consumerId", consumerId, + "channelID", channelID, + "error", err.Error(), + ) + } + } + } + k.DeleteConsumerIdToChannelId(ctx, consumerId) + k.DeleteChannelIdToConsumerId(ctx, channelID) + } + + // delete consumer commission rate + provAddrs := k.GetAllCommissionRateValidators(ctx, consumerId) + for _, addr := range provAddrs { + k.DeleteConsumerCommissionRate(ctx, consumerId, addr) + } + + k.DeleteInitChainHeight(ctx, consumerId) + k.DeleteSlashAcks(ctx, consumerId) + k.DeletePendingVSCPackets(ctx, consumerId) + + k.DeleteAllowlist(ctx, consumerId) + k.DeleteDenylist(ctx, consumerId) + k.DeleteAllOptedIn(ctx, consumerId) + k.DeleteConsumerValSet(ctx, consumerId) + + // TODO (PERMISSIONLESS) add newly-added state to be deleted + + k.Logger(ctx).Info("consumer chain removed from provider", "consumerId", consumerId) + + return nil +} + +// +// Setters and Getters +// + +// GetConsumerStopTime returns the stop time associated with the to-be-stopped chain with consumer id +func (k Keeper) GetConsumerStopTime(ctx sdk.Context, consumerId string) (time.Time, error) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.ConsumerIdToStopTimeKey(consumerId)) + if buf == nil { + return time.Time{}, fmt.Errorf("failed to retrieve stop time for consumer id (%s)", consumerId) + } + var time time.Time + if err := time.UnmarshalBinary(buf); err != nil { + return time, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) + } + return time, nil +} + +// SetConsumerStopTime sets the stop time associated with this consumer id +func (k Keeper) SetConsumerStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { + store := ctx.KVStore(k.storeKey) + buf, err := stopTime.MarshalBinary() + if err != nil { + return fmt.Errorf("failed to marshal stop time (%+v) for consumer id (%s): %w", stopTime, consumerId, err) + } + store.Set(types.ConsumerIdToStopTimeKey(consumerId), buf) + return nil +} + +// DeleteConsumerStopTime deletes the stop time associated with this consumer id +func (k Keeper) DeleteConsumerStopTime(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerIdToStopTimeKey(consumerId)) +} + +// getConsumerIdsBasedOnTime returns all the consumer ids stored under this specific `key(time)` +func (k Keeper) getConsumerIdsBasedOnTime(ctx sdk.Context, key func(time.Time) []byte, time time.Time) (types.ConsumerIds, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(key(time)) + if bz == nil { + return types.ConsumerIds{}, nil + } + + var consumerIds types.ConsumerIds + + if err := consumerIds.Unmarshal(bz); err != nil { + return types.ConsumerIds{}, fmt.Errorf("failed to unmarshal consumer ids: %w", err) + } + return consumerIds, nil +} + +// appendConsumerIdOnTime appends the consumer id on all the other consumer ids under `key(time)` +func (k Keeper) appendConsumerIdOnTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) + if err != nil { + return err + } + + consumersWithAppend := types.ConsumerIds{ + Ids: append(consumers.Ids, consumerId), + } + + bz, err := consumersWithAppend.Marshal() + if err != nil { + return err + } + + store.Set(key(time), bz) + return nil +} + +// removeConsumerIdFromTime removes consumer id stored under `key(time)` +func (k Keeper) removeConsumerIdFromTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { + store := ctx.KVStore(k.storeKey) + + consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) + if err != nil { + return err + } + + if len(consumers.Ids) == 0 { + return fmt.Errorf("no consumer ids found for this time: %s", time.String()) + } + + // find the index of the consumer we want to remove + index := -1 + for i := 0; i < len(consumers.Ids); i = i + 1 { + if consumers.Ids[i] == consumerId { + index = i + break + } + } + + if index == -1 { + return fmt.Errorf("failed to find consumer id (%s)", consumerId) + } + + if len(consumers.Ids) == 1 { + store.Delete(key(time)) + return nil + } + + consumersWithRemoval := types.ConsumerIds{ + Ids: append(consumers.Ids[:index], consumers.Ids[index+1:]...), + } + + bz, err := consumersWithRemoval.Marshal() + if err != nil { + return err + } + + store.Set(key(time), bz) + return nil +} + +// GetConsumersToBeLaunched returns all the consumer ids of chains stored under this spawn time +func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error) { + return k.getConsumerIdsBasedOnTime(ctx, types.SpawnTimeToConsumerIdsKey, spawnTime) +} + +// AppendConsumerToBeLaunched appends the provider consumer id for the given spawn time +func (k Keeper) AppendConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + return k.appendConsumerIdOnTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) +} + +// RemoveConsumerToBeLaunched removes consumer id from if stored for this specific spawn time +func (k Keeper) RemoveConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { + return k.removeConsumerIdFromTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) +} + +// GetConsumersToBeStopped returns all the consumer ids of chains stored under this stop time +func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { + return k.getConsumerIdsBasedOnTime(ctx, types.StopTimeToConsumerIdsKey, stopTime) +} + +// AppendConsumerToBeStopped appends the provider consumer id for the given stop time +func (k Keeper) AppendConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { + return k.appendConsumerIdOnTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) +} + +// RemoveConsumerToBeStopped removes consumer id from if stored for this specific stop time +func (k Keeper) RemoveConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { + return k.removeConsumerIdFromTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) +} diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/consumer_lifecycle_test.go similarity index 62% rename from x/ccv/provider/keeper/proposal_test.go rename to x/ccv/provider/keeper/consumer_lifecycle_test.go index f33978a8d5..cf5aaa873e 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/consumer_lifecycle_test.go @@ -3,456 +3,98 @@ package keeper_test import ( "encoding/json" "fmt" - "testing" "time" - cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + abci "github.com/cometbft/cometbft/abci/types" "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" _go "github.com/cosmos/ics23/go" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - abci "github.com/cometbft/cometbft/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" + cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" -) - -// -// Initialization sub-protocol related tests of proposal.go -// - -// Tests the CreateConsumerClient method against the spec, -// with more granularity than what's covered in TestHandleCreateConsumerChainProposal. -func TestCreateConsumerClient(t *testing.T) { - type testCase struct { - description string - // Any state-mutating setup on keeper and expected mock calls, specific to this test case - setup func(*providerkeeper.Keeper, sdk.Context, *testkeeper.MockedKeepers) - // Whether a client should be created - expClientCreated bool - } - tests := []testCase{ - { - description: "No state mutation, new client should be created", - setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - - // Valid client creation is asserted with mock expectations here - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set - gomock.InOrder( - testkeeper.GetMocksForCreateConsumerClient(ctx, mocks, "chainID", clienttypes.NewHeight(4, 5))..., - ) - }, - expClientCreated: true, - }, - { - description: "chain for this consumer id has already launched, and hence client was created, NO new one is created", - setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) - - // Expect none of the client creation related calls to happen - mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Times(0) - mocks.MockClientKeeper.EXPECT().CreateClient(gomock.Any(), gomock.Any(), gomock.Any()).Times(0) - mocks.MockClientKeeper.EXPECT().GetSelfConsensusState(gomock.Any(), gomock.Any()).Times(0) - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 0) // returns empty validator set - }, - expClientCreated: false, - }, - } - - for _, tc := range tests { - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Test specific setup - tc.setup(&providerKeeper, ctx, &mocks) - - // Call method with same arbitrary values as defined above in mock expectations. - providerKeeper.SetConsumerChainId(ctx, "0", "chainID") - providerKeeper.SetConsumerMetadata(ctx, "0", testkeeper.GetTestConsumerMetadata()) - providerKeeper.SetConsumerInitializationParameters(ctx, "0", testkeeper.GetTestInitializationParameters()) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", testkeeper.GetTestPowerShapingParameters()) - err := providerKeeper.CreateConsumerClient(ctx, "0") - - if tc.expClientCreated { - require.NoError(t, err) - testCreatedConsumerClient(t, ctx, providerKeeper, "0", "clientID") - } else { - require.Error(t, err) - } - - // Assert mock calls from setup functions - ctrl.Finish() - } -} - -// Executes test assertions for a created consumer client. -// -// Note: Separated from TestCreateConsumerClient to also be called from TestCreateConsumerChainProposal. -func testCreatedConsumerClient(t *testing.T, - ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId, expectedClientID string, -) { - t.Helper() - // ClientID should be stored. - clientId, found := providerKeeper.GetConsumerClientId(ctx, consumerId) - require.True(t, found, "consumer client not found") - require.Equal(t, expectedClientID, clientId) - - // Only assert that consumer genesis was set, - // more granular tests on consumer genesis should be defined in TestMakeConsumerGenesis - _, ok := providerKeeper.GetConsumerGenesis(ctx, consumerId) - require.True(t, ok) -} - -// Tests the StopConsumerChain method against the spec, -// with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. -// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 -// Spec tag: [CCV-PCF-STCC.1] -func TestStopConsumerChain(t *testing.T) { - type testCase struct { - description string - // State-mutating setup specific to this test case - setup func(sdk.Context, *providerkeeper.Keeper, testkeeper.MockedKeepers) - // Whether we should expect the method to return an error - expErr bool - } - - consumerId := "0" - - tests := []testCase{ - { - description: "proposal dropped, client doesn't exist", - setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - // No mocks, meaning no external keeper methods are allowed to be called. - }, - expErr: true, - }, - { - description: "valid stop of consumer chain, all mock calls hit", - setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks, consumerId) - - // set consumer minimum equivocation height - providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerId, 1) - - // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel - gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) - }, - expErr: false, - }, - } - - for _, tc := range tests { - - // Common setup - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Setup specific to test case - tc.setup(ctx, &providerKeeper, mocks) - - err := providerKeeper.StopConsumerChain(ctx, consumerId, true) - - if tc.expErr { - require.Error(t, err, t) - } else { - require.NoError(t, err) - } - - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) - - ctrl.Finish() - } -} - -// TODO (PERMISSIONLESS) -// WE DO NOT go by order in permissionless (?) DO WE need to? -// TestGetConsumerRemovalPropsToExecute tests that pending consumer removal proposals -// that are ready to execute are accessed in order by timestamp via the iterator -//func TestGetConsumerRemovalPropsToExecute(t *testing.T) { -// now := time.Now().UTC() -// sampleProp1 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-2", StopTime: now} -// sampleProp2 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-1", StopTime: now.Add(time.Hour)} -// sampleProp3 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-4", StopTime: now.Add(-time.Hour)} -// sampleProp4 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-3", StopTime: now} -// sampleProp5 := providertypes.ConsumerRemovalProposal{ConsumerId: "chain-1", StopTime: now.Add(2 * time.Hour)} -// -// getExpectedOrder := func(props []providertypes.ConsumerRemovalProposal, accessTime time.Time) []providertypes.ConsumerRemovalProposal { -// expectedOrder := []providertypes.ConsumerRemovalProposal{} -// for _, prop := range props { -// if !accessTime.Before(prop.StopTime) { -// expectedOrder = append(expectedOrder, prop) -// } -// } -// // sorting by SpawnTime.UnixNano() -// sort.Slice(expectedOrder, func(i, j int) bool { -// if expectedOrder[i].StopTime.UTC() == expectedOrder[j].StopTime.UTC() { -// // proposals with same StopTime -// return expectedOrder[i].ConsumerId < expectedOrder[j].ConsumerId -// } -// return expectedOrder[i].StopTime.UTC().Before(expectedOrder[j].StopTime.UTC()) -// }) -// return expectedOrder -// } -// -// testCases := []struct { -// propSubmitOrder []providertypes.ConsumerRemovalProposal -// accessTime time.Time -// }{ -// { -// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ -// sampleProp1, sampleProp2, sampleProp3, sampleProp4, sampleProp5, -// }, -// accessTime: now, -// }, -// { -// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ -// sampleProp3, sampleProp2, sampleProp1, sampleProp5, sampleProp4, -// }, -// accessTime: now.Add(time.Hour), -// }, -// { -// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ -// sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, -// }, -// accessTime: now.Add(-2 * time.Hour), -// }, -// { -// propSubmitOrder: []providertypes.ConsumerRemovalProposal{ -// sampleProp5, sampleProp4, sampleProp3, sampleProp2, sampleProp1, -// }, -// accessTime: now.Add(3 * time.Hour), -// }, -// } -// -// for _, tc := range testCases { -// providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) -// defer ctrl.Finish() -// -// expectedOrderedProps := getExpectedOrder(tc.propSubmitOrder, tc.accessTime) -// -// for _, prop := range tc.propSubmitOrder { -// cpProp := prop -// providerKeeper.SetPendingConsumerRemovalProp(ctx, &cpProp) -// } -// propsToExecute := providerKeeper.GetConsumerRemovalPropsToExecute(ctx.WithBlockTime(tc.accessTime)) -// require.Equal(t, expectedOrderedProps, propsToExecute) -// } -//} - -// TestMakeConsumerGenesis tests the MakeConsumerGenesis keeper method. -// An expected genesis state is hardcoded in json, unmarshaled, and compared -// against an actual consumer genesis state constructed by a provider keeper. -func TestMakeConsumerGenesis(t *testing.T) { - keeperParams := testkeeper.NewInMemKeeperParams(t) - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) - moduleParams := providertypes.Params{ - TemplateClient: &ibctmtypes.ClientState{ - TrustLevel: ibctmtypes.DefaultTrustLevel, - MaxClockDrift: 10000000000, - ProofSpecs: []*_go.ProofSpec{ - { - LeafSpec: &_go.LeafOp{ - Hash: _go.HashOp_SHA256, - PrehashKey: _go.HashOp_NO_HASH, - PrehashValue: _go.HashOp_SHA256, - Length: _go.LengthOp_VAR_PROTO, - Prefix: []byte{0x00}, - }, - InnerSpec: &_go.InnerSpec{ - ChildOrder: []int32{0, 1}, - ChildSize: 33, - MinPrefixLength: 4, - MaxPrefixLength: 12, - Hash: _go.HashOp_SHA256, - }, - MaxDepth: 0, - MinDepth: 0, - }, - { - LeafSpec: &_go.LeafOp{ - Hash: _go.HashOp_SHA256, - PrehashKey: _go.HashOp_NO_HASH, - PrehashValue: _go.HashOp_SHA256, - Length: _go.LengthOp_VAR_PROTO, - Prefix: []byte{0x00}, - }, - InnerSpec: &_go.InnerSpec{ - ChildOrder: []int32{0, 1}, - ChildSize: 32, - MinPrefixLength: 1, - MaxPrefixLength: 1, - Hash: _go.HashOp_SHA256, - }, - MaxDepth: 0, - }, - }, - UpgradePath: []string{"upgrade", "upgradedIBCState"}, - AllowUpdateAfterExpiry: true, - AllowUpdateAfterMisbehaviour: true, - }, - // Note these are unused provider parameters for this test, and not actually asserted against - // They must be populated with reasonable values to satisfy SetParams though. - TrustingPeriodFraction: providertypes.DefaultTrustingPeriodFraction, - CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, - SlashMeterReplenishPeriod: providertypes.DefaultSlashMeterReplenishPeriod, - SlashMeterReplenishFraction: providertypes.DefaultSlashMeterReplenishFraction, - ConsumerRewardDenomRegistrationFee: sdk.Coin{ - Denom: "stake", - Amount: math.NewInt(1000000), - }, - BlocksPerEpoch: 600, - NumberOfEpochsToStartReceivingRewards: 24, - } - providerKeeper.SetParams(ctx, moduleParams) - defer ctrl.Finish() - - // - // Other setup not covered by custom template client state - // - ctx = ctx.WithChainID("testchain1") // consumerId is obtained from ctx - ctx = ctx.WithBlockHeight(5) // RevisionHeight obtained from ctx - testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) - gomock.InOrder(testkeeper.GetMocksForMakeConsumerGenesis(ctx, &mocks, 1814400000000000)...) - - // matches params from jsonString - consumerMetadata := providertypes.ConsumerMetadata{ - Name: "name", - Description: "description", - } - - ccvTimeoutPeriod := time.Duration(2419200000000000) - transferTimeoutPeriod := time.Duration(3600000000000) - unbondingPeriod := time.Duration(1728000000000000) - initializationParameters := providertypes.ConsumerInitializationParameters{ - BlocksPerDistributionTransmission: 1000, - CcvTimeoutPeriod: ccvTimeoutPeriod, - TransferTimeoutPeriod: transferTimeoutPeriod, - ConsumerRedistributionFraction: "0.75", - HistoricalEntries: 10000, - UnbondingPeriod: unbondingPeriod, - } - providerKeeper.SetConsumerChainId(ctx, "0", "testchain1") - providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) - providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", providertypes.PowerShapingParameters{}) - - actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, "0") - require.NoError(t, err) - - // JSON string with tabs, newlines and spaces for readability - jsonString := `{ - "params": { - "enabled": true, - "blocks_per_distribution_transmission": 1000, - "ccv_timeout_period": 2419200000000000, - "transfer_timeout_period": 3600000000000, - "consumer_redistribution_fraction": "0.75", - "historical_entries": 10000, - "unbonding_period": 1728000000000000, - "soft_opt_out_threshold": "0", - "reward_denoms": [], - "provider_reward_denoms": [], - "retry_delay_period": 3600000000000 - }, - "new_chain": true, - "provider" : { - "client_state": { - "chain_id": "testchain1", - "trust_level": { - "numerator": 1, - "denominator": 3 - }, - "trusting_period": 1197504000000000, - "unbonding_period": 1814400000000000, - "max_clock_drift": 10000000000, - "frozen_height": {}, - "latest_height": { - "revision_height": 5 - }, - "proof_specs": [ - { - "leaf_spec": { - "hash": 1, - "prehash_value": 1, - "length": 1, - "prefix": "AA==" - }, - "inner_spec": { - "child_order": [0, 1], - "child_size": 33, - "min_prefix_length": 4, - "max_prefix_length": 12, - "hash": 1 - } - }, - { - "leaf_spec": { - "hash": 1, - "prehash_value": 1, - "length": 1, - "prefix": "AA==" - }, - "inner_spec": { - "child_order": [0, 1], - "child_size": 32, - "min_prefix_length": 1, - "max_prefix_length": 1, - "hash": 1 - } - } - ], - "upgrade_path": ["upgrade", "upgradedIBCState"], - "allow_update_after_expiry": true, - "allow_update_after_misbehaviour": true - }, - "consensus_state": { - "timestamp": "2020-01-02T00:00:10Z", - "root": { - "hash": "LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA=" - }, - "next_validators_hash": "E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE" - }, - "initial_val_set": [ - { - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro=" - }, - "power": 1 - } - ] - } - }` +) - var expectedGenesis ccvtypes.ConsumerGenesisState - err = json.Unmarshal([]byte(jsonString), &expectedGenesis) // ignores tabs, newlines and spaces +func TestPrepareConsumerForLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + spawnTime := time.Now().UTC() + err := providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", time.Time{}, spawnTime) require.NoError(t, err) - // Zeroing out different fields that are challenging to mock - actualGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} - expectedGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} - actualGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} - expectedGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} + consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) - require.Equal(t, expectedGenesis, actualGenesis, "consumer chain genesis created incorrectly") + nextSpawnTime := spawnTime.Add(time.Hour) + err = providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", spawnTime, nextSpawnTime) + require.NoError(t, err) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Empty(t, consumers) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, nextSpawnTime) + require.NoError(t, err) + require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) +} + +func TestCanLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // cannot launch an unknown chain + _, canLaunch := providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // cannot launch a chain without initialization parameters + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // set valid initialization parameters + initializationParameters := testkeeper.GetTestInitializationParameters() + err := providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) + require.NoError(t, err) + + // cannot launch a launched chain + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // cannot launch a stopped chain + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.False(t, canLaunch) + + // initialized chain can launch + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.True(t, canLaunch) + + // chain cannot launch without a genesis hash + initializationParameters.GenesisHash = nil + err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) + _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") + require.NoError(t, err) + require.False(t, canLaunch) } -// TestBeginBlockInit directly tests BeginBlockInit against the spec using helpers defined above. -func TestBeginBlockInit(t *testing.T) { +// TestBeginBlockInit directly tests BeginBlockLaunchConsumers against the spec using helpers defined above. +func TestBeginBlockLaunchConsumers(t *testing.T) { now := time.Now().UTC() keeperParams := testkeeper.NewInMemKeeperParams(t) @@ -610,13 +252,16 @@ func TestBeginBlockInit(t *testing.T) { providerKeeper.SetConsumerMetadata(ctx, fmt.Sprintf("%d", i), r) } for i, r := range initializationParameters { - providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) + err := providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) + require.NoError(t, err) // set up the chains in their initialized phase, hence they could launch providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.AppendConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) + err = providerKeeper.AppendConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) + require.NoError(t, err) } for i, r := range powerShapingParameters { - providerKeeper.SetConsumerPowerShapingParameters(ctx, fmt.Sprintf("%d", i), r) + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, fmt.Sprintf("%d", i), r) + require.NoError(t, err) } // opt in a sample validator so the chain's proposal can successfully execute @@ -631,7 +276,7 @@ func TestBeginBlockInit(t *testing.T) { providerKeeper.SetOptedIn(ctx, "3", providertypes.NewProviderConsAddress(consAddr)) - providerKeeper.BeginBlockInit(ctx) + providerKeeper.BeginBlockLaunchConsumers(ctx) // first chain was successfully launched phase := providerKeeper.GetConsumerPhase(ctx, "0") @@ -645,28 +290,348 @@ func TestBeginBlockInit(t *testing.T) { _, found = providerKeeper.GetConsumerGenesis(ctx, "1") require.True(t, found) - // third chain was not launched because its spawn time has not passed - phase = providerKeeper.GetConsumerPhase(ctx, "2") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) - _, found = providerKeeper.GetConsumerGenesis(ctx, "2") - require.False(t, found) + // third chain was not launched because its spawn time has not passed + phase = providerKeeper.GetConsumerPhase(ctx, "2") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "2") + require.False(t, found) + + // fourth chain corresponds to an Opt-In chain with one opted-in validator and hence the chain gets + // successfully executed + phase = providerKeeper.GetConsumerPhase(ctx, "3") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "3") + require.True(t, found) + + // fifth chain corresponds to an Opt-In chain with no opted-in validators and hence the + // chain launch is NOT successful + phase = providerKeeper.GetConsumerPhase(ctx, "4") + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + _, found = providerKeeper.GetConsumerGenesis(ctx, "4") + require.False(t, found) +} + +// TestGetConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned +func TestGetConsumersReadyToLaunch(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // no chains to-be-launched exist + require.Empty(t, providerKeeper.GetConsumersReadyToLaunch(ctx, 5)) + + err := providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", time.Unix(10, 0)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", time.Unix(20, 0)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", time.Unix(30, 0)) + require.NoError(t, err) + + // time has not yet reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) + require.Empty(t, providerKeeper.GetConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(10, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of "consumerId1" and "consumerId2" + ctx = ctx.WithBlockTime(time.Unix(20, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetConsumersReadyToLaunch(ctx, 3)) + + // time has reached the spawn time of all chains + ctx = ctx.WithBlockTime(time.Unix(30, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetConsumersReadyToLaunch(ctx, 3)) + + // limit the number of returned consumer chains + require.Equal(t, []string{}, providerKeeper.GetConsumersReadyToLaunch(ctx, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetConsumersReadyToLaunch(ctx, 1)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetConsumersReadyToLaunch(ctx, 2)) +} + +// Tests the CreateConsumerClient method against the spec, +// with more granularity than what's covered in TestHandleCreateConsumerChainProposal. +func TestCreateConsumerClient(t *testing.T) { + type testCase struct { + description string + // Any state-mutating setup on keeper and expected mock calls, specific to this test case + setup func(*providerkeeper.Keeper, sdk.Context, *testkeeper.MockedKeepers) + // Whether a client should be created + expClientCreated bool + } + tests := []testCase{ + { + description: "No state mutation, new client should be created", + setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + + // Valid client creation is asserted with mock expectations here + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set + gomock.InOrder( + testkeeper.GetMocksForCreateConsumerClient(ctx, mocks, "chainID", clienttypes.NewHeight(4, 5))..., + ) + }, + expClientCreated: true, + }, + { + description: "chain for this consumer id has already launched, and hence client was created, NO new one is created", + setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + + // Expect none of the client creation related calls to happen + mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Times(0) + mocks.MockClientKeeper.EXPECT().CreateClient(gomock.Any(), gomock.Any(), gomock.Any()).Times(0) + mocks.MockClientKeeper.EXPECT().GetSelfConsensusState(gomock.Any(), gomock.Any()).Times(0) + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 0) // returns empty validator set + }, + expClientCreated: false, + }, + } + + for _, tc := range tests { + // Common setup + keeperParams := testkeeper.NewInMemKeeperParams(t) + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + + // Test specific setup + tc.setup(&providerKeeper, ctx, &mocks) + + // Call method with same arbitrary values as defined above in mock expectations. + providerKeeper.SetConsumerChainId(ctx, "0", "chainID") + providerKeeper.SetConsumerMetadata(ctx, "0", testkeeper.GetTestConsumerMetadata()) + providerKeeper.SetConsumerInitializationParameters(ctx, "0", testkeeper.GetTestInitializationParameters()) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", testkeeper.GetTestPowerShapingParameters()) + err := providerKeeper.CreateConsumerClient(ctx, "0") + + if tc.expClientCreated { + require.NoError(t, err) + testCreatedConsumerClient(t, ctx, providerKeeper, "0", "clientID") + } else { + require.Error(t, err) + } + + // Assert mock calls from setup functions + ctrl.Finish() + } +} + +// Executes test assertions for a created consumer client. +// +// Note: Separated from TestCreateConsumerClient to also be called from TestCreateConsumerChainProposal. +func testCreatedConsumerClient(t *testing.T, + ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId, expectedClientID string, +) { + t.Helper() + // ClientID should be stored. + clientId, found := providerKeeper.GetConsumerClientId(ctx, consumerId) + require.True(t, found, "consumer client not found") + require.Equal(t, expectedClientID, clientId) + + // Only assert that consumer genesis was set, + // more granular tests on consumer genesis should be defined in TestMakeConsumerGenesis + _, ok := providerKeeper.GetConsumerGenesis(ctx, consumerId) + require.True(t, ok) +} + +// TestMakeConsumerGenesis tests the MakeConsumerGenesis keeper method. +// An expected genesis state is hardcoded in json, unmarshaled, and compared +// against an actual consumer genesis state constructed by a provider keeper. +func TestMakeConsumerGenesis(t *testing.T) { + keeperParams := testkeeper.NewInMemKeeperParams(t) + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + moduleParams := providertypes.Params{ + TemplateClient: &ibctmtypes.ClientState{ + TrustLevel: ibctmtypes.DefaultTrustLevel, + MaxClockDrift: 10000000000, + ProofSpecs: []*_go.ProofSpec{ + { + LeafSpec: &_go.LeafOp{ + Hash: _go.HashOp_SHA256, + PrehashKey: _go.HashOp_NO_HASH, + PrehashValue: _go.HashOp_SHA256, + Length: _go.LengthOp_VAR_PROTO, + Prefix: []byte{0x00}, + }, + InnerSpec: &_go.InnerSpec{ + ChildOrder: []int32{0, 1}, + ChildSize: 33, + MinPrefixLength: 4, + MaxPrefixLength: 12, + Hash: _go.HashOp_SHA256, + }, + MaxDepth: 0, + MinDepth: 0, + }, + { + LeafSpec: &_go.LeafOp{ + Hash: _go.HashOp_SHA256, + PrehashKey: _go.HashOp_NO_HASH, + PrehashValue: _go.HashOp_SHA256, + Length: _go.LengthOp_VAR_PROTO, + Prefix: []byte{0x00}, + }, + InnerSpec: &_go.InnerSpec{ + ChildOrder: []int32{0, 1}, + ChildSize: 32, + MinPrefixLength: 1, + MaxPrefixLength: 1, + Hash: _go.HashOp_SHA256, + }, + MaxDepth: 0, + }, + }, + UpgradePath: []string{"upgrade", "upgradedIBCState"}, + AllowUpdateAfterExpiry: true, + AllowUpdateAfterMisbehaviour: true, + }, + // Note these are unused provider parameters for this test, and not actually asserted against + // They must be populated with reasonable values to satisfy SetParams though. + TrustingPeriodFraction: providertypes.DefaultTrustingPeriodFraction, + CcvTimeoutPeriod: ccvtypes.DefaultCCVTimeoutPeriod, + SlashMeterReplenishPeriod: providertypes.DefaultSlashMeterReplenishPeriod, + SlashMeterReplenishFraction: providertypes.DefaultSlashMeterReplenishFraction, + ConsumerRewardDenomRegistrationFee: sdk.Coin{ + Denom: "stake", + Amount: math.NewInt(1000000), + }, + BlocksPerEpoch: 600, + NumberOfEpochsToStartReceivingRewards: 24, + } + providerKeeper.SetParams(ctx, moduleParams) + defer ctrl.Finish() + + // + // Other setup not covered by custom template client state + // + ctx = ctx.WithChainID("testchain1") // consumerId is obtained from ctx + ctx = ctx.WithBlockHeight(5) // RevisionHeight obtained from ctx + testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) + gomock.InOrder(testkeeper.GetMocksForMakeConsumerGenesis(ctx, &mocks, 1814400000000000)...) + + // matches params from jsonString + consumerMetadata := providertypes.ConsumerMetadata{ + Name: "name", + Description: "description", + } + + ccvTimeoutPeriod := time.Duration(2419200000000000) + transferTimeoutPeriod := time.Duration(3600000000000) + unbondingPeriod := time.Duration(1728000000000000) + initializationParameters := providertypes.ConsumerInitializationParameters{ + BlocksPerDistributionTransmission: 1000, + CcvTimeoutPeriod: ccvTimeoutPeriod, + TransferTimeoutPeriod: transferTimeoutPeriod, + ConsumerRedistributionFraction: "0.75", + HistoricalEntries: 10000, + UnbondingPeriod: unbondingPeriod, + } + providerKeeper.SetConsumerChainId(ctx, "0", "testchain1") + providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) + providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) + providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", providertypes.PowerShapingParameters{}) + + actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, "0") + require.NoError(t, err) + + // JSON string with tabs, newlines and spaces for readability + jsonString := `{ + "params": { + "enabled": true, + "blocks_per_distribution_transmission": 1000, + "ccv_timeout_period": 2419200000000000, + "transfer_timeout_period": 3600000000000, + "consumer_redistribution_fraction": "0.75", + "historical_entries": 10000, + "unbonding_period": 1728000000000000, + "soft_opt_out_threshold": "0", + "reward_denoms": [], + "provider_reward_denoms": [], + "retry_delay_period": 3600000000000 + }, + "new_chain": true, + "provider" : { + "client_state": { + "chain_id": "testchain1", + "trust_level": { + "numerator": 1, + "denominator": 3 + }, + "trusting_period": 1197504000000000, + "unbonding_period": 1814400000000000, + "max_clock_drift": 10000000000, + "frozen_height": {}, + "latest_height": { + "revision_height": 5 + }, + "proof_specs": [ + { + "leaf_spec": { + "hash": 1, + "prehash_value": 1, + "length": 1, + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [0, 1], + "child_size": 33, + "min_prefix_length": 4, + "max_prefix_length": 12, + "hash": 1 + } + }, + { + "leaf_spec": { + "hash": 1, + "prehash_value": 1, + "length": 1, + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [0, 1], + "child_size": 32, + "min_prefix_length": 1, + "max_prefix_length": 1, + "hash": 1 + } + } + ], + "upgrade_path": ["upgrade", "upgradedIBCState"], + "allow_update_after_expiry": true, + "allow_update_after_misbehaviour": true + }, + "consensus_state": { + "timestamp": "2020-01-02T00:00:10Z", + "root": { + "hash": "LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA=" + }, + "next_validators_hash": "E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE" + }, + "initial_val_set": [ + { + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro=" + }, + "power": 1 + } + ] + } + }` + + var expectedGenesis ccvtypes.ConsumerGenesisState + err = json.Unmarshal([]byte(jsonString), &expectedGenesis) // ignores tabs, newlines and spaces + require.NoError(t, err) - // fourth chain corresponds to an Opt-In chain with one opted-in validator and hence the chain gets - // successfully executed - phase = providerKeeper.GetConsumerPhase(ctx, "3") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) - _, found = providerKeeper.GetConsumerGenesis(ctx, "3") - require.True(t, found) + // Zeroing out different fields that are challenging to mock + actualGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} + expectedGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} + actualGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} + expectedGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} - // fifth chain corresponds to an Opt-In chain with no opted-in validators and hence the - // chain launch is NOT successful - phase = providerKeeper.GetConsumerPhase(ctx, "4") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) - _, found = providerKeeper.GetConsumerGenesis(ctx, "4") - require.False(t, found) + require.Equal(t, expectedGenesis, actualGenesis, "consumer chain genesis created incorrectly") } -func TestBeginBlockCCR(t *testing.T) { +func TestBeginBlockStopConsumers(t *testing.T) { now := time.Now().UTC() keeperParams := testkeeper.NewInMemKeeperParams(t) @@ -677,12 +642,18 @@ func TestBeginBlockCCR(t *testing.T) { chainIds := []string{"chain1", "chain2", "chain3"} consumerIds := []string{"consumerId1", "consumerId2", "consumerId3"} - providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) - providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) - providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) - providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[1], now) - providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) - providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) + err := providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) + require.NoError(t, err) + err = providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[1], now) + require.NoError(t, err) + err = providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) + require.NoError(t, err) // // Mock expectations @@ -712,13 +683,16 @@ func TestBeginBlockCCR(t *testing.T) { registrationRecord := testkeeper.GetTestConsumerMetadata() providerKeeper.SetConsumerChainId(ctx, consumerId, chainIds[i]) - providerKeeper.SetConsumerMetadata(ctx, consumerId, registrationRecord) - providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, initializationRecord) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, testkeeper.GetTestPowerShapingParameters()) + err = providerKeeper.SetConsumerMetadata(ctx, consumerId, registrationRecord) + require.NoError(t, err) + err = providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, initializationRecord) + require.NoError(t, err) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, testkeeper.GetTestPowerShapingParameters()) + require.NoError(t, err) providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - providerKeeper.SetClientIdToConsumerId(ctx, "clientID", consumerId) + providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") - err := providerKeeper.CreateConsumerClient(ctx, consumerId) + err = providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) @@ -731,7 +705,7 @@ func TestBeginBlockCCR(t *testing.T) { // Test execution // - providerKeeper.BeginBlockCCR(ctx) + providerKeeper.BeginBlockStopConsumers(ctx) // Only the 3rd (final) proposal is still stored as pending phase := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) @@ -742,3 +716,251 @@ func TestBeginBlockCCR(t *testing.T) { phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) } + +func TestGetConsumersReadyToStop(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // no chains to-be-stopped exist + require.Empty(t, providerKeeper.GetConsumersReadyToStop(ctx, 3)) + + err := providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) + require.NoError(t, err) + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) + require.NoError(t, err) + + // time has not yet reached the stop time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) + require.Empty(t, providerKeeper.GetConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of "consumerId1" + ctx = ctx.WithBlockTime(time.Unix(10, 0)) + require.Equal(t, []string{"consumerId1"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of "consumerId1" and "consumerId2" + ctx = ctx.WithBlockTime(time.Unix(20, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) + + // time has reached the stop time of all chains + ctx = ctx.WithBlockTime(time.Unix(30, 0)) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) +} + +// Tests the StopConsumerChain method against the spec, +// with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. +// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 +// Spec tag: [CCV-PCF-STCC.1] +func TestStopConsumerChain(t *testing.T) { + type testCase struct { + description string + // State-mutating setup specific to this test case + setup func(sdk.Context, *providerkeeper.Keeper, testkeeper.MockedKeepers) + // Whether we should expect the method to return an error + expErr bool + } + + consumerId := "0" + + tests := []testCase{ + { + description: "proposal dropped, client doesn't exist", + setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { + // No mocks, meaning no external keeper methods are allowed to be called. + }, + expErr: true, + }, + { + description: "valid stop of consumer chain, all mock calls hit", + setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { + testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks, consumerId) + + // set consumer minimum equivocation height + providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerId, 1) + + // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel + gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + }, + expErr: false, + }, + } + + for _, tc := range tests { + + // Common setup + keeperParams := testkeeper.NewInMemKeeperParams(t) + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, keeperParams) + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + + // Setup specific to test case + tc.setup(ctx, &providerKeeper, mocks) + + err := providerKeeper.StopConsumerChain(ctx, consumerId, true) + + if tc.expErr { + require.Error(t, err, t) + } else { + require.NoError(t, err) + } + + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) + + ctrl.Finish() + } +} + +// +// Setters and Getters +// + +// TestConsumerStopTime tests the getter, setter, and deletion of the consumer id to stop times methods +func TestConsumerStopTime(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + _, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.Error(t, err) + + expectedStopTime := time.Unix(1234, 56789) + providerKeeper.SetConsumerStopTime(ctx, "consumerId", expectedStopTime) + actualStopTime, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.NoError(t, err) + require.Equal(t, actualStopTime, expectedStopTime) + + providerKeeper.DeleteConsumerStopTime(ctx, "consumerId") + _, err = providerKeeper.GetConsumerStopTime(ctx, "consumerId") + require.Error(t, err) +} + +// TestConsumersToBeLaunched tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` +func TestConsumersToBeLaunched(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + spawnTime := time.Now() + err := providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", spawnTime) + require.NoError(t, err) + consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1"}, consumers.Ids) + + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) + + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) + + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId2", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // also add consumer ids under a different spawn time and verify everything under the original spawn time is still there + spawnTimePlusOneHour := spawnTime.Add(time.Hour) + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) + require.NoError(t, err) + require.Equal(t, []string{"consumerId4"}, consumers.Ids) + + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // start removing all consumers from `spawnTime` + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId3", spawnTime) + require.NoError(t, err) + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId1", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // remove from `spawnTimePlusOneHour` + err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // add another consumer for `spawnTime` + err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId5", spawnTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId5"}, consumers.Ids) +} + +// TestConsumersToBeStopped tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` +func TestConsumersToBeStopped(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + stopTime := time.Now() + err := providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", stopTime) + require.NoError(t, err) + consumers, err := providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1"}, consumers.Ids) + + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) + + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) + + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId2", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // also add consumer ids under a different stop time and verify everything under the original stop time is still there + stopTimePlusOneHour := stopTime.Add(time.Hour) + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + require.NoError(t, err) + require.Equal(t, []string{"consumerId4"}, consumers.Ids) + + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) + + // start removing all consumers from `stopTime` + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId3", stopTime) + require.NoError(t, err) + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId1", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // remove from `stopTimePlusOneHour` + err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + require.NoError(t, err) + require.Empty(t, consumers.Ids) + + // add another consumer for `stopTime` + err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId5", stopTime) + require.NoError(t, err) + consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + require.NoError(t, err) + require.Equal(t, []string{"consumerId5"}, consumers.Ids) +} diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 9d67181158..87a2e5e9e4 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -361,3 +361,40 @@ func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, consumerId stri commissionRate, ) } + +// TODO: this method needs to be tested +func (k Keeper) ChangeRewardDenoms(ctx sdk.Context, denomsToAdd, denomsToRemove []string) []sdk.Attribute { + // initialize an empty slice to store event attributes + eventAttributes := []sdk.Attribute{} + + // loop through denomsToAdd and add each denomination if it is not already registered + for _, denomToAdd := range denomsToAdd { + // Log error and move on if one of the denoms is already registered + if k.ConsumerRewardDenomExists(ctx, denomToAdd) { + k.Logger(ctx).Error("ChangeRewardDenoms: denom already registered", + "denomToAdd", denomToAdd, + ) + continue + } + k.SetConsumerRewardDenom(ctx, denomToAdd) + + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeAddConsumerRewardDenom, denomToAdd)) + } + + // loop through denomsToRemove and remove each denomination if it is registered + for _, denomToRemove := range denomsToRemove { + // Log error and move on if one of the denoms is not registered + if !k.ConsumerRewardDenomExists(ctx, denomToRemove) { + k.Logger(ctx).Error("ChangeRewardDenoms: denom not registered", + "denomToRemove", denomToRemove, + ) + continue + } + k.DeleteConsumerRewardDenom(ctx, denomToRemove) + + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeRemoveConsumerRewardDenom, denomToRemove)) + } + + // return the slice of event attributes + return eventAttributes +} diff --git a/x/ccv/provider/keeper/distribution_test.go b/x/ccv/provider/keeper/distribution_test.go index 57ff82bc95..c449b0149c 100644 --- a/x/ccv/provider/keeper/distribution_test.go +++ b/x/ccv/provider/keeper/distribution_test.go @@ -296,3 +296,35 @@ func TestIsEligibleForConsumerRewards(t *testing.T) { require.True(t, keeper.IsEligibleForConsumerRewards(ctx.WithBlockHeight(numberOfBlocks+1), 1)) require.False(t, keeper.IsEligibleForConsumerRewards(ctx.WithBlockHeight(numberOfBlocks+1), 2)) } + +func TestChangeRewardDenoms(t *testing.T) { + keeper, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + + // Test adding a new denomination + denomsToAdd := []string{"denom1"} + denomsToRemove := []string{} + attributes := keeper.ChangeRewardDenoms(ctx, denomsToAdd, denomsToRemove) + + require.Len(t, attributes, 1) + require.Equal(t, providertypes.AttributeAddConsumerRewardDenom, attributes[0].Key) + require.Equal(t, "denom1", attributes[0].Value) + require.True(t, keeper.ConsumerRewardDenomExists(ctx, "denom1")) + + // Test adding a denomination that is already registered + attributes = keeper.ChangeRewardDenoms(ctx, denomsToAdd, denomsToRemove) + require.Len(t, attributes, 0) // No attributes should be returned since the denom is already registered + + // Test removing a registered denomination + denomsToAdd = []string{} + denomsToRemove = []string{"denom1"} + attributes = keeper.ChangeRewardDenoms(ctx, denomsToAdd, denomsToRemove) + + require.Len(t, attributes, 1) + require.Equal(t, providertypes.AttributeRemoveConsumerRewardDenom, attributes[0].Key) + require.Equal(t, "denom1", attributes[0].Value) + require.False(t, keeper.ConsumerRewardDenomExists(ctx, "denom1")) + + // Test removing a denomination that is not registered + attributes = keeper.ChangeRewardDenoms(ctx, denomsToAdd, denomsToRemove) + require.Len(t, attributes, 0) // No attributes should be returned since the denom is not registered +} diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 9063e1cdd0..c540c4980c 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -578,7 +578,7 @@ func TestQueryConsumerIdFromClientId(t *testing.T) { require.ErrorContains(t, err, "no known consumer chain") expectedConsumerId := "consumerId" - providerKeeper.SetClientIdToConsumerId(ctx, "clientId", expectedConsumerId) + providerKeeper.SetConsumerClientId(ctx, expectedConsumerId, "clientId") res, err := providerKeeper.QueryConsumerIdFromClientId(ctx, &types.QueryConsumerIdFromClientIdRequest{ClientId: "clientId"}) require.NoError(t, err) diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 4598ff30c1..0fc911c8dc 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -636,10 +636,21 @@ func (k Keeper) DeletePendingVSCPackets(ctx sdk.Context, consumerId string) { store.Delete(types.PendingVSCsKey(consumerId)) } -// SetConsumerClientId sets the client id for the given consumer id -func (k Keeper) SetConsumerClientId(ctx sdk.Context, consumerId, clientID string) { +// SetConsumerClientId sets the client id for the given consumer id. +// Note that the method also stores a reverse index that can be accessed +// by calling GetClientIdToConsumerId. +func (k Keeper) SetConsumerClientId(ctx sdk.Context, consumerId, clientId string) { store := ctx.KVStore(k.storeKey) - store.Set(types.ConsumerIdToClientIdKey(consumerId), []byte(clientID)) + + if prevClientId, found := k.GetConsumerClientId(ctx, consumerId); found { + // delete reverse index + store.Delete(types.ClientIdToConsumerIdKey(prevClientId)) + } + + store.Set(types.ConsumerIdToClientIdKey(consumerId), []byte(clientId)) + + // set the reverse index + store.Set(types.ClientIdToConsumerIdKey(clientId), []byte(consumerId)) } // GetConsumerClientId returns the client id for the given consumer id. @@ -652,9 +663,26 @@ func (k Keeper) GetConsumerClientId(ctx sdk.Context, consumerId string) (string, return string(clientIdBytes), true } +// GetClientIdToConsumerId returns the consumer id associated with this client id +func (k Keeper) GetClientIdToConsumerId(ctx sdk.Context, clientId string) (string, bool) { + store := ctx.KVStore(k.storeKey) + consumerIdBytes := store.Get(types.ClientIdToConsumerIdKey(clientId)) + if consumerIdBytes == nil { + return "", false + } + return string(consumerIdBytes), true +} + // DeleteConsumerClientId removes from the store the client id for the given consumer id. +// Note that the method also removes the reverse index. func (k Keeper) DeleteConsumerClientId(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) + + if clientId, found := k.GetConsumerClientId(ctx, consumerId); found { + // delete reverse index + store.Delete(types.ClientIdToConsumerIdKey(clientId)) + } + store.Delete(types.ConsumerIdToClientIdKey(consumerId)) } @@ -902,6 +930,19 @@ func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool { return !iterator.Valid() } +// UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id +func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string) { + k.DeleteAllowlist(ctx, consumerId) + for _, address := range allowlist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetAllowlist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } +} + // SetDenylist denylists validator with `providerAddr` address on chain `consumerId` func (k Keeper) SetDenylist( ctx sdk.Context, @@ -965,6 +1006,19 @@ func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool { return !iterator.Valid() } +// UpdateDenylist populates the denylist store for the consumer chain with this consumer id +func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string) { + k.DeleteDenylist(ctx, consumerId) + for _, address := range denylist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetDenylist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } +} + // SetMinimumPowerInTopN sets the minimum power required for a validator to be in the top N // for a given consumer chain. func (k Keeper) SetMinimumPowerInTopN( @@ -1004,6 +1058,30 @@ func (k Keeper) DeleteMinimumPowerInTopN( store.Delete(types.MinimumPowerInTopNKey(consumerId)) } +// UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id +func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN uint32, newTopN uint32) error { + // if the top N changes, we need to update the new minimum power in top N + if newTopN != oldTopN { + if newTopN > 0 { + // if the chain receives a non-zero top N value, store the minimum power in the top N + bondedValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) + if err != nil { + return err + } + minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, newTopN) + if err != nil { + return err + } + k.SetMinimumPowerInTopN(ctx, consumerId, minPower) + } else { + // if the chain receives a zero top N value, we delete the min power + k.DeleteMinimumPowerInTopN(ctx, consumerId) + } + } + + return nil +} + func (k Keeper) UnbondingCanComplete(ctx sdk.Context, id uint64) error { return k.stakingKeeper.UnbondingCanComplete(ctx, id) } diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 1794c2fba5..5431c95390 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -8,17 +8,19 @@ import ( "cosmossdk.io/math" ibctesting "github.com/cosmos/ibc-go/v8/testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" cryptotestutil "github.com/cosmos/interchain-security/v5/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" ) @@ -55,7 +57,7 @@ func TestGetAllValsetUpdateBlockHeights(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - cases := []types.ValsetUpdateIdToHeight{ + cases := []providertypes.ValsetUpdateIdToHeight{ { ValsetUpdateId: 2, Height: 22, @@ -288,10 +290,10 @@ func TestGetAllOptedIn(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - expectedOptedInValidators := []types.ProviderConsAddress{ - types.NewProviderConsAddress([]byte("providerAddr1")), - types.NewProviderConsAddress([]byte("providerAddr2")), - types.NewProviderConsAddress([]byte("providerAddr3")), + expectedOptedInValidators := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress([]byte("providerAddr1")), + providertypes.NewProviderConsAddress([]byte("providerAddr2")), + providertypes.NewProviderConsAddress([]byte("providerAddr3")), } for _, expectedOptedInValidator := range expectedOptedInValidators { @@ -301,7 +303,7 @@ func TestGetAllOptedIn(t *testing.T) { actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "consumerId") // sort validators first to be able to compare - sortOptedInValidators := func(addresses []types.ProviderConsAddress) { + sortOptedInValidators := func(addresses []providertypes.ProviderConsAddress) { sort.Slice(addresses, func(i, j int) bool { return bytes.Compare(addresses[i].ToSdkConsAddr(), addresses[j].ToSdkConsAddr()) < 0 }) @@ -316,8 +318,8 @@ func TestOptedIn(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - optedInValidator1 := types.NewProviderConsAddress([]byte("providerAddr1")) - optedInValidator2 := types.NewProviderConsAddress([]byte("providerAddr2")) + optedInValidator1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) + optedInValidator2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", optedInValidator1)) providerKeeper.SetOptedIn(ctx, "consumerId", optedInValidator1) @@ -339,8 +341,8 @@ func TestConsumerCommissionRate(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) - providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) + providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) + providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) cr, found := providerKeeper.GetConsumerCommissionRate(ctx, "consumerId", providerAddr1) require.False(t, found) @@ -380,14 +382,14 @@ func TestAllowlist(t *testing.T) { // no validator was allowlisted and hence the allowlist is empty require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) - providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) + providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) providerKeeper.SetAllowlist(ctx, chainID, providerAddr1) require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr1)) // allowlist is not empty anymore require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) - providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) + providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) providerKeeper.SetAllowlist(ctx, chainID, providerAddr2) require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr2)) require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) @@ -398,6 +400,25 @@ func TestAllowlist(t *testing.T) { require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) } +func TestUpdateAllowlist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateAllowlist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedAllowlist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) +} + // TestDenylist tests the `SetDenylist`, `IsDenylisted`, `DeleteDenylist`, and `IsDenylistEmpty` methods func TestDenylist(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) @@ -408,14 +429,14 @@ func TestDenylist(t *testing.T) { // no validator was denylisted and hence the denylist is empty require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) - providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) + providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) providerKeeper.SetDenylist(ctx, chainID, providerAddr1) require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr1)) // denylist is not empty anymore require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) - providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) + providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) providerKeeper.SetDenylist(ctx, chainID, providerAddr2) require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr2)) require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) @@ -426,6 +447,25 @@ func TestDenylist(t *testing.T) { require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) } +func TestUpdateDenylist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateDenylist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedDenylist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) +} + // Tests setting, getting and deleting parameters that are stored per-consumer chain. // The tests cover the following parameters: // - MinimumPowerInTopN @@ -490,3 +530,109 @@ func TestKeeperConsumerParams(t *testing.T) { }) } } + +// TestConsumerClientId tests the getter, setter, and deletion of the client id <> consumer id mappings +func TestConsumerClientId(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "123" + clientIds := []string{"clientId1", "clientId2"} + + _, found := providerKeeper.GetConsumerClientId(ctx, consumerId) + require.False(t, found) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) + require.False(t, found) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) + require.False(t, found) + + providerKeeper.SetConsumerClientId(ctx, consumerId, clientIds[0]) + res, found := providerKeeper.GetConsumerClientId(ctx, consumerId) + require.True(t, found) + require.Equal(t, clientIds[0], res) + res, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) + require.True(t, found) + require.Equal(t, consumerId, res) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) + require.False(t, found) + + // overwrite the client ID + providerKeeper.SetConsumerClientId(ctx, consumerId, clientIds[1]) + res, found = providerKeeper.GetConsumerClientId(ctx, consumerId) + require.True(t, found) + require.Equal(t, clientIds[1], res) + res, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) + require.True(t, found) + require.Equal(t, consumerId, res) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) + require.False(t, found) + + providerKeeper.DeleteConsumerClientId(ctx, consumerId) + _, found = providerKeeper.GetConsumerClientId(ctx, consumerId) + require.False(t, found) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[0]) + require.False(t, found) + _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) + require.False(t, found) +} + +func TestUpdateMinimumPowerInTopN(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + // test case where Top N is 0 in which case there's no minimum power in top N + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 0, + }) + + err := providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 0) + require.NoError(t, err) + _, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.False(t, found) + + // test cases where Top N > 0 and for this we mock some validators + powers := []int64{10, 20, 30} + validators := []stakingtypes.Validator{ + createStakingValidator(ctx, mocks, powers[0], 1), // this validator has ~16 of the total voting power + createStakingValidator(ctx, mocks, powers[1], 2), // this validator has ~33% of the total voting gpower + createStakingValidator(ctx, mocks, powers[2], 3), // this validator has 50% of the total voting power + } + mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() + + maxProviderConsensusValidators := int64(3) + params := providerKeeper.GetParams(ctx) + params.MaxProviderConsensusValidators = maxProviderConsensusValidators + providerKeeper.SetParams(ctx, params) + + // when top N is 50, the minimum power is 30 (because top validator has to validate) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 50, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 50) + require.NoError(t, err) + minimumPowerInTopN, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(30), minimumPowerInTopN) + + // when top N is 51, the minimum power is 20 (because top 2 validators have to validate) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 51, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 50, 51) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(20), minimumPowerInTopN) + + // when top N is 100, the minimum power is 10 (that of the validator with the lowest power) + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 100, + }) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 51, 100) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(10), minimumPowerInTopN) +} diff --git a/x/ccv/provider/keeper/legacy_proposal.go b/x/ccv/provider/keeper/legacy_proposal.go deleted file mode 100644 index a3e6ed2f30..0000000000 --- a/x/ccv/provider/keeper/legacy_proposal.go +++ /dev/null @@ -1,35 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -func (k Keeper) HandleLegacyConsumerRewardDenomProposal(ctx sdk.Context, p *types.ChangeRewardDenomsProposal) error { - for _, denomToAdd := range p.DenomsToAdd { - // Log error and move on if one of the denoms is already registered - if k.ConsumerRewardDenomExists(ctx, denomToAdd) { - ctx.Logger().Error("denom %s already registered", denomToAdd) - continue - } - k.SetConsumerRewardDenom(ctx, denomToAdd) - ctx.EventManager().EmitEvent(sdk.NewEvent( - types.EventTypeAddConsumerRewardDenom, - sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToAdd), - )) - } - for _, denomToRemove := range p.DenomsToRemove { - // Log error and move on if one of the denoms is not registered - if !k.ConsumerRewardDenomExists(ctx, denomToRemove) { - ctx.Logger().Error("denom %s not registered", denomToRemove) - continue - } - k.DeleteConsumerRewardDenom(ctx, denomToRemove) - ctx.EventManager().EmitEvent(sdk.NewEvent( - types.EventTypeRemoveConsumerRewardDenom, - sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToRemove), - )) - } - return nil -} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index b10cb883c6..962575e00d 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -128,15 +128,20 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon // ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChangeRewardDenoms) (*types.MsgChangeRewardDenomsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if k.GetAuthority() != msg.Authority { return nil, errorsmod.Wrapf(types.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Authority) } - sdkCtx := sdk.UnwrapSDKContext(goCtx) - err := k.Keeper.HandleConsumerRewardDenomProposal(sdkCtx, msg) - if err != nil { - return nil, errorsmod.Wrapf(err, "failed handling Change Reward Denoms proposal") - } + eventAttributes := k.Keeper.ChangeRewardDenoms(ctx, msg.DenomsToAdd, msg.DenomsToRemove) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeChangeConsumerRewardDenom, + eventAttributes..., + ), + ) return &types.MsgChangeRewardDenomsResponse{}, nil } @@ -354,7 +359,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon "cannot create a Top N chain using the `MsgCreateConsumer` message; use `MsgUpdateConsumer` instead") } - // TODO UpdateAllowlist & UpdateDenylist + // TODO (PERMISSIONLESS) UpdateAllowlist & UpdateDenylist } if err := k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, powerShapingParameters); err != nil { return &resp, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index f684f8b80d..695db64463 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -4,12 +4,8 @@ import ( "encoding/binary" "fmt" "strconv" - "time" - errorsmod "cosmossdk.io/errors" - storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) @@ -211,149 +207,6 @@ func (k Keeper) IsConsumerActive(ctx sdk.Context, consumerId string) bool { phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED } -// GetConsumerStopTime returns the stop time associated with the to-be-stopped chain with consumer id -func (k Keeper) GetConsumerStopTime(ctx sdk.Context, consumerId string) (time.Time, error) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.ConsumerIdToStopTimeKey(consumerId)) - if buf == nil { - return time.Time{}, fmt.Errorf("failed to retrieve stop time for consumer id (%s)", consumerId) - } - var time time.Time - if err := time.UnmarshalBinary(buf); err != nil { - return time, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) - } - return time, nil -} - -// SetConsumerStopTime sets the stop time associated with this consumer id -func (k Keeper) SetConsumerStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { - store := ctx.KVStore(k.storeKey) - buf, err := stopTime.MarshalBinary() - if err != nil { - return fmt.Errorf("failed to marshal stop time (%+v) for consumer id (%s): %w", stopTime, consumerId, err) - } - store.Set(types.ConsumerIdToStopTimeKey(consumerId), buf) - return nil -} - -// DeleteConsumerStopTime deletes the stop time associated with this consumer id -func (k Keeper) DeleteConsumerStopTime(ctx sdk.Context, consumerId string) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerIdToStopTimeKey(consumerId)) -} - -// getConsumerIdsBasedOnTime returns all the consumer ids stored under this specific `key(time)` -func (k Keeper) getConsumerIdsBasedOnTime(ctx sdk.Context, key func(time.Time) []byte, time time.Time) (types.ConsumerIds, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(key(time)) - if bz == nil { - return types.ConsumerIds{}, nil - } - - var consumerIds types.ConsumerIds - - if err := consumerIds.Unmarshal(bz); err != nil { - return types.ConsumerIds{}, fmt.Errorf("failed to unmarshal consumer ids: %w", err) - } - return consumerIds, nil -} - -// appendConsumerIdOnTime appends the consumer id on all the other consumer ids under `key(time)` -func (k Keeper) appendConsumerIdOnTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { - store := ctx.KVStore(k.storeKey) - - consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) - if err != nil { - return err - } - - consumersWithAppend := types.ConsumerIds{ - Ids: append(consumers.Ids, consumerId), - } - - bz, err := consumersWithAppend.Marshal() - if err != nil { - return err - } - - store.Set(key(time), bz) - return nil -} - -// removeConsumerIdFromTime removes consumer id stored under `key(time)` -func (k Keeper) removeConsumerIdFromTime(ctx sdk.Context, consumerId string, key func(time.Time) []byte, time time.Time) error { - store := ctx.KVStore(k.storeKey) - - consumers, err := k.getConsumerIdsBasedOnTime(ctx, key, time) - if err != nil { - return err - } - - if len(consumers.Ids) == 0 { - return fmt.Errorf("no consumer ids found for this time: %s", time.String()) - } - - // find the index of the consumer we want to remove - index := -1 - for i := 0; i < len(consumers.Ids); i = i + 1 { - if consumers.Ids[i] == consumerId { - index = i - break - } - } - - if index == -1 { - return fmt.Errorf("failed to find consumer id (%s)", consumerId) - } - - if len(consumers.Ids) == 1 { - store.Delete(key(time)) - return nil - } - - consumersWithRemoval := types.ConsumerIds{ - Ids: append(consumers.Ids[:index], consumers.Ids[index+1:]...), - } - - bz, err := consumersWithRemoval.Marshal() - if err != nil { - return err - } - - store.Set(key(time), bz) - return nil -} - -// GetConsumersToBeLaunched returns all the consumer ids of chains stored under this spawn time -func (k Keeper) GetConsumersToBeLaunched(ctx sdk.Context, spawnTime time.Time) (types.ConsumerIds, error) { - return k.getConsumerIdsBasedOnTime(ctx, types.SpawnTimeToConsumerIdsKey, spawnTime) -} - -// AppendConsumerToBeLaunched appends the provider consumer id for the given spawn time -func (k Keeper) AppendConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { - return k.appendConsumerIdOnTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) -} - -// RemoveConsumerToBeLaunched removes consumer id from if stored for this specific spawn time -func (k Keeper) RemoveConsumerToBeLaunched(ctx sdk.Context, consumerId string, spawnTime time.Time) error { - return k.removeConsumerIdFromTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) -} - -// GetConsumersToBeStopped returns all the consumer ids of chains stored under this stop time -func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { - return k.getConsumerIdsBasedOnTime(ctx, types.StopTimeToConsumerIdsKey, stopTime) -} - -// AppendConsumerToBeStopped appends the provider consumer id for the given stop time -func (k Keeper) AppendConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { - return k.appendConsumerIdOnTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) -} - -// RemoveConsumerToBeStopped removes consumer id from if stored for this specific stop time -func (k Keeper) RemoveConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { - return k.removeConsumerIdFromTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) -} - // GetOptedInConsumerIds returns all the consumer ids where the given validator is opted in func (k Keeper) GetOptedInConsumerIds(ctx sdk.Context, providerAddr types.ProviderConsAddress) (types.ConsumerIds, error) { store := ctx.KVStore(k.storeKey) @@ -371,6 +224,7 @@ func (k Keeper) GetOptedInConsumerIds(ctx sdk.Context, providerAddr types.Provid } // AppendOptedInConsumerId appends given consumer id to the list of consumers that validator has opted in +// TODO (PERMISSIONLESS) -- combine it with SetOptedIn func (k Keeper) AppendOptedInConsumerId(ctx sdk.Context, providerAddr types.ProviderConsAddress, consumerId string) error { store := ctx.KVStore(k.storeKey) @@ -436,184 +290,6 @@ func (k Keeper) RemoveOptedInConsumerId(ctx sdk.Context, providerAddr types.Prov return nil } -// GetClientIdToConsumerId returns the consumer id associated with this client id -func (k Keeper) GetClientIdToConsumerId(ctx sdk.Context, clientId string) (string, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.ClientIdToConsumerIdKey(clientId)) - if buf == nil { - return "", false - } - return string(buf), true -} - -// SetClientIdToConsumerId sets the client id associated with this consumer id -func (k Keeper) SetClientIdToConsumerId(ctx sdk.Context, clientId string, consumerId string) { - store := ctx.KVStore(k.storeKey) - store.Set(types.ClientIdToConsumerIdKey(clientId), []byte(consumerId)) -} - -// DeleteClientIdToConsumerId deletes the client id to consumer id association -func (k Keeper) DeleteClientIdToConsumerId(ctx sdk.Context, clientId string) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ClientIdToConsumerIdKey(clientId)) -} - -// GetInitializedConsumersReadyToLaunch returns the consumer ids of the pending initialized consumer chains -// that are ready to launch, i.e., consumer clients to be created. -func (k Keeper) GetInitializedConsumersReadyToLaunch(ctx sdk.Context, limit uint32) []string { - store := ctx.KVStore(k.storeKey) - - spawnTimeToConsumerIdsKeyPrefix := types.SpawnTimeToConsumerIdsKeyPrefix() - iterator := storetypes.KVStorePrefixIterator(store, []byte{spawnTimeToConsumerIdsKeyPrefix}) - defer iterator.Close() - - result := []string{} - for ; iterator.Valid(); iterator.Next() { - spawnTime, err := types.ParseTime(types.SpawnTimeToConsumerIdsKeyPrefix(), iterator.Key()) - if err != nil { - k.Logger(ctx).Error("failed to parse spawn time", - "error", err) - continue - } - if spawnTime.After(ctx.BlockTime()) { - return result - } - - // if current block time is equal to or after spawnTime, and the chain is initialized, we can launch the chain - consumerIds, err := k.GetConsumersToBeLaunched(ctx, spawnTime) - if err != nil { - k.Logger(ctx).Error("failed to retrieve consumers to launch", - "spawn time", spawnTime, - "error", err) - continue - } - if len(result)+len(consumerIds.Ids) >= int(limit) { - remainingConsumerIds := len(result) + len(consumerIds.Ids) - int(limit) - if len(consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]) == 0 { - return result - } - return append(result, consumerIds.Ids[:len(consumerIds.Ids)-remainingConsumerIds]...) - } else { - result = append(result, consumerIds.Ids...) - } - } - - return result -} - -// GetLaunchedConsumersReadyToStop returns the consumer ids of the pending launched consumer chains -// that are ready to stop -func (k Keeper) GetLaunchedConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { - store := ctx.KVStore(k.storeKey) - - stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() - iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) - defer iterator.Close() - - result := []string{} - for ; iterator.Valid(); iterator.Next() { - stopTime, err := types.ParseTime(types.StopTimeToConsumerIdsKeyPrefix(), iterator.Key()) - if err != nil { - k.Logger(ctx).Error("failed to parse stop time", - "error", err) - continue - } - if stopTime.After(ctx.BlockTime()) { - return result - } - - consumers, err := k.GetConsumersToBeStopped(ctx, stopTime) - if err != nil { - k.Logger(ctx).Error("failed to retrieve consumers to stop", - "stop time", stopTime, - "error", err) - continue - } - if len(result)+len(consumers.Ids) >= int(limit) { - remainingConsumerIds := len(result) + len(consumers.Ids) - int(limit) - if len(consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]) == 0 { - return result - } - return append(result, consumers.Ids[:len(consumers.Ids)-remainingConsumerIds]...) - } else { - result = append(result, consumers.Ids...) - } - } - - return result -} - -// LaunchConsumer launches the chain with the provided consumer id by creating the consumer client and the respective -// consumer genesis file -func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { - err := k.CreateConsumerClient(ctx, consumerId) - if err != nil { - return err - } - - consumerGenesis, found := k.GetConsumerGenesis(ctx, consumerId) - if !found { - return errorsmod.Wrapf(types.ErrNoConsumerGenesis, "consumer genesis could not be found for consumer id: %s", consumerId) - } - - if len(consumerGenesis.Provider.InitialValSet) == 0 { - return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in consumer id: %s", consumerId) - } - - return nil -} - -// UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id -func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string) { - k.DeleteAllowlist(ctx, consumerId) - for _, address := range allowlist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetAllowlist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) - } -} - -// UpdateDenylist populates the denylist store for the consumer chain with this consumer id -func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string) { - k.DeleteDenylist(ctx, consumerId) - for _, address := range denylist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetDenylist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) - } - -} - -// UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id -func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN uint32, newTopN uint32) error { - // if the top N changes, we need to update the new minimum power in top N - if newTopN != oldTopN { - if newTopN > 0 { - // if the chain receives a non-zero top N value, store the minimum power in the top N - bondedValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) - if err != nil { - return err - } - minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, newTopN) - if err != nil { - return err - } - k.SetMinimumPowerInTopN(ctx, consumerId, minPower) - } else { - // if the chain receives a zero top N value, we delete the min power - k.DeleteMinimumPowerInTopN(ctx, consumerId) - } - } - - return nil -} - // IsValidatorOptedInToChainId checks if the validator with `providerAddr` is opted into the chain with the specified `chainId`. // It returns `found == true` and the corresponding chain's `consumerId` if the validator is opted in. Otherwise, it returns an empty string // for `consumerId` and `found == false`. @@ -642,96 +318,3 @@ func (k Keeper) IsValidatorOptedInToChainId(ctx sdk.Context, providerAddr types. } return "", false } - -// PrepareConsumerForLaunch prepares to move the launch of a consumer chain from the previous spawn time to spawn time. -// Previous spawn time can correspond to its zero value if the validator was not previously set for launch. -func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, previousSpawnTime time.Time, spawnTime time.Time) error { - if !previousSpawnTime.Equal(time.Time{}) { - // if this is not the first initialization and hence `previousSpawnTime` does not contain the zero value of `Time` - // remove the consumer id from the previous spawn time - err := k.RemoveConsumerToBeLaunched(ctx, consumerId, previousSpawnTime) - if err != nil { - return err - } - } - return k.AppendConsumerToBeLaunched(ctx, consumerId, spawnTime) -} - -// CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence -// is ready to launch and at what spawn time -// TODO (PERMISSIONLESS): could remove, all fields should be there because we validate the initialization parameters -func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { - // a chain that is already launched or stopped cannot launch again - phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED || phase == types.ConsumerPhase_CONSUMER_PHASE_STOPPED { - return time.Time{}, false - } - - initializationParameters, err := k.GetConsumerInitializationParameters(ctx, consumerId) - if err != nil { - return time.Time{}, false - } - - spawnTimeIsNotZero := !initializationParameters.SpawnTime.Equal(time.Time{}) - - genesisHashSet := initializationParameters.GenesisHash != nil - binaryHashSet := initializationParameters.BinaryHash != nil - - consumerRedistributionFractionSet := initializationParameters.ConsumerRedistributionFraction != "" - blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0 - historicalEntriesSet := initializationParameters.HistoricalEntries > 0 - - return initializationParameters.SpawnTime, spawnTimeIsNotZero && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && - blocksPerDistributionTransmissionSet && historicalEntriesSet -} - -// HasAtMostOnceCorrectMsgUpdateConsumer checks that the proposal has at most one `MsgUpdateConsumer` that is -// correctly set (i.e., the owner address of the to-be-updated consumer corresponds to the gov module). Returns -// the single `MsgUpdateConsumer` message if only one correctly set exists. -func (k Keeper) HasAtMostOnceCorrectMsgUpdateConsumer(ctx sdk.Context, proposal *govv1.Proposal) (*types.MsgUpdateConsumer, error) { - var msgUpdateConsumer *types.MsgUpdateConsumer - for _, msg := range proposal.GetMessages() { - sdkMsg, isMsgUpdateConsumer := msg.GetCachedValue().(*types.MsgUpdateConsumer) - if isMsgUpdateConsumer { - // A `MsgUpdateConsumer` can only succeed if the owner of the consumer chain is the gov module. - // If that's not the case, we immediately fail the proposal. - // Note that someone could potentially change the owner of a chain to be that of the gov module - // while a proposal is active and before the proposal is executed. Even then, we still do not allow - // `MsgUpdateConsumer` proposals if the owner of the chain is not the gov module to avoid someone forgetting - // to change the owner address while the proposal is active. - ownerAddress, err := k.GetConsumerOwnerAddress(ctx, sdkMsg.ConsumerId) - if err != nil { - return nil, fmt.Errorf("cannot find owner address for consumer with consumer id (%s): %s", sdkMsg.ConsumerId, err.Error()) - } else if ownerAddress != k.GetAuthority() { - return nil, fmt.Errorf("owner address (%s) is not the gov module (%s)", ownerAddress, k.GetAuthority()) - } - - if msgUpdateConsumer != nil { - return nil, fmt.Errorf("proposal can contain at most one `MsgUpdateConsumer` message") - } - msgUpdateConsumer = sdkMsg - } - } - return msgUpdateConsumer, nil -} - -// DoesNotHaveDeprecatedMessage checks that the provided proposal does not contain any deprecated messages and returns -// an error if this is the case -func DoesNotHaveDeprecatedMessage(proposal *govv1.Proposal) error { - for _, msg := range proposal.GetMessages() { - // if the proposal contains a deprecated message, cancel the proposal - _, isMsgConsumerAddition := msg.GetCachedValue().(*types.MsgConsumerAddition) - if isMsgConsumerAddition { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerAddition`; use `MsgCreateConsumer` instead") - } - _, isMsgConsumerModification := msg.GetCachedValue().(*types.MsgConsumerModification) - if isMsgConsumerModification { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerModification`; use `MsgUpdateConsumer` instead") - } - _, isMsgConsumerRemoval := msg.GetCachedValue().(*types.MsgConsumerRemoval) - if isMsgConsumerRemoval { - return fmt.Errorf("proposal cannot contain deprecated `MsgConsumerRemoval`; use `MsgRemoveConsumer` instead") - } - } - return nil -} diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index f4eb4922c1..20a929f595 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -4,14 +4,9 @@ import ( "testing" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -244,149 +239,6 @@ func TestConsumerPhase(t *testing.T) { require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) } -// TestConsumerStopTime tests the getter, setter, and deletion of the consumer id to stop times methods -func TestConsumerStopTime(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - _, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") - require.Error(t, err) - - expectedStopTime := time.Unix(1234, 56789) - providerKeeper.SetConsumerStopTime(ctx, "consumerId", expectedStopTime) - actualStopTime, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") - require.NoError(t, err) - require.Equal(t, actualStopTime, expectedStopTime) - - providerKeeper.DeleteConsumerStopTime(ctx, "consumerId") - _, err = providerKeeper.GetConsumerStopTime(ctx, "consumerId") - require.Error(t, err) -} - -// TestConsumersToBeLaunched tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` -func TestConsumersToBeLaunched(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - spawnTime := time.Now() - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", spawnTime) - consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1"}, consumers.Ids) - - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", spawnTime) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) - - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", spawnTime) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) - - err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId2", spawnTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - - // also add consumer ids under a different spawn time and verify everything under the original spawn time is still there - spawnTimePlusOneHour := spawnTime.Add(time.Hour) - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) - require.NoError(t, err) - require.Equal(t, []string{"consumerId4"}, consumers.Ids) - - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - - // start removing all consumers from `spawnTime` - err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId3", spawnTime) - require.NoError(t, err) - err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId1", spawnTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Empty(t, consumers.Ids) - - // remove from `spawnTimePlusOneHour` - err = providerKeeper.RemoveConsumerToBeLaunched(ctx, "consumerId4", spawnTimePlusOneHour) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTimePlusOneHour) - require.NoError(t, err) - require.Empty(t, consumers.Ids) - - // add another consumer for `spawnTime` - err = providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId5", spawnTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId5"}, consumers.Ids) -} - -// TestConsumersToBeStopped tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` -func TestConsumersToBeStopped(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - stopTime := time.Now() - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", stopTime) - consumers, err := providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1"}, consumers.Ids) - - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", stopTime) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) - - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", stopTime) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) - - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId2", stopTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - - // also add consumer ids under a different stop time and verify everything under the original stop time is still there - stopTimePlusOneHour := stopTime.Add(time.Hour) - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) - require.NoError(t, err) - require.Equal(t, []string{"consumerId4"}, consumers.Ids) - - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - - // start removing all consumers from `stopTime` - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId3", stopTime) - require.NoError(t, err) - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId1", stopTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Empty(t, consumers.Ids) - - // remove from `stopTimePlusOneHour` - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) - require.NoError(t, err) - require.Empty(t, consumers.Ids) - - // add another consumer for `stopTime` - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId5", stopTime) - require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) - require.NoError(t, err) - require.Equal(t, []string{"consumerId5"}, consumers.Ids) -} - // TestOptedInConsumerIds tests the `GetOptedInConsumerIds`, `AppendOptedInConsumerId`, and `RemoveOptedInConsumerId` methods func TestGetOptedInConsumerIds(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) @@ -441,192 +293,6 @@ func TestGetOptedInConsumerIds(t *testing.T) { require.Empty(t, consumers) } -// TestConsumerChainId tests the getter, setter, and deletion of the client id to consumer id methods -func TestClientIdToConsumerId(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - _, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.False(t, found) - - providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId") - consumerId, found := providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.True(t, found) - require.Equal(t, "consumerId", consumerId) - - // assert that overwriting the current consumer id record works - providerKeeper.SetClientIdToConsumerId(ctx, "clientId", "consumerId2") - consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.True(t, found) - require.Equal(t, "consumerId2", consumerId) - - providerKeeper.DeleteClientIdToConsumerId(ctx, "clientId") - consumerId, found = providerKeeper.GetClientIdToConsumerId(ctx, "clientId") - require.False(t, found) - require.Equal(t, "", consumerId) -} - -// TestGetInitializedConsumersReadyToLaunch tests that the ready to-be-launched consumer chains are returned -func TestGetInitializedConsumersReadyToLaunch(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // no chains to-be-launched exist - require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 5)) - - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendConsumerToBeLaunched(ctx, "consumerId3", time.Unix(30, 0)) - - // time has not yet reached the spawn time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) - require.Empty(t, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) - - // time has reached the spawn time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(10, 0)) - require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) - - // time has reached the spawn time of "consumerId1" and "consumerId2" - ctx = ctx.WithBlockTime(time.Unix(20, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) - - // time has reached the spawn time of all chains - ctx = ctx.WithBlockTime(time.Unix(30, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 3)) - - // limit the number of returned consumer chains - require.Equal(t, []string{}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 0)) - require.Equal(t, []string{"consumerId1"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 1)) - require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetInitializedConsumersReadyToLaunch(ctx, 2)) -} - -func TestGetLaunchedConsumersReadyToStop(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // no chains to-be-stopped exist - require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) - providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) - - // time has not yet reached the stop time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) - require.Empty(t, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - - // time has reached the stop time of "consumerId1" - ctx = ctx.WithBlockTime(time.Unix(10, 0)) - require.Equal(t, []string{"consumerId1"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - - // time has reached the stop time of "consumerId1" and "consumerId2" - ctx = ctx.WithBlockTime(time.Unix(20, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) - - // time has reached the stop time of all chains - ctx = ctx.WithBlockTime(time.Unix(30, 0)) - require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetLaunchedConsumersReadyToStop(ctx, 3)) -} - -func TestUpdateAllowlist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" - consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) - providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) - - providerKeeper.UpdateAllowlist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) - - expectedAllowlist := []providertypes.ProviderConsAddress{ - providertypes.NewProviderConsAddress(consAddr1), - providertypes.NewProviderConsAddress(consAddr2)} - require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) -} - -func TestUpdateDenylist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" - consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) - providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) - - providerKeeper.UpdateDenylist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) - - expectedDenylist := []providertypes.ProviderConsAddress{ - providertypes.NewProviderConsAddress(consAddr1), - providertypes.NewProviderConsAddress(consAddr2)} - require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) -} - -func TestUpdateMinimumPowerInTopN(t *testing.T) { - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - // test case where Top N is 0 in which case there's no minimum power in top N - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 0, - }) - - err := providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 0) - require.NoError(t, err) - _, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.False(t, found) - - // test cases where Top N > 0 and for this we mock some validators - powers := []int64{10, 20, 30} - validators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, powers[0], 1), // this validator has ~16 of the total voting power - createStakingValidator(ctx, mocks, powers[1], 2), // this validator has ~33% of the total voting gpower - createStakingValidator(ctx, mocks, powers[2], 3), // this validator has 50% of the total voting power - } - mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() - - maxProviderConsensusValidators := int64(3) - params := providerKeeper.GetParams(ctx) - params.MaxProviderConsensusValidators = maxProviderConsensusValidators - providerKeeper.SetParams(ctx, params) - - // when top N is 50, the minimum power is 30 (because top validator has to validate) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 50, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 50) - require.NoError(t, err) - minimumPowerInTopN, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(30), minimumPowerInTopN) - - // when top N is 51, the minimum power is 20 (because top 2 validators have to validate) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 51, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 50, 51) - require.NoError(t, err) - minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(20), minimumPowerInTopN) - - // when top N is 100, the minimum power is 10 (that of the validator with the lowest power) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 100, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 51, 100) - require.NoError(t, err) - minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(10), minimumPowerInTopN) -} - func TestIsValidatorOptedInToChain(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -644,127 +310,3 @@ func TestIsValidatorOptedInToChain(t *testing.T) { require.True(t, found) require.Equal(t, expectedConsumerId, actualConsumerId) } - -func TestPrepareConsumerForLaunch(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - spawnTime := time.Now().UTC() - err := providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", time.Time{}, spawnTime) - require.NoError(t, err) - - consumers, err := providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) - - nextSpawnTime := spawnTime.Add(time.Hour) - err = providerKeeper.PrepareConsumerForLaunch(ctx, "consumerId", spawnTime, nextSpawnTime) - require.NoError(t, err) - - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, spawnTime) - require.NoError(t, err) - require.Empty(t, consumers) - - consumers, err = providerKeeper.GetConsumersToBeLaunched(ctx, nextSpawnTime) - require.NoError(t, err) - require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) -} - -func TestCanLaunch(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // cannot launch an unknown chain - _, canLaunch := providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // cannot launch a chain without initialization parameters - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // set valid initialization parameters - initializationParameters := testkeeper.GetTestInitializationParameters() - err := providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) - require.NoError(t, err) - - // cannot launch a launched chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // cannot launch a stopped chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // initialized chain can launch - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.True(t, canLaunch) - - // chain cannot launch without a genesis hash - initializationParameters.GenesisHash = nil - err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.NoError(t, err) - require.False(t, canLaunch) -} - -func TestHasAtMostOnceCorrectMsgUpdateConsumer(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - expectedMsgUpdateConsumer := providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "consumerId", NewOwnerAddress: "new owner address"} - - proposal, err := govv1.NewProposal([]sdk.Msg{&expectedMsgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - - _, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) - require.ErrorContains(t, err, "cannot find owner address") - - // set owner address that is not the gov module - providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "owner address") - _, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) - require.ErrorContains(t, err, "is not the gov module") - - // set owner address that is the gov module - providerKeeper.SetConsumerOwnerAddress(ctx, "consumerId", "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn") - actualMsgUpdateConsumer, err := providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &proposal) - require.NoError(t, err) - require.Equal(t, expectedMsgUpdateConsumer, *actualMsgUpdateConsumer) - - // a proposal with 2 `MsgUpdateConsumer` messages - invalidProposal, err := govv1.NewProposal([]sdk.Msg{&expectedMsgUpdateConsumer, &expectedMsgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - actualMsgUpdateConsumer, err = providerKeeper.HasAtMostOnceCorrectMsgUpdateConsumer(ctx, &invalidProposal) - require.ErrorContains(t, err, "proposal can contain at most one") - require.Nil(t, actualMsgUpdateConsumer) -} - -func TestDoesNotHaveDeprecatedMessage(t *testing.T) { - msgConsumerAddition := providertypes.MsgConsumerAddition{} - proposal, err := govv1.NewProposal([]sdk.Msg{&msgConsumerAddition}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - err = keeper.DoesNotHaveDeprecatedMessage(&proposal) - require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerAddition`") - - msgConsumerModification := providertypes.MsgConsumerModification{} - proposal, err = govv1.NewProposal([]sdk.Msg{&msgConsumerModification}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - err = keeper.DoesNotHaveDeprecatedMessage(&proposal) - require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerModification`") - - msgConsumerRemoval := providertypes.MsgConsumerRemoval{} - proposal, err = govv1.NewProposal([]sdk.Msg{&msgConsumerRemoval}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - err = keeper.DoesNotHaveDeprecatedMessage(&proposal) - require.ErrorContains(t, err, "cannot contain deprecated `MsgConsumerRemoval`") - - // a proposal with no deprecated messages - msgUpdateConsumer := providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "consumerId", NewOwnerAddress: "new owner address"} - proposal, err = govv1.NewProposal([]sdk.Msg{&msgUpdateConsumer}, 1, time.Now(), time.Now().Add(1*time.Hour), "metadata", "title", "summary", sdk.AccAddress{}, false) - require.NoError(t, err) - err = keeper.DoesNotHaveDeprecatedMessage(&proposal) - require.Nil(t, err) -} diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 9367a944a6..acdceb5ea2 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -501,10 +501,9 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { gomock.InOrder(mockCalls...) // Execute setup - providerKeeper.SetClientIdToConsumerId(ctx, "clientID", "consumerChainID") + providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientID") err := providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) - providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientID") // No panic should occur, StopConsumerChain should be called providerKeeper.SendVSCPacketsToChain(ctx, "consumerChainID", "CCVChannelID") diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index 7ed39ad5b6..bc1bd85526 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -266,15 +266,20 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk // This is to migrate everything under `ProviderConsAddrToOptedInConsumerIdsKey` // `OptedIn` was already re-keyed earlier (see above) and hence we can use `consumerId` here. for _, providerConsAddr := range pk.GetAllOptedIn(ctx, consumerId) { - pk.AppendOptedInConsumerId(ctx, providerConsAddr, consumerId) + err := pk.AppendOptedInConsumerId(ctx, providerConsAddr, consumerId) + if err != nil { + return err + } } // set clientId -> consumerId mapping - clientId, found := pk.GetConsumerClientId(ctx, consumerId) // consumer to client was already re-keyed so we can use `consumerId` here + // consumer to client was already re-keyed so we can use `consumerId` here + // however, during the rekeying, the reverse index was not set + clientId, found := pk.GetConsumerClientId(ctx, consumerId) if !found { return errorsmod.Wrapf(ccv.ErrInvalidConsumerState, "cannot find client ID associated with consumer ID: %s", consumerId) } - pk.SetClientIdToConsumerId(ctx, clientId, consumerId) + pk.SetConsumerClientId(ctx, consumerId, clientId) } return nil diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index 65ced5f37e..30ac49363a 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -174,9 +174,9 @@ func (am AppModule) BeginBlock(ctx context.Context) error { sdkCtx := sdk.UnwrapSDKContext(ctx) // Create clients to consumer chains that are due to be spawned - am.keeper.BeginBlockInit(sdkCtx) + am.keeper.BeginBlockLaunchConsumers(sdkCtx) // Stop and remove state for any consumer chains that are due to be stopped - am.keeper.BeginBlockCCR(sdkCtx) + am.keeper.BeginBlockStopConsumers(sdkCtx) // Check for replenishing slash meter before any slash packets are processed for this block am.keeper.BeginBlockCIS(sdkCtx) // BeginBlock logic needed for the Reward Distribution sub-protocol diff --git a/x/ccv/provider/proposal_handler.go b/x/ccv/provider/proposal_handler.go index 01d92d3e9e..ea66146039 100644 --- a/x/ccv/provider/proposal_handler.go +++ b/x/ccv/provider/proposal_handler.go @@ -22,7 +22,7 @@ func NewProviderProposalHandler(k keeper.Keeper) govv1beta1.Handler { case *types.ConsumerRemovalProposal: return nil case *types.ChangeRewardDenomsProposal: - return k.HandleLegacyConsumerRewardDenomProposal(ctx, c) + return nil default: return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ccv proposal content type: %T", c) } diff --git a/x/ccv/provider/types/events.go b/x/ccv/provider/types/events.go index 982b383f03..d539d695e2 100644 --- a/x/ccv/provider/types/events.go +++ b/x/ccv/provider/types/events.go @@ -4,8 +4,7 @@ package types const ( EventTypeConsumerClientCreated = "consumer_client_created" EventTypeAssignConsumerKey = "assign_consumer_key" - EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom" - EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" + EventTypeChangeConsumerRewardDenom = "change_consumer_reward_denom" EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" EventTypeSetConsumerCommissionRate = "set_consumer_commission_rate" EventTypeOptIn = "opt_in" @@ -16,7 +15,8 @@ const ( AttributeUnbondingPeriod = "unbonding_period" AttributeProviderValidatorAddress = "provider_validator_address" AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" - AttributeConsumerRewardDenom = "consumer_reward_denom" + AttributeAddConsumerRewardDenom = "add_consumer_reward_denom" + AttributeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" AttributeConsumerCommissionRate = "consumer_commission_rate" AttributeConsumerId = "consumer_chain_id" ) diff --git a/x/ccv/provider/types/legacy_proposal_test.go b/x/ccv/provider/types/legacy_proposal_test.go index 4a13a4290b..21f7a2da8a 100644 --- a/x/ccv/provider/types/legacy_proposal_test.go +++ b/x/ccv/provider/types/legacy_proposal_test.go @@ -542,76 +542,6 @@ func TestChangeRewardDenomsProposalValidateBasic(t *testing.T) { } } -func TestMsgUpdateConsumerValidateBasic(t *testing.T) { - testCases := []struct { - name string - powerShapingParameters types.PowerShapingParameters - expPass bool - }{ - { - "success", - types.PowerShapingParameters{ - Top_N: 50, - ValidatorsPowerCap: 100, - ValidatorSetCap: 34, - Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, - Denylist: nil, - MinStake: 0, - AllowInactiveVals: false, - }, - true, - }, - { - "top N is invalid", - types.PowerShapingParameters{ - Top_N: 10, - ValidatorsPowerCap: 0, - ValidatorSetCap: 0, - Allowlist: nil, - Denylist: nil, - }, - false, - }, - { - "validators power cap is invalid", - types.PowerShapingParameters{ - Top_N: 50, - ValidatorsPowerCap: 101, - ValidatorSetCap: 0, - Allowlist: nil, - Denylist: nil, - MinStake: 0, - AllowInactiveVals: false, - }, - false, - }, - { - "valid proposal", - types.PowerShapingParameters{ - Top_N: 54, - ValidatorsPowerCap: 92, - ValidatorSetCap: 0, - Allowlist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, - Denylist: []string{"cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j", "cosmosvalcons1arwg2sh5fd2wq4mwl6d05pyz4nrwls2mayg36j"}, - MinStake: 0, - AllowInactiveVals: false, - }, - true, - }, - } - - for _, tc := range testCases { - // TODO (PERMISSIONLESS) add more tests - msg, _ := types.NewMsgUpdateConsumer("", "0", "cosmos1p3ucd3ptpw902fluyjzhq3ffgq4ntddac9sa3s", nil, nil, &tc.powerShapingParameters) - err := msg.ValidateBasic() - if tc.expPass { - require.NoError(t, err, "valid case: %s should not return error. got %w", tc.name, err) - } else { - require.Error(t, err, "invalid case: '%s' must return error but got none", tc.name) - } - } -} - func TestValidatePSSFeatures(t *testing.T) { require.NoError(t, types.ValidatePSSFeatures(0, 0)) require.NoError(t, types.ValidatePSSFeatures(50, 0)) diff --git a/x/ccv/provider/types/msg_test.go b/x/ccv/provider/types/msg_test.go index 60f7d31675..ecab465ab9 100644 --- a/x/ccv/provider/types/msg_test.go +++ b/x/ccv/provider/types/msg_test.go @@ -362,3 +362,77 @@ func TestValidateByteSlice(t *testing.T) { } } } + +func TestMsgUpdateConsumerValidateBasic(t *testing.T) { + consAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr3 := "cosmosvalcons1muys5jyqk4xd27e208nym85kn0t4zjcfeu63fe" + + testCases := []struct { + name string + powerShapingParameters types.PowerShapingParameters + expPass bool + }{ + { + "success", + types.PowerShapingParameters{ + Top_N: 50, + ValidatorsPowerCap: 100, + ValidatorSetCap: 34, + Allowlist: []string{consAddr1}, + Denylist: nil, + MinStake: 0, + AllowInactiveVals: false, + }, + true, + }, + { + "top N is invalid", + types.PowerShapingParameters{ + Top_N: 10, + ValidatorsPowerCap: 0, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + }, + false, + }, + { + "validators power cap is invalid", + types.PowerShapingParameters{ + Top_N: 50, + ValidatorsPowerCap: 101, + ValidatorSetCap: 0, + Allowlist: nil, + Denylist: nil, + MinStake: 0, + AllowInactiveVals: false, + }, + false, + }, + { + "valid proposal", + types.PowerShapingParameters{ + Top_N: 54, + ValidatorsPowerCap: 92, + ValidatorSetCap: 0, + Allowlist: []string{consAddr1}, + Denylist: []string{consAddr2, consAddr3}, + MinStake: 0, + AllowInactiveVals: false, + }, + true, + }, + } + + for _, tc := range testCases { + // TODO (PERMISSIONLESS) add more tests + msg, _ := types.NewMsgUpdateConsumer("", "0", "cosmos1p3ucd3ptpw902fluyjzhq3ffgq4ntddac9sa3s", nil, nil, &tc.powerShapingParameters) + err := msg.ValidateBasic() + if tc.expPass { + require.NoError(t, err, "valid case: %s should not return error. got %w", tc.name, err) + } else { + require.Error(t, err, "invalid case: '%s' must return error but got none", tc.name) + } + } +} From e1b1dc2831267ae2bf85a95ff844ddb7ada06942 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Mon, 2 Sep 2024 12:34:59 +0200 Subject: [PATCH 25/43] fix!: provider msg validation (#2197) * validate MsgAssignConsumerKey * validate MsgSubmitConsumerMisbehaviour and MsgSubmitConsumerDoubleVoting * move RemoveConsumer * refactor: rearrange messages in msg.go * validate MsgOptIn and MsgOptOut * validate MsgSetConsumerCommissionRate * remove ValidateBasic for deprecated msgs * remove deprecated GetSigners * remove deprecated GetSignBytes * remove deprecated govv1beta1 validation * remove Route and Type * Update x/ccv/provider/keeper/msg_server.go Co-authored-by: insumity * apply review suggestions * apply review suggestions --------- Co-authored-by: insumity --- x/ccv/provider/keeper/msg_server.go | 78 +-- x/ccv/provider/types/errors.go | 19 +- x/ccv/provider/types/keys_test.go | 3 +- x/ccv/provider/types/legacy_proposal.go | 152 +--- x/ccv/provider/types/legacy_proposal_test.go | 557 --------------- x/ccv/provider/types/msg.go | 686 ++++++------------- 6 files changed, 246 insertions(+), 1249 deletions(-) delete mode 100644 x/ccv/provider/types/legacy_proposal_test.go diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 962575e00d..1764796c57 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -87,45 +87,6 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign return &types.MsgAssignConsumerKeyResponse{}, nil } -// RemoveConsumer defines an RPC handler method for MsgRemoveConsumer -func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - resp := types.MsgRemoveConsumerResponse{} - - consumerId := msg.ConsumerId - ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) - if err != nil { - return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) - } - - if msg.Signer != ownerAddress { - return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) - } - - phase := k.Keeper.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { - return nil, errorsmod.Wrapf(types.ErrInvalidPhase, - "chain with consumer id: %s has to be in its launched phase", consumerId) - } - - previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) - if err == nil { - if err := k.Keeper.RemoveConsumerToBeStopped(ctx, consumerId, previousStopTime); err != nil { - return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot remove previous stop time: %s", err.Error()) - } - } - - if err := k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime); err != nil { - return &resp, errorsmod.Wrapf(types.ErrInvalidStopTime, "cannot set stop time: %s", err.Error()) - } - if err := k.Keeper.AppendConsumerToBeStopped(ctx, consumerId, msg.StopTime); err != nil { - return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot set consumer to be stop: %s", err.Error()) - } - - return &resp, nil -} - // ChangeRewardDenoms defines a rpc handler method for MsgChangeRewardDenoms func (k msgServer) ChangeRewardDenoms(goCtx context.Context, msg *types.MsgChangeRewardDenoms) (*types.MsgChangeRewardDenomsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -495,6 +456,45 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, nil } +// RemoveConsumer defines an RPC handler method for MsgRemoveConsumer +func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveConsumer) (*types.MsgRemoveConsumerResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + resp := types.MsgRemoveConsumerResponse{} + + consumerId := msg.ConsumerId + ownerAddress, err := k.Keeper.GetConsumerOwnerAddress(ctx, consumerId) + if err != nil { + return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) + } + + if msg.Signer != ownerAddress { + return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + } + + phase := k.Keeper.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + return nil, errorsmod.Wrapf(types.ErrInvalidPhase, + "chain with consumer id: %s has to be in its launched phase", consumerId) + } + + previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) + if err == nil { + if err := k.Keeper.RemoveConsumerToBeStopped(ctx, consumerId, previousStopTime); err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot remove previous stop time: %s", err.Error()) + } + } + + if err := k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime); err != nil { + return &resp, errorsmod.Wrapf(types.ErrInvalidStopTime, "cannot set stop time: %s", err.Error()) + } + if err := k.Keeper.AppendConsumerToBeStopped(ctx, consumerId, msg.StopTime); err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot set consumer to be stopped: %s", err.Error()) + } + + return &resp, nil +} + func (k msgServer) ConsumerAddition(_ context.Context, _ *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { return nil, fmt.Errorf("`MsgConsumerAddition` is deprecated. Use `MsgCreateConsumer`") } diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 90bb46ccaf..b4fe49942f 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -10,26 +10,15 @@ var ( ErrInvalidConsumerRemovalProp = errorsmod.Register(ModuleName, 2, "invalid consumer removal proposal") ErrUnknownConsumerId = errorsmod.Register(ModuleName, 3, "no consumer chain with this consumer id") ErrUnknownConsumerChannelId = errorsmod.Register(ModuleName, 4, "no consumer chain with this channel id") - ErrInvalidConsumerConsensusPubKey = errorsmod.Register(ModuleName, 5, "empty consumer consensus public key") ErrInvalidConsumerId = errorsmod.Register(ModuleName, 6, "invalid consumer id") - ErrConsumerKeyNotFound = errorsmod.Register(ModuleName, 7, "consumer key not found") - ErrNoValidatorConsumerAddress = errorsmod.Register(ModuleName, 8, "error getting validator consumer address") - ErrNoValidatorProviderAddress = errorsmod.Register(ModuleName, 9, "error getting validator provider address") ErrConsumerKeyInUse = errorsmod.Register(ModuleName, 10, "consumer key is already in use by a validator") ErrCannotAssignDefaultKeyAssignment = errorsmod.Register(ModuleName, 11, "cannot re-assign default key assignment") - ErrInvalidConsumerParams = errorsmod.Register(ModuleName, 12, "invalid consumer params") - ErrInvalidProviderAddress = errorsmod.Register(ModuleName, 13, "invalid provider address") ErrInvalidConsumerRewardDenom = errorsmod.Register(ModuleName, 14, "invalid consumer reward denom") - ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 15, "invalid depositor address") ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") - ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists") ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") - ErrInvalidConsumerCommissionRate = errorsmod.Register(ModuleName, 19, "consumer commission rate is invalid") ErrCannotOptOutFromTopN = errorsmod.Register(ModuleName, 20, "cannot opt out from a Top N chain") - ErrNoUnconfirmedVSCPacket = errorsmod.Register(ModuleName, 21, "no unconfirmed vsc packet for this chain id") ErrInvalidConsumerModificationProposal = errorsmod.Register(ModuleName, 22, "invalid consumer modification proposal") ErrNoUnbondingTime = errorsmod.Register(ModuleName, 23, "provider unbonding time not found") - ErrInvalidAddress = errorsmod.Register(ModuleName, 24, "invalid address") ErrUnauthorized = errorsmod.Register(ModuleName, 25, "unauthorized") ErrBlankConsumerChainID = errorsmod.Register(ModuleName, 26, "consumer chain id must not be blank") ErrInvalidPhase = errorsmod.Register(ModuleName, 27, "cannot perform action in the current phase of consumer chain") @@ -37,7 +26,6 @@ var ( ErrInvalidPowerShapingParameters = errorsmod.Register(ModuleName, 29, "invalid power shaping parameters") ErrInvalidConsumerInitializationParameters = errorsmod.Register(ModuleName, 30, "invalid consumer initialization parameters") ErrCannotUpdateMinimumPowerInTopN = errorsmod.Register(ModuleName, 31, "cannot update minimum power in Top N") - ErrNoChainId = errorsmod.Register(ModuleName, 32, "missing chain id for consumer chain") ErrNoConsumerGenesis = errorsmod.Register(ModuleName, 33, "missing consumer genesis") ErrInvalidConsumerGenesis = errorsmod.Register(ModuleName, 34, "invalid consumer genesis") ErrNoConsumerId = errorsmod.Register(ModuleName, 35, "missing consumer id") @@ -51,4 +39,11 @@ var ( ErrInvalidStopTime = errorsmod.Register(ModuleName, 43, "invalid stop time") ErrInvalidMsgCreateConsumer = errorsmod.Register(ModuleName, 44, "invalid create consumer message") ErrInvalidMsgUpdateConsumer = errorsmod.Register(ModuleName, 45, "invalid update consumer message") + ErrInvalidMsgAssignConsumerKey = errorsmod.Register(ModuleName, 46, "invalid assign consumer key message") + ErrInvalidMsgSubmitConsumerMisbehaviour = errorsmod.Register(ModuleName, 47, "invalid submit consumer misbehaviour message") + ErrInvalidMsgSubmitConsumerDoubleVoting = errorsmod.Register(ModuleName, 48, "invalid submit consumer double voting message") + ErrInvalidMsgOptIn = errorsmod.Register(ModuleName, 49, "invalid opt in message") + ErrInvalidMsgOptOut = errorsmod.Register(ModuleName, 50, "invalid opt out message") + ErrInvalidMsgSetConsumerCommissionRate = errorsmod.Register(ModuleName, 51, "invalid set consumer commission rate message") + ErrInvalidMsgChangeRewardDenoms = errorsmod.Register(ModuleName, 52, "invalid change reward denoms message") ) diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index 7f475e0b14..741b036c78 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -11,7 +11,6 @@ import ( cryptoutil "github.com/cosmos/interchain-security/v5/testutil/crypto" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ) @@ -201,7 +200,7 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.ConsumerCommissionRateKey("13", providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.MinimumPowerInTopNKey("13"), providertypes.ConsumerAddrsToPruneV2Key("13", time.Time{}), - providerkeeper.GetValidatorKey(types.LastProviderConsensusValsPrefix(), providertypes.NewProviderConsAddress([]byte{0x05})), + providerkeeper.GetValidatorKey(providertypes.LastProviderConsensusValsPrefix(), providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.ConsumerIdKey(), providertypes.ConsumerIdToChainIdKey("13"), providertypes.ConsumerIdToOwnerAddressKey("13"), diff --git a/x/ccv/provider/types/legacy_proposal.go b/x/ccv/provider/types/legacy_proposal.go index 3124cc3d87..9cc6ef2a77 100644 --- a/x/ccv/provider/types/legacy_proposal.go +++ b/x/ccv/provider/types/legacy_proposal.go @@ -1,21 +1,13 @@ package types import ( - "errors" "fmt" - "strings" time "time" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" - evidencetypes "cosmossdk.io/x/evidence/types" - sdk "github.com/cosmos/cosmos-sdk/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) const ( @@ -100,79 +92,9 @@ func (cccp *ConsumerAdditionProposal) ProposalType() string { return ProposalTypeConsumerAddition } -// ValidatePSSFeatures returns an error if the `topN` and `validatorsPowerCap` parameters are no in the correct ranges -func ValidatePSSFeatures(topN, validatorsPowerCap uint32) error { - // Top N corresponds to the top N% of validators that have to validate the consumer chain and can only be 0 (for an - // Opt In chain) or in the range [50, 100] (for a Top N chain). - if topN != 0 && (topN < 50 || topN > 100) { - return fmt.Errorf("Top N can either be 0 or in the range [50, 100]") - } - - if validatorsPowerCap != 0 && validatorsPowerCap > 100 { - return fmt.Errorf("validators' power cap has to be in the range [1, 100]") - } - - return nil -} - // ValidateBasic runs basic stateless validity checks func (cccp *ConsumerAdditionProposal) ValidateBasic() error { - if err := govv1beta1.ValidateAbstract(cccp); err != nil { - return err - } - - if strings.TrimSpace(cccp.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "consumer chain id must not be blank") - } - - if cccp.InitialHeight.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "initial height cannot be zero") - } - - if len(cccp.GenesisHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "genesis hash cannot be empty") - } - if len(cccp.BinaryHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "binary hash cannot be empty") - } - - if cccp.SpawnTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "spawn time cannot be zero") - } - - if err := ccvtypes.ValidateStringFraction(cccp.ConsumerRedistributionFraction); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerAdditionProposal, "consumer redistribution fraction is invalid: %s", err) - } - - if err := ccvtypes.ValidatePositiveInt64(cccp.BlocksPerDistributionTransmission); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "blocks per distribution transmission cannot be < 1") - } - - if err := ccvtypes.ValidateDistributionTransmissionChannel(cccp.DistributionTransmissionChannel); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "distribution transmission channel") - } - - if err := ccvtypes.ValidatePositiveInt64(cccp.HistoricalEntries); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "historical entries cannot be < 1") - } - - if err := ccvtypes.ValidateDuration(cccp.CcvTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "ccv timeout period cannot be zero") - } - - if err := ccvtypes.ValidateDuration(cccp.TransferTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "transfer timeout period cannot be zero") - } - - if err := ccvtypes.ValidateDuration(cccp.UnbondingPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "unbonding period cannot be zero") - } - - err := ValidatePSSFeatures(cccp.Top_N, cccp.ValidatorsPowerCap) - if err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerAdditionProposal, "invalid PSS features: %s", err.Error()) - } - return nil + return fmt.Errorf("ConsumerAdditionProposal is deprecated") } // String returns the string representation of the ConsumerAdditionProposal. @@ -226,18 +148,7 @@ func (sccp *ConsumerRemovalProposal) ProposalType() string { return ProposalType // ValidateBasic runs basic stateless validity checks func (sccp *ConsumerRemovalProposal) ValidateBasic() error { - if err := govv1beta1.ValidateAbstract(sccp); err != nil { - return err - } - - if strings.TrimSpace(sccp.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "consumer chain id must not be blank") - } - - if sccp.StopTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "spawn time cannot be zero") - } - return nil + return fmt.Errorf("ConsumerRemovalProposal is deprecated") } // NewConsumerModificationProposal creates a new consumer modification proposal. @@ -274,19 +185,7 @@ func (cccp *ConsumerModificationProposal) ProposalType() string { // ValidateBasic runs basic stateless validity checks func (cccp *ConsumerModificationProposal) ValidateBasic() error { - if err := govv1beta1.ValidateAbstract(cccp); err != nil { - return err - } - - if strings.TrimSpace(cccp.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerModificationProposal, "consumer chain id must not be blank") - } - - err := ValidatePSSFeatures(cccp.Top_N, cccp.ValidatorsPowerCap) - if err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) - } - return nil + return fmt.Errorf("ConsumerModificationProposal is deprecated") } // NewEquivocationProposal creates a new equivocation proposal. @@ -310,18 +209,7 @@ func (sp *EquivocationProposal) ProposalType() string { // ValidateBasic runs basic stateless validity checks func (sp *EquivocationProposal) ValidateBasic() error { - if err := govv1beta1.ValidateAbstract(sp); err != nil { - return err - } - if len(sp.Equivocations) == 0 { - return errors.New("invalid equivocation proposal: empty equivocations") - } - for i := 0; i < len(sp.Equivocations); i++ { - if err := sp.Equivocations[i].ValidateBasic(); err != nil { - return err - } - } - return nil + return fmt.Errorf("EquivocationProposal is deprecated") } func NewChangeRewardDenomsProposal(title, description string, @@ -345,35 +233,5 @@ func (crdp *ChangeRewardDenomsProposal) ProposalType() string { // ValidateBasic runs basic stateless validity checks on a ChangeRewardDenomsProposal. func (crdp *ChangeRewardDenomsProposal) ValidateBasic() error { - emptyDenomsToAdd := len(crdp.DenomsToAdd) == 0 - emptyDenomsToRemove := len(crdp.DenomsToRemove) == 0 - // Return error if both sets are empty or nil - if emptyDenomsToAdd && emptyDenomsToRemove { - return fmt.Errorf( - "invalid change reward denoms proposal: both denoms to add and denoms to remove are empty") - } - - // Return error if a denom is in both sets - for _, denomToAdd := range crdp.DenomsToAdd { - for _, denomToRemove := range crdp.DenomsToRemove { - if denomToAdd == denomToRemove { - return fmt.Errorf( - "invalid change reward denoms proposal: %s cannot be both added and removed", denomToAdd) - } - } - } - - // Return error if any denom is "invalid" - for _, denom := range crdp.DenomsToAdd { - if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { - return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) - } - } - for _, denom := range crdp.DenomsToRemove { - if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { - return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) - } - } - - return nil + return fmt.Errorf("ChangeRewardDenomsProposal is deprecated") } diff --git a/x/ccv/provider/types/legacy_proposal_test.go b/x/ccv/provider/types/legacy_proposal_test.go deleted file mode 100644 index 21f7a2da8a..0000000000 --- a/x/ccv/provider/types/legacy_proposal_test.go +++ /dev/null @@ -1,557 +0,0 @@ -package types_test - -import ( - fmt "fmt" - "testing" - "time" - - clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - "github.com/golang/protobuf/proto" //nolint:staticcheck // see: https://github.com/cosmos/interchain-security/issues/236 - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -func TestConsumerAdditionProposalValidateBasic(t *testing.T) { - initialHeight := clienttypes.NewHeight(2, 3) - - testCases := []struct { - name string - proposal govv1beta1.Content - expPass bool - }{ - { - "success", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - true, - }, - { - "success with 0.0 fraction", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.0", // fraction can be 0.0 but not empty - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - true, - }, - { - "fails validate abstract - empty title", - types.NewConsumerAdditionProposal(" ", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "chainID is empty", - types.NewConsumerAdditionProposal("title", "description", " ", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "initial height is zero", - &types.ConsumerAdditionProposal{ - Title: "title", - Description: "description", - ChainId: "chainID", - InitialHeight: clienttypes.Height{}, - GenesisHash: []byte("gen_hash"), - BinaryHash: []byte("bin_hash"), - SpawnTime: time.Now(), - BlocksPerDistributionTransmission: 10, - CcvTimeoutPeriod: 100000000000, - TransferTimeoutPeriod: 100000000000, - ConsumerRedistributionFraction: "0.75", - DistributionTransmissionChannel: "", - HistoricalEntries: 10000, - UnbondingPeriod: 100000000000, - }, - false, - }, - { - "genesis hash is empty", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte(""), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "binary hash is empty", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte(""), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "spawn time is zero", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Time{}, - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "consumer redistribution fraction is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "", // fraction can be 0.0 but not empty - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "blocks per distribution transmission is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 0, - "", - 100000000000, - 10000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "distribution transmission channel is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "badchannel/", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "historical entries is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - -2, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "ccv timeout period is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 0, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "transfer timeout period is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 0, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "unbonding period is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 0, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "top N is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 10, - 0, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "validators power cap is invalid", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 50, - 101, - 0, - nil, - nil, - 0, - false, - ), - false, - }, - { - "valid proposal with PSS features", - types.NewConsumerAdditionProposal("title", "description", "chainID", initialHeight, []byte("gen_hash"), []byte("bin_hash"), time.Now(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 34, - 101, - []string{"addr1"}, - []string{"addr2", "addr3"}, - 0, - false, - ), - true, - }, - } - - for _, tc := range testCases { - - err := tc.proposal.ValidateBasic() - if tc.expPass { - require.NoError(t, err, "valid case: %s should not return error. got %w", tc.name, err) - } else { - require.Error(t, err, "invalid case: '%s' must return error but got none", tc.name) - } - } -} - -func TestMarshalConsumerAdditionProposal(t *testing.T) { - content := types.NewConsumerAdditionProposal("title", "description", "chainID", clienttypes.NewHeight(0, 1), []byte("gen_hash"), []byte("bin_hash"), time.Now().UTC(), - "0.75", - 10, - "", - 10000, - 100000000000, - 100000000000, - 100000000000, - 0, - 0, - 0, - nil, - nil, - 0, - false, - ) - - cccp, ok := content.(*types.ConsumerAdditionProposal) - require.True(t, ok) - - // create codec - ir := codectypes.NewInterfaceRegistry() - types.RegisterInterfaces(ir) - govv1.RegisterInterfaces(ir) - clienttypes.RegisterInterfaces(ir) - ibctmtypes.RegisterInterfaces(ir) - cdc := codec.NewProtoCodec(ir) - - // marshal proposal - bz, err := cdc.MarshalJSON(cccp) - require.NoError(t, err) - - // unmarshal proposal - newCccp := &types.ConsumerAdditionProposal{} - err = cdc.UnmarshalJSON(bz, newCccp) - require.NoError(t, err) - - require.True(t, proto.Equal(cccp, newCccp), "unmarshalled proposal does not equal original proposal") -} - -func TestConsumerAdditionProposalString(t *testing.T) { - initialHeight := clienttypes.NewHeight(2, 3) - spawnTime := time.Now() - proposal := types.NewConsumerAdditionProposal( - "title", - "description", - "chainID", - initialHeight, - []byte("gen_hash"), - []byte("bin_hash"), - spawnTime, - "0.75", - 10001, - "", - 500000, - 100000000000, - 10000000000, - 100000000000, - 0, - 0, - 0, - []string{}, - []string{}, - 0, - false, - ) - - expect := fmt.Sprintf(`CreateConsumerChain Proposal - Title: title - Description: description - ChainID: chainID - InitialHeight: %s - GenesisHash: %s - BinaryHash: %s - SpawnTime: %s - ConsumerRedistributionFraction: %s - BlocksPerDistributionTransmission: %d - DistributionTransmissionChannel: %s - HistoricalEntries: %d - CcvTimeoutPeriod: %d - TransferTimeoutPeriod: %d - UnbondingPeriod: %d`, initialHeight, []byte("gen_hash"), []byte("bin_hash"), spawnTime, - "0.75", - 10001, - "", - 500000, - 100000000000, - 10000000000, - 100000000000) - - require.Equal(t, expect, proposal.String(), "string method for ConsumerAdditionProposal returned unexpected string") -} - -func TestChangeRewardDenomsProposalValidateBasic(t *testing.T) { - tcs := []struct { - name string - proposal govv1beta1.Content - expectError bool - expectPanic bool - }{ - { - name: "invalid change reward denoms proposal, none to add or remove", - proposal: types.NewChangeRewardDenomsProposal( - "title", "description", []string{}, []string{}), - expectError: true, - }, - { - name: "invalid change reward denoms proposal, same denom in both sets", - proposal: types.NewChangeRewardDenomsProposal( - "title", "description", []string{"denom1"}, []string{"denom1"}), - expectError: true, - }, - { - name: "valid change reward denoms proposal", - proposal: types.NewChangeRewardDenomsProposal( - "title", "description", []string{"denom1"}, []string{"denom2"}), - expectError: false, - }, - { - name: "invalid prop, invalid denom, will panic", - proposal: types.NewChangeRewardDenomsProposal( - "title", "description", []string{"!@blah"}, []string{"denom2"}), - expectPanic: true, - }, - } - - for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { - if tc.expectPanic { - require.Panics(t, func() { tc.proposal.ValidateBasic() }) - return - } - err := tc.proposal.ValidateBasic() - if tc.expectError { - require.Error(t, err) - return - } - require.NoError(t, err) - }) - } -} - -func TestValidatePSSFeatures(t *testing.T) { - require.NoError(t, types.ValidatePSSFeatures(0, 0)) - require.NoError(t, types.ValidatePSSFeatures(50, 0)) - require.NoError(t, types.ValidatePSSFeatures(100, 0)) - require.NoError(t, types.ValidatePSSFeatures(0, 10)) - require.NoError(t, types.ValidatePSSFeatures(0, 100)) - require.NoError(t, types.ValidatePSSFeatures(50, 100)) - - require.Error(t, types.ValidatePSSFeatures(10, 0)) - require.Error(t, types.ValidatePSSFeatures(49, 0)) - require.Error(t, types.ValidatePSSFeatures(101, 0)) - require.Error(t, types.ValidatePSSFeatures(50, 101)) -} diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 9bca3f996f..361ac79a2c 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -15,25 +15,13 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" tmtypes "github.com/cometbft/cometbft/proto/tendermint/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -// provider message types const ( - TypeMsgAssignConsumerKey = "assign_consumer_key" - TypeMsgSubmitConsumerMisbehaviour = "submit_consumer_misbehaviour" - TypeMsgSubmitConsumerDoubleVoting = "submit_consumer_double_vote" - TypeMsgCreateConsumer = "create_consumer" - TypeMsgUpdateConsumer = "update_consumer" - TypeMsgRemoveConsumer = "remove_consumer" - TypeMsgOptIn = "opt_in" - TypeMsgOptOut = "opt_out" - TypeMsgSetConsumerCommissionRate = "set_consumer_commission_rate" - // MaxNameLength defines the maximum consumer name length MaxNameLength = 50 // MaxDescriptionLength defines the maximum consumer description length @@ -83,167 +71,209 @@ func NewMsgAssignConsumerKey(consumerId string, providerValidatorAddress sdk.Val }, nil } -// Route implements the sdk.Msg interface. -func (msg MsgAssignConsumerKey) Route() string { return RouterKey } - -// Type implements the sdk.Msg interface. -func (msg MsgAssignConsumerKey) Type() string { - return TypeMsgAssignConsumerKey -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -// If the validator address is not same as delegator's, then the validator must -// sign the msg as well. -func (msg MsgAssignConsumerKey) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg MsgAssignConsumerKey) ValidateBasic() error { + if err := validateDeprecatedChainId(msg.ChainId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ChainId: %s", err.Error()) } - return []sdk.AccAddress{valAddr.Bytes()} -} -// GetSignBytes returns the message bytes to sign over. -func (msg MsgAssignConsumerKey) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgAssignConsumerKey) ValidateBasic() error { if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ConsumerId: %s", err.Error()) } - _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - return ErrInvalidProviderAddress + + if err := validateProviderAddress(msg.ProviderAddr); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ProviderAddr: %s", err.Error()) } + if msg.ConsumerKey == "" { - return ErrInvalidConsumerConsensusPubKey + return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ConsumerKey cannot be empty") } if _, _, err := ParseConsumerKeyFromJson(msg.ConsumerKey); err != nil { - return ErrInvalidConsumerConsensusPubKey + return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ConsumerKey: %s", err.Error()) } + return nil } -// ParseConsumerKeyFromJson parses the consumer key from a JSON string, -// this replaces deserializing a protobuf any. -func ParseConsumerKeyFromJson(jsonStr string) (pkType, key string, err error) { - type PubKey struct { - Type string `json:"@type"` - Key string `json:"key"` +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg *MsgChangeRewardDenoms) ValidateBasic() error { + emptyDenomsToAdd := len(msg.DenomsToAdd) == 0 + emptyDenomsToRemove := len(msg.DenomsToRemove) == 0 + // Return error if both sets are empty or nil + if emptyDenomsToAdd && emptyDenomsToRemove { + return errorsmod.Wrapf(ErrInvalidMsgChangeRewardDenoms, "both DenomsToAdd and DenomsToRemove are empty") } - var pubKey PubKey - err = json.Unmarshal([]byte(jsonStr), &pubKey) - if err != nil { - return "", "", err + + denomMap := map[string]struct{}{} + for _, denom := range msg.DenomsToAdd { + // validate the denom + if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { + return errorsmod.Wrapf(ErrInvalidMsgChangeRewardDenoms, "DenomsToAdd: invalid denom(%s)", denom) + } + denomMap[denom] = struct{}{} + } + for _, denom := range msg.DenomsToRemove { + // validate the denom + if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { + return errorsmod.Wrapf(ErrInvalidMsgChangeRewardDenoms, "DenomsToRemove: invalid denom(%s)", denom) + } + // denom cannot be in both sets + if _, found := denomMap[denom]; found { + return errorsmod.Wrapf(ErrInvalidMsgChangeRewardDenoms, + "denom(%s) cannot be both added and removed", denom) + } } - return pubKey.Type, pubKey.Key, nil -} -func NewMsgSubmitConsumerMisbehaviour(submitter sdk.AccAddress, misbehaviour *ibctmtypes.Misbehaviour) (*MsgSubmitConsumerMisbehaviour, error) { - return &MsgSubmitConsumerMisbehaviour{Submitter: submitter.String(), Misbehaviour: misbehaviour}, nil + return nil } -// Route implements the sdk.Msg interface. -func (msg MsgSubmitConsumerMisbehaviour) Route() string { return RouterKey } - -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerMisbehaviour) Type() string { - return TypeMsgSubmitConsumerMisbehaviour +func NewMsgSubmitConsumerMisbehaviour( + submitter sdk.AccAddress, + misbehaviour *ibctmtypes.Misbehaviour, +) (*MsgSubmitConsumerMisbehaviour, error) { + return &MsgSubmitConsumerMisbehaviour{ + Submitter: submitter.String(), + Misbehaviour: misbehaviour, + }, nil } -// Type implements the sdk.Msg interface. +// ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { - if msg.Submitter == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter) - } if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerMisbehaviour, "ConsumerId: %s", err.Error()) } if err := msg.Misbehaviour.ValidateBasic(); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerMisbehaviour, "Misbehaviour: %s", err.Error()) } return nil } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerMisbehaviour) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) +func NewMsgSubmitConsumerDoubleVoting( + submitter sdk.AccAddress, + ev *tmtypes.DuplicateVoteEvidence, + header *ibctmtypes.Header, +) (*MsgSubmitConsumerDoubleVoting, error) { + return &MsgSubmitConsumerDoubleVoting{ + Submitter: submitter.String(), + DuplicateVoteEvidence: ev, + InfractionBlockHeader: header, + }, nil } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerMisbehaviour) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(msg.Submitter) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error { + if dve, err := cmttypes.DuplicateVoteEvidenceFromProto(msg.DuplicateVoteEvidence); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "DuplicateVoteEvidence: %s", err.Error()) + } else { + if err = dve.ValidateBasic(); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "DuplicateVoteEvidence: %s", err.Error()) + } } - return []sdk.AccAddress{addr} -} -func NewMsgSubmitConsumerDoubleVoting(submitter sdk.AccAddress, ev *tmtypes.DuplicateVoteEvidence, header *ibctmtypes.Header) (*MsgSubmitConsumerDoubleVoting, error) { - return &MsgSubmitConsumerDoubleVoting{Submitter: submitter.String(), DuplicateVoteEvidence: ev, InfractionBlockHeader: header}, nil -} + if err := ValidateHeaderForConsumerDoubleVoting(msg.InfractionBlockHeader); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "ValidateTendermintHeader: %s", err.Error()) + } -// Route implements the sdk.Msg interface. -func (msg MsgSubmitConsumerDoubleVoting) Route() string { return RouterKey } + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSubmitConsumerDoubleVoting, "ConsumerId: %s", err.Error()) + } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerDoubleVoting) Type() string { - return TypeMsgSubmitConsumerDoubleVoting + return nil } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error { - if msg.Submitter == "" { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Submitter) - } - if msg.DuplicateVoteEvidence == nil { - return fmt.Errorf("double voting evidence cannot be nil") +// NewMsgOptIn creates a new NewMsgOptIn instance. +func NewMsgOptIn(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { + return &MsgOptIn{ + ConsumerId: consumerId, + ProviderAddr: providerValidatorAddress.String(), + ConsumerKey: consumerConsensusPubKey, + Signer: signer, + }, nil +} + +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg MsgOptIn) ValidateBasic() error { + if err := validateDeprecatedChainId(msg.ChainId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ChainId: %s", err.Error()) } - if msg.InfractionBlockHeader == nil { - return fmt.Errorf("infraction block header cannot be nil") + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ConsumerId: %s", err.Error()) } - if msg.InfractionBlockHeader.SignedHeader == nil { - return fmt.Errorf("signed header in infraction block header cannot be nil") + if err := validateProviderAddress(msg.ProviderAddr); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ProviderAddr: %s", err.Error()) } - if msg.InfractionBlockHeader.SignedHeader.Header == nil { - return fmt.Errorf("invalid signed header in infraction block header, 'SignedHeader.Header' is nil") + if msg.ConsumerKey != "" { + if _, _, err := ParseConsumerKeyFromJson(msg.ConsumerKey); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ConsumerKey: %s", err.Error()) + } } + return nil +} - if msg.InfractionBlockHeader.ValidatorSet == nil { - return fmt.Errorf("invalid infraction block header, validator set is nil") +// NewMsgOptOut creates a new NewMsgOptIn instance. +func NewMsgOptOut(consumerId string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { + return &MsgOptOut{ + ConsumerId: consumerId, + ProviderAddr: providerValidatorAddress.String(), + Signer: signer, + }, nil +} + +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg MsgOptOut) ValidateBasic() error { + if err := validateDeprecatedChainId(msg.ChainId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptOut, "ChainId: %s", err.Error()) } if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err + return errorsmod.Wrapf(ErrInvalidMsgOptOut, "ConsumerId: %s", err.Error()) + } + + if err := validateProviderAddress(msg.ProviderAddr); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgOptOut, "ProviderAddr: %s", err.Error()) } return nil } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerDoubleVoting) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) +// NewMsgSetConsumerCommissionRate creates a new MsgSetConsumerCommissionRate msg instance. +func NewMsgSetConsumerCommissionRate( + consumerId string, + commission math.LegacyDec, + providerValidatorAddress sdk.ValAddress, + signer string, +) *MsgSetConsumerCommissionRate { + return &MsgSetConsumerCommissionRate{ + ConsumerId: consumerId, + Rate: commission, + ProviderAddr: providerValidatorAddress.String(), + Signer: signer, + } } -// Type implements the sdk.Msg interface. -func (msg MsgSubmitConsumerDoubleVoting) GetSigners() []sdk.AccAddress { - addr, err := sdk.AccAddressFromBech32(msg.Submitter) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) +// ValidateBasic implements the sdk.HasValidateBasic interface. +func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { + if err := validateDeprecatedChainId(msg.ChainId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "ChainId: %s", err.Error()) + } + + if err := ValidateConsumerId(msg.ConsumerId); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "ConsumerId: %s", err.Error()) + } + + if err := validateProviderAddress(msg.ProviderAddr); err != nil { + return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "ProviderAddr: %s", err.Error()) + } + + if msg.Rate.IsNegative() || msg.Rate.GT(math.LegacyOneDec()) { + return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "consumer commission rate should be in the range [0, 1]") } - return []sdk.AccAddress{addr} + + return nil } // NewMsgCreateConsumer creates a new MsgCreateConsumer instance @@ -258,15 +288,7 @@ func NewMsgCreateConsumer(signer string, chainId string, metadata ConsumerMetada }, nil } -// Type implements the sdk.Msg interface. -func (msg MsgCreateConsumer) Type() string { - return TypeMsgCreateConsumer -} - -// Route implements the sdk.Msg interface. -func (msg MsgCreateConsumer) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. +// ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgCreateConsumer) ValidateBasic() error { if err := ValidateStringField("ChainId", msg.ChainId, cmttypes.MaxChainIDLen); err != nil { return errorsmod.Wrapf(ErrInvalidMsgCreateConsumer, "ChainId: %s", err.Error()) @@ -295,23 +317,6 @@ func (msg MsgCreateConsumer) ValidateBasic() error { return nil } -// Type implements the sdk.Msg interface. -func (msg MsgCreateConsumer) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgCreateConsumer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Signer) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - // NewMsgUpdateConsumer creates a new MsgUpdateConsumer instance func NewMsgUpdateConsumer(signer string, consumerId string, ownerAddress string, metadata *ConsumerMetadata, initializationParameters *ConsumerInitializationParameters, powerShapingParameters *PowerShapingParameters) (*MsgUpdateConsumer, error) { @@ -325,15 +330,7 @@ func NewMsgUpdateConsumer(signer string, consumerId string, ownerAddress string, }, nil } -// Type implements the sdk.Msg interface. -func (msg MsgUpdateConsumer) Type() string { - return TypeMsgUpdateConsumer -} - -// Route implements the sdk.Msg interface. -func (msg MsgUpdateConsumer) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. +// ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgUpdateConsumer) ValidateBasic() error { if err := ValidateConsumerId(msg.ConsumerId); err != nil { return errorsmod.Wrapf(ErrInvalidMsgUpdateConsumer, "ConsumerId: %s", err.Error()) @@ -362,23 +359,6 @@ func (msg MsgUpdateConsumer) ValidateBasic() error { return nil } -// Type implements the sdk.Msg interface. -func (msg MsgUpdateConsumer) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgUpdateConsumer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Signer) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - // NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance func NewMsgRemoveConsumer(signer string, consumerId string, stopTime time.Time) (*MsgRemoveConsumer, error) { return &MsgRemoveConsumer{ @@ -388,15 +368,7 @@ func NewMsgRemoveConsumer(signer string, consumerId string, stopTime time.Time) }, nil } -// Type implements the sdk.Msg interface. -func (msg MsgRemoveConsumer) Type() string { - return TypeMsgRemoveConsumer -} - -// Route implements the sdk.Msg interface. -func (msg MsgRemoveConsumer) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. +// ValidateBasic implements the sdk.HasValidateBasic interface. func (msg MsgRemoveConsumer) ValidateBasic() error { if err := ValidateConsumerId(msg.ConsumerId); err != nil { return err @@ -404,336 +376,49 @@ func (msg MsgRemoveConsumer) ValidateBasic() error { return nil } -// Type implements the sdk.Msg interface. -func (msg MsgRemoveConsumer) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgRemoveConsumer) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Signer) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// Route implements the sdk.Msg interface. -func (msg MsgConsumerAddition) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgConsumerAddition) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return ErrBlankConsumerChainID - } - - if msg.InitialHeight.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "initial height cannot be zero") - } - - if len(msg.GenesisHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "genesis hash cannot be empty") - } - if len(msg.BinaryHash) == 0 { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "binary hash cannot be empty") - } - - if msg.SpawnTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "spawn time cannot be zero") - } - - if err := ccvtypes.ValidateStringFraction(msg.ConsumerRedistributionFraction); err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerAdditionProposal, "consumer redistribution fraction is invalid: %s", err) - } - - if err := ccvtypes.ValidatePositiveInt64(msg.BlocksPerDistributionTransmission); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "blocks per distribution transmission cannot be < 1") - } - - if err := ccvtypes.ValidateDistributionTransmissionChannel(msg.DistributionTransmissionChannel); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "distribution transmission channel") - } - - if err := ccvtypes.ValidatePositiveInt64(msg.HistoricalEntries); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "historical entries cannot be < 1") - } - - if err := ccvtypes.ValidateDuration(msg.CcvTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "ccv timeout period cannot be zero") - } - - if err := ccvtypes.ValidateDuration(msg.TransferTimeoutPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "transfer timeout period cannot be zero") - } +// +// Validation methods +// - if err := ccvtypes.ValidateDuration(msg.UnbondingPeriod); err != nil { - return errorsmod.Wrap(ErrInvalidConsumerAdditionProposal, "unbonding period cannot be zero") - } - - return nil -} - -// Type implements the sdk.Msg interface. -func (msg MsgConsumerAddition) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgConsumerAddition) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Authority) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// Route implements the sdk.Msg interface. -func (msg MsgConsumerModification) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgConsumerModification) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return ErrBlankConsumerChainID - } - - err := ValidatePSSFeatures(msg.Top_N, msg.ValidatorsPowerCap) - if err != nil { - return errorsmod.Wrapf(ErrInvalidConsumerModificationProposal, "invalid PSS features: %s", err.Error()) - } - - return nil -} - -// Type implements the sdk.Msg interface. -func (msg MsgConsumerModification) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgConsumerModification) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Authority) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// Route implements the sdk.Msg interface. -func (msg MsgConsumerRemoval) Route() string { return RouterKey } - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgConsumerRemoval) ValidateBasic() error { - if strings.TrimSpace(msg.ChainId) == "" { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "consumer chain id must not be blank") - } - - if msg.StopTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerRemovalProp, "spawn time cannot be zero") - } - return nil -} - -// Type implements the sdk.Msg interface. -func (msg MsgConsumerRemoval) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgConsumerRemoval) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.Authority) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// NewMsgOptIn creates a new NewMsgOptIn instance. -func NewMsgOptIn(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { - return &MsgOptIn{ - ConsumerId: consumerId, - ProviderAddr: providerValidatorAddress.String(), - ConsumerKey: consumerConsensusPubKey, - Signer: signer, - }, nil -} - -// Type implements the sdk.Msg interface. -func (msg MsgOptIn) Type() string { - return TypeMsgOptIn -} - -// Route implements the sdk.Msg interface. -func (msg MsgOptIn) Route() string { return RouterKey } - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgOptIn) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgOptIn) ValidateBasic() error { - if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err - } - _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - return ErrInvalidProviderAddress - } - - if msg.ConsumerKey != "" { - if _, _, err := ParseConsumerKeyFromJson(msg.ConsumerKey); err != nil { - return ErrInvalidConsumerConsensusPubKey - } - } - return nil -} - -// NewMsgOptOut creates a new NewMsgOptIn instance. -func NewMsgOptOut(consumerId string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { - return &MsgOptOut{ - ConsumerId: consumerId, - ProviderAddr: providerValidatorAddress.String(), - Signer: signer, - }, nil -} - -// Type implements the sdk.Msg interface. -func (msg MsgOptOut) Type() string { - return TypeMsgOptOut -} - -// Route implements the sdk.Msg interface. -func (msg MsgOptOut) Route() string { return RouterKey } - -// GetSigners implements the sdk.Msg interface. It returns the address(es) that -// must sign over msg.GetSignBytes(). -func (msg MsgOptOut) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -// GetSignBytes returns the message bytes to sign over. -func (msg MsgOptOut) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// ValidateBasic implements the sdk.Msg interface. -func (msg MsgOptOut) ValidateBasic() error { - if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err +// ParseConsumerKeyFromJson parses the consumer key from a JSON string, +// this replaces deserializing a protobuf any. +func ParseConsumerKeyFromJson(jsonStr string) (pkType, key string, err error) { + type PubKey struct { + Type string `json:"@type"` + Key string `json:"key"` } - _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + var pubKey PubKey + err = json.Unmarshal([]byte(jsonStr), &pubKey) if err != nil { - return ErrInvalidProviderAddress - } - return nil -} - -// NewMsgSetConsumerCommissionRate creates a new MsgSetConsumerCommissionRate msg instance. -func NewMsgSetConsumerCommissionRate(consumerId string, commission math.LegacyDec, providerValidatorAddress sdk.ValAddress, signer string) *MsgSetConsumerCommissionRate { - return &MsgSetConsumerCommissionRate{ - ConsumerId: consumerId, - Rate: commission, - ProviderAddr: providerValidatorAddress.String(), - Signer: signer, + return "", "", err } + return pubKey.Type, pubKey.Key, nil } -func (msg MsgSetConsumerCommissionRate) Route() string { - return RouterKey -} - -func (msg MsgSetConsumerCommissionRate) Type() string { - return TypeMsgSetConsumerCommissionRate -} - -func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { - if err := ValidateConsumerId(msg.ConsumerId); err != nil { - return err - } - _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - return ErrInvalidProviderAddress - } - - if msg.Rate.IsNegative() || msg.Rate.GT(math.LegacyOneDec()) { - return errorsmod.Wrapf(ErrInvalidConsumerCommissionRate, "consumer commission rate should be in the range [0, 1]") +// ValidateHeaderForConsumerDoubleVoting validates Tendermint light client header +// for consumer double voting evidence. +// +// TODO create unit test +func ValidateHeaderForConsumerDoubleVoting(header *ibctmtypes.Header) error { + if header == nil { + return fmt.Errorf("infraction block header cannot be nil") } - return nil -} - -func (msg *MsgChangeRewardDenoms) ValidateBasic() error { - emptyDenomsToAdd := len(msg.DenomsToAdd) == 0 - emptyDenomsToRemove := len(msg.DenomsToRemove) == 0 - // Return error if both sets are empty or nil - if emptyDenomsToAdd && emptyDenomsToRemove { - return fmt.Errorf( - "invalid change reward denoms proposal: both denoms to add and denoms to remove are empty") + if header.SignedHeader == nil { + return fmt.Errorf("signed header in infraction block header cannot be nil") } - // Return error if a denom is in both sets - for _, denomToAdd := range msg.DenomsToAdd { - for _, denomToRemove := range msg.DenomsToRemove { - if denomToAdd == denomToRemove { - return fmt.Errorf( - "invalid change reward denoms proposal: %s cannot be both added and removed", denomToAdd) - } - } + if header.SignedHeader.Header == nil { + return fmt.Errorf("invalid signed header in infraction block header, 'SignedHeader.Header' is nil") } - // Return error if any denom is "invalid" - for _, denom := range msg.DenomsToAdd { - if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { - return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) - } - } - for _, denom := range msg.DenomsToRemove { - if !sdk.NewCoin(denom, math.NewInt(1)).IsValid() { - return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) - } + if header.ValidatorSet == nil { + return fmt.Errorf("invalid infraction block header, validator set is nil") } return nil } -func (msg MsgSetConsumerCommissionRate) GetSigners() []sdk.AccAddress { - valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) - if err != nil { - // same behavior as in cosmos-sdk - panic(err) - } - return []sdk.AccAddress{valAddr.Bytes()} -} - -func (msg MsgSetConsumerCommissionRate) GetSignBytes() []byte { - bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - // ValidateConsumerId validates the provided consumer id and returns an error if it is not valid func ValidateConsumerId(consumerId string) error { if strings.TrimSpace(consumerId) == "" { @@ -887,3 +572,20 @@ func ValidateByteSlice(hash []byte, maxLength int) error { } return nil } + +func validateDeprecatedChainId(chainId string) error { + if strings.TrimSpace(chainId) != "" { + return fmt.Errorf("found non-empty chainId(%s); chainId is deprecated, use consumerId instead", chainId) + } + + return nil +} + +// validateProviderAddress validates that the address is a sdk.ValAddress in Bech32 string format +func validateProviderAddress(addr string) error { + _, err := sdk.ValAddressFromBech32(addr) + if err != nil { + return fmt.Errorf("invalid provider address(%s)", addr) + } + return nil +} From 4f2194c51dc0f51ab849b8b38487dec3c0b46052 Mon Sep 17 00:00:00 2001 From: bernd-m <43466467+bermuell@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:15:29 +0200 Subject: [PATCH 26/43] test: fix e2e tests + PSS e2e tests use permissionless (#2192) Fix e2e tests + make PSS e2e tests use Permissionless ICS --- tests/e2e/actions.go | 663 ++++++++++++++++-------- tests/e2e/config.go | 1 + tests/e2e/main.go | 7 + tests/e2e/state.go | 79 ++- tests/e2e/steps_partial_set_security.go | 441 ++++------------ tests/e2e/test_driver.go | 14 +- tests/e2e/testlib/types.go | 4 +- tests/e2e/testlib/utils.go | 49 ++ 8 files changed, 699 insertions(+), 559 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 088ad19801..22e1842050 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "encoding/base64" "encoding/json" "fmt" "log" @@ -16,10 +15,12 @@ import ( "sync" "time" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/tidwall/gjson" "golang.org/x/mod/semver" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" @@ -42,6 +43,13 @@ type SendTokensAction struct { Amount uint } +type TxResponse struct { + TxHash string `json:"txhash"` + Code int `json:"code"` + RawLog string `json:"raw_log"` + Events []sdk.Event `json:"events"` +} + func (tr Chain) sendTokens( action SendTokensAction, verbose bool, @@ -250,6 +258,121 @@ func (tr Chain) submitTextProposal( tr.waitBlocks(action.Chain, 1, 10*time.Second) } +type UpdateConsumerChainAction struct { + Chain ChainID + From ValidatorID + ConsumerChain ChainID + NewOwner string + InitialHeight clienttypes.Height + SpawnTime uint + DistributionChannel string + TopN uint32 + ValidatorsPowerCap uint32 + ValidatorSetCap uint32 + Allowlist []string + Denylist []string + MinStake uint64 + AllowInactiveVals bool +} + +func (tr Chain) updateConsumerChain(action UpdateConsumerChainAction, verbose bool) { + + spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) + params := ccvtypes.DefaultParams() + initParams := types.ConsumerInitializationParameters{ + InitialHeight: action.InitialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + + UnbondingPeriod: params.UnbondingPeriod, + CcvTimeoutPeriod: params.CcvTimeoutPeriod, + TransferTimeoutPeriod: params.TransferTimeoutPeriod, + ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, + HistoricalEntries: params.HistoricalEntries, + DistributionTransmissionChannel: action.DistributionChannel, + } + + powerShapingParams := types.PowerShapingParameters{ + Top_N: action.TopN, + ValidatorsPowerCap: action.ValidatorsPowerCap, + ValidatorSetCap: action.ValidatorSetCap, + Allowlist: action.Allowlist, + Denylist: action.Denylist, + MinStake: action.MinStake, + AllowInactiveVals: action.AllowInactiveVals, + } + + consumerId := tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId + msg := types.MsgUpdateConsumer{ + ConsumerId: string(consumerId), + NewOwnerAddress: action.NewOwner, + InitializationParameters: &initParams, + PowerShapingParameters: &powerShapingParams, + } + tr.UpdateConsumer(action.Chain, action.From, msg) +} + +type CreateConsumerChainAction struct { + Chain ChainID + From ValidatorID + ConsumerChain ChainID + InitialHeight clienttypes.Height + SpawnTime uint + DistributionChannel string + TopN uint32 + ValidatorsPowerCap uint32 + ValidatorSetCap uint32 + Allowlist []string + Denylist []string + MinStake uint64 + AllowInactiveVals bool +} + +// createConsumerChain creates and initializes a consumer chain +func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bool) { + + spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) + params := ccvtypes.DefaultParams() + initParams := types.ConsumerInitializationParameters{ + InitialHeight: action.InitialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + + UnbondingPeriod: params.UnbondingPeriod, + CcvTimeoutPeriod: params.CcvTimeoutPeriod, + TransferTimeoutPeriod: params.TransferTimeoutPeriod, + ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, + HistoricalEntries: params.HistoricalEntries, + DistributionTransmissionChannel: action.DistributionChannel, + } + + powerShapingParams := types.PowerShapingParameters{ + Top_N: action.TopN, + ValidatorsPowerCap: action.ValidatorsPowerCap, + ValidatorSetCap: action.ValidatorSetCap, + Allowlist: action.Allowlist, + Denylist: action.Denylist, + MinStake: action.MinStake, + AllowInactiveVals: action.AllowInactiveVals, + } + + metadata := types.ConsumerMetadata{ + Name: "chain name of " + string(action.Chain), + Description: "no description", + Metadata: "no metadata", + } + + // create consumer to get a consumer-id + consumerId := tr.CreateConsumer(action.Chain, action.ConsumerChain, action.From, metadata, &initParams, &powerShapingParams) + if verbose { + fmt.Println("Create consumer chain", string(action.ConsumerChain), " with consumer-id", string(consumerId)) + } +} + type SubmitConsumerAdditionProposalAction struct { PreCCV bool Chain ChainID @@ -268,73 +391,223 @@ type SubmitConsumerAdditionProposalAction struct { AllowInactiveVals bool } +func (tr Chain) UpdateConsumer(providerChain ChainID, validator ValidatorID, update types.MsgUpdateConsumer) { + content, err := json.Marshal(update) + if err != nil { + log.Fatal("failed marshalling MsgUpdateConsumer: ", err.Error()) + } + jsonFile := "/update-consumer.json" + bz, err := tr.target.ExecCommand( + "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, content, jsonFile), + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + // Send consumer chain update + cmd := tr.target.ExecCommand( + tr.testConfig.chainConfigs[providerChain].BinaryName, + "tx", "provider", "update-consumer", jsonFile, + `--from`, `validator`+fmt.Sprint(validator), + `--chain-id`, string(tr.testConfig.chainConfigs[providerChain].ChainId), + `--home`, tr.getValidatorHome(providerChain, validator), + `--gas`, `900000`, + `--node`, tr.getValidatorNode(providerChain, validator), + `--keyring-backend`, `test`, + "--output", "json", + `-y`, + ) + + bz, err = cmd.CombinedOutput() + if err != nil { + log.Fatal("update consumer failed ", "error: ", err, "output: ", string(bz)) + } + + // Check transaction + txResponse := &TxResponse{} + err = json.Unmarshal(bz, txResponse) + if err != nil { + log.Fatalf("unmarshalling tx response on update-consumer: %s, json: %s", err.Error(), string(bz)) + } + + if txResponse.Code != 0 { + log.Fatalf("sending update-consumer transaction failed with error code %d, Log:'%s'", txResponse.Code, txResponse.RawLog) + } + tr.waitBlocks(providerChain, 2, 10*time.Second) +} + +// CreateConsumer creates a consumer chain and returns its consumer-id +func (tr Chain) CreateConsumer(providerChain, consumerChain ChainID, validator ValidatorID, metadata types.ConsumerMetadata, initParams *types.ConsumerInitializationParameters, powerShapingParams *types.PowerShapingParameters) ConsumerID { + + chainID := string(tr.testConfig.chainConfigs[consumerChain].ChainId) + msg := types.MsgCreateConsumer{ + ChainId: chainID, + Metadata: metadata, + InitializationParameters: initParams, + PowerShapingParameters: powerShapingParams, + } + + content, err := json.Marshal(msg) + if err != nil { + log.Fatalf("failed marshalling MsgCreateConsumer: %s", err.Error()) + } + jsonFile := "/create-consumer.json" + bz, err := tr.target.ExecCommand( + "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, content, jsonFile), + ).CombinedOutput() + if err != nil { + log.Fatal(err, "\n", string(bz)) + } + + // Send consumer chain creation + cmd := tr.target.ExecCommand( + tr.testConfig.chainConfigs[providerChain].BinaryName, + "tx", "provider", "create-consumer", jsonFile, + `--from`, `validator`+fmt.Sprint(validator), + `--chain-id`, string(tr.testConfig.chainConfigs[providerChain].ChainId), + `--home`, tr.getValidatorHome(providerChain, validator), + `--gas`, `900000`, + `--node`, tr.getValidatorNode(providerChain, validator), + `--keyring-backend`, `test`, + "--output", "json", + `-y`, + ) + + bz, err = cmd.CombinedOutput() + if err != nil { + log.Fatal("create consumer failed ", "error: ", err, "output: ", string(bz)) + } + + txResponse := &TxResponse{} + err = json.Unmarshal(bz, txResponse) + if err != nil { + log.Fatalf("unmarshalling tx response on create-consumer: %s, json: %s", err.Error(), string(bz)) + } + + if txResponse.Code != 0 { + log.Fatalf("sending transaction failed with error code %d, Log:'%s'", txResponse.Code, txResponse.RawLog) + } + + // TODO: introduce waitForTx (see issue #2198) + tr.waitBlocks(providerChain, 2, 10*time.Second) + + // Get Consumer ID from transaction + cmd = tr.target.ExecCommand( + tr.testConfig.chainConfigs[providerChain].BinaryName, + "query", "tx", txResponse.TxHash, + `--node`, tr.getValidatorNode(providerChain, validator), + "--output", "json", + ) + bz, err = cmd.CombinedOutput() + if err != nil { + log.Fatalf("not able to query tx containing creation-consumer: tx: %s, err: %s, out: %s", + txResponse.TxHash, err.Error(), string(bz)) + } + + err = json.Unmarshal(bz, txResponse) + if err != nil { + log.Fatalf("unmarshalling tx containing create-consumer: %s, json: %s", err.Error(), string(bz)) + } + + consumerId := "" + for _, event := range txResponse.Events { + if event.Type != "consumer_creation" { + continue + } + attr, exists := event.GetAttribute("consumer_id") + if !exists { + log.Fatalf("no event with consumer_id found in tx content of create-consumer: %v", event) + } + consumerId = attr.Value + } + if consumerId == "" { + log.Fatalf("no consumer-id found in consumer creation transaction events for chain '%s'. events: %v", consumerChain, txResponse.Events) + } + + cfg, exists := tr.testConfig.chainConfigs[e2e.ChainID(chainID)] + if !exists { + log.Fatal("no chain config found for consumer chain", chainID) + } + if cfg.ConsumerId != "" && cfg.ConsumerId != e2e.ConsumerID(consumerId) { + log.Fatalf("chain '%s'registered already with a different consumer ID '%s'", chainID, consumerId) + } + + // Set the new created consumer-id on the chain's config + cfg.ConsumerId = e2e.ConsumerID(consumerId) + tr.testConfig.chainConfigs[e2e.ChainID(chainID)] = cfg + + return e2e.ConsumerID(consumerId) +} + +// submitConsumerAdditionProposal initializes a consumer chain and submits a governance proposal func (tr Chain) submitConsumerAdditionProposal( action SubmitConsumerAdditionProposalAction, verbose bool, ) { - spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) params := ccvtypes.DefaultParams() - template := ` - { - "messages": [ - { - "@type": "/interchain_security.ccv.provider.v1.MsgConsumerAddition", - "chain_id": "%s", - "initial_height": { - "revision_number": "%d", - "revision_height": "%d" - }, - "genesis_hash": "%s", - "binary_hash": "%s", - "spawn_time": "%s", - "unbonding_period": "%s", - "ccv_timeout_period": "%s", - "transfer_timeout_period": "%s", - "consumer_redistribution_fraction": "%s", - "blocks_per_distribution_transmission": "%d", - "historical_entries": "%d", - "distribution_transmission_channel": "%s", - "top_N": %d, - "validators_power_cap": %d, - "validator_set_cap": %d, - "allowlist": %s, - "denylist": %s, - "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", - "allow_inactive_vals": %t, - "min_stake": "%d" - } - ], -"metadata": "ipfs://CID", -"deposit": "%dstake", -"title": "Propose the addition of a new chain", -"summary": "Gonna be a great chain", -"expedited": false -}` - jsonStr := fmt.Sprintf(template, - string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), - action.InitialHeight.RevisionNumber, - action.InitialHeight.RevisionHeight, - base64.StdEncoding.EncodeToString([]byte("gen_hash")), - base64.StdEncoding.EncodeToString([]byte("bin_hash")), - spawnTime.Local().Format(time.RFC3339Nano), - params.UnbondingPeriod, - params.CcvTimeoutPeriod, - params.TransferTimeoutPeriod, - params.ConsumerRedistributionFraction, - params.BlocksPerDistributionTransmission, - params.HistoricalEntries, - action.DistributionChannel, - action.TopN, - action.ValidatorsPowerCap, - action.ValidatorSetCap, - action.Allowlist, - action.Denylist, - action.AllowInactiveVals, - action.MinStake, - action.Deposit) + spawnTime := tr.testConfig.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) - //#nosec G204 -- bypass unsafe quoting warning (no production code) - proposalFile := "/consumer-addition.proposal" + Metadata := types.ConsumerMetadata{ + Name: "chain " + string(action.Chain), + Description: "no description", + Metadata: "no metadata", + } + + initializationParameters := types.ConsumerInitializationParameters{ + InitialHeight: action.InitialHeight, + GenesisHash: []byte("gen_hash"), + BinaryHash: []byte("bin_hash"), + SpawnTime: spawnTime, + + UnbondingPeriod: params.UnbondingPeriod, + CcvTimeoutPeriod: params.CcvTimeoutPeriod, + TransferTimeoutPeriod: params.TransferTimeoutPeriod, + ConsumerRedistributionFraction: params.ConsumerRedistributionFraction, + BlocksPerDistributionTransmission: params.BlocksPerDistributionTransmission, + HistoricalEntries: params.HistoricalEntries, + DistributionTransmissionChannel: action.DistributionChannel, + } + + consumerId := tr.CreateConsumer(action.Chain, action.ConsumerChain, action.From, Metadata, nil, nil) + authority := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" + + // Update consumer to change owner to governance before submitting the proposal + update := &types.MsgUpdateConsumer{ + ConsumerId: string(consumerId), + NewOwnerAddress: authority, + } + // For the MsgUpdateConsumer sent in the proposal + powerShapingParameters := types.PowerShapingParameters{ + Top_N: 0, + ValidatorsPowerCap: action.ValidatorsPowerCap, + ValidatorSetCap: action.ValidatorSetCap, + Allowlist: action.Allowlist, + Denylist: action.Denylist, + MinStake: action.MinStake, + AllowInactiveVals: action.AllowInactiveVals, + } + update.PowerShapingParameters = &powerShapingParameters + tr.UpdateConsumer(action.Chain, action.From, *update) + + // - set PowerShaping params TopN > 0 for consumer chain + update.PowerShapingParameters.Top_N = action.TopN + update.Signer = authority + update.NewOwnerAddress = "" + update.InitializationParameters = &initializationParameters + update.InitializationParameters.SpawnTime = spawnTime + update.Metadata = &Metadata + + // Generate proposal content + title := "Propose the addition of a new chain" + description := "description of the consumer modification proposal" + summary := "Gonna be a great chain" + expedited := false + metadata := "ipfs://CID" + deposit := fmt.Sprintf("%dstake", action.Deposit) + jsonStr := e2e.GenerateGovProposalContent(title, summary, metadata, deposit, description, expedited, update) + + // #nosec G204 -- bypass unsafe quoting warning (no production code) + proposalFile := "/update-consumer-proposal.json" bz, err := tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, proposalFile), ).CombinedOutput() @@ -352,6 +625,7 @@ func (tr Chain) submitConsumerAdditionProposal( `--gas`, `900000`, `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, + `-o json`, `-y`, ) @@ -361,7 +635,17 @@ func (tr Chain) submitConsumerAdditionProposal( } bz, err = cmd.CombinedOutput() if err != nil { - log.Fatal("submit-proposal failed:", err, "\n", string(bz)) + log.Fatal("executing submit-proposal failed:", err, "\n", string(bz)) + } + + txResponse := &TxResponse{} + err = json.Unmarshal(bz, txResponse) + if err != nil { + log.Fatalf("failed unmarshalling tx response on submit consumer update: %s, json: %s", err.Error(), string(bz)) + } + + if txResponse.Code != 0 { + log.Fatalf("gov submit consumer update transaction failed with error code %d, Log:'%s'", txResponse.Code, txResponse.RawLog) } if verbose { @@ -467,34 +751,25 @@ func (tr Chain) submitConsumerRemovalProposal( action SubmitConsumerRemovalProposalAction, verbose bool, ) { - template := ` - { - "messages": [ - { - "@type": "/interchain_security.ccv.provider.v1.MsgConsumerRemoval", - "chain_id": "%s", - "stop_time": "%s", - "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" - } - ], - "metadata": "ipfs://CID", - "deposit": "%dstake", - "title": "%s", - "summary": "It was a great chain", - "expedited": false - } -` + consumerId := string(tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId) title := fmt.Sprintf("Stop the %v chain", action.ConsumerChain) - stopTime := tr.testConfig.containerConfig.Now.Add(action.StopTimeOffset).Format(time.RFC3339Nano) + description := "stop consumer chain" + summary := "It was a great chain" + expedited := false + metadata := "ipfs://CID" + deposit := fmt.Sprintf("%dstake", action.Deposit) + authority := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" - jsonStr := fmt.Sprintf(template, - string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), - stopTime, - action.Deposit, - title) + msg := types.MsgRemoveConsumer{ + ConsumerId: consumerId, + StopTime: tr.testConfig.containerConfig.Now.Add(action.StopTimeOffset), + Signer: authority, + } + + jsonStr := e2e.GenerateGovProposalContent(title, summary, metadata, deposit, description, expedited, &msg) // #nosec G204 -- bypass unsafe quoting warning (no production code) - proposalFile := "/consumer-removal.proposal" + proposalFile := "/remove-consumer-proposal.json" bz, err := tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, proposalFile), ).CombinedOutput() @@ -599,47 +874,31 @@ func (tr Chain) submitConsumerModificationProposal( action SubmitConsumerModificationProposalAction, verbose bool, ) { - template := ` - -{ -"messages": [ - { - "@type": "/interchain_security.ccv.provider.v1.MsgConsumerModification", - "title": "Propose the modification of the PSS parameters of a chain", - "description": "description of the consumer modification proposal", - "chain_id": "%s", - "top_N": %d, - "validators_power_cap": %d, - "validator_set_cap": %d, - "allowlist": %s, - "denylist": %s, - "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", - "min_stake": %d, - "allow_inactive_vals": %t - } - ], -"metadata": "ipfs://CID", -"deposit": "%sstake", -"title": "Propose the modification of the PSS parameters of a chain", -"summary": "summary of a modification proposal", -"expedited": false - } -` - jsonStr := fmt.Sprintf(template, - string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), - action.TopN, - action.ValidatorsPowerCap, - action.ValidatorSetCap, - action.Allowlist, - action.Denylist, - action.Deposit, - action.MinStake, - action.AllowInactiveVals, - ) + consumerId := string(tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId) + title := "Propose the modification of the PSS parameters of a chain" + description := "description of the consumer modification proposal" + summary := "summary of a modification proposal" + expedited := false + metadata := "ipfs://CID" + deposit := fmt.Sprintf("%dstake", action.Deposit) + authority := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" + + msg := types.MsgUpdateConsumer{ + Signer: authority, + ConsumerId: consumerId, + PowerShapingParameters: &types.PowerShapingParameters{ + Top_N: action.TopN, + ValidatorsPowerCap: action.ValidatorsPowerCap, + ValidatorSetCap: action.ValidatorSetCap, + Allowlist: action.Allowlist, + Denylist: action.Denylist, + }, + } + jsonStr := e2e.GenerateGovProposalContent(title, summary, metadata, deposit, description, expedited, &msg) // #nosec G204 -- bypass unsafe quoting warning (no production code) - proposalFile := "/consumer-mod.proposal" + proposalFile := "/update-consumer-proposal.json" bz, err := tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, proposalFile), ).CombinedOutput() @@ -754,26 +1013,21 @@ func (tr Chain) submitEnableTransfersProposalAction( ) { // gov signed address got by checking the gov module acc address in the test container // interchain-security-cdd q auth module-account gov --node tcp://7.7.9.253:26658 - template := ` - { - "messages": [ - { - "@type": "/ibc.applications.transfer.v1.MsgUpdateParams", - "signer": "consumer10d07y265gmmuvt4z0w9aw880jnsr700jlh7295", - "params": { - "send_enabled": true, - "receive_enabled": true - } - } - ], - "metadata": "ipfs://CID", - "deposit": "%dstake", - "title": "%s", - "summary": "Enable transfer send", - "expedited": false - } - ` - jsonStr := fmt.Sprintf(template, action.Deposit, action.Title) + + msgUpdateParams := ibctransfertypes.MsgUpdateParams{ + Signer: "consumer10d07y265gmmuvt4z0w9aw880jnsr700jlh7295", + Params: ibctransfertypes.Params{ + SendEnabled: true, + ReceiveEnabled: true, + }, + } + // Generate proposal content + description := "update IBC params" + summary := "Enable transfer send/receive" + expedited := false + metadata := "ipfs://CID" + deposit := fmt.Sprintf("%dstake", action.Deposit) + jsonStr := e2e.GenerateGovProposalContent(action.Title, summary, metadata, deposit, description, expedited, &msgUpdateParams) //#nosec G204 -- bypass unsafe quoting warning (no production code) bz, err := tr.target.ExecCommand( @@ -880,23 +1134,34 @@ func (tr *Chain) startConsumerChain( func (tr *Chain) getConsumerGenesis(providerChain, consumerChain ChainID) string { fmt.Println("Exporting consumer genesis from provider") providerBinaryName := tr.testConfig.chainConfigs[providerChain].BinaryName + consumerId := string(tr.testConfig.chainConfigs[consumerChain].ConsumerId) - cmd := tr.target.ExecCommand( - providerBinaryName, + now := time.Now() + timeout := now.Add(30 * time.Second) + var bz []byte + var err error + for { + cmd := tr.target.ExecCommand( + providerBinaryName, - "query", "provider", "consumer-genesis", - string(tr.testConfig.chainConfigs[consumerChain].ChainId), + "query", "provider", "consumer-genesis", consumerId, - `--node`, tr.target.GetQueryNode(providerChain), - `-o`, `json`, - ) + `--node`, tr.target.GetQueryNode(providerChain), + `-o`, `json`, + ) + bz, err = cmd.CombinedOutput() + if err == nil { + break + } - bz, err := cmd.CombinedOutput() - if err != nil { - log.Fatal(err, "\n", string(bz)) + if time.Now().After(timeout) { + log.Print("Failed running command: ", cmd) + log.Fatal(err, "\n", string(bz)) + } + time.Sleep(2 * time.Second) } - if tr.testConfig.transformGenesis || needsGenesisTransform(tr.testConfig) { + if tr.testConfig.transformGenesis || needsGenesisTransform(*tr.testConfig) { return string(tr.transformConsumerGenesis(consumerChain, bz)) } else { fmt.Println("No genesis transformation performed") @@ -1071,28 +1336,9 @@ func (tr Chain) changeoverChain( action ChangeoverChainAction, verbose bool, ) { - // sleep until the consumer chain genesis is ready on consumer - time.Sleep(5 * time.Second) - cmd := tr.target.ExecCommand( - tr.testConfig.chainConfigs[action.ProviderChain].BinaryName, - - "query", "provider", "consumer-genesis", - string(tr.testConfig.chainConfigs[action.SovereignChain].ChainId), - - `--node`, tr.target.GetQueryNode(action.ProviderChain), - `-o`, `json`, - ) - - if verbose { - log.Println("changeoverChain cmd: ", cmd.String()) - } - bz, err := cmd.CombinedOutput() - if err != nil { - log.Fatal(err, "\n", string(bz)) - } + consumerGenesis := ".app_state.ccvconsumer = " + tr.getConsumerGenesis(action.ProviderChain, action.SovereignChain) - consumerGenesis := ".app_state.ccvconsumer = " + string(bz) consumerGenesisChanges := tr.testConfig.chainConfigs[action.SovereignChain].GenesisChanges if consumerGenesisChanges != "" { consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges @@ -2229,32 +2475,24 @@ type SubmitChangeRewardDenomsProposalAction struct { } func (tr Chain) submitChangeRewardDenomsProposal(action SubmitChangeRewardDenomsProposalAction, verbose bool) { - template := ` -{ - "messages": [ - { - "@type": "/interchain_security.ccv.provider.v1.MsgChangeRewardDenoms", - "denoms_to_add": ["%s"], - "denoms_to_remove": ["%s"], - "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" - } - ], - "metadata": "ipfs://CID", - "deposit": "%dstake", - "title": "change reward denoms", - "summary": "Proposal to change reward denoms", - "expedited": false -}` - denomsToAdd := action.Denom - denomsToRemove := "stake" - jsonStr := fmt.Sprintf(template, - denomsToAdd, - denomsToRemove, - action.Deposit) + changeRewMsg := types.MsgChangeRewardDenoms{ + DenomsToAdd: []string{action.Denom}, + DenomsToRemove: []string{"stake"}, + Authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", + } + + // Generate proposal content + title := "change reward denoms" + description := "change reward denoms" + summary := "Proposal to change reward denoms" + expedited := false + metadata := "ipfs://CID" + deposit := fmt.Sprintf("%dstake", action.Deposit) + jsonStr := e2e.GenerateGovProposalContent(title, summary, metadata, deposit, description, expedited, &changeRewMsg) //#nosec G204 -- bypass unsafe quoting warning (no production code) - proposalFile := "/change-reward.proposal" + proposalFile := "/change-rewards-proposal.json" bz, err := tr.target.ExecCommand( "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, proposalFile), ).CombinedOutput() @@ -2480,10 +2718,11 @@ func (tr Chain) assignConsumerPubKey(action AssignConsumerPubKeyAction, verbose if tr.testConfig.useCometmock { gas = "9000000" } + assignKey := fmt.Sprintf( `%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, - string(tr.testConfig.chainConfigs[action.Chain].ChainId), + string(tr.testConfig.chainConfigs[action.Chain].ConsumerId), action.ConsumerPubkey, action.Validator, tr.testConfig.chainConfigs[ChainID("provi")].ChainId, @@ -2659,7 +2898,7 @@ type OptInAction struct { Validator ValidatorID } -func (tr Chain) optIn(action OptInAction, target ExecutionTarget, verbose bool) { +func (tr Chain) optIn(action OptInAction, verbose bool) { // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then @@ -2671,7 +2910,7 @@ func (tr Chain) optIn(action OptInAction, target ExecutionTarget, verbose bool) optIn := fmt.Sprintf( `%s tx provider opt-in %s --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, - string(tr.testConfig.chainConfigs[action.Chain].ChainId), + string(tr.testConfig.chainConfigs[action.Chain].ConsumerId), action.Validator, tr.testConfig.chainConfigs[ChainID("provi")].ChainId, tr.getValidatorHome(ChainID("provi"), action.Validator), @@ -2679,7 +2918,7 @@ func (tr Chain) optIn(action OptInAction, target ExecutionTarget, verbose bool) gas, ) - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( "/bin/bash", "-c", optIn, ) @@ -2709,7 +2948,7 @@ type OptOutAction struct { ExpectError bool } -func (tr Chain) optOut(action OptOutAction, target ExecutionTarget, verbose bool) { +func (tr Chain) optOut(action OptOutAction, verbose bool) { // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then @@ -2721,7 +2960,7 @@ func (tr Chain) optOut(action OptOutAction, target ExecutionTarget, verbose bool optOut := fmt.Sprintf( `%s tx provider opt-out %s --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, - string(tr.testConfig.chainConfigs[action.Chain].ChainId), + string(tr.testConfig.chainConfigs[action.Chain].ConsumerId), action.Validator, tr.testConfig.chainConfigs[ChainID("provi")].ChainId, tr.getValidatorHome(ChainID("provi"), action.Validator), @@ -2729,7 +2968,7 @@ func (tr Chain) optOut(action OptOutAction, target ExecutionTarget, verbose bool gas, ) - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( "/bin/bash", "-c", optOut, ) @@ -2759,6 +2998,7 @@ func (tr Chain) optOut(action OptOutAction, target ExecutionTarget, verbose bool type SetConsumerCommissionRateAction struct { Chain ChainID + ConsumerID ConsumerID Validator ValidatorID CommissionRate float64 @@ -2767,7 +3007,7 @@ type SetConsumerCommissionRateAction struct { ExpectedError string } -func (tr Chain) setConsumerCommissionRate(action SetConsumerCommissionRateAction, target ExecutionTarget, verbose bool) { +func (tr Chain) setConsumerCommissionRate(action SetConsumerCommissionRateAction, verbose bool) { // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" // Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then @@ -2775,11 +3015,16 @@ func (tr Chain) setConsumerCommissionRate(action SetConsumerCommissionRateAction gas = "9000000" } + consumerId := string(tr.testConfig.chainConfigs[action.Chain].ConsumerId) + if action.ConsumerID != "" { + consumerId = string(action.ConsumerID) + } + // Use: "set-consumer-commission-rate [consumer-chain-id] [commission-rate]" setCommissionRate := fmt.Sprintf( `%s tx provider set-consumer-commission-rate %s %f --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, tr.testConfig.chainConfigs[ChainID("provi")].BinaryName, - string(tr.testConfig.chainConfigs[action.Chain].ChainId), + consumerId, action.CommissionRate, action.Validator, tr.testConfig.chainConfigs[ChainID("provi")].ChainId, @@ -2788,7 +3033,7 @@ func (tr Chain) setConsumerCommissionRate(action SetConsumerCommissionRateAction gas, ) - cmd := target.ExecCommand( + cmd := tr.target.ExecCommand( "/bin/bash", "-c", setCommissionRate, ) diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 4fa762b5f7..c3f8f712b1 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -74,6 +74,7 @@ var hermesTemplates = map[string]string{ // type aliases for shared types from e2e package type ( ChainID = e2e.ChainID + ConsumerID = e2e.ConsumerID ValidatorID = e2e.ValidatorID ValidatorConfig = e2e.ValidatorConfig ChainConfig = e2e.ChainConfig diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 2864c9b413..e8ae6b2166 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -246,6 +246,13 @@ var stepChoices = map[string]StepChoice{ description: "test minting without inactive validators as a sanity check", testConfig: MintTestCfg, }, + // TODO PERMISSIONLESS: ADD NEW E2E TEST + /* "permissionless-ics": { + name: "permissionless-ics", + steps: stepsPermissionlessICS(), + description: "test permissionless ics", + testConfig: DefaultTestCfg, + }, */ "inactive-vals-outside-max-validators": { name: "inactive-vals-outside-max-validators", steps: stepsInactiveValsTopNReproduce(), diff --git a/tests/e2e/state.go b/tests/e2e/state.go index f29c8f59f0..676d8dcfc5 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -12,6 +12,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" e2e "github.com/cosmos/interchain-security/v5/tests/e2e/testlib" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "github.com/kylelemons/godebug/pretty" "github.com/tidwall/gjson" "gopkg.in/yaml.v2" @@ -38,7 +39,7 @@ type State map[ChainID]ChainState type Chain struct { target e2e.TargetDriver - testConfig TestConfig + testConfig *TestConfig } func (tr Chain) GetChainState(chain ChainID, modelState ChainState) ChainState { @@ -335,7 +336,7 @@ func intPtr(i int) *int { } type Commands struct { - containerConfig ContainerConfig // FIXME only needed for 'Now' time tracking + containerConfig *ContainerConfig validatorConfigs map[ValidatorID]ValidatorConfig chainConfigs map[ChainID]ChainConfig target e2e.PlatformDriver @@ -465,6 +466,30 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { Title: title, Description: description, } + case "/interchain_security.ccv.provider.v1.MsgUpdateConsumer": + consumerId := rawContent.Get("consumer_id").String() + consumerChainId := ChainID("") + for _, chainCfg := range tr.chainConfigs { + if chainCfg.ConsumerId == e2e.ConsumerID(consumerId) { + consumerChainId = chainCfg.ChainId + break + } + } + + updateProposal := ConsumerAdditionProposal{ + Deposit: uint(deposit), + Chain: consumerChainId, + Status: status, + } + if rawContent.Get("initialization_parameters").Exists() { + spawnTime := rawContent.Get("initialization_parameters.spawn_time").Time().Sub(tr.containerConfig.Now) + updateProposal.SpawnTime = int(spawnTime.Milliseconds()) + updateProposal.InitialHeight = clienttypes.Height{ + RevisionNumber: rawContent.Get("initialization_parameters.initial_height.revision_number").Uint(), + RevisionHeight: rawContent.Get("initialization_parameters.initial_height.revision_height").Uint(), + } + } + return updateProposal case "/interchain_security.ccv.provider.v1.MsgConsumerAddition": chainId := rawContent.Get("chain_id").String() spawnTime := rawContent.Get("spawn_time").Time().Sub(tr.containerConfig.Now) @@ -498,13 +523,13 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { Title: title, Type: "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", } - case "/interchain_security.ccv.provider.v1.MsgConsumerRemoval": - chainId := rawContent.Get("chain_id").String() + case "/interchain_security.ccv.provider.v1.MsgRemoveConsumer": + consumerId := rawContent.Get("consumer_id").String() stopTime := rawContent.Get("stop_time").Time().Sub(tr.containerConfig.Now) var chain ChainID for i, conf := range tr.chainConfigs { - if string(conf.ChainId) == chainId { + if string(conf.ConsumerId) == consumerId { chain = i break } @@ -746,8 +771,13 @@ func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { arr := gjson.Get(string(bz), "chains").Array() chains := make(map[ChainID]bool) for _, c := range arr { - id := c.Get("chain_id").String() - chains[ChainID(id)] = true + phase := c.Get("phase").String() + if phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)] || + phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_REGISTERED)] || + phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)] { + id := c.Get("chain_id").String() + chains[ChainID(id)] = true + } } return chains @@ -755,10 +785,11 @@ func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { func (tr Commands) GetConsumerAddress(consumerChain ChainID, validator ValidatorID) string { binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + consumerId := tr.chainConfigs[ChainID(consumerChain)].ConsumerId cmd := tr.target.ExecCommand(binaryName, "query", "provider", "validator-consumer-key", - string(consumerChain), tr.validatorConfigs[validator].ValconsAddress, + string(consumerId), tr.validatorConfigs[validator].ValconsAddress, `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) @@ -773,10 +804,12 @@ func (tr Commands) GetConsumerAddress(consumerChain ChainID, validator Validator func (tr Commands) GetProviderAddressFromConsumer(consumerChain ChainID, validator ValidatorID) string { binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + consumerId := tr.chainConfigs[ChainID(consumerChain)].ConsumerId + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "validator-provider-key", - string(consumerChain), tr.validatorConfigs[validator].ConsumerValconsAddressOnProvider, + string(consumerId), tr.validatorConfigs[validator].ConsumerValconsAddressOnProvider, `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) @@ -898,7 +931,12 @@ func (tr Commands) GetHasToValidate( arr := gjson.Get(string(bz), "consumer_chain_ids").Array() chains := []ChainID{} for _, c := range arr { - chains = append(chains, ChainID(c.String())) + for _, chain := range tr.chainConfigs { + if chain.ConsumerId == ConsumerID(c.String()) { + chains = append(chains, chain.ChainId) + break + } + } } return chains @@ -969,20 +1007,25 @@ func (tr Commands) GetTrustedHeight( func (tr Commands) GetProposedConsumerChains(chain ChainID) []string { binaryName := tr.chainConfigs[chain].BinaryName - bz, err := tr.target.ExecCommand(binaryName, - "query", "provider", "list-proposed-consumer-chains", + cmd := tr.target.ExecCommand(binaryName, + "query", "provider", "list-consumer-chains", `--node`, tr.GetQueryNode(chain), `-o`, `json`, - ).CombinedOutput() + ) + bz, err := cmd.CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } - arr := gjson.Get(string(bz), "proposedChains").Array() + arr := gjson.Get(string(bz), "chains").Array() chains := []string{} for _, c := range arr { - cid := c.Get("chainID").String() - chains = append(chains, cid) + cid := c.Get("chain_id").String() + phase := c.Get("phase").String() + if phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)] || + phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_REGISTERED)] { + chains = append(chains, cid) + } } return chains @@ -1013,9 +1056,11 @@ func (tr Commands) GetQueryNodeIP(chain ChainID) string { // GetConsumerCommissionRate returns the commission rate of the given validator on the given consumerChain func (tr Commands) GetConsumerCommissionRate(consumerChain ChainID, validator ValidatorID) float64 { binaryName := tr.chainConfigs[ChainID("provi")].BinaryName + consumerId := tr.chainConfigs[consumerChain].ConsumerId + cmd := tr.target.ExecCommand(binaryName, "query", "provider", "validator-consumer-commission-rate", - string(consumerChain), tr.validatorConfigs[validator].ValconsAddress, + string(consumerId), tr.validatorConfigs[validator].ValconsAddress, `--node`, tr.GetQueryNode(ChainID("provi")), `-o`, `json`, ) diff --git a/tests/e2e/steps_partial_set_security.go b/tests/e2e/steps_partial_set_security.go index 80eff1aedd..156457769b 100644 --- a/tests/e2e/steps_partial_set_security.go +++ b/tests/e2e/steps_partial_set_security.go @@ -2,6 +2,7 @@ package main import ( "strconv" + "time" gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" @@ -32,6 +33,7 @@ func stepsOptInChain() []Step { { Action: SetConsumerCommissionRateAction{ Chain: ChainID("consu"), + ConsumerID: "99999", Validator: ValidatorID("bob"), CommissionRate: 0.123, ExpectError: true, @@ -40,31 +42,17 @@ func stepsOptInChain() []Step { State: State{}, }, { - Action: SubmitConsumerAdditionProposalAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), - SpawnTime: 0, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, }, State: State{ ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {}, - ValidatorID("carol"): {}, - }, + ProposedConsumerChains: &[]string{"consu"}, }, }, }, @@ -127,25 +115,15 @@ func stepsOptInChain() []Step { }, }, { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, - Vote: []string{"yes", "yes"}, - PropNumber: 1, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: 0, // launch now + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, }, + State: State{}, }, { // we start all the validators but only "alice" and "bob" have opted in and hence @@ -1052,33 +1030,18 @@ func stepsValidatorSetCappedChain() []Step { }, }, { - Action: SubmitConsumerAdditionProposalAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - Deposit: 10000001, - ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - // we can have at most 2 validators validating the consumer chain + Action: CreateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, ValidatorSetCap: 2, }, State: State{ ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {}, - ValidatorID("carol"): {}, - }, + ProposedConsumerChains: &[]string{"consu"}, }, }, }, @@ -1143,25 +1106,17 @@ func stepsValidatorSetCappedChain() []Step { State: State{}, }, { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, - Vote: []string{"yes", "yes"}, - PropNumber: 1, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, + // Update with SpawnTime 0 will trigger launch of consumer chain + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: 0, // launch now + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, + ValidatorSetCap: 2, }, + State: State{}, }, { Action: StartConsumerChainAction{ @@ -1513,36 +1468,17 @@ func stepsValidatorsAllowlistedChain() []Step { }, }, { - Action: SubmitConsumerAdditionProposalAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), - SpawnTime: 0, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, - // only "alice" and "bob" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Allowlist: []string{ - "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - }, }, State: State{ ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {}, - ValidatorID("carol"): {}, - }, + ProposedConsumerChains: &[]string{"consu"}, }, }, }, @@ -1606,25 +1542,21 @@ func stepsValidatorsAllowlistedChain() []Step { State: State{}, }, { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, - Vote: []string{"yes", "yes"}, - PropNumber: 1, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, + // Update with SpawnTime 0 will trigger launch of consumer chain + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: 0, // launch now + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, + // only "alice" and "bob" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) + Allowlist: []string{ + "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", }, }, + State: State{}, }, { Action: StartConsumerChainAction{ @@ -1719,33 +1651,18 @@ func stepsValidatorsDenylistedChain() []Step { }, }, { - Action: SubmitConsumerAdditionProposalAction{ - Chain: ChainID("provi"), - From: ValidatorID("alice"), - Deposit: 10000001, - ConsumerChain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - TopN: 0, - // only "bob" is denylisted (see `getDefaultValidators` in `tests/e2e/config.go`) - Denylist: []string{"cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"}, + Action: CreateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, + ValidatorSetCap: 2, }, State: State{ ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {}, - ValidatorID("carol"): {}, - }, + ProposedConsumerChains: &[]string{"consu"}, }, }, }, @@ -1809,25 +1726,17 @@ func stepsValidatorsDenylistedChain() []Step { State: State{}, }, { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, - Vote: []string{"yes", "yes"}, - PropNumber: 1, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, + // Update with SpawnTime 0 will trigger launch of consumer chain + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: 0, // launch now + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, + Denylist: []string{"cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39"}, }, + State: State{}, }, { Action: StartConsumerChainAction{ @@ -1923,31 +1832,17 @@ func stepsModifyChain() []Step { }, }, { - Action: SubmitConsumerAdditionProposalAction{ + Action: CreateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), - SpawnTime: 0, + SpawnTime: uint(time.Minute * 10), // set spawn-time far in the future InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, TopN: 0, }, State: State{ ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - HasToValidate: &map[ValidatorID][]ChainID{ - ValidatorID("alice"): {}, - ValidatorID("bob"): {}, - ValidatorID("carol"): {}, - }, + ProposedConsumerChains: &[]string{"consu"}, }, }, }, @@ -2011,25 +1906,16 @@ func stepsModifyChain() []Step { State: State{}, }, { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, - Vote: []string{"yes", "yes", "yes"}, - PropNumber: 1, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 1: ConsumerAdditionProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - SpawnTime: 0, - InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, + // Update with SpawnTime 0 will trigger launch of consumer chain + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + SpawnTime: 0, // launch now + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, }, + State: State{}, }, { Action: StartConsumerChainAction{ @@ -2105,43 +1991,16 @@ func stepsModifyChain() []Step { // 1. set `ValidatorsPowerCap` to 40% { - Action: SubmitConsumerModificationProposalAction{ + Action: UpdateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, ValidatorsPowerCap: 40, }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 2: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - }, - }, - }, - { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, - Vote: []string{"yes", "yes", "yes"}, - PropNumber: 2, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 2: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, - }, + State: State{}, }, { Action: RelayPacketsAction{ @@ -2171,43 +2030,16 @@ func stepsModifyChain() []Step { // 2. set the `ValidatorSetCap` to a maximum of 2 validators { - Action: SubmitConsumerModificationProposalAction{ + Action: UpdateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, ValidatorSetCap: 2, }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 3: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - }, - }, - }, - { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, - Vote: []string{"yes", "yes", "yes"}, - PropNumber: 3, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 3: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, - }, + State: State{}, }, { Action: RelayPacketsAction{ @@ -2235,50 +2067,21 @@ func stepsModifyChain() []Step { }, }, }, - // 3. set an allowlist with 2 validators { - Action: SubmitConsumerModificationProposalAction{ + Action: UpdateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), - // only "alice" and "carol" are allowlisted (see `getDefaultValidators` in `tests/e2e/config.go`) + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, Allowlist: []string{ "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", }, }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 4: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - }, - }, - }, - { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, - Vote: []string{"yes", "yes", "yes"}, - PropNumber: 4, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 4: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, - }, + State: State{}, }, { Action: RelayPacketsAction{ @@ -2304,47 +2107,19 @@ func stepsModifyChain() []Step { }, }, }, - // 4. set a denylist with 1 validator { - Action: SubmitConsumerModificationProposalAction{ + Action: UpdateConsumerChainAction{ Chain: ChainID("provi"), From: ValidatorID("alice"), - Deposit: 10000001, ConsumerChain: ChainID("consu"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, // only "alice" is denylisted (see `getDefaultValidators` in `tests/e2e/config.go`) Denylist: []string{"cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq"}, }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 5: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), - }, - }, - }, - }, - }, - { - Action: VoteGovProposalAction{ - Chain: ChainID("provi"), - From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, - Vote: []string{"yes", "yes", "yes"}, - PropNumber: 5, - }, - State: State{ - ChainID("provi"): ChainState{ - Proposals: &map[uint]Proposal{ - 5: ConsumerModificationProposal{ - Deposit: 10000001, - Chain: ChainID("consu"), - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), - }, - }, - }, - }, + State: State{}, }, { Action: RelayPacketsAction{ @@ -2370,8 +2145,20 @@ func stepsModifyChain() []Step { }, }, }, - // 5. modify the chain from Opt In to Top 100% + // -- Change the owner to governance authority + { + Action: UpdateConsumerChainAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + ConsumerChain: ChainID("consu"), + NewOwner: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + TopN: 0, + }, + State: State{}, + }, { Action: SubmitConsumerModificationProposalAction{ Chain: ChainID("provi"), @@ -2383,7 +2170,7 @@ func stepsModifyChain() []Step { State: State{ ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ - 6: ConsumerModificationProposal{ + 1: ConsumerAdditionProposal{ Deposit: 10000001, Chain: ChainID("consu"), Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), @@ -2397,12 +2184,12 @@ func stepsModifyChain() []Step { Chain: ChainID("provi"), From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, Vote: []string{"yes", "yes", "yes"}, - PropNumber: 6, + PropNumber: 1, }, State: State{ ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ - 6: ConsumerModificationProposal{ + 1: ConsumerAdditionProposal{ Deposit: 10000001, Chain: ChainID("consu"), Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), diff --git a/tests/e2e/test_driver.go b/tests/e2e/test_driver.go index f65ddfe6ab..6c2bc35d77 100644 --- a/tests/e2e/test_driver.go +++ b/tests/e2e/test_driver.go @@ -79,7 +79,7 @@ func (td *DefaultDriver) getIcsVersion(chainID ChainID) string { func (td *DefaultDriver) getTargetDriver(chainID ChainID) Chain { target := Chain{ - testConfig: td.testCfg, + testConfig: &td.testCfg, } icsVersion := td.getIcsVersion(chainID) switch icsVersion { @@ -95,7 +95,7 @@ func (td *DefaultDriver) getTargetDriver(chainID ChainID) Chain { } default: target.target = Commands{ - containerConfig: td.testCfg.containerConfig, + containerConfig: &td.testCfg.containerConfig, validatorConfigs: td.testCfg.validatorConfigs, chainConfigs: td.testCfg.chainConfigs, target: td.target, @@ -227,12 +227,16 @@ func (td *DefaultDriver) runAction(action interface{}) error { } else { target.submitChangeRewardDenomsProposal(action, td.verbose) } + case CreateConsumerChainAction: + target.createConsumerChain(action, td.verbose) + case UpdateConsumerChainAction: + target.updateConsumerChain(action, td.verbose) case OptInAction: - target.optIn(action, td.target, td.verbose) + target.optIn(action, td.verbose) case OptOutAction: - target.optOut(action, td.target, td.verbose) + target.optOut(action, td.verbose) case SetConsumerCommissionRateAction: - target.setConsumerCommissionRate(action, td.target, td.verbose) + target.setConsumerCommissionRate(action, td.verbose) default: log.Fatalf("unknown action in testRun %s: %#v", td.testCfg.name, action) } diff --git a/tests/e2e/testlib/types.go b/tests/e2e/testlib/types.go index bd7996b988..8694e7185d 100644 --- a/tests/e2e/testlib/types.go +++ b/tests/e2e/testlib/types.go @@ -12,6 +12,7 @@ import ( type ( ChainID string + ConsumerID string ValidatorID string ) @@ -124,7 +125,8 @@ type ValidatorConfig struct { // Attributes that are unique to a chain. Allows us to map (part of) // the set of strings defined above to a set of viable chains type ChainConfig struct { - ChainId ChainID + ChainId ChainID + ConsumerId ConsumerID // The account prefix configured on the chain. For example, on the Hub, this is "cosmos" AccountPrefix string // Must be unique per chain diff --git a/tests/e2e/testlib/utils.go b/tests/e2e/testlib/utils.go index 08f410269f..c9d663a3f5 100644 --- a/tests/e2e/testlib/utils.go +++ b/tests/e2e/testlib/utils.go @@ -2,11 +2,60 @@ package e2e import ( "bufio" + "encoding/json" "fmt" "log" "os/exec" + + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) +// GovernanceProposal is used to generate content to be used for `gov submit-proposal` command +type GovernanceProposal struct { + // Msgs defines an array of sdk.Msgs proto-JSON-encoded as Anys. + Messages []json.RawMessage `json:"messages,omitempty"` + Metadata string `json:"metadata"` + Deposit string `json:"deposit"` + Title string `json:"title"` + Summary string `json:"summary"` + Expedited bool `json:"expedited"` +} + +// GenerateGovProposalContent creates proposal content ready to be used by `gov submit-proposal` command +func GenerateGovProposalContent(title, summary, metadata, deposit, description string, expedited bool, msgs ...sdk.Msg) string { + + // Register the messages. Needed for correct type annotation in the resulting json + modcodec := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + modcodec.InterfaceRegistry().RegisterImplementations( + (*sdk.Msg)(nil), + msgs..., + ) + + proposal := GovernanceProposal{ + Metadata: metadata, + Deposit: deposit, + Title: title, + Summary: summary, + Expedited: expedited, + } + + for _, msg := range msgs { + msgJson, err := modcodec.MarshalInterfaceJSON(msg) + if err != nil { + panic(fmt.Errorf("failed marshalling message '%v' for gov proposal: err=%s", msg, err)) + } + proposal.Messages = append(proposal.Messages, msgJson) + } + raw, err := json.MarshalIndent(proposal, "", " ") + if err != nil { + panic(fmt.Errorf("failed to marshal proposal: %w", err)) + } + + return string(raw) +} + func ExecuteCommand(cmd *exec.Cmd, cmdName string, verbose bool) { if verbose { fmt.Println(cmdName+" cmd:", cmd.String()) From 5f1a27cf03070c737ec22d126b47acf4c3920351 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Tue, 3 Sep 2024 12:17:37 +0200 Subject: [PATCH 27/43] refactor: power shaping (#2207) * update allowlist and denylist power shaping update * fix tests * refactor: move power shaping params to power_shaping.go * rename record to parameters --- .../integration/partial_set_security_test.go | 14 +- tests/mbt/driver/setup.go | 3 +- testutil/keeper/unit_test_helpers.go | 11 +- .../keeper/consumer_lifecycle_test.go | 20 +- x/ccv/provider/keeper/grpc_query_test.go | 15 +- x/ccv/provider/keeper/keeper.go | 215 ------------ x/ccv/provider/keeper/keeper_test.go | 223 ------------- x/ccv/provider/keeper/msg_server.go | 5 - .../keeper/partial_set_security_test.go | 27 +- x/ccv/provider/keeper/permissionless.go | 31 -- x/ccv/provider/keeper/permissionless_test.go | 43 --- x/ccv/provider/keeper/power_shaping.go | 286 ++++++++++++++++ x/ccv/provider/keeper/power_shaping_test.go | 313 ++++++++++++++++++ x/ccv/provider/keeper/relay_test.go | 6 +- x/ccv/types/errors.go | 2 + 15 files changed, 665 insertions(+), 549 deletions(-) create mode 100644 x/ccv/provider/keeper/power_shaping.go create mode 100644 x/ccv/provider/keeper/power_shaping_test.go diff --git a/tests/integration/partial_set_security_test.go b/tests/integration/partial_set_security_test.go index e99ce6f44a..db628aaccd 100644 --- a/tests/integration/partial_set_security_test.go +++ b/tests/integration/partial_set_security_test.go @@ -1,11 +1,12 @@ package integration import ( - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "slices" "sort" "testing" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + "cosmossdk.io/math" ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" "github.com/stretchr/testify/require" @@ -152,9 +153,14 @@ func TestMinStake(t *testing.T) { // adjust parameters // set the minStake according to the test case - providerKeeper.SetConsumerPowerShapingParameters(s.providerChain.GetContext(), s.getFirstBundle().ConsumerId, types.PowerShapingParameters{ - MinStake: tc.minStake, - }) + err = providerKeeper.SetConsumerPowerShapingParameters( + s.providerChain.GetContext(), + s.getFirstBundle().ConsumerId, + types.PowerShapingParameters{ + MinStake: tc.minStake, + }, + ) + s.Require().NoError(err) // delegate and undelegate to trigger a vscupdate diff --git a/tests/mbt/driver/setup.go b/tests/mbt/driver/setup.go index adaa444167..97102960d6 100644 --- a/tests/mbt/driver/setup.go +++ b/tests/mbt/driver/setup.go @@ -389,9 +389,10 @@ func (s *Driver) ConfigureNewPath(consumerChain, providerChain *ibctesting.TestC require.NoError(s.t, err, "Error setting consumer genesis on provider for chain %v", consumerChain.ChainID) // set the top N percentage to 100 to simulate a full consumer - s.providerKeeper().SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerChain.ChainID, types.PowerShapingParameters{ + err = s.providerKeeper().SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerChain.ChainID, types.PowerShapingParameters{ Top_N: 100, }) + require.NoError(s.t, err, "Error setting consumer top N for chain %v", consumerChain.ChainID) // Client ID is set in InitGenesis and we treat it as a black box. So // must query it to use it with the endpoint. diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 6249227e00..1572937607 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -232,12 +232,15 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, gomock.InOrder(expectations...) providerKeeper.SetConsumerChainId(ctx, consumerId, "chainID") - providerKeeper.SetConsumerMetadata(ctx, consumerId, GetTestConsumerMetadata()) - providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, GetTestInitializationParameters()) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters()) + err := providerKeeper.SetConsumerMetadata(ctx, consumerId, GetTestConsumerMetadata()) + require.NoError(t, err) + err = providerKeeper.SetConsumerInitializationParameters(ctx, consumerId, GetTestInitializationParameters()) + require.NoError(t, err) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters()) + require.NoError(t, err) providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - err := providerKeeper.CreateConsumerClient(ctx, consumerId) + err = providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) // set the mapping consumer ID <> client ID for the consumer chain providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") diff --git a/x/ccv/provider/keeper/consumer_lifecycle_test.go b/x/ccv/provider/keeper/consumer_lifecycle_test.go index cf5aaa873e..7fc238570c 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle_test.go +++ b/x/ccv/provider/keeper/consumer_lifecycle_test.go @@ -398,11 +398,14 @@ func TestCreateConsumerClient(t *testing.T) { // Call method with same arbitrary values as defined above in mock expectations. providerKeeper.SetConsumerChainId(ctx, "0", "chainID") - providerKeeper.SetConsumerMetadata(ctx, "0", testkeeper.GetTestConsumerMetadata()) - providerKeeper.SetConsumerInitializationParameters(ctx, "0", testkeeper.GetTestInitializationParameters()) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", testkeeper.GetTestPowerShapingParameters()) - err := providerKeeper.CreateConsumerClient(ctx, "0") + err := providerKeeper.SetConsumerMetadata(ctx, "0", testkeeper.GetTestConsumerMetadata()) + require.NoError(t, err) + err = providerKeeper.SetConsumerInitializationParameters(ctx, "0", testkeeper.GetTestInitializationParameters()) + require.NoError(t, err) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", testkeeper.GetTestPowerShapingParameters()) + require.NoError(t, err) + err = providerKeeper.CreateConsumerClient(ctx, "0") if tc.expClientCreated { require.NoError(t, err) testCreatedConsumerClient(t, ctx, providerKeeper, "0", "clientID") @@ -526,9 +529,12 @@ func TestMakeConsumerGenesis(t *testing.T) { UnbondingPeriod: unbondingPeriod, } providerKeeper.SetConsumerChainId(ctx, "0", "testchain1") - providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) - providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", providertypes.PowerShapingParameters{}) + err := providerKeeper.SetConsumerMetadata(ctx, "0", consumerMetadata) + require.NoError(t, err) + err = providerKeeper.SetConsumerInitializationParameters(ctx, "0", initializationParameters) + require.NoError(t, err) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "0", providertypes.PowerShapingParameters{}) + require.NoError(t, err) actualGenesis, _, err := providerKeeper.MakeConsumerGenesis(ctx, "0") require.NoError(t, err) diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index c540c4980c..9d91bd25f7 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -184,7 +184,8 @@ func TestQueryConsumerValidators(t *testing.T) { require.Equal(t, res.Validators[0].ProviderAddress, providerAddr1.String()) // update consumer TopN param - pk.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{Top_N: 50}) + err = pk.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{Top_N: 50}) + require.NoError(t, err) // expect both opted-in and topN validator expRes := types.QueryConsumerValidatorsResponse{ @@ -445,13 +446,14 @@ func TestGetConsumerChain(t *testing.T) { clientID := fmt.Sprintf("client-%d", len(consumerID)-i) topN := topNs[i] pk.SetConsumerClientId(ctx, consumerID, clientID) - pk.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{ + err := pk.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{ Top_N: topN, ValidatorSetCap: validatorSetCaps[i], ValidatorsPowerCap: validatorPowerCaps[i], MinStake: minStakes[i].Uint64(), AllowInactiveVals: allowInactiveVals[i], }) + require.NoError(t, err) pk.SetMinimumPowerInTopN(ctx, consumerID, expectedMinPowerInTopNs[i]) for _, addr := range allowlists[i] { pk.SetAllowlist(ctx, consumerID, addr) @@ -532,7 +534,8 @@ func TestQueryConsumerChain(t *testing.T) { _, err = providerKeeper.QueryConsumerChain(ctx, &req) require.Error(t, err) - providerKeeper.SetConsumerMetadata(ctx, consumerId, types.ConsumerMetadata{Name: chainId}) + err = providerKeeper.SetConsumerMetadata(ctx, consumerId, types.ConsumerMetadata{Name: chainId}) + require.NoError(t, err) expRes := types.QueryConsumerChainResponse{ ChainId: chainId, @@ -548,17 +551,19 @@ func TestQueryConsumerChain(t *testing.T) { require.NoError(t, err) require.Equal(t, &expRes, res) - providerKeeper.SetConsumerInitializationParameters( + err = providerKeeper.SetConsumerInitializationParameters( ctx, consumerId, types.ConsumerInitializationParameters{SpawnTime: ctx.BlockTime()}, ) + require.NoError(t, err) - providerKeeper.SetConsumerPowerShapingParameters( + err = providerKeeper.SetConsumerPowerShapingParameters( ctx, consumerId, types.PowerShapingParameters{Top_N: uint32(50)}, ) + require.NoError(t, err) expRes.InitParams = &types.ConsumerInitializationParameters{SpawnTime: ctx.BlockTime()} expRes.PowerShapingParams = &types.PowerShapingParameters{Top_N: uint32(50)} diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 0fc911c8dc..b4c037c0c3 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -867,221 +867,6 @@ func (k Keeper) DeleteConsumerCommissionRate( store.Delete(types.ConsumerCommissionRateKey(consumerId, providerAddr)) } -// SetAllowlist allowlists validator with `providerAddr` address on chain `consumerId` -func (k Keeper) SetAllowlist( - ctx sdk.Context, - consumerId string, - providerAddr types.ProviderConsAddress, -) { - store := ctx.KVStore(k.storeKey) - store.Set(types.AllowlistKey(consumerId, providerAddr), []byte{}) -} - -// GetAllowList returns all allowlisted validators -func (k Keeper) GetAllowList( - ctx sdk.Context, - consumerId string, -) (providerConsAddresses []types.ProviderConsAddress) { - store := ctx.KVStore(k.storeKey) - key := types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId) - iterator := storetypes.KVStorePrefixIterator(store, key) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - providerConsAddresses = append(providerConsAddresses, types.NewProviderConsAddress(iterator.Key()[len(key):])) - } - - return providerConsAddresses -} - -// IsAllowlisted returns `true` if validator with `providerAddr` has been allowlisted on chain `consumerId` -func (k Keeper) IsAllowlisted( - ctx sdk.Context, - consumerId string, - providerAddr types.ProviderConsAddress, -) bool { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.AllowlistKey(consumerId, providerAddr)) - return bz != nil -} - -// DeleteAllowlist deletes all allowlisted validators -func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) - defer iterator.Close() - - keysToDel := [][]byte{} - for ; iterator.Valid(); iterator.Next() { - keysToDel = append(keysToDel, iterator.Key()) - } - - for _, key := range keysToDel { - store.Delete(key) - } -} - -// IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `consumerId` -func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) - defer iterator.Close() - - return !iterator.Valid() -} - -// UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id -func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string) { - k.DeleteAllowlist(ctx, consumerId) - for _, address := range allowlist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetAllowlist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) - } -} - -// SetDenylist denylists validator with `providerAddr` address on chain `consumerId` -func (k Keeper) SetDenylist( - ctx sdk.Context, - consumerId string, - providerAddr types.ProviderConsAddress, -) { - store := ctx.KVStore(k.storeKey) - store.Set(types.DenylistKey(consumerId, providerAddr), []byte{}) -} - -// GetDenyList returns all denylisted validators -func (k Keeper) GetDenyList( - ctx sdk.Context, - consumerId string, -) (providerConsAddresses []types.ProviderConsAddress) { - store := ctx.KVStore(k.storeKey) - key := types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId) - iterator := storetypes.KVStorePrefixIterator(store, key) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - providerConsAddresses = append(providerConsAddresses, types.NewProviderConsAddress(iterator.Key()[len(key):])) - } - - return providerConsAddresses -} - -// IsDenylisted returns `true` if validator with `providerAddr` has been denylisted on chain `consumerId` -func (k Keeper) IsDenylisted( - ctx sdk.Context, - consumerId string, - providerAddr types.ProviderConsAddress, -) bool { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.DenylistKey(consumerId, providerAddr)) - return bz != nil -} - -// DeleteDenylist deletes all denylisted validators -func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string) { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) - defer iterator.Close() - - keysToDel := [][]byte{} - for ; iterator.Valid(); iterator.Next() { - keysToDel = append(keysToDel, iterator.Key()) - } - - for _, key := range keysToDel { - store.Delete(key) - } -} - -// IsDenylistEmpty returns `true` if no validator is denylisted on chain `consumerId` -func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool { - store := ctx.KVStore(k.storeKey) - iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) - defer iterator.Close() - - return !iterator.Valid() -} - -// UpdateDenylist populates the denylist store for the consumer chain with this consumer id -func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string) { - k.DeleteDenylist(ctx, consumerId) - for _, address := range denylist { - consAddr, err := sdk.ConsAddressFromBech32(address) - if err != nil { - continue - } - - k.SetDenylist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) - } -} - -// SetMinimumPowerInTopN sets the minimum power required for a validator to be in the top N -// for a given consumer chain. -func (k Keeper) SetMinimumPowerInTopN( - ctx sdk.Context, - consumerId string, - power int64, -) { - store := ctx.KVStore(k.storeKey) - - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, uint64(power)) - - store.Set(types.MinimumPowerInTopNKey(consumerId), buf) -} - -// GetMinimumPowerInTopN returns the minimum power required for a validator to be in the top N -// for a given consumer chain. -func (k Keeper) GetMinimumPowerInTopN( - ctx sdk.Context, - consumerId string, -) (int64, bool) { - store := ctx.KVStore(k.storeKey) - buf := store.Get(types.MinimumPowerInTopNKey(consumerId)) - if buf == nil { - return 0, false - } - return int64(binary.BigEndian.Uint64(buf)), true -} - -// DeleteMinimumPowerInTopN removes the minimum power required for a validator to be in the top N -// for a given consumer chain. -func (k Keeper) DeleteMinimumPowerInTopN( - ctx sdk.Context, - consumerId string, -) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.MinimumPowerInTopNKey(consumerId)) -} - -// UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id -func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN uint32, newTopN uint32) error { - // if the top N changes, we need to update the new minimum power in top N - if newTopN != oldTopN { - if newTopN > 0 { - // if the chain receives a non-zero top N value, store the minimum power in the top N - bondedValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) - if err != nil { - return err - } - minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, newTopN) - if err != nil { - return err - } - k.SetMinimumPowerInTopN(ctx, consumerId, minPower) - } else { - // if the chain receives a zero top N value, we delete the min power - k.DeleteMinimumPowerInTopN(ctx, consumerId) - } - } - - return nil -} - func (k Keeper) UnbondingCanComplete(ctx sdk.Context, id uint64) error { return k.stakingKeeper.UnbondingCanComplete(ctx, id) } diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 5431c95390..0a5fe59c97 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -8,12 +8,9 @@ import ( "cosmossdk.io/math" ibctesting "github.com/cosmos/ibc-go/v8/testing" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" @@ -372,165 +369,6 @@ func TestConsumerCommissionRate(t *testing.T) { require.False(t, found) } -// TestAllowlist tests the `SetAllowlist`, `IsAllowlisted`, `DeleteAllowlist`, and `IsAllowlistEmpty` methods -func TestAllowlist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - chainID := "consumerId" - - // no validator was allowlisted and hence the allowlist is empty - require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) - - providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) - providerKeeper.SetAllowlist(ctx, chainID, providerAddr1) - require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr1)) - - // allowlist is not empty anymore - require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) - - providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) - providerKeeper.SetAllowlist(ctx, chainID, providerAddr2) - require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr2)) - require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) - - providerKeeper.DeleteAllowlist(ctx, chainID) - require.False(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr1)) - require.False(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr2)) - require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) -} - -func TestUpdateAllowlist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" - consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) - providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) - - providerKeeper.UpdateAllowlist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) - - expectedAllowlist := []providertypes.ProviderConsAddress{ - providertypes.NewProviderConsAddress(consAddr1), - providertypes.NewProviderConsAddress(consAddr2)} - require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) -} - -// TestDenylist tests the `SetDenylist`, `IsDenylisted`, `DeleteDenylist`, and `IsDenylistEmpty` methods -func TestDenylist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - chainID := "consumerId" - - // no validator was denylisted and hence the denylist is empty - require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) - - providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) - providerKeeper.SetDenylist(ctx, chainID, providerAddr1) - require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr1)) - - // denylist is not empty anymore - require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) - - providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) - providerKeeper.SetDenylist(ctx, chainID, providerAddr2) - require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr2)) - require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) - - providerKeeper.DeleteDenylist(ctx, chainID) - require.False(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr1)) - require.False(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr2)) - require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) -} - -func TestUpdateDenylist(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" - consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) - providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" - consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) - - providerKeeper.UpdateDenylist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) - - expectedDenylist := []providertypes.ProviderConsAddress{ - providertypes.NewProviderConsAddress(consAddr1), - providertypes.NewProviderConsAddress(consAddr2)} - require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) -} - -// Tests setting, getting and deleting parameters that are stored per-consumer chain. -// The tests cover the following parameters: -// - MinimumPowerInTopN -func TestKeeperConsumerParams(t *testing.T) { - k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - - tests := []struct { - name string - settingFunc func(sdk.Context, string, int64) - getFunc func(sdk.Context, string) int64 - deleteFunc func(sdk.Context, string) - initialValue int64 - updatedValue int64 - }{ - { - name: "Minimum Power In Top N", - settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetMinimumPowerInTopN(ctx, id, val) }, - getFunc: func(ctx sdk.Context, id string) int64 { - minimumPowerInTopN, _ := k.GetMinimumPowerInTopN(ctx, id) - return minimumPowerInTopN - }, - deleteFunc: func(ctx sdk.Context, id string) { k.DeleteMinimumPowerInTopN(ctx, id) }, - initialValue: 1000, - updatedValue: 2000, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - chainID := "consumerId" - // Set initial value - tt.settingFunc(ctx, chainID, int64(tt.initialValue)) - - // Retrieve and check initial value - actualValue := tt.getFunc(ctx, chainID) - require.EqualValues(t, tt.initialValue, actualValue) - - // Update value - tt.settingFunc(ctx, chainID, int64(tt.updatedValue)) - - // Retrieve and check updated value - newActualValue := tt.getFunc(ctx, chainID) - require.EqualValues(t, tt.updatedValue, newActualValue) - - // Check non-existent consumer id - res := tt.getFunc(ctx, "not the consumerId") - require.Zero(t, res) - - // Delete value - tt.deleteFunc(ctx, chainID) - - // Check that value was deleted - res = tt.getFunc(ctx, chainID) - require.Zero(t, res) - - // Try deleting again - tt.deleteFunc(ctx, chainID) - - // Check that the value is still deleted - res = tt.getFunc(ctx, chainID) - require.Zero(t, res) - }) - } -} - // TestConsumerClientId tests the getter, setter, and deletion of the client id <> consumer id mappings func TestConsumerClientId(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) @@ -575,64 +413,3 @@ func TestConsumerClientId(t *testing.T) { _, found = providerKeeper.GetClientIdToConsumerId(ctx, clientIds[1]) require.False(t, found) } - -func TestUpdateMinimumPowerInTopN(t *testing.T) { - providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - consumerId := "0" - - // test case where Top N is 0 in which case there's no minimum power in top N - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 0, - }) - - err := providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 0) - require.NoError(t, err) - _, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.False(t, found) - - // test cases where Top N > 0 and for this we mock some validators - powers := []int64{10, 20, 30} - validators := []stakingtypes.Validator{ - createStakingValidator(ctx, mocks, powers[0], 1), // this validator has ~16 of the total voting power - createStakingValidator(ctx, mocks, powers[1], 2), // this validator has ~33% of the total voting gpower - createStakingValidator(ctx, mocks, powers[2], 3), // this validator has 50% of the total voting power - } - mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() - - maxProviderConsensusValidators := int64(3) - params := providerKeeper.GetParams(ctx) - params.MaxProviderConsensusValidators = maxProviderConsensusValidators - providerKeeper.SetParams(ctx, params) - - // when top N is 50, the minimum power is 30 (because top validator has to validate) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 50, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 50) - require.NoError(t, err) - minimumPowerInTopN, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(30), minimumPowerInTopN) - - // when top N is 51, the minimum power is 20 (because top 2 validators have to validate) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 51, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 50, 51) - require.NoError(t, err) - minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(20), minimumPowerInTopN) - - // when top N is 100, the minimum power is 10 (that of the validator with the lowest power) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ - Top_N: 100, - }) - err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 51, 100) - require.NoError(t, err) - minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) - require.True(t, found) - require.Equal(t, int64(10), minimumPowerInTopN) -} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 1764796c57..83664e369e 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -319,8 +319,6 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon return &resp, errorsmod.Wrap(types.ErrCannotCreateTopNChain, "cannot create a Top N chain using the `MsgCreateConsumer` message; use `MsgUpdateConsumer` instead") } - - // TODO (PERMISSIONLESS) UpdateAllowlist & UpdateDenylist } if err := k.Keeper.SetConsumerPowerShapingParameters(ctx, consumerId, powerShapingParameters); err != nil { return &resp, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, @@ -418,9 +416,6 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrInvalidPowerShapingParameters, "cannot set power shaping parameters") } - - k.Keeper.UpdateAllowlist(ctx, consumerId, msg.PowerShapingParameters.Allowlist) - k.Keeper.UpdateDenylist(ctx, consumerId, msg.PowerShapingParameters.Denylist) err = k.Keeper.UpdateMinimumPowerInTopN(ctx, consumerId, oldTopN, msg.PowerShapingParameters.Top_N) if err != nil { return &resp, errorsmod.Wrapf(types.ErrCannotUpdateMinimumPowerInTopN, diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index f760599907..b29ff94a47 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -409,7 +409,8 @@ func TestCanValidateChain(t *testing.T) { // with TopN chains, the validator can be considered, mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(gomock.Any(), providerAddr.Address).Return(validator, nil).Times(2) - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 50}) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 50}) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerID) require.NoError(t, err) // validator's power is LT the min power @@ -422,7 +423,8 @@ func TestCanValidateChain(t *testing.T) { require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 2)) // With OptIn chains, validator can validate only if it has already opted-in - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 0}) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerID, types.PowerShapingParameters{Top_N: 0}) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerID) require.NoError(t, err) require.True(t, providerKeeper.CanValidateChain(ctx, consumerID, providerAddr, powerShapingParameters.Top_N, 2)) @@ -471,41 +473,46 @@ func TestCapValidatorSet(t *testing.T) { consumerValidators := providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 0, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 100, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, validators, consumerValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 1, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, []types.ConsensusValidator{validatorC}, consumerValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 2, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) require.Equal(t, []types.ConsensusValidator{validatorC, validatorB}, consumerValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorSetCap: 3, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) consumerValidators = providerKeeper.CapValidatorSet(ctx, powerShapingParameters, validators) @@ -563,9 +570,10 @@ func TestCapValidatorsPower(t *testing.T) { sortValidators(cappedValidators) require.Equal(t, validators, cappedValidators) - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ ValidatorsPowerCap: 33, }) + require.NoError(t, err) powerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) cappedValidators = providerKeeper.CapValidatorsPower(ctx, powerShapingParameters.ValidatorsPowerCap, validators) @@ -858,10 +866,11 @@ func TestIfInactiveValsDisallowedProperty(t *testing.T) { // Set up the parameters in the provider keeper // do not allow inactive validators - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", types.PowerShapingParameters{ MinStake: minStake, AllowInactiveVals: false, }) + require.NoError(t, err) params := providerKeeper.GetParams(ctx) params.MaxProviderConsensusValidators = int64(maxProviderConsensusVals) providerKeeper.SetParams(ctx, params) diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index 695db64463..ecedda108d 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -143,37 +143,6 @@ func (k Keeper) DeleteConsumerInitializationParameters(ctx sdk.Context, consumer store.Delete(types.ConsumerIdToInitializationParametersKey(consumerId)) } -// GetConsumerPowerShapingParameters returns the power-shaping parameters associated with this consumer id -func (k Keeper) GetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) (types.PowerShapingParameters, error) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ConsumerIdToPowerShapingParametersKey(consumerId)) - if bz == nil { - return types.PowerShapingParameters{}, fmt.Errorf("failed to retrieve power-shaping parameters for consumer id (%s)", consumerId) - } - var record types.PowerShapingParameters - if err := record.Unmarshal(bz); err != nil { - return types.PowerShapingParameters{}, fmt.Errorf("failed to unmarshal power-shaping parameters for consumer id (%s): %w", consumerId, err) - } - return record, nil -} - -// SetConsumerPowerShapingParameters sets the power-shaping parameters associated with this consumer id -func (k Keeper) SetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string, parameters types.PowerShapingParameters) error { - store := ctx.KVStore(k.storeKey) - bz, err := parameters.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal power-shaping parameters (%+v) for consumer id (%s): %w", parameters, consumerId, err) - } - store.Set(types.ConsumerIdToPowerShapingParametersKey(consumerId), bz) - return nil -} - -// DeleteConsumerPowerShapingParameters deletes the power-shaping parameters associated with this consumer id -func (k Keeper) DeleteConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerIdToPowerShapingParametersKey(consumerId)) -} - // GetConsumerPhase returns the phase associated with this consumer id func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) types.ConsumerPhase { store := ctx.KVStore(k.storeKey) diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index 20a929f595..049b5d92c1 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -179,49 +179,6 @@ func TestConsumerInitializationParameters(t *testing.T) { require.Equal(t, providertypes.ConsumerInitializationParameters{}, actualInitializationParameters) } -// TestConsumerPowerShapingParameters tests the getter, setter, and deletion of the consumer id to power-shaping parameters methods -func TestConsumerPowerShapingParameters(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.Error(t, err) - - expectedPowerShapingParameters := providertypes.PowerShapingParameters{ - Top_N: 10, - ValidatorsPowerCap: 34, - ValidatorSetCap: 10, - Allowlist: []string{"allowlist1", "allowlist2"}, - Denylist: []string{"denylist1", "denylist2"}, - MinStake: 234, - AllowInactiveVals: true, - } - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", expectedPowerShapingParameters) - actualPowerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.NoError(t, err) - require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) - - // assert that overwriting the current initialization record works - expectedPowerShapingParameters = providertypes.PowerShapingParameters{ - Top_N: 12, - ValidatorsPowerCap: 67, - ValidatorSetCap: 20, - Allowlist: []string{"allowlist3", "allowlist4"}, - Denylist: []string{"denylist3", "denylist4"}, - MinStake: 567, - AllowInactiveVals: false, - } - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", expectedPowerShapingParameters) - actualPowerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.NoError(t, err) - require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) - - providerKeeper.DeleteConsumerPowerShapingParameters(ctx, "consumerId") - actualPowerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.Error(t, err) - require.Equal(t, providertypes.PowerShapingParameters{}, actualPowerShapingParameters) -} - // TestConsumerPhase tests the getter, setter, and deletion of the consumer id to phase methods func TestConsumerPhase(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) diff --git a/x/ccv/provider/keeper/power_shaping.go b/x/ccv/provider/keeper/power_shaping.go new file mode 100644 index 0000000000..c54ca41e4e --- /dev/null +++ b/x/ccv/provider/keeper/power_shaping.go @@ -0,0 +1,286 @@ +package keeper + +import ( + "encoding/binary" + "errors" + "fmt" + + errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" +) + +// GetConsumerPowerShapingParameters returns the power-shaping parameters associated with this consumer id +func (k Keeper) GetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string) (types.PowerShapingParameters, error) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerIdToPowerShapingParametersKey(consumerId)) + if bz == nil { + return types.PowerShapingParameters{}, errorsmod.Wrapf(ccvtypes.ErrStoreKeyNotFound, + "GetConsumerPowerShapingParameters, consumerId(%s)", consumerId) + } + var parameters types.PowerShapingParameters + if err := parameters.Unmarshal(bz); err != nil { + return types.PowerShapingParameters{}, errorsmod.Wrapf(ccvtypes.ErrStoreUnmarshal, + "GetConsumerPowerShapingParameters, consumerId(%s): %s", consumerId, err.Error()) + } + return parameters, nil +} + +// SetConsumerPowerShapingParameters sets the power-shaping parameters associated with this consumer id. +// Note that it also updates the allowlist and denylist indexes if they are different +func (k Keeper) SetConsumerPowerShapingParameters(ctx sdk.Context, consumerId string, parameters types.PowerShapingParameters) error { + store := ctx.KVStore(k.storeKey) + bz, err := parameters.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal power-shaping parameters (%+v) for consumer id (%s): %w", parameters, consumerId, err) + } + + // get old power shaping params + oldParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) + // ignore ErrStoreKeyNotFound errors as this might be the first time the power shaping params are set + if errors.Is(err, ccvtypes.ErrStoreUnmarshal) { + return fmt.Errorf("cannot get consumer previous power shaping parameters: %w", err) + } + + store.Set(types.ConsumerIdToPowerShapingParametersKey(consumerId), bz) + + // update allowlist and denylist indexes if needed + if !equalStringSlices(oldParameters.Allowlist, parameters.Allowlist) { + k.UpdateAllowlist(ctx, consumerId, parameters.Allowlist) + } + if !equalStringSlices(oldParameters.Denylist, parameters.Denylist) { + k.UpdateDenylist(ctx, consumerId, parameters.Denylist) + } + + return nil +} + +// equalStringSlices returns true if two string slices are equal +func equalStringSlices(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i, v := range a { + if v != b[i] { + return false + } + } + return true +} + +// SetAllowlist allowlists validator with `providerAddr` address on chain `consumerId` +func (k Keeper) SetAllowlist( + ctx sdk.Context, + consumerId string, + providerAddr types.ProviderConsAddress, +) { + store := ctx.KVStore(k.storeKey) + store.Set(types.AllowlistKey(consumerId, providerAddr), []byte{}) +} + +// GetAllowList returns all allowlisted validators +func (k Keeper) GetAllowList( + ctx sdk.Context, + consumerId string, +) (providerConsAddresses []types.ProviderConsAddress) { + store := ctx.KVStore(k.storeKey) + key := types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId) + iterator := storetypes.KVStorePrefixIterator(store, key) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + providerConsAddresses = append(providerConsAddresses, types.NewProviderConsAddress(iterator.Key()[len(key):])) + } + + return providerConsAddresses +} + +// IsAllowlisted returns `true` if validator with `providerAddr` has been allowlisted on chain `consumerId` +func (k Keeper) IsAllowlisted( + ctx sdk.Context, + consumerId string, + providerAddr types.ProviderConsAddress, +) bool { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.AllowlistKey(consumerId, providerAddr)) + return bz != nil +} + +// DeleteAllowlist deletes all allowlisted validators +func (k Keeper) DeleteAllowlist(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) + defer iterator.Close() + + keysToDel := [][]byte{} + for ; iterator.Valid(); iterator.Next() { + keysToDel = append(keysToDel, iterator.Key()) + } + + for _, key := range keysToDel { + store.Delete(key) + } +} + +// IsAllowlistEmpty returns `true` if no validator is allowlisted on chain `consumerId` +func (k Keeper) IsAllowlistEmpty(ctx sdk.Context, consumerId string) bool { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.AllowlistKeyPrefix(), consumerId)) + defer iterator.Close() + + return !iterator.Valid() +} + +// UpdateAllowlist populates the allowlist store for the consumer chain with this consumer id +func (k Keeper) UpdateAllowlist(ctx sdk.Context, consumerId string, allowlist []string) { + k.DeleteAllowlist(ctx, consumerId) + for _, address := range allowlist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetAllowlist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } +} + +// SetDenylist denylists validator with `providerAddr` address on chain `consumerId` +func (k Keeper) SetDenylist( + ctx sdk.Context, + consumerId string, + providerAddr types.ProviderConsAddress, +) { + store := ctx.KVStore(k.storeKey) + store.Set(types.DenylistKey(consumerId, providerAddr), []byte{}) +} + +// GetDenyList returns all denylisted validators +func (k Keeper) GetDenyList( + ctx sdk.Context, + consumerId string, +) (providerConsAddresses []types.ProviderConsAddress) { + store := ctx.KVStore(k.storeKey) + key := types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId) + iterator := storetypes.KVStorePrefixIterator(store, key) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + providerConsAddresses = append(providerConsAddresses, types.NewProviderConsAddress(iterator.Key()[len(key):])) + } + + return providerConsAddresses +} + +// IsDenylisted returns `true` if validator with `providerAddr` has been denylisted on chain `consumerId` +func (k Keeper) IsDenylisted( + ctx sdk.Context, + consumerId string, + providerAddr types.ProviderConsAddress, +) bool { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DenylistKey(consumerId, providerAddr)) + return bz != nil +} + +// DeleteDenylist deletes all denylisted validators +func (k Keeper) DeleteDenylist(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) + defer iterator.Close() + + keysToDel := [][]byte{} + for ; iterator.Valid(); iterator.Next() { + keysToDel = append(keysToDel, iterator.Key()) + } + + for _, key := range keysToDel { + store.Delete(key) + } +} + +// IsDenylistEmpty returns `true` if no validator is denylisted on chain `consumerId` +func (k Keeper) IsDenylistEmpty(ctx sdk.Context, consumerId string) bool { + store := ctx.KVStore(k.storeKey) + iterator := storetypes.KVStorePrefixIterator(store, types.StringIdWithLenKey(types.DenylistKeyPrefix(), consumerId)) + defer iterator.Close() + + return !iterator.Valid() +} + +// UpdateDenylist populates the denylist store for the consumer chain with this consumer id +func (k Keeper) UpdateDenylist(ctx sdk.Context, consumerId string, denylist []string) { + k.DeleteDenylist(ctx, consumerId) + for _, address := range denylist { + consAddr, err := sdk.ConsAddressFromBech32(address) + if err != nil { + continue + } + + k.SetDenylist(ctx, consumerId, types.NewProviderConsAddress(consAddr)) + } +} + +// SetMinimumPowerInTopN sets the minimum power required for a validator to be in the top N +// for a given consumer chain. +func (k Keeper) SetMinimumPowerInTopN( + ctx sdk.Context, + consumerId string, + power int64, +) { + store := ctx.KVStore(k.storeKey) + + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, uint64(power)) + + store.Set(types.MinimumPowerInTopNKey(consumerId), buf) +} + +// GetMinimumPowerInTopN returns the minimum power required for a validator to be in the top N +// for a given consumer chain. +func (k Keeper) GetMinimumPowerInTopN( + ctx sdk.Context, + consumerId string, +) (int64, bool) { + store := ctx.KVStore(k.storeKey) + buf := store.Get(types.MinimumPowerInTopNKey(consumerId)) + if buf == nil { + return 0, false + } + return int64(binary.BigEndian.Uint64(buf)), true +} + +// DeleteMinimumPowerInTopN removes the minimum power required for a validator to be in the top N +// for a given consumer chain. +func (k Keeper) DeleteMinimumPowerInTopN( + ctx sdk.Context, + consumerId string, +) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.MinimumPowerInTopNKey(consumerId)) +} + +// UpdateMinimumPowerInTopN populates the minimum power in Top N for the consumer chain with this consumer id +func (k Keeper) UpdateMinimumPowerInTopN(ctx sdk.Context, consumerId string, oldTopN uint32, newTopN uint32) error { + // if the top N changes, we need to update the new minimum power in top N + if newTopN != oldTopN { + if newTopN > 0 { + // if the chain receives a non-zero top N value, store the minimum power in the top N + bondedValidators, err := k.GetLastProviderConsensusActiveValidators(ctx) + if err != nil { + return err + } + minPower, err := k.ComputeMinPowerInTopN(ctx, bondedValidators, newTopN) + if err != nil { + return err + } + k.SetMinimumPowerInTopN(ctx, consumerId, minPower) + } else { + // if the chain receives a zero top N value, we delete the min power + k.DeleteMinimumPowerInTopN(ctx, consumerId) + } + } + + return nil +} diff --git a/x/ccv/provider/keeper/power_shaping_test.go b/x/ccv/provider/keeper/power_shaping_test.go new file mode 100644 index 0000000000..bcf49373c6 --- /dev/null +++ b/x/ccv/provider/keeper/power_shaping_test.go @@ -0,0 +1,313 @@ +package keeper_test + +import ( + "bytes" + "errors" + "sort" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + testkeeper "github.com/cosmos/interchain-security/v5/testutil/keeper" + providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" +) + +// TestConsumerPowerShapingParameters tests the getter and setter of the consumer id to power-shaping parameters methods +func TestConsumerPowerShapingParameters(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "consumerId" + consAddrs := []string{ + "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + "cosmosvalcons1muys5jyqk4xd27e208nym85kn0t4zjcfeu63fe", + "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + } + providerConsAddr := []providertypes.ProviderConsAddress{} + for _, addr := range consAddrs { + ca, _ := sdk.ConsAddressFromBech32(addr) + providerConsAddr = append(providerConsAddr, providertypes.NewProviderConsAddress(ca)) + } + sortProviderConsAddr := func(consAddrs []providertypes.ProviderConsAddress) { + sort.Slice(consAddrs, func(i, j int) bool { + return bytes.Compare(consAddrs[i].Address, consAddrs[j].Address) < 0 + }) + } + + _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + require.Error(t, err) + require.True(t, errors.Is(err, ccvtypes.ErrStoreKeyNotFound)) + + expectedPowerShapingParameters := providertypes.PowerShapingParameters{ + Top_N: 10, + ValidatorsPowerCap: 34, + ValidatorSetCap: 10, + Allowlist: []string{consAddrs[0], consAddrs[1]}, + Denylist: []string{consAddrs[2], consAddrs[3]}, + MinStake: 234, + AllowInactiveVals: true, + } + expectedAllowlist := []providertypes.ProviderConsAddress{providerConsAddr[0], providerConsAddr[1]} + sortProviderConsAddr(expectedAllowlist) + expectedDenylist := []providertypes.ProviderConsAddress{providerConsAddr[2], providerConsAddr[3]} + sortProviderConsAddr(expectedDenylist) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, expectedPowerShapingParameters) + require.NoError(t, err) + actualPowerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) + require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) + require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) + + // assert that overwriting the current initialization record works + expectedPowerShapingParameters = providertypes.PowerShapingParameters{ + Top_N: 12, + ValidatorsPowerCap: 67, + ValidatorSetCap: 20, + Allowlist: []string{consAddrs[4], consAddrs[5]}, + Denylist: []string{consAddrs[2], consAddrs[3]}, + MinStake: 567, + AllowInactiveVals: false, + } + expectedAllowlist = []providertypes.ProviderConsAddress{providerConsAddr[4], providerConsAddr[5]} + sortProviderConsAddr(expectedAllowlist) + expectedDenylist = []providertypes.ProviderConsAddress{providerConsAddr[2], providerConsAddr[3]} + sortProviderConsAddr(expectedDenylist) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, expectedPowerShapingParameters) + require.NoError(t, err) + actualPowerShapingParameters, err = providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + require.NoError(t, err) + require.Equal(t, expectedPowerShapingParameters, actualPowerShapingParameters) + require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) + require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) +} + +// TestAllowlist tests the `SetAllowlist`, `IsAllowlisted`, `DeleteAllowlist`, and `IsAllowlistEmpty` methods +func TestAllowlist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + chainID := "consumerId" + + // no validator was allowlisted and hence the allowlist is empty + require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) + + providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) + providerKeeper.SetAllowlist(ctx, chainID, providerAddr1) + require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr1)) + + // allowlist is not empty anymore + require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) + + providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) + providerKeeper.SetAllowlist(ctx, chainID, providerAddr2) + require.True(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr2)) + require.False(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) + + providerKeeper.DeleteAllowlist(ctx, chainID) + require.False(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr1)) + require.False(t, providerKeeper.IsAllowlisted(ctx, chainID, providerAddr2)) + require.True(t, providerKeeper.IsAllowlistEmpty(ctx, chainID)) +} + +func TestUpdateAllowlist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateAllowlist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedAllowlist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedAllowlist, providerKeeper.GetAllowList(ctx, consumerId)) +} + +// TestDenylist tests the `SetDenylist`, `IsDenylisted`, `DeleteDenylist`, and `IsDenylistEmpty` methods +func TestDenylist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + chainID := "consumerId" + + // no validator was denylisted and hence the denylist is empty + require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) + + providerAddr1 := providertypes.NewProviderConsAddress([]byte("providerAddr1")) + providerKeeper.SetDenylist(ctx, chainID, providerAddr1) + require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr1)) + + // denylist is not empty anymore + require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) + + providerAddr2 := providertypes.NewProviderConsAddress([]byte("providerAddr2")) + providerKeeper.SetDenylist(ctx, chainID, providerAddr2) + require.True(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr2)) + require.False(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) + + providerKeeper.DeleteDenylist(ctx, chainID) + require.False(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr1)) + require.False(t, providerKeeper.IsDenylisted(ctx, chainID, providerAddr2)) + require.True(t, providerKeeper.IsDenylistEmpty(ctx, chainID)) +} + +func TestUpdateDenylist(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + providerConsAddr1 := "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq" + consAddr1, _ := sdk.ConsAddressFromBech32(providerConsAddr1) + providerConsAddr2 := "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39" + consAddr2, _ := sdk.ConsAddressFromBech32(providerConsAddr2) + + providerKeeper.UpdateDenylist(ctx, consumerId, []string{providerConsAddr1, providerConsAddr2}) + + expectedDenylist := []providertypes.ProviderConsAddress{ + providertypes.NewProviderConsAddress(consAddr1), + providertypes.NewProviderConsAddress(consAddr2)} + require.Equal(t, expectedDenylist, providerKeeper.GetDenyList(ctx, consumerId)) +} + +// Tests setting, getting and deleting parameters that are stored per-consumer chain. +// The tests cover the following parameters: +// - MinimumPowerInTopN +func TestKeeperConsumerParams(t *testing.T) { + k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + + tests := []struct { + name string + settingFunc func(sdk.Context, string, int64) + getFunc func(sdk.Context, string) int64 + deleteFunc func(sdk.Context, string) + initialValue int64 + updatedValue int64 + }{ + { + name: "Minimum Power In Top N", + settingFunc: func(ctx sdk.Context, id string, val int64) { k.SetMinimumPowerInTopN(ctx, id, val) }, + getFunc: func(ctx sdk.Context, id string) int64 { + minimumPowerInTopN, _ := k.GetMinimumPowerInTopN(ctx, id) + return minimumPowerInTopN + }, + deleteFunc: func(ctx sdk.Context, id string) { k.DeleteMinimumPowerInTopN(ctx, id) }, + initialValue: 1000, + updatedValue: 2000, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + chainID := "consumerId" + // Set initial value + tt.settingFunc(ctx, chainID, int64(tt.initialValue)) + + // Retrieve and check initial value + actualValue := tt.getFunc(ctx, chainID) + require.EqualValues(t, tt.initialValue, actualValue) + + // Update value + tt.settingFunc(ctx, chainID, int64(tt.updatedValue)) + + // Retrieve and check updated value + newActualValue := tt.getFunc(ctx, chainID) + require.EqualValues(t, tt.updatedValue, newActualValue) + + // Check non-existent consumer id + res := tt.getFunc(ctx, "not the consumerId") + require.Zero(t, res) + + // Delete value + tt.deleteFunc(ctx, chainID) + + // Check that value was deleted + res = tt.getFunc(ctx, chainID) + require.Zero(t, res) + + // Try deleting again + tt.deleteFunc(ctx, chainID) + + // Check that the value is still deleted + res = tt.getFunc(ctx, chainID) + require.Zero(t, res) + }) + } +} + +func TestUpdateMinimumPowerInTopN(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + consumerId := "0" + + // test case where Top N is 0 in which case there's no minimum power in top N + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 0, + }) + require.NoError(t, err) + + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 0) + require.NoError(t, err) + _, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.False(t, found) + + // test cases where Top N > 0 and for this we mock some validators + powers := []int64{10, 20, 30} + validators := []stakingtypes.Validator{ + createStakingValidator(ctx, mocks, powers[0], 1), // this validator has ~16 of the total voting power + createStakingValidator(ctx, mocks, powers[1], 2), // this validator has ~33% of the total voting gpower + createStakingValidator(ctx, mocks, powers[2], 3), // this validator has 50% of the total voting power + } + mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(validators, nil).AnyTimes() + + maxProviderConsensusValidators := int64(3) + params := providerKeeper.GetParams(ctx) + params.MaxProviderConsensusValidators = maxProviderConsensusValidators + providerKeeper.SetParams(ctx, params) + + // when top N is 50, the minimum power is 30 (because top validator has to validate) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 50, + }) + require.NoError(t, err) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 0, 50) + require.NoError(t, err) + minimumPowerInTopN, found := providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(30), minimumPowerInTopN) + + // when top N is 51, the minimum power is 20 (because top 2 validators have to validate) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 51, + }) + require.NoError(t, err) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 50, 51) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(20), minimumPowerInTopN) + + // when top N is 100, the minimum power is 10 (that of the validator with the lowest power) + err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{ + Top_N: 100, + }) + require.NoError(t, err) + err = providerKeeper.UpdateMinimumPowerInTopN(ctx, consumerId, 51, 100) + require.NoError(t, err) + minimumPowerInTopN, found = providerKeeper.GetMinimumPowerInTopN(ctx, consumerId) + require.True(t, found) + require.Equal(t, int64(10), minimumPowerInTopN) +} diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index acdceb5ea2..e45fedf35a 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -588,9 +588,10 @@ func TestEndBlockVSU(t *testing.T) { chainID := "consumerId" - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ Top_N: 100, }) + require.NoError(t, err) // 10 blocks constitute an epoch params := providertypes.DefaultParams() @@ -741,10 +742,11 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { // add a consumer chain providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") - providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ + err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ Top_N: 50, // would opt in E ValidatorsPowerCap: 40, // set a power-capping of 40% }) + require.NoError(t, err) // opt in all validators providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) diff --git a/x/ccv/types/errors.go b/x/ccv/types/errors.go index e492984e48..995d9905e8 100644 --- a/x/ccv/types/errors.go +++ b/x/ccv/types/errors.go @@ -22,4 +22,6 @@ var ( ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 14, "consumer chain already exists") ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 15, "consumer chain not found") ErrInvalidDoubleVotingEvidence = errorsmod.Register(ModuleName, 16, "invalid consumer double voting evidence") + ErrStoreKeyNotFound = errorsmod.Register(ModuleName, 17, "store key not found") + ErrStoreUnmarshal = errorsmod.Register(ModuleName, 18, "cannot unmarshal value from store") ) From cb6b525b35aea080e5b6fbcd127660acc6deb8cf Mon Sep 17 00:00:00 2001 From: mpoke Date: Tue, 3 Sep 2024 19:31:03 +0200 Subject: [PATCH 28/43] fix merge conflicts --- x/ccv/provider/keeper/relay.go | 2 +- x/ccv/provider/keeper/relay_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index f3f4da9e4e..cbd429c008 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -183,7 +183,7 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId str // If this happens, most likely the consumer is malicious; remove it err := k.StopConsumerChain(ctx, consumerId, true) if err != nil { - return fmt.Errorf("stopping consumer, chainID(%s): %w", chainID, err) + return fmt.Errorf("stopping consumer, consumerId(%s): %w", consumerId, err) } return nil } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 26ce495fa5..70effd1753 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -127,7 +127,7 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{}) require.NoError(t, err) - err := providerKeeper.QueueVSCPackets(ctx) + err = providerKeeper.QueueVSCPackets(ctx) require.NoError(t, err) // the height of consumer validator A should not be modified because A was already a consumer validator @@ -626,7 +626,7 @@ func TestEndBlockVSU(t *testing.T) { // with block height of 1 we do not expect any queueing of VSC packets ctx = ctx.WithBlockHeight(1) - _, err := providerKeeper.EndBlockVSU(ctx) + _, err = providerKeeper.EndBlockVSU(ctx) require.NoError(t, err) require.Equal(t, 0, len(providerKeeper.GetPendingVSCPackets(ctx, chainID))) @@ -772,7 +772,7 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { params.MaxProviderConsensusValidators = 180 providerKeeper.SetParams(ctx, params) - err := providerKeeper.QueueVSCPackets(ctx) + err = providerKeeper.QueueVSCPackets(ctx) require.NoError(t, err) actualQueuedVSCPackets := providerKeeper.GetPendingVSCPackets(ctx, "consumerId") From 7301916eeafa3700a03d5ddf47a0779801c6d3a1 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Wed, 4 Sep 2024 09:15:45 +0200 Subject: [PATCH 29/43] feat: fix queries (#2209) * remove chain ID from all-pairs-valconsensus-address * add consumer_id to Chain * add GetAllLaunchedConsumerIds * fix UT * apply review suggestions --- .../ccv/provider/v1/query.proto | 20 +- x/ccv/provider/client/cli/query.go | 32 +- x/ccv/provider/keeper/grpc_query.go | 65 +-- x/ccv/provider/keeper/grpc_query_test.go | 90 +-- x/ccv/provider/keeper/keeper.go | 25 +- x/ccv/provider/types/query.pb.go | 549 ++++++++++-------- x/ccv/provider/types/query.pb.gw.go | 28 +- 7 files changed, 448 insertions(+), 361 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index f6d2f406aa..42c5f40974 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -64,11 +64,11 @@ service Query { "/interchain_security/ccv/provider/registered_consumer_reward_denoms"; } - // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address + // QueryAllPairsValConsAddrByConsumer returns a list of pair valconsensus address // between provider and consumer chain - rpc QueryAllPairsValConAddrByConsumerChainID ( - QueryAllPairsValConAddrByConsumerChainIDRequest) - returns (QueryAllPairsValConAddrByConsumerChainIDResponse) { + rpc QueryAllPairsValConsAddrByConsumer ( + QueryAllPairsValConsAddrByConsumerRequest) + returns (QueryAllPairsValConsAddrByConsumerResponse) { option (google.api.http) = { get: "/interchain_security/ccv/provider/address_pairs/{consumer_id}"; }; @@ -110,7 +110,7 @@ service Query { }; } - // QueryConsumerValidators returns the latest set consumer-validator set for a given chainID + // QueryConsumerValidators returns the latest set consumer-validator set for a given consumer ID // Note that this does not necessarily mean that the consumer chain is using this validator set at this exact moment // because a VSCPacket could be delayed to be delivered on the consumer chain. rpc QueryConsumerValidators(QueryConsumerValidatorsRequest) @@ -168,7 +168,6 @@ message QueryConsumerChainsResponse { repeated Chain chains = 1; } message Chain { string chain_id = 1; string client_id = 2; - // If chain with `chainID` is a Top-N chain, i.e., enforces at least one validator to validate chain `chainID` uint32 top_N = 3; // If the chain is a Top-N chain, this is the minimum power required to be in the top N. // Otherwise, this is -1. @@ -184,13 +183,14 @@ message Chain { // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. repeated string denylist = 8; // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) - ConsumerPhase phase = 9; + string phase = 9; // The metadata of the consumer chain ConsumerMetadata metadata = 10 [(gogoproto.nullable) = false ]; // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. uint64 min_stake = 11; // Corresponds to whether inactive validators are allowed to validate the consumer chain. bool allow_inactive_vals = 12; + string consumer_id = 13; } message QueryValidatorConsumerAddrRequest { @@ -241,12 +241,12 @@ message QueryRegisteredConsumerRewardDenomsResponse { repeated string denoms = 1; } -message QueryAllPairsValConAddrByConsumerChainIDRequest { +message QueryAllPairsValConsAddrByConsumerRequest { // The id of the consumer chain string consumer_id = 1; } -message QueryAllPairsValConAddrByConsumerChainIDResponse { +message QueryAllPairsValConsAddrByConsumerResponse { repeated PairValConAddrProviderAndConsumer pair_val_con_addr = 1; } @@ -332,7 +332,7 @@ message QueryConsumerChainsValidatorHasToValidateRequest { } message QueryConsumerChainsValidatorHasToValidateResponse { - repeated string consumer_chain_ids = 1; + repeated string consumer_ids = 1; } message QueryValidatorConsumerCommissionRateRequest { diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index be516d584f..c249aa5264 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -31,7 +31,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdProviderValidatorKey()) cmd.AddCommand(CmdThrottleState()) cmd.AddCommand(CmdRegisteredConsumerRewardDenoms()) - cmd.AddCommand(CmdAllPairsValConAddrByConsumerChainID()) + cmd.AddCommand(CmdAllPairsValConsAddrByConsumer()) cmd.AddCommand(CmdProviderParameters()) cmd.AddCommand(CmdConsumerChainOptedInValidators()) cmd.AddCommand(CmdConsumerValidators()) @@ -123,13 +123,13 @@ func CmdConsumerChains() *cobra.Command { func CmdConsumerValidatorKeyAssignment() *cobra.Command { bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() cmd := &cobra.Command{ - Use: "validator-consumer-key [chainid] [provider-validator-address]", + Use: "validator-consumer-key [consumerId] [provider-validator-address]", Short: "Query assigned validator consensus public key for a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Returns the currently assigned validator consensus public key for a consumer chain, if one has been assigned. Example: -$ %s query provider validator-consumer-key foochain %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj +$ %s query provider validator-consumer-key 3 %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj `, version.AppName, bech32PrefixConsAddr, ), @@ -285,10 +285,10 @@ $ %s query provider registered-consumer-reward-denoms return cmd } -func CmdAllPairsValConAddrByConsumerChainID() *cobra.Command { +func CmdAllPairsValConsAddrByConsumer() *cobra.Command { cmd := &cobra.Command{ - Use: "all-pairs-valconsensus-address [consumer-chain-id]", - Short: "Query all pairs of valconsensus address by consumer chainId.", + Use: "all-pairs-valconsensus-address [consumer-id]", + Short: "Query all pairs of valconsensus address by consumer ID.", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -297,8 +297,8 @@ func CmdAllPairsValConAddrByConsumerChainID() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - req := types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: args[0]} - res, err := queryClient.QueryAllPairsValConAddrByConsumerChainID(cmd.Context(), &req) + req := types.QueryAllPairsValConsAddrByConsumerRequest{ConsumerId: args[0]} + res, err := queryClient.QueryAllPairsValConsAddrByConsumer(cmd.Context(), &req) if err != nil { return err } @@ -346,15 +346,15 @@ $ %s query provider params return cmd } -// Command to query opted-in validators by consumer chain ID +// Command to query opted-in validators by consumer ID func CmdConsumerChainOptedInValidators() *cobra.Command { cmd := &cobra.Command{ - Use: "consumer-opted-in-validators [chainid]", + Use: "consumer-opted-in-validators [consumer-id]", Short: "Query opted-in validators for a given consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Query opted-in validators for a given consumer chain. Example: -$ %s consumer-opted-in-validators foochain +$ %s consumer-opted-in-validators 3 `, version.AppName), ), Args: cobra.ExactArgs(1), @@ -380,16 +380,16 @@ $ %s consumer-opted-in-validators foochain return cmd } -// Command to query the consumer validators by consumer chain ID +// Command to query the consumer validators by consumer ID func CmdConsumerValidators() *cobra.Command { cmd := &cobra.Command{ - Use: "consumer-validators [chainid]", + Use: "consumer-validators [consumer-id]", Short: "Query the last set consumer-validator set for a given consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Query the last set consumer-validator set for a given consumer chain. Note that this does not necessarily mean that the consumer chain is currently using this validator set because a VSCPacket could be delayed, etc. Example: -$ %s consumer-validators foochain +$ %s consumer-validators 3 `, version.AppName), ), Args: cobra.ExactArgs(1), @@ -462,12 +462,12 @@ $ %s has-to-validate %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj func CmdValidatorConsumerCommissionRate() *cobra.Command { bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() cmd := &cobra.Command{ - Use: "validator-consumer-commission-rate [chainid] [provider-validator-address]", + Use: "validator-consumer-commission-rate [consumer-id] [provider-validator-address]", Short: "Query the consumer commission rate a validator charges on a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Query the consumer commission rate a validator charges on a consumer chain. Example: -$ %s validator-consumer-commission-rate foochain %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj +$ %s validator-consumer-commission-rate 3 %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj `, version.AppName, bech32PrefixConsAddr), ), Args: cobra.ExactArgs(2), diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 57dd6ce317..08c93fae08 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -5,14 +5,12 @@ import ( "context" "fmt" "sort" - "strconv" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" @@ -51,31 +49,13 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu ctx := sdk.UnwrapSDKContext(goCtx) consumerIds := []string{} - phaseFilter := req.Phase - - // if the phase filter is set Launched get consumer from the state directly - if phaseFilter == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { - consumerIds = append(consumerIds, k.GetAllRegisteredConsumerIds(ctx)...) - // otherwise iterate over all the consumer using the last unused consumer Id - } else { - firstUnusedConsumerId, ok := k.GetConsumerId(ctx) - if !ok { - return &types.QueryConsumerChainsResponse{}, nil - } - for i := uint64(0); i < firstUnusedConsumerId; i++ { - // if the phase filter is set, verify that the consumer has the same phase - if phaseFilter != types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { - p := k.GetConsumerPhase(ctx, strconv.FormatInt(int64(i), 10)) - if p == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { - return nil, status.Error(codes.Internal, fmt.Sprintf("cannot retrieve phase for consumer id: %d", i)) - } - if p != phaseFilter { - continue - } - } - - consumerIds = append(consumerIds, strconv.FormatInt(int64(i), 10)) + for _, consumerID := range k.GetAllConsumerIds(ctx) { + phase := k.GetConsumerPhase(ctx, consumerID) + if req.Phase != types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED && req.Phase != phase { + // ignore consumer chain + continue } + consumerIds = append(consumerIds, consumerID) } // set limit to default value @@ -84,12 +64,12 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu // update limit if specified limit = int(req.Limit) } + if len(consumerIds) > limit { + consumerIds = consumerIds[:limit] + } - chains := make([]*types.Chain, math.Min(len(consumerIds), limit)) + chains := make([]*types.Chain, len(consumerIds)) for i, cID := range consumerIds { - if i == limit { - break - } c, err := k.GetConsumerChain(ctx, cID) if err != nil { return nil, status.Error(codes.Internal, err.Error()) @@ -108,6 +88,7 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai } clientID, _ := k.GetConsumerClientId(ctx, consumerId) + powerShapingParameters, err := k.GetConsumerPowerShapingParameters(ctx, consumerId) if err != nil { return types.Chain{}, fmt.Errorf("cannot find power shaping parameters for consumer (%s): %s", consumerId, err.Error()) @@ -116,15 +97,9 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai // Get the minimal power in the top N for the consumer chain minPowerInTopN, found := k.GetMinimumPowerInTopN(ctx, consumerId) if !found { - k.Logger(ctx).Error("failed to get minimum power in top N, treating as -1", "chain", consumerId) minPowerInTopN = -1 } - phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { - return types.Chain{}, fmt.Errorf("cannot find phase for consumer (%s)", consumerId) - } - allowlist := k.GetAllowList(ctx, consumerId) strAllowlist := make([]string, len(allowlist)) for i, addr := range allowlist { @@ -148,10 +123,11 @@ func (k Keeper) GetConsumerChain(ctx sdk.Context, consumerId string) (types.Chai ValidatorsPowerCap: powerShapingParameters.ValidatorsPowerCap, Allowlist: strAllowlist, Denylist: strDenylist, - Phase: phase, + Phase: k.GetConsumerPhase(ctx, consumerId).String(), Metadata: metadata, AllowInactiveVals: powerShapingParameters.AllowInactiveVals, MinStake: powerShapingParameters.MinStake, + ConsumerId: consumerId, }, nil } @@ -243,7 +219,10 @@ func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req * }, nil } -func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, req *types.QueryAllPairsValConAddrByConsumerChainIDRequest) (*types.QueryAllPairsValConAddrByConsumerChainIDResponse, error) { +func (k Keeper) QueryAllPairsValConsAddrByConsumer( + goCtx context.Context, + req *types.QueryAllPairsValConsAddrByConsumerRequest, +) (*types.QueryAllPairsValConsAddrByConsumerResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } @@ -270,7 +249,7 @@ func (k Keeper) QueryAllPairsValConAddrByConsumerChainID(goCtx context.Context, }) } - return &types.QueryAllPairsValConAddrByConsumerChainIDResponse{ + return &types.QueryAllPairsValConsAddrByConsumerResponse{ PairValConAddr: pairValConAddrs, }, nil } @@ -445,14 +424,14 @@ func (k Keeper) QueryConsumerChainsValidatorHasToValidate(goCtx context.Context, // get all the consumer chains for which the validator is either already // opted-in, currently a consumer validator or if its voting power is within the TopN validators consumersToValidate := []string{} - for _, consumerChainID := range k.GetAllRegisteredConsumerIds(ctx) { - if hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerChainID); err == nil && hasToValidate { - consumersToValidate = append(consumersToValidate, consumerChainID) + for _, consumerId := range k.GetAllLaunchedConsumerIds(ctx) { + if hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerId); err == nil && hasToValidate { + consumersToValidate = append(consumersToValidate, consumerId) } } return &types.QueryConsumerChainsValidatorHasToValidateResponse{ - ConsumerChainIds: consumersToValidate, + ConsumerIds: consumersToValidate, }, nil } diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 9d91bd25f7..5c55979dfa 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -6,7 +6,6 @@ import ( "sort" "strconv" "testing" - "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -25,7 +24,7 @@ import ( ccvtypes "github.com/cosmos/interchain-security/v5/x/ccv/types" ) -func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { +func TestQueryAllPairsValConsAddrByConsumer(t *testing.T) { consumerId := "0" providerConsAddress, err := sdk.ConsAddressFromBech32("cosmosvalcons1wpex7anfv3jhystyv3eq20r35a") @@ -47,19 +46,19 @@ func TestQueryAllPairsValConAddrByConsumerChainID(t *testing.T) { require.Equal(t, consumerPubKey, consumerKey) // Request is nil - _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, nil) + _, err = pk.QueryAllPairsValConsAddrByConsumer(ctx, nil) require.Error(t, err) // Request with empty consumer id - _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{}) + _, err = pk.QueryAllPairsValConsAddrByConsumer(ctx, &types.QueryAllPairsValConsAddrByConsumerRequest{}) require.Error(t, err) // Request with invalid consumer id - _, err = pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: "invalidConsumerId"}) + _, err = pk.QueryAllPairsValConsAddrByConsumer(ctx, &types.QueryAllPairsValConsAddrByConsumerRequest{ConsumerId: "invalidConsumerId"}) require.Error(t, err) // Request is valid - response, err := pk.QueryAllPairsValConAddrByConsumerChainID(ctx, &types.QueryAllPairsValConAddrByConsumerChainIDRequest{ConsumerId: consumerId}) + response, err := pk.QueryAllPairsValConsAddrByConsumer(ctx, &types.QueryAllPairsValConsAddrByConsumerRequest{ConsumerId: consumerId}) require.NoError(t, err) expectedResult := types.PairValConAddrProviderAndConsumer{ @@ -304,16 +303,28 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { ProviderAddress: providerAddr.String(), } + consumerNum := 4 + consumerIds := make([]string, consumerNum) + + msgServer := keeper.NewMsgServerImpl(&pk) + // set up some consumer chains - consumerIDs := []string{"1", "23", "456", "6789"} - for _, cID := range consumerIDs { - pk.SetConsumerClientId(ctx, cID, "clientID") - err := pk.SetConsumerPowerShapingParameters(ctx, cID, types.PowerShapingParameters{}) + for i := 0; i < consumerNum; i++ { + chainID := "consumer-" + strconv.Itoa(i) + metadata := types.ConsumerMetadata{Name: chainID} + msg := types.MsgCreateConsumer{ + ChainId: chainID, + Metadata: metadata, + } + resp, err := msgServer.CreateConsumer(ctx, &msg) require.NoError(t, err) + consumerId := resp.ConsumerId + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + consumerIds[i] = consumerId } // set `providerAddr` as a consumer validator on first consumer chain - pk.SetConsumerValidator(ctx, consumerIDs[0], types.ConsensusValidator{ + pk.SetConsumerValidator(ctx, consumerIds[0], types.ConsensusValidator{ ProviderConsAddr: providerAddr.ToSdkConsAddr(), Power: 1, PublicKey: &crypto.PublicKey{ @@ -324,7 +335,7 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { }) // set `providerAddr` as an opted-in validator on third consumer chain - pk.SetOptedIn(ctx, consumerIDs[2], providerAddr) + pk.SetOptedIn(ctx, consumerIds[2], providerAddr) // set max provider consensus vals to include all validators params := pk.GetParams(ctx) @@ -334,11 +345,11 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { // `providerAddr` has to validate // - first consumer because it is a consumer validator in this chain, // - third consumer because it opted in - expectedChains := []string{consumerIDs[0], consumerIDs[2]} + expectedChains := []string{consumerIds[0], consumerIds[2]} res, err := pk.QueryConsumerChainsValidatorHasToValidate(ctx, &req) require.NoError(t, err) - require.Equal(t, expectedChains, res.ConsumerChainIds) + require.Equal(t, expectedChains, res.ConsumerIds) } func TestQueryValidatorConsumerCommissionRate(t *testing.T) { @@ -487,10 +498,11 @@ func TestGetConsumerChain(t *testing.T) { ValidatorsPowerCap: validatorPowerCaps[i], Allowlist: strAllowlist, Denylist: strDenylist, - Phase: phase, + Phase: phase.String(), Metadata: metadataLists[i], AllowInactiveVals: allowInactiveVals[i], MinStake: minStakes[i].Uint64(), + ConsumerId: consumerIDs[i], }) } @@ -603,10 +615,28 @@ func TestQueryConsumerChains(t *testing.T) { require.NoError(t, err) require.Len(t, res.Chains, 0) + msgServer := keeper.NewMsgServerImpl(&pk) + + phases := []types.ConsumerPhase{ + types.ConsumerPhase_CONSUMER_PHASE_REGISTERED, + types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, + types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, + types.ConsumerPhase_CONSUMER_PHASE_STOPPED, + } + // create four consumer chains in different phase for i := 0; i < consumerNum; i++ { - cID := pk.FetchAndIncrementConsumerId(ctx) chainID := "consumer-" + strconv.Itoa(i) + metadata := types.ConsumerMetadata{Name: chainID} + msg := types.MsgCreateConsumer{ + ChainId: chainID, + Metadata: metadata, + } + resp, err := msgServer.CreateConsumer(ctx, &msg) + require.NoError(t, err) + consumerId := resp.ConsumerId + + pk.SetConsumerPhase(ctx, consumerId, phases[i]) c := types.Chain{ ChainId: chainID, MinPowerInTop_N: -1, @@ -614,17 +644,11 @@ func TestQueryConsumerChains(t *testing.T) { ValidatorSetCap: 0, Allowlist: []string{}, Denylist: []string{}, - Phase: types.ConsumerPhase(i + 1), - Metadata: types.ConsumerMetadata{Name: chainID}, + Phase: phases[i].String(), + Metadata: metadata, + ConsumerId: consumerId, } - pk.SetConsumerPhase(ctx, cID, c.Phase) - err := pk.SetConsumerMetadata(ctx, cID, c.Metadata) - require.NoError(t, err) - err = pk.SetConsumerPowerShapingParameters(ctx, cID, types.PowerShapingParameters{}) - require.NoError(t, err) - pk.SetConsumerChainId(ctx, cID, chainID) - - consumerIds[i] = cID + consumerIds[i] = consumerId consumers[i] = &c } @@ -649,7 +673,7 @@ func TestQueryConsumerChains(t *testing.T) { { name: "expect registered consumers when phase filter is set to Registered", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[0].Phase = types.ConsumerPhase_CONSUMER_PHASE_REGISTERED + consumers[0].Phase = types.ConsumerPhase_CONSUMER_PHASE_REGISTERED.String() pk.SetConsumerPhase(ctx, consumerIds[0], types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) }, phase_filter: types.ConsumerPhase_CONSUMER_PHASE_REGISTERED, @@ -658,9 +682,7 @@ func TestQueryConsumerChains(t *testing.T) { { name: "expect initialized consumers when phase is set to Initialized", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[1].Phase = types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED - err := pk.AppendConsumerToBeLaunched(ctx, consumerIds[1], time.Now()) - require.NoError(t, err) + consumers[1].Phase = types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED.String() pk.SetConsumerPhase(ctx, consumerIds[1], types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) }, phase_filter: types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, @@ -669,9 +691,7 @@ func TestQueryConsumerChains(t *testing.T) { { name: "expect launched consumers when phase is set to Launched", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[2].Phase = types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED - consumers[2].ClientId = "ClientID" - pk.SetConsumerClientId(ctx, consumerIds[2], consumers[2].ClientId) + consumers[2].Phase = types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED.String() pk.SetConsumerPhase(ctx, consumerIds[2], types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) }, phase_filter: types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, @@ -680,7 +700,7 @@ func TestQueryConsumerChains(t *testing.T) { { name: "expect stopped consumers when phase is set to Stopped", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[3].Phase = types.ConsumerPhase_CONSUMER_PHASE_STOPPED + consumers[3].Phase = types.ConsumerPhase_CONSUMER_PHASE_STOPPED.String() pk.SetConsumerPhase(ctx, consumerIds[3], types.ConsumerPhase_CONSUMER_PHASE_STOPPED) }, phase_filter: types.ConsumerPhase_CONSUMER_PHASE_STOPPED, @@ -700,7 +720,7 @@ func TestQueryConsumerChains(t *testing.T) { } res, err := pk.QueryConsumerChains(ctx, &req) require.NoError(t, err) - require.Equal(t, &expectedResponse, res) + require.Equal(t, &expectedResponse, res, tc.name) }) } } diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index b4c037c0c3..5274753f31 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -712,8 +712,8 @@ func (k Keeper) BondDenom(ctx sdk.Context) (string, error) { return k.stakingKeeper.BondDenom(ctx) } -// GetAllActiveConsumerIds returns all the consumer ids of chains that are registered, initialized, or launched -func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { +// GetAllConsumerIds returns all the existing consumer ids +func (k Keeper) GetAllConsumerIds(ctx sdk.Context) []string { latestConsumerId, found := k.GetConsumerId(ctx) if !found { return []string{} @@ -722,12 +722,33 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { consumerIds := []string{} for i := uint64(0); i < latestConsumerId; i++ { consumerId := fmt.Sprintf("%d", i) + consumerIds = append(consumerIds, consumerId) + } + + return consumerIds +} + +// GetAllActiveConsumerIds returns all the consumer ids of chains that are registered, initialized, or launched +func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { + consumerIds := []string{} + for _, consumerId := range k.GetAllConsumerIds(ctx) { if !k.IsConsumerActive(ctx, consumerId) { continue } consumerIds = append(consumerIds, consumerId) } + return consumerIds +} +// GetAllLaunchedConsumerIds returns all the consumer ids of chains that are launched +func (k Keeper) GetAllLaunchedConsumerIds(ctx sdk.Context) []string { + consumerIds := []string{} + for _, consumerId := range k.GetAllConsumerIds(ctx) { + if phase := k.GetConsumerPhase(ctx, consumerId); phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + continue + } + consumerIds = append(consumerIds, consumerId) + } return consumerIds } diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 161c4e70f9..88d4b2ac69 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -229,8 +229,7 @@ func (m *QueryConsumerChainsResponse) GetChains() []*Chain { type Chain struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` - // If chain with `chainID` is a Top-N chain, i.e., enforces at least one validator to validate chain `chainID` - Top_N uint32 `protobuf:"varint,3,opt,name=top_N,json=topN,proto3" json:"top_N,omitempty"` + Top_N uint32 `protobuf:"varint,3,opt,name=top_N,json=topN,proto3" json:"top_N,omitempty"` // If the chain is a Top-N chain, this is the minimum power required to be in the top N. // Otherwise, this is -1. MinPowerInTop_N int64 `protobuf:"varint,4,opt,name=min_power_in_top_N,json=minPowerInTopN,proto3" json:"min_power_in_top_N,omitempty"` @@ -245,13 +244,14 @@ type Chain struct { // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) - Phase ConsumerPhase `protobuf:"varint,9,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` + Phase string `protobuf:"bytes,9,opt,name=phase,proto3" json:"phase,omitempty"` // The metadata of the consumer chain Metadata ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata"` // Corresponds to the minimal amount of (provider chain) stake required to validate on the consumer chain. MinStake uint64 `protobuf:"varint,11,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` // Corresponds to whether inactive validators are allowed to validate the consumer chain. - AllowInactiveVals bool `protobuf:"varint,12,opt,name=allow_inactive_vals,json=allowInactiveVals,proto3" json:"allow_inactive_vals,omitempty"` + AllowInactiveVals bool `protobuf:"varint,12,opt,name=allow_inactive_vals,json=allowInactiveVals,proto3" json:"allow_inactive_vals,omitempty"` + ConsumerId string `protobuf:"bytes,13,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } func (m *Chain) Reset() { *m = Chain{} } @@ -343,11 +343,11 @@ func (m *Chain) GetDenylist() []string { return nil } -func (m *Chain) GetPhase() ConsumerPhase { +func (m *Chain) GetPhase() string { if m != nil { return m.Phase } - return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED + return "" } func (m *Chain) GetMetadata() ConsumerMetadata { @@ -371,6 +371,13 @@ func (m *Chain) GetAllowInactiveVals() bool { return false } +func (m *Chain) GetConsumerId() string { + if m != nil { + return m.ConsumerId + } + return "" +} + type QueryValidatorConsumerAddrRequest struct { // The consensus address of the validator on the provider chain ProviderAddress string `protobuf:"bytes,1,opt,name=provider_address,json=providerAddress,proto3" json:"provider_address,omitempty" yaml:"address"` @@ -730,27 +737,27 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) GetDenoms() []string { return nil } -type QueryAllPairsValConAddrByConsumerChainIDRequest struct { +type QueryAllPairsValConsAddrByConsumerRequest struct { // The id of the consumer chain ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Reset() { - *m = QueryAllPairsValConAddrByConsumerChainIDRequest{} +func (m *QueryAllPairsValConsAddrByConsumerRequest) Reset() { + *m = QueryAllPairsValConsAddrByConsumerRequest{} } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) String() string { +func (m *QueryAllPairsValConsAddrByConsumerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllPairsValConAddrByConsumerChainIDRequest) ProtoMessage() {} -func (*QueryAllPairsValConAddrByConsumerChainIDRequest) Descriptor() ([]byte, []int) { +func (*QueryAllPairsValConsAddrByConsumerRequest) ProtoMessage() {} +func (*QueryAllPairsValConsAddrByConsumerRequest) Descriptor() ([]byte, []int) { return fileDescriptor_422512d7b7586cd7, []int{13} } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAllPairsValConsAddrByConsumerRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -760,45 +767,45 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Marshal(b []byte, return b[:n], nil } } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest.Merge(m, src) +func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPairsValConsAddrByConsumerRequest.Merge(m, src) } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_Size() int { +func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_Size() int { return m.Size() } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest.DiscardUnknown(m) +func (m *QueryAllPairsValConsAddrByConsumerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPairsValConsAddrByConsumerRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryAllPairsValConsAddrByConsumerRequest proto.InternalMessageInfo -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) GetConsumerId() string { +func (m *QueryAllPairsValConsAddrByConsumerRequest) GetConsumerId() string { if m != nil { return m.ConsumerId } return "" } -type QueryAllPairsValConAddrByConsumerChainIDResponse struct { +type QueryAllPairsValConsAddrByConsumerResponse struct { PairValConAddr []*PairValConAddrProviderAndConsumer `protobuf:"bytes,1,rep,name=pair_val_con_addr,json=pairValConAddr,proto3" json:"pair_val_con_addr,omitempty"` } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Reset() { - *m = QueryAllPairsValConAddrByConsumerChainIDResponse{} +func (m *QueryAllPairsValConsAddrByConsumerResponse) Reset() { + *m = QueryAllPairsValConsAddrByConsumerResponse{} } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) String() string { +func (m *QueryAllPairsValConsAddrByConsumerResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllPairsValConAddrByConsumerChainIDResponse) ProtoMessage() {} -func (*QueryAllPairsValConAddrByConsumerChainIDResponse) Descriptor() ([]byte, []int) { +func (*QueryAllPairsValConsAddrByConsumerResponse) ProtoMessage() {} +func (*QueryAllPairsValConsAddrByConsumerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_422512d7b7586cd7, []int{14} } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryAllPairsValConsAddrByConsumerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAllPairsValConsAddrByConsumerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAllPairsValConsAddrByConsumerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -808,19 +815,19 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Marshal(b []byte, return b[:n], nil } } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDResponse.Merge(m, src) +func (m *QueryAllPairsValConsAddrByConsumerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllPairsValConsAddrByConsumerResponse.Merge(m, src) } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_Size() int { +func (m *QueryAllPairsValConsAddrByConsumerResponse) XXX_Size() int { return m.Size() } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDResponse.DiscardUnknown(m) +func (m *QueryAllPairsValConsAddrByConsumerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllPairsValConsAddrByConsumerResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAllPairsValConAddrByConsumerChainIDResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryAllPairsValConsAddrByConsumerResponse proto.InternalMessageInfo -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) GetPairValConAddr() []*PairValConAddrProviderAndConsumer { +func (m *QueryAllPairsValConsAddrByConsumerResponse) GetPairValConAddr() []*PairValConAddrProviderAndConsumer { if m != nil { return m.PairValConAddr } @@ -1339,7 +1346,7 @@ func (m *QueryConsumerChainsValidatorHasToValidateRequest) GetProviderAddress() } type QueryConsumerChainsValidatorHasToValidateResponse struct { - ConsumerChainIds []string `protobuf:"bytes,1,rep,name=consumer_chain_ids,json=consumerChainIds,proto3" json:"consumer_chain_ids,omitempty"` + ConsumerIds []string `protobuf:"bytes,1,rep,name=consumer_ids,json=consumerIds,proto3" json:"consumer_ids,omitempty"` } func (m *QueryConsumerChainsValidatorHasToValidateResponse) Reset() { @@ -1379,9 +1386,9 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) XXX_DiscardUnknown() var xxx_messageInfo_QueryConsumerChainsValidatorHasToValidateResponse proto.InternalMessageInfo -func (m *QueryConsumerChainsValidatorHasToValidateResponse) GetConsumerChainIds() []string { +func (m *QueryConsumerChainsValidatorHasToValidateResponse) GetConsumerIds() []string { if m != nil { - return m.ConsumerChainIds + return m.ConsumerIds } return nil } @@ -1799,8 +1806,8 @@ func init() { proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateResponse") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsRequest)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsRequest") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsResponse") - proto.RegisterType((*QueryAllPairsValConAddrByConsumerChainIDRequest)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDRequest") - proto.RegisterType((*QueryAllPairsValConAddrByConsumerChainIDResponse)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConAddrByConsumerChainIDResponse") + proto.RegisterType((*QueryAllPairsValConsAddrByConsumerRequest)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConsAddrByConsumerRequest") + proto.RegisterType((*QueryAllPairsValConsAddrByConsumerResponse)(nil), "interchain_security.ccv.provider.v1.QueryAllPairsValConsAddrByConsumerResponse") proto.RegisterType((*PairValConAddrProviderAndConsumer)(nil), "interchain_security.ccv.provider.v1.PairValConAddrProviderAndConsumer") proto.RegisterType((*QueryParamsRequest)(nil), "interchain_security.ccv.provider.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "interchain_security.ccv.provider.v1.QueryParamsResponse") @@ -1826,155 +1833,156 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0x37, 0xe5, 0x8f, 0xc8, 0xe3, 0xc4, 0xbb, 0x99, 0x38, 0x89, 0x22, 0x27, 0x96, 0xc3, 0x6c, - 0x00, 0x6f, 0x3e, 0x44, 0x5b, 0x45, 0xba, 0xbb, 0xd9, 0xe6, 0xc3, 0x52, 0xec, 0x44, 0x48, 0x93, - 0x78, 0x69, 0x27, 0x0b, 0x64, 0x91, 0xb2, 0x63, 0x72, 0x56, 0x9a, 0x9a, 0x22, 0x19, 0xce, 0x48, - 0x89, 0xea, 0xfa, 0xd2, 0x53, 0x2e, 0x05, 0xb6, 0x28, 0x7a, 0x2d, 0x16, 0x05, 0x7a, 0x2f, 0x8a, - 0x45, 0x81, 0xfe, 0x07, 0x7b, 0xeb, 0x76, 0x7b, 0x29, 0x0a, 0x34, 0x2d, 0x92, 0x16, 0xe8, 0xa5, - 0x40, 0xbb, 0xed, 0x1f, 0x50, 0x70, 0x38, 0xa4, 0x44, 0x86, 0x96, 0x49, 0xcb, 0x37, 0x71, 0xe6, - 0xbd, 0xdf, 0xfb, 0x98, 0x37, 0x6f, 0xde, 0x7b, 0x36, 0x50, 0x88, 0xc5, 0xb0, 0xab, 0x37, 0x11, - 0xb1, 0x34, 0x8a, 0xf5, 0xb6, 0x4b, 0x58, 0x57, 0xd1, 0xf5, 0x8e, 0xe2, 0xb8, 0x76, 0x87, 0x18, - 0xd8, 0x55, 0x3a, 0x4b, 0xca, 0xd3, 0x36, 0x76, 0xbb, 0x65, 0xc7, 0xb5, 0x99, 0x0d, 0xcf, 0x25, - 0x30, 0x94, 0x75, 0xbd, 0x53, 0x0e, 0x18, 0xca, 0x9d, 0xa5, 0xe2, 0xe9, 0x86, 0x6d, 0x37, 0x4c, - 0xac, 0x20, 0x87, 0x28, 0xc8, 0xb2, 0x6c, 0x86, 0x18, 0xb1, 0x2d, 0xea, 0x43, 0x14, 0x67, 0x1a, - 0x76, 0xc3, 0xe6, 0x3f, 0x15, 0xef, 0x97, 0x58, 0x2d, 0x09, 0x1e, 0xfe, 0xb5, 0xd9, 0xfe, 0x54, - 0x61, 0xa4, 0x85, 0x29, 0x43, 0x2d, 0x47, 0x10, 0x54, 0xd2, 0xa8, 0x1a, 0x6a, 0xe1, 0xf3, 0x2c, - 0xee, 0xc6, 0xd3, 0x59, 0x52, 0x68, 0x13, 0xb9, 0xd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x18, 0x37, - 0x49, 0x8b, 0xb0, 0x42, 0x6e, 0x5e, 0x5a, 0x18, 0x57, 0xfd, 0x0f, 0x19, 0xc5, 0x5c, 0x17, 0x48, - 0x17, 0x96, 0x57, 0xc1, 0x04, 0x97, 0x45, 0x0b, 0xd2, 0xfc, 0xe8, 0xc2, 0x54, 0xe5, 0x42, 0x3a, - 0xf9, 0xde, 0xb6, 0x2a, 0x38, 0xe5, 0x17, 0x63, 0x60, 0x9c, 0xaf, 0xc0, 0x53, 0x20, 0xef, 0x73, - 0x86, 0xa7, 0x70, 0x88, 0x7f, 0xd7, 0x0d, 0x38, 0x0b, 0x26, 0x75, 0x93, 0x60, 0x8b, 0x79, 0x7b, - 0x39, 0xbe, 0x97, 0xf7, 0x17, 0xea, 0x06, 0x3c, 0x06, 0xc6, 0x99, 0xed, 0x68, 0xf7, 0x0b, 0xa3, - 0xf3, 0xd2, 0xc2, 0x11, 0x75, 0x8c, 0xd9, 0xce, 0x7d, 0x78, 0x01, 0xc0, 0x16, 0xb1, 0x34, 0xc7, - 0x7e, 0xe6, 0x1d, 0xab, 0xa5, 0xf9, 0x14, 0x63, 0xf3, 0xd2, 0xc2, 0xa8, 0x3a, 0xdd, 0x22, 0xd6, - 0x9a, 0xb7, 0x51, 0xb7, 0x36, 0x3c, 0xda, 0x45, 0x30, 0xd3, 0x41, 0x26, 0x31, 0x10, 0xb3, 0x5d, - 0x2a, 0x58, 0x74, 0xe4, 0x14, 0xc6, 0x39, 0x1e, 0xec, 0xed, 0x71, 0xa6, 0x1a, 0x72, 0xe0, 0x05, - 0x70, 0x34, 0x5c, 0xd5, 0x28, 0x66, 0x9c, 0x7c, 0x82, 0x93, 0xbf, 0x15, 0x6e, 0xac, 0x63, 0xe6, - 0xd1, 0x9e, 0x06, 0x93, 0xc8, 0x34, 0xed, 0x67, 0x26, 0xa1, 0xac, 0x70, 0x68, 0x7e, 0x74, 0x61, - 0x52, 0xed, 0x2d, 0xc0, 0x22, 0xc8, 0x1b,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, 0x47, 0xec, - 0x67, 0x56, 0x3c, 0x4e, 0xd4, 0xc3, 0x7c, 0x31, 0x48, 0x85, 0x33, 0x41, 0x77, 0x3c, 0xca, 0x37, - 0x13, 0x3a, 0xdd, 0xb1, 0x83, 0xec, 0x74, 0x3f, 0x05, 0x53, 0xc4, 0x22, 0x4c, 0x13, 0x95, 0xd5, - 0x38, 0xc7, 0x5e, 0xc9, 0x84, 0x5d, 0xb7, 0x08, 0x23, 0xc8, 0x24, 0x3f, 0xe4, 0x13, 0x3c, 0x5e, - 0x6f, 0x79, 0xdd, 0x0a, 0x55, 0x81, 0x87, 0xec, 0xd7, 0x5f, 0xb0, 0x05, 0x66, 0xfc, 0x09, 0x04, - 0x6d, 0x22, 0x87, 0x58, 0x8d, 0x40, 0xe0, 0x04, 0x17, 0xf8, 0x61, 0xba, 0x52, 0xce, 0x03, 0x58, - 0xf7, 0xf9, 0xfb, 0xc4, 0x40, 0x27, 0xbe, 0x4e, 0x2b, 0xbf, 0x3b, 0x03, 0xc6, 0xf9, 0x21, 0xc1, - 0x7f, 0x48, 0x60, 0x26, 0x69, 0xce, 0x05, 0x6f, 0x66, 0x4f, 0x99, 0xd1, 0x11, 0x5b, 0x71, 0x79, - 0x08, 0x04, 0x3f, 0x5a, 0xe4, 0x3b, 0x3f, 0xfe, 0xe3, 0xdf, 0x7f, 0x96, 0xab, 0xc2, 0x9b, 0x7b, - 0x0f, 0x59, 0xc3, 0xa8, 0x14, 0x83, 0x34, 0x65, 0xbb, 0x2f, 0x4e, 0x77, 0xe0, 0x6b, 0x49, 0x54, - 0xcd, 0xd1, 0xe4, 0x09, 0x6f, 0x64, 0x57, 0x32, 0x32, 0x8c, 0x2b, 0xde, 0xdc, 0x3f, 0x80, 0x30, - 0xb2, 0xce, 0x8d, 0xac, 0xc1, 0xe5, 0x0c, 0x46, 0xfa, 0x63, 0x34, 0x65, 0x9b, 0x87, 0xff, 0x8e, - 0xb2, 0xcd, 0x07, 0x77, 0x3b, 0xf0,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b, 0xfb, 0x11, 0x25, 0xb6, 0xe5, 0xc5, 0x3b, 0xc3, 0x03, 0x65, 0xb7, 0xba, 0xef, 0x68, - 0x95, 0xed, 0x70, 0x2a, 0xb0, 0x03, 0xff, 0x12, 0x54, 0x87, 0x91, 0xf4, 0x94, 0xa5, 0x3a, 0x4c, - 0x6a, 0xfc, 0x8b, 0x37, 0xf6, 0xcd, 0x2f, 0x4c, 0x5b, 0xe5, 0xa6, 0xdd, 0x84, 0xd7, 0xb3, 0x26, - 0xc0, 0x68, 0x14, 0x57, 0x3f, 0xfe, 0xf2, 0xd5, 0x9c, 0xf4, 0xd5, 0xab, 0x39, 0xe9, 0x6f, 0xaf, - 0xe6, 0xa4, 0xcf, 0x5e, 0xcf, 0x8d, 0x7c, 0xf5, 0x7a, 0x6e, 0xe4, 0x4f, 0xaf, 0xe7, 0x46, 0x1e, - 0x5f, 0x6b, 0x10, 0xd6, 0x6c, 0x6f, 0x96, 0x75, 0xbb, 0x25, 0xfe, 0x63, 0xa4, 0x4f, 0xd4, 0xe5, - 0x50, 0x54, 0xe7, 0x8a, 0xf2, 0x3c, 0x56, 0x8d, 0x76, 0x1d, 0x4c, 0x37, 0x27, 0xf8, 0xdf, 0x02, - 0xbf, 0xf5, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0xad, 0x83, 0x18, 0xd1, 0x23, 0x00, 0x00, + // 2371 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0xcd, 0x6f, 0xdc, 0xc6, + 0x15, 0x17, 0x57, 0x1f, 0x5e, 0x8d, 0x2c, 0x25, 0x1e, 0xcb, 0xf6, 0x7a, 0x65, 0x6b, 0x65, 0x3a, + 0x06, 0x14, 0x3b, 0x5e, 0x4a, 0x5b, 0xb8, 0x49, 0x9c, 0xfa, 0x43, 0xbb, 0x96, 0xec, 0x85, 0x63, + 0x5b, 0xa1, 0x14,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0xc8, 0xac, 0xdb, 0x61, 0xa6, 0x48, 0x5f, 0x2b, 0x3d, 0x11, + 0x41, 0xbf, 0x17, 0x5c, 0x58, 0x40, 0x9c, 0xed, 0x7f, 0x79, 0x63, 0xe7, 0x85, 0x82, 0xbb, 0x30, + 0xd7, 0xf7, 0x04, 0x47, 0x0f, 0x10, 0x11, 0x79, 0x05, 0xcc, 0x47, 0x44, 0xee, 0x43, 0xeb, 0x9f, + 0x1e, 0x01, 0x0b, 0x03, 0x30, 0xc2, 0x5f, 0x07, 0x7d, 0x8a, 0xe2, 0x11, 0x92, 0xcb, 0x18, 0x21, + 0xb0, 0x00, 0xc6, 0x79, 0x69, 0xc2, 0x63, 0x6b, 0xb4, 0x9a, 0x2b, 0x48, 0xaa, 0xbf, 0x00, 0xdf, + 0x05, 0x63, 0x1e, 0xcb, 0x71, 0x63, 0x5c, 0x9b, 0x0b, 0xec, 0x7c, 0xff, 0xf4, 0xbc, 0x34, 0xe7, + 0x17, 0xc7, 0xc4, 0xdc, 0x2e, 0x63, 0x47, 0x69, 0xe9, 0xb4, 0x59, 0x7e, 0x1f, 0x35, 0x74, 0xa3, + 0x7b, 0x0b, 0x19, 0x05, 0x49, 0xe5, 0x2c, 0xf0, 0x02, 0x98, 0x09, 0xb5, 0xf2, 0xd1, 0xc7, 0x79, + 0x7e, 0x9d, 0x0e, 0x56, 0x79, 0xc9, 0x03, 0x1f, 0x83, 0x42, 0x48, 0x66, 0x38, 0xad, 0x16, 0x26, + 0x04, 0x3b, 0xb6, 0xc6, 0xa5, 0x4e, 0x70, 0xa9, 0xe7, 0x53, 0x48, 0x55, 0x4f, 0x06, 0x20, 0xb5, + 0x10, 0x43, 0x65, 0x5a, 0x3c, 0x06, 0x85, 0xd0, 0xb5, 0x71, 0xf8, 0x23, 0x19, 0xe0, 0x03, 0x90, + 0x18, 0xfc, 0x5d, 0x30, 0x65, 0x22, 0x62, 0x78, 0xd8, 0x65, 0x9d, 0x53, 0x21, 0xcf, 0x3d,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xff, 0x48, 0xb1, 0x3f, 0x46, + 0x47, 0xfb, 0x5f, 0x78, 0x3b, 0xfb, 0x11, 0x25, 0x36, 0xe1, 0xc5, 0x3b, 0x07, 0x07, 0xca, 0x6e, + 0x75, 0xdf, 0xd1, 0x2a, 0x3b, 0xe1, 0x0c, 0x60, 0x17, 0xfe, 0x39, 0xa8, 0x05, 0x23, 0xe9, 0x29, + 0x4b, 0x2d, 0x98, 0xd4, 0xe6, 0x17, 0x6f, 0xec, 0x9b, 0x5f, 0x98, 0xb6, 0xc6, 0x4d, 0xbb, 0x09, + 0xaf, 0x67, 0x4d, 0x80, 0xd1, 0x28, 0xae, 0x7e, 0xf4, 0xe5, 0x8b, 0x79, 0xe9, 0xab, 0x17, 0xf3, + 0xd2, 0x5f, 0x5f, 0xcc, 0x4b, 0x9f, 0xbd, 0x9c, 0x1f, 0xf9, 0xea, 0xe5, 0xfc, 0xc8, 0x1f, 0x5f, + 0xce, 0x8f, 0x3c, 0xba, 0xd6, 0xc0, 0xb4, 0xd9, 0xde, 0x2a, 0x1b, 0x4e, 0x4b, 0xfc, 0xd7, 0x47, + 0x9f, 0xa8, 0xcb, 0xa1, 0xa8, 0xce, 0x15, 0xe5, 0x59, 0xac, 0xf6, 0xec, 0xba, 0x88, 0x6c, 0x4d, + 0xf0, 0x3f, 0xf1, 0x7d, 0xeb, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x1f, 0xf9, 0xd9, 0x95, + 0x23, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2007,9 +2015,9 @@ type QueryClient interface { // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) - // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address + // QueryAllPairsValConsAddrByConsumer returns a list of pair valconsensus address // between provider and consumer chain - QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, in *QueryAllPairsValConAddrByConsumerChainIDRequest, opts ...grpc.CallOption) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) + QueryAllPairsValConsAddrByConsumer(ctx context.Context, in *QueryAllPairsValConsAddrByConsumerRequest, opts ...grpc.CallOption) (*QueryAllPairsValConsAddrByConsumerResponse, error) // QueryParams returns all current values of provider parameters QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // QueryConsumerChainOptedInValidators returns a list of validators consensus addresses @@ -2021,7 +2029,7 @@ type QueryClient interface { // QueryValidatorConsumerCommissionRate returns the commission rate a given // validator charges on a given consumer chain QueryValidatorConsumerCommissionRate(ctx context.Context, in *QueryValidatorConsumerCommissionRateRequest, opts ...grpc.CallOption) (*QueryValidatorConsumerCommissionRateResponse, error) - // QueryConsumerValidators returns the latest set consumer-validator set for a given chainID + // QueryConsumerValidators returns the latest set consumer-validator set for a given consumer ID // Note that this does not necessarily mean that the consumer chain is using this validator set at this exact moment // because a VSCPacket could be delayed to be delivered on the consumer chain. QueryConsumerValidators(ctx context.Context, in *QueryConsumerValidatorsRequest, opts ...grpc.CallOption) (*QueryConsumerValidatorsResponse, error) @@ -2098,9 +2106,9 @@ func (c *queryClient) QueryRegisteredConsumerRewardDenoms(ctx context.Context, i return out, nil } -func (c *queryClient) QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, in *QueryAllPairsValConAddrByConsumerChainIDRequest, opts ...grpc.CallOption) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) { - out := new(QueryAllPairsValConAddrByConsumerChainIDResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryAllPairsValConAddrByConsumerChainID", in, out, opts...) +func (c *queryClient) QueryAllPairsValConsAddrByConsumer(ctx context.Context, in *QueryAllPairsValConsAddrByConsumerRequest, opts ...grpc.CallOption) (*QueryAllPairsValConsAddrByConsumerResponse, error) { + out := new(QueryAllPairsValConsAddrByConsumerResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryAllPairsValConsAddrByConsumer", in, out, opts...) if err != nil { return nil, err } @@ -2199,9 +2207,9 @@ type QueryServer interface { // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(context.Context, *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) - // QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address + // QueryAllPairsValConsAddrByConsumer returns a list of pair valconsensus address // between provider and consumer chain - QueryAllPairsValConAddrByConsumerChainID(context.Context, *QueryAllPairsValConAddrByConsumerChainIDRequest) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) + QueryAllPairsValConsAddrByConsumer(context.Context, *QueryAllPairsValConsAddrByConsumerRequest) (*QueryAllPairsValConsAddrByConsumerResponse, error) // QueryParams returns all current values of provider parameters QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // QueryConsumerChainOptedInValidators returns a list of validators consensus addresses @@ -2213,7 +2221,7 @@ type QueryServer interface { // QueryValidatorConsumerCommissionRate returns the commission rate a given // validator charges on a given consumer chain QueryValidatorConsumerCommissionRate(context.Context, *QueryValidatorConsumerCommissionRateRequest) (*QueryValidatorConsumerCommissionRateResponse, error) - // QueryConsumerValidators returns the latest set consumer-validator set for a given chainID + // QueryConsumerValidators returns the latest set consumer-validator set for a given consumer ID // Note that this does not necessarily mean that the consumer chain is using this validator set at this exact moment // because a VSCPacket could be delayed to be delivered on the consumer chain. QueryConsumerValidators(context.Context, *QueryConsumerValidatorsRequest) (*QueryConsumerValidatorsResponse, error) @@ -2250,8 +2258,8 @@ func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *Qu func (*UnimplementedQueryServer) QueryRegisteredConsumerRewardDenoms(ctx context.Context, req *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryRegisteredConsumerRewardDenoms not implemented") } -func (*UnimplementedQueryServer) QueryAllPairsValConAddrByConsumerChainID(ctx context.Context, req *QueryAllPairsValConAddrByConsumerChainIDRequest) (*QueryAllPairsValConAddrByConsumerChainIDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAllPairsValConAddrByConsumerChainID not implemented") +func (*UnimplementedQueryServer) QueryAllPairsValConsAddrByConsumer(ctx context.Context, req *QueryAllPairsValConsAddrByConsumerRequest) (*QueryAllPairsValConsAddrByConsumerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAllPairsValConsAddrByConsumer not implemented") } func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryParams not implemented") @@ -2390,20 +2398,20 @@ func _Query_QueryRegisteredConsumerRewardDenoms_Handler(srv interface{}, ctx con return interceptor(ctx, in, info, handler) } -func _Query_QueryAllPairsValConAddrByConsumerChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllPairsValConAddrByConsumerChainIDRequest) +func _Query_QueryAllPairsValConsAddrByConsumer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllPairsValConsAddrByConsumerRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAllPairsValConAddrByConsumerChainID(ctx, in) + return srv.(QueryServer).QueryAllPairsValConsAddrByConsumer(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryAllPairsValConAddrByConsumerChainID", + FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryAllPairsValConsAddrByConsumer", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAllPairsValConAddrByConsumerChainID(ctx, req.(*QueryAllPairsValConAddrByConsumerChainIDRequest)) + return srv.(QueryServer).QueryAllPairsValConsAddrByConsumer(ctx, req.(*QueryAllPairsValConsAddrByConsumerRequest)) } return interceptor(ctx, in, info, handler) } @@ -2581,8 +2589,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_QueryRegisteredConsumerRewardDenoms_Handler, }, { - MethodName: "QueryAllPairsValConAddrByConsumerChainID", - Handler: _Query_QueryAllPairsValConAddrByConsumerChainID_Handler, + MethodName: "QueryAllPairsValConsAddrByConsumer", + Handler: _Query_QueryAllPairsValConsAddrByConsumer_Handler, }, { MethodName: "QueryParams", @@ -2774,6 +2782,13 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ConsumerId) > 0 { + i -= len(m.ConsumerId) + copy(dAtA[i:], m.ConsumerId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerId))) + i-- + dAtA[i] = 0x6a + } if m.AllowInactiveVals { i-- if m.AllowInactiveVals { @@ -2799,10 +2814,12 @@ func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x52 - if m.Phase != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Phase)) + if len(m.Phase) > 0 { + i -= len(m.Phase) + copy(dAtA[i:], m.Phase) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Phase))) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x4a } if len(m.Denylist) > 0 { for iNdEx := len(m.Denylist) - 1; iNdEx >= 0; iNdEx-- { @@ -3112,7 +3129,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA return len(dAtA) - i, nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAllPairsValConsAddrByConsumerRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3122,12 +3139,12 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Marshal() (dAtA []byte return dAtA[:n], nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAllPairsValConsAddrByConsumerRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAllPairsValConsAddrByConsumerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3142,7 +3159,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) MarshalToSizedBuffer(d return len(dAtA) - i, nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAllPairsValConsAddrByConsumerResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3152,12 +3169,12 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Marshal() (dAtA []byt return dAtA[:n], nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAllPairsValConsAddrByConsumerResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAllPairsValConsAddrByConsumerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3602,11 +3619,11 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) MarshalToSizedBuffer _ = i var l int _ = l - if len(m.ConsumerChainIds) > 0 { - for iNdEx := len(m.ConsumerChainIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ConsumerChainIds[iNdEx]) - copy(dAtA[i:], m.ConsumerChainIds[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerChainIds[iNdEx]))) + if len(m.ConsumerIds) > 0 { + for iNdEx := len(m.ConsumerIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ConsumerIds[iNdEx]) + copy(dAtA[i:], m.ConsumerIds[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ConsumerIds[iNdEx]))) i-- dAtA[i] = 0xa } @@ -4006,8 +4023,9 @@ func (m *Chain) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } - if m.Phase != 0 { - n += 1 + sovQuery(uint64(m.Phase)) + l = len(m.Phase) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } l = m.Metadata.Size() n += 1 + l + sovQuery(uint64(l)) @@ -4017,6 +4035,10 @@ func (m *Chain) Size() (n int) { if m.AllowInactiveVals { n += 2 } + l = len(m.ConsumerId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4130,7 +4152,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) Size() (n int) { return n } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Size() (n int) { +func (m *QueryAllPairsValConsAddrByConsumerRequest) Size() (n int) { if m == nil { return 0 } @@ -4143,7 +4165,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Size() (n int) { return n } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Size() (n int) { +func (m *QueryAllPairsValConsAddrByConsumerResponse) Size() (n int) { if m == nil { return 0 } @@ -4323,8 +4345,8 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) Size() (n int) { } var l int _ = l - if len(m.ConsumerChainIds) > 0 { - for _, s := range m.ConsumerChainIds { + if len(m.ConsumerIds) > 0 { + for _, s := range m.ConsumerIds { l = len(s) n += 1 + l + sovQuery(uint64(l)) } @@ -5028,10 +5050,10 @@ func (m *Chain) Unmarshal(dAtA []byte) error { m.Denylist = append(m.Denylist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 9: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) } - m.Phase = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5041,11 +5063,24 @@ func (m *Chain) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Phase |= ConsumerPhase(b&0x7F) << shift + 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.Phase = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) @@ -5118,6 +5153,38 @@ func (m *Chain) Unmarshal(dAtA []byte) error { } } m.AllowInactiveVals = bool(v != 0) + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerId", 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.ConsumerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5834,7 +5901,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) Unmarshal(dAtA []byte) err } return nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllPairsValConsAddrByConsumerRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5857,10 +5924,10 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPairsValConAddrByConsumerChainIDRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPairsValConsAddrByConsumerRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPairsValConAddrByConsumerChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPairsValConsAddrByConsumerRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5916,7 +5983,7 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDRequest) Unmarshal(dAtA []byte) } return nil } -func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllPairsValConsAddrByConsumerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5939,10 +6006,10 @@ func (m *QueryAllPairsValConAddrByConsumerChainIDResponse) Unmarshal(dAtA []byte fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllPairsValConAddrByConsumerChainIDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllPairsValConsAddrByConsumerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllPairsValConAddrByConsumerChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllPairsValConsAddrByConsumerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -7161,7 +7228,7 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) Unmarshal(dAtA []byt switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerChainIds", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerIds", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7189,7 +7256,7 @@ func (m *QueryConsumerChainsValidatorHasToValidateResponse) Unmarshal(dAtA []byt if postIndex > l { return io.ErrUnexpectedEOF } - m.ConsumerChainIds = append(m.ConsumerChainIds, string(dAtA[iNdEx:postIndex])) + m.ConsumerIds = append(m.ConsumerIds, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 8d1a7ad91e..92f8f09f5a 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -277,8 +277,8 @@ func local_request_Query_QueryRegisteredConsumerRewardDenoms_0(ctx context.Conte } -func request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest +func request_Query_QueryAllPairsValConsAddrByConsumer_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPairsValConsAddrByConsumerRequest var metadata runtime.ServerMetadata var ( @@ -299,13 +299,13 @@ func request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Contex return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - msg, err := client.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryAllPairsValConsAddrByConsumer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllPairsValConAddrByConsumerChainIDRequest +func local_request_Query_QueryAllPairsValConsAddrByConsumer_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllPairsValConsAddrByConsumerRequest var metadata runtime.ServerMetadata var ( @@ -326,7 +326,7 @@ func local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx context. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - msg, err := server.QueryAllPairsValConAddrByConsumerChainID(ctx, &protoReq) + msg, err := server.QueryAllPairsValConsAddrByConsumer(ctx, &protoReq) return msg, metadata, err } @@ -857,7 +857,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAllPairsValConsAddrByConsumer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -868,7 +868,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAllPairsValConAddrByConsumerChainID_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryAllPairsValConsAddrByConsumer_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 { @@ -876,7 +876,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryAllPairsValConAddrByConsumerChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAllPairsValConsAddrByConsumer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1225,7 +1225,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAllPairsValConsAddrByConsumer_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) @@ -1234,14 +1234,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAllPairsValConAddrByConsumerChainID_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryAllPairsValConsAddrByConsumer_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_QueryAllPairsValConAddrByConsumerChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAllPairsValConsAddrByConsumer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1421,7 +1421,7 @@ var ( 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))) - pattern_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "address_pairs", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAllPairsValConsAddrByConsumer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"interchain_security", "ccv", "provider", "address_pairs", "consumer_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "params"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1453,7 +1453,7 @@ var ( forward_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.ForwardResponseMessage - forward_Query_QueryAllPairsValConAddrByConsumerChainID_0 = runtime.ForwardResponseMessage + forward_Query_QueryAllPairsValConsAddrByConsumer_0 = runtime.ForwardResponseMessage forward_Query_QueryParams_0 = runtime.ForwardResponseMessage From 3cc9ba22b76efe36d309d4b272614c97a09d51c5 Mon Sep 17 00:00:00 2001 From: insumity Date: Wed, 4 Sep 2024 15:27:39 +0200 Subject: [PATCH 30/43] fix!: remove `stopTime` from `MsgRemoveConsumer` (#2208) * init commit * renamed stop time to removal time * fix errors in tests * add GetAllConsumerWithIBCClients * use GetAllConsumerWithIBCClients for efficiency * fix UTs * remove GetAllLaunchedConsumerIds as not needed * typo in GetAllConsumersWithIBCClients * improve comment * Apply suggestions from code review Co-authored-by: Marius Poke * took into account comments --------- Co-authored-by: mpoke --- .../ccv/provider/v1/genesis.proto | 2 + .../ccv/provider/v1/provider.proto | 2 + .../ccv/provider/v1/query.proto | 2 +- .../ccv/provider/v1/tx.proto | 7 +- tests/e2e/action_rapid_test.go | 9 +- tests/e2e/actions.go | 20 +- tests/e2e/state.go | 9 +- tests/e2e/state_rapid_test.go | 7 +- tests/e2e/steps_stop_chain.go | 50 ++- tests/e2e/testlib/types.go | 7 +- tests/e2e/trace_handlers_test.go | 14 +- tests/e2e/v4/state.go | 9 +- tests/integration/stop_consumer.go | 7 +- testutil/keeper/expectations.go | 5 +- testutil/keeper/unit_test_helpers.go | 32 +- x/ccv/provider/client/cli/query.go | 2 +- x/ccv/provider/client/cli/tx.go | 17 +- x/ccv/provider/keeper/consumer_lifecycle.go | 167 +++++---- .../keeper/consumer_lifecycle_test.go | 126 +++---- x/ccv/provider/keeper/distribution.go | 12 +- x/ccv/provider/keeper/genesis.go | 11 +- x/ccv/provider/keeper/genesis_test.go | 2 + x/ccv/provider/keeper/grpc_query.go | 4 +- x/ccv/provider/keeper/grpc_query_test.go | 5 + x/ccv/provider/keeper/keeper.go | 21 +- x/ccv/provider/keeper/keeper_test.go | 28 +- x/ccv/provider/keeper/msg_server.go | 21 +- x/ccv/provider/keeper/permissionless.go | 8 +- x/ccv/provider/keeper/relay.go | 42 ++- x/ccv/provider/keeper/relay_test.go | 97 ++++-- .../provider/migrations/v5/migration_test.go | 9 +- x/ccv/provider/migrations/v5/migrations.go | 4 +- x/ccv/provider/migrations/v6/migrations.go | 3 +- x/ccv/provider/module.go | 2 +- x/ccv/provider/types/consumer.go | 2 + x/ccv/provider/types/errors.go | 2 +- x/ccv/provider/types/genesis.pb.go | 131 ++++--- x/ccv/provider/types/keys.go | 48 +-- x/ccv/provider/types/keys_test.go | 8 +- x/ccv/provider/types/msg.go | 7 +- x/ccv/provider/types/provider.pb.go | 33 +- x/ccv/provider/types/query.pb.go | 2 +- x/ccv/provider/types/tx.pb.go | 320 ++++++++---------- 43 files changed, 679 insertions(+), 637 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/genesis.proto b/proto/interchain_security/ccv/provider/v1/genesis.proto index 8a8a3e4cb8..0f212b0271 100644 --- a/proto/interchain_security/ccv/provider/v1/genesis.proto +++ b/proto/interchain_security/ccv/provider/v1/genesis.proto @@ -78,6 +78,8 @@ message ConsumerState { repeated interchain_security.ccv.v1.ValidatorSetChangePacketData pending_valset_changes = 6 [ (gogoproto.nullable) = false ]; repeated string slash_downtime_ack = 7; + // the phase of the consumer chain + ConsumerPhase phase = 9; } // ValsetUpdateIdToHeight defines the genesis information for the mapping diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 3a4a1108aa..0a96af8cae 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -480,4 +480,6 @@ enum ConsumerPhase { CONSUMER_PHASE_LAUNCHED = 3; // STOPPED defines the phase in which a previously-launched chain has stopped. CONSUMER_PHASE_STOPPED = 4; + // DELETED defines the phase in which the state of a stopped chain has been deleted. + CONSUMER_PHASE_DELETED = 5; } diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 42c5f40974..e6b3c2d8d9 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -156,7 +156,7 @@ message QueryConsumerGenesisResponse { message QueryConsumerChainsRequest { // The phase of the consumer chains returned (optional) - // Registered=1|Initialized=2|Launched=3|Stopped=4 + // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 ConsumerPhase phase = 1; // The limit of consumer chains returned (optional) // default is 100 diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 19541025e5..8f2d7b5c1c 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -228,12 +228,7 @@ message MsgRemoveConsumer { // the consumer id of the consumer chain to be stopped string consumer_id = 1; - // the time on the provider chain at which all validators are responsible to - // stop their consumer chain validator node - google.protobuf.Timestamp stop_time = 2 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - // signer address - string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string signer = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgRemoveConsumerResponse defines response type for MsgRemoveConsumer messages diff --git a/tests/e2e/action_rapid_test.go b/tests/e2e/action_rapid_test.go index 004eb30d95..d51cb64129 100644 --- a/tests/e2e/action_rapid_test.go +++ b/tests/e2e/action_rapid_test.go @@ -261,11 +261,10 @@ func GetSubmitConsumerAdditionProposalActionGen() *rapid.Generator[SubmitConsume 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")), + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), } }) } diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 22e1842050..b1356814eb 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -740,11 +740,10 @@ func (tr Chain) submitConsumerAdditionLegacyProposal( } type SubmitConsumerRemovalProposalAction struct { - Chain ChainID - From ValidatorID - Deposit uint - ConsumerChain ChainID - StopTimeOffset time.Duration // offset from time.Now() + Chain ChainID + From ValidatorID + Deposit uint + ConsumerChain ChainID } func (tr Chain) submitConsumerRemovalProposal( @@ -762,7 +761,6 @@ func (tr Chain) submitConsumerRemovalProposal( msg := types.MsgRemoveConsumer{ ConsumerId: consumerId, - StopTime: tr.testConfig.containerConfig.Now.Add(action.StopTimeOffset), Signer: authority, } @@ -811,13 +809,11 @@ func (tr Chain) submitConsumerRemovalLegacyProposal( action SubmitConsumerRemovalProposalAction, verbose bool, ) { - stopTime := tr.testConfig.containerConfig.Now.Add(action.StopTimeOffset) prop := client.ConsumerRemovalProposalJSON{ - Title: fmt.Sprintf("Stop the %v chain", action.ConsumerChain), - Summary: "It was a great chain", - ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), - StopTime: stopTime, - Deposit: fmt.Sprint(action.Deposit) + `stake`, + Title: fmt.Sprintf("Stop the %v chain", action.ConsumerChain), + Summary: "It was a great chain", + ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId), + Deposit: fmt.Sprint(action.Deposit) + `stake`, } bz, err := json.Marshal(prop) diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 676d8dcfc5..cdb25a0907 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -525,7 +525,6 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { } case "/interchain_security.ccv.provider.v1.MsgRemoveConsumer": consumerId := rawContent.Get("consumer_id").String() - stopTime := rawContent.Get("stop_time").Time().Sub(tr.containerConfig.Now) var chain ChainID for i, conf := range tr.chainConfigs { @@ -536,10 +535,9 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { } return ConsumerRemovalProposal{ - Deposit: uint(deposit), - Status: status, - Chain: chain, - StopTime: int(stopTime.Milliseconds()), + Deposit: uint(deposit), + Status: status, + Chain: chain, } case "/ibc.applications.transfer.v1.MsgUpdateParams": var params IBCTransferParams @@ -757,7 +755,6 @@ func (tr Commands) GetIBCTransferParams(chain ChainID) IBCTransferParams { func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { binaryName := tr.chainConfigs[chain].BinaryName cmd := tr.target.ExecCommand(binaryName, - "query", "provider", "list-consumer-chains", `--node`, tr.GetQueryNode(chain), `-o`, `json`, diff --git a/tests/e2e/state_rapid_test.go b/tests/e2e/state_rapid_test.go index 1ca36d5578..fc591d5db1 100644 --- a/tests/e2e/state_rapid_test.go +++ b/tests/e2e/state_rapid_test.go @@ -203,10 +203,9 @@ func GetConsumerAdditionProposalGen() *rapid.Generator[ConsumerAdditionProposal] 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"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Chain: GetChainIDGen().Draw(t, "Chain"), + Status: rapid.String().Draw(t, "Status"), } }) } diff --git a/tests/e2e/steps_stop_chain.go b/tests/e2e/steps_stop_chain.go index fbf86e4733..9efc240ee6 100644 --- a/tests/e2e/steps_stop_chain.go +++ b/tests/e2e/steps_stop_chain.go @@ -1,10 +1,8 @@ package main import ( - "strconv" - "time" - gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "strconv" ) // start relayer so that all messages are relayed @@ -22,11 +20,10 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { s := []Step{ { Action: SubmitConsumerRemovalProposalAction{ - Chain: ChainID("provi"), - From: ValidatorID("bob"), - Deposit: 10000001, - ConsumerChain: ChainID(consumerName), - StopTimeOffset: 0 * time.Millisecond, + Chain: ChainID("provi"), + From: ValidatorID("bob"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), }, State: State{ ChainID("provi"): ChainState{ @@ -35,10 +32,9 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { }, Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID(consumerName), - StopTime: 0, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), + Deposit: 10000001, + Chain: ChainID(consumerName), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not yet removed @@ -56,10 +52,9 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID(consumerName), - StopTime: 0, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), + Deposit: 10000001, + Chain: ChainID(consumerName), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ @@ -80,11 +75,10 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) [] s := []Step{ { Action: SubmitConsumerRemovalProposalAction{ - Chain: ChainID("provi"), - From: ValidatorID("bob"), - Deposit: 10000001, - ConsumerChain: ChainID(consumerName), - StopTimeOffset: 0 * time.Millisecond, + Chain: ChainID("provi"), + From: ValidatorID("bob"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), }, State: State{ ChainID("provi"): ChainState{ @@ -93,10 +87,9 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) [] }, Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID(consumerName), - StopTime: 0, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), + Deposit: 10000001, + Chain: ChainID(consumerName), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed @@ -114,10 +107,9 @@ func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) [] ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID(consumerName), - StopTime: 0, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_REJECTED)), + Deposit: 10000001, + Chain: ChainID(consumerName), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_REJECTED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/testlib/types.go b/tests/e2e/testlib/types.go index 8694e7185d..0c10d8578d 100644 --- a/tests/e2e/testlib/types.go +++ b/tests/e2e/testlib/types.go @@ -306,10 +306,9 @@ func (p UpgradeProposal) isProposal() {} func (p ConsumerAdditionProposal) isProposal() {} type ConsumerRemovalProposal struct { - Deposit uint - Chain ChainID - StopTime int - Status string + Deposit uint + Chain ChainID + Status string } func (p ConsumerRemovalProposal) isProposal() {} diff --git a/tests/e2e/trace_handlers_test.go b/tests/e2e/trace_handlers_test.go index e4f9e46f12..a773d00fe5 100644 --- a/tests/e2e/trace_handlers_test.go +++ b/tests/e2e/trace_handlers_test.go @@ -27,10 +27,9 @@ var proposalInStateSteps = []Step{ ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ 1: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID("foo"), - StopTime: 0, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), + Deposit: 10000001, + Chain: ChainID("foo"), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)), }, }, }, @@ -136,10 +135,9 @@ func TestMarshalAndUnmarshalChainState(t *testing.T) { "consumer removal proposal": {ChainState{ Proposals: &map[uint]Proposal{ 5: ConsumerRemovalProposal{ - Deposit: 10000001, - Chain: ChainID("test123"), - StopTime: 5000000000, - Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), + Deposit: 10000001, + Chain: ChainID("test123"), + Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)), }, }, ValBalances: &map[ValidatorID]uint{ diff --git a/tests/e2e/v4/state.go b/tests/e2e/v4/state.go index 594004bc24..b4b7b70190 100644 --- a/tests/e2e/v4/state.go +++ b/tests/e2e/v4/state.go @@ -317,7 +317,6 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { } case "/interchain_security.ccv.provider.v1.ConsumerRemovalProposal": chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String() - stopTime := gjson.Get(string(bz), `messages.0.content.stop_time`).Time().Sub(containerConfig.Now) var chain ChainID for i, conf := range chainConfigs { @@ -328,10 +327,9 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal { } return ConsumerRemovalProposal{ - Deposit: uint(deposit), - Status: status, - Chain: chain, - StopTime: int(stopTime.Milliseconds()), + Deposit: uint(deposit), + Status: status, + Chain: chain, } case "/cosmos.params.v1beta1.ParameterChangeProposal": return ParamsProposal{ @@ -391,7 +389,6 @@ func (tr Commands) GetParam(chain ChainID, param Param) string { func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { binaryName := tr.ChainConfigs[chain].BinaryName cmd := tr.Target.ExecCommand(binaryName, - "query", "provider", "list-consumer-chains", `--node`, tr.GetQueryNode(chain), `-o`, `json`, diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index c296026e0a..6da22d6b66 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -3,6 +3,7 @@ package integration import ( "cosmossdk.io/math" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -88,7 +89,8 @@ func (s *CCVTestSuite) TestStopConsumerChain() { } // stop the consumer chain - err = providerKeeper.StopConsumerChain(s.providerCtx(), firstBundle.ConsumerId, true) + providerKeeper.SetConsumerPhase(s.providerCtx(), firstBundle.ConsumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + err = providerKeeper.DeleteConsumerChain(s.providerCtx(), firstBundle.ConsumerId) s.Require().NoError(err) // check all states are removed and the unbonding operation released @@ -105,7 +107,8 @@ func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() { providerKeeper := s.providerApp.GetProviderKeeper() // stop the consumer chain - err := providerKeeper.StopConsumerChain(s.providerCtx(), s.getFirstBundle().ConsumerId, true) + providerKeeper.SetConsumerPhase(s.providerCtx(), s.getFirstBundle().ConsumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + err := providerKeeper.DeleteConsumerChain(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().NoError(err) err = s.path.EndpointA.UpdateClient() diff --git a/testutil/keeper/expectations.go b/testutil/keeper/expectations.go index 3ceaf4fd2b..53d16a6581 100644 --- a/testutil/keeper/expectations.go +++ b/testutil/keeper/expectations.go @@ -80,9 +80,8 @@ func GetMocksForSetConsumerChain(ctx sdk.Context, mocks *MockedKeepers, } } -// GetMocksForStopConsumerChainWithCloseChannel returns mock expectations needed to call StopConsumerChain() when -// `closeChan` is true. -func GetMocksForStopConsumerChainWithCloseChannel(ctx sdk.Context, mocks *MockedKeepers) []*gomock.Call { +// GetMocksForDeleteConsumerChain returns mock expectations needed to call `DeleteConsumerChain` +func GetMocksForDeleteConsumerChain(ctx sdk.Context, mocks *MockedKeepers) []*gomock.Call { dummyCap := &capabilitytypes.Capability{} return []*gomock.Call{ mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), types.ProviderPortID, "channelID").Return( diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 1572937607..7de405b434 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -212,12 +212,12 @@ func GetNewSlashPacketData() types.SlashPacketData { } } -// SetupForStoppingConsumerChain registers expected mock calls and corresponding state setup -// which assert that a consumer chain was properly setup to be later stopped from `StopConsumerChain`. -// Note: This function only setups and tests that we correctly setup a consumer chain that we could later stop when -// calling `StopConsumerChain` -- this does NOT necessarily mean that the consumer chain is stopped. -// Also see `TestProviderStateIsCleanedAfterConsumerChainIsStopped`. -func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, +// SetupForDeleteConsumerChain registers expected mock calls and corresponding state setup +// which assert that a consumer chain was properly setup to be later deleted with `DeleteConsumerChain`. +// Note: This function only setups and tests that we correctly setup a consumer chain that we could later delete when +// calling `DeleteConsumerChain` -- this does NOT necessarily mean that the consumer chain is deleted. +// Also see `TestProviderStateIsCleanedAfterConsumerChainIsDeleted`. +func SetupForDeleteConsumerChain(t *testing.T, ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks MockedKeepers, consumerId string, ) { @@ -238,6 +238,8 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, require.NoError(t, err) err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, GetTestPowerShapingParameters()) require.NoError(t, err) + + // set the chain to initialized so that we can create a consumer client providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) err = providerKeeper.CreateConsumerClient(ctx, consumerId) @@ -247,11 +249,14 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, // set the channel ID for the consumer chain err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) + + // set the chain to stopped sto the chain can be deleted + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) } -// TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned -// after a stopped consumer chain. -func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, +// TestProviderStateIsCleanedAfterConsumerChainIsDeleted executes test assertions for the provider's state being cleaned +// after a deleted consumer chain. +func TestProviderStateIsCleanedAfterConsumerChainIsDeleted(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, consumerId, expectedChannelID string, expErr bool, ) { t.Helper() @@ -266,15 +271,6 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk acks := providerKeeper.GetSlashAcks(ctx, consumerId) require.Empty(t, acks) - // in case the chain was successfully stopped, it should not contain a Top N associated to it - ps, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) - if expErr { - require.Error(t, err) - } else { - require.NoError(t, err) - } - require.Empty(t, ps) - // test key assignment state is cleaned require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId)) require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &consumerId)) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index c249aa5264..c6e0d53159 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -78,7 +78,7 @@ func CmdConsumerChains() *cobra.Command { Short: "Query consumer chains for provider chain.", Long: `Query consumer chains for provider chain. An optional integer parameter can be passed for phase filtering of consumer chains, - (Registered=1|Initialized=2|Launched=3|Stopped=4).`, + (Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5).`, Args: cobra.MaximumNArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 00826278b0..9a8a7e5046 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -1,13 +1,11 @@ package cli import ( + "cosmossdk.io/math" "encoding/json" "fmt" "os" "strings" - "time" - - "cosmossdk.io/math" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cobra" @@ -402,16 +400,14 @@ Example: func NewRemoveConsumerCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "remove-consumer [consumer-id] [stop-time-layout] [stop-time-value]", + Use: "remove-consumer [consumer-id]", Short: "remove a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Removes (and stops) a consumer chain. Note that only the owner of the chain can remove it. -Stop time is parsed by using the layout and the value (see https://pkg.go.dev/time#Parse). - Example: -%s tx provider remove-consumer [consumer-id] [stop-time-layout] [stop-time-value] --from node0 --home ../node0 --chain-id $CID +%s tx provider remove-consumer [consumer-id] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -426,15 +422,12 @@ Example: signer := clientCtx.GetFromAddress().String() consumerId := args[0] - stopTimeLayout := args[1] - stopTimeValue := args[2] - stopTime, err := time.Parse(stopTimeLayout, stopTimeValue) if err != nil { return err } - msg, err := types.NewMsgRemoveConsumer(signer, consumerId, stopTime) + msg, err := types.NewMsgRemoveConsumer(signer, consumerId) if err != nil { return err } diff --git a/x/ccv/provider/keeper/consumer_lifecycle.go b/x/ccv/provider/keeper/consumer_lifecycle.go index 58c83be9cf..1dc3ef3d95 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle.go +++ b/x/ccv/provider/keeper/consumer_lifecycle.go @@ -68,7 +68,7 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) { // TODO (PERMISSIONLESS): we can parameterize the limit for _, consumerId := range k.GetConsumersReadyToLaunch(ctx, 200) { - record, err := k.GetConsumerInitializationParameters(ctx, consumerId) + initializationParameters, err := k.GetConsumerInitializationParameters(ctx, consumerId) if err != nil { ctx.Logger().Error("could not retrieve initialization record", "consumerId", consumerId, @@ -77,7 +77,7 @@ func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) { } // Remove consumer to prevent re-trying launching this chain. // We would only try to re-launch this chain if a new `MsgUpdateConsumer` message is sent. - err = k.RemoveConsumerToBeLaunched(ctx, consumerId, record.SpawnTime) + err = k.RemoveConsumerToBeLaunched(ctx, consumerId, initializationParameters.SpawnTime) if err != nil { ctx.Logger().Error("could not remove consumer from to-be-launched queue", "consumerId", consumerId, @@ -93,7 +93,6 @@ func (k Keeper) BeginBlockLaunchConsumers(ctx sdk.Context) { "error", err) continue } - k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // the cached context is created with a new EventManager, so we merge the events into the original context ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events()) @@ -161,6 +160,8 @@ func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in consumer id: %s", consumerId) } + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + return nil } @@ -353,36 +354,58 @@ func (k Keeper) MakeConsumerGenesis( return gen, hash, nil } -// BeginBlockStopConsumers iterates over the pending consumer proposals and stop/removes the chain if the stop time has passed -func (k Keeper) BeginBlockStopConsumers(ctx sdk.Context) { +// StopAndPrepareForConsumerRemoval sets the phase of the chain to stopped and prepares to get the state of the +// chain removed after unbonding period elapses +func (k Keeper) StopAndPrepareForConsumerRemoval(ctx sdk.Context, consumerId string) error { + // The phase of the chain is immediately set to stopped, albeit its state is removed later (see below). + // Setting the phase here helps in not considering this chain when we look at launched chains (e.g., in `QueueVSCPackets) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + + // state of this chain is removed once UnbondingPeriod elapses + unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) + if err != nil { + return err + } + removalTime := ctx.BlockTime().Add(unbondingPeriod) + + if err := k.SetConsumerRemovalTime(ctx, consumerId, removalTime); err != nil { + return fmt.Errorf("cannot set removal time (%s): %s", removalTime.String(), err.Error()) + } + if err := k.AppendConsumerToBeRemoved(ctx, consumerId, removalTime); err != nil { + return errorsmod.Wrapf(ccv.ErrInvalidConsumerState, "cannot set consumer to be removed: %s", err.Error()) + } + + return nil +} + +// BeginBlockRemoveConsumers iterates over the pending consumer proposals and stop/removes the chain if the removal time has passed +func (k Keeper) BeginBlockRemoveConsumers(ctx sdk.Context) { // TODO (PERMISSIONLESS): parameterize the limit for _, consumerId := range k.GetConsumersReadyToStop(ctx, 200) { - // stop consumer chain in a cached context to handle errors - cachedCtx, writeFn := ctx.CacheContext() - - stopTime, err := k.GetConsumerStopTime(ctx, consumerId) + removalTime, err := k.GetConsumerRemovalTime(ctx, consumerId) if err != nil { k.Logger(ctx).Error("chain could not be stopped", "consumerId", consumerId, - "err", err.Error()) + "error", err.Error()) continue } - err = k.StopConsumerChain(cachedCtx, consumerId, true) + // Remove consumer to prevent re-trying removing this chain. + err = k.RemoveConsumerToBeRemoved(ctx, consumerId, removalTime) if err != nil { - k.Logger(ctx).Error("consumer chain could not be stopped", + ctx.Logger().Error("could not remove consumer from to-be-removed queue", "consumerId", consumerId, - "err", err.Error()) + "error", err) continue } - k.SetConsumerPhase(cachedCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) - - err = k.RemoveConsumerToBeStopped(ctx, consumerId, stopTime) + // delete consumer chain in a cached context to abort deletion in case of errors + cachedCtx, writeFn := ctx.CacheContext() + err = k.DeleteConsumerChain(cachedCtx, consumerId) if err != nil { - ctx.Logger().Error("could not remove consumer from to-be-stopped queue", + k.Logger(ctx).Error("consumer chain could not be removed", "consumerId", consumerId, - "error", err) + "error", err.Error()) continue } @@ -391,9 +414,9 @@ func (k Keeper) BeginBlockStopConsumers(ctx sdk.Context) { writeFn() - k.Logger(ctx).Info("executed consumer removal", + k.Logger(ctx).Info("executed consumer deletion", "consumer id", consumerId, - "stop time", stopTime, + "removal time", removalTime, ) } } @@ -403,26 +426,26 @@ func (k Keeper) BeginBlockStopConsumers(ctx sdk.Context) { func (k Keeper) GetConsumersReadyToStop(ctx sdk.Context, limit uint32) []string { store := ctx.KVStore(k.storeKey) - stopTimeToConsumerIdsKeyPrefix := types.StopTimeToConsumerIdsKeyPrefix() - iterator := storetypes.KVStorePrefixIterator(store, []byte{stopTimeToConsumerIdsKeyPrefix}) + removalTimeToConsumerIdsKeyPrefix := types.RemovalTimeToConsumerIdsKeyPrefix() + iterator := storetypes.KVStorePrefixIterator(store, []byte{removalTimeToConsumerIdsKeyPrefix}) defer iterator.Close() result := []string{} for ; iterator.Valid(); iterator.Next() { - stopTime, err := types.ParseTime(stopTimeToConsumerIdsKeyPrefix, iterator.Key()) + removalTime, err := types.ParseTime(removalTimeToConsumerIdsKeyPrefix, iterator.Key()) if err != nil { - k.Logger(ctx).Error("failed to parse stop time", + k.Logger(ctx).Error("failed to parse removal time", "error", err) continue } - if stopTime.After(ctx.BlockTime()) { + if removalTime.After(ctx.BlockTime()) { return result } - consumers, err := k.GetConsumersToBeStopped(ctx, stopTime) + consumers, err := k.GetConsumersToBeRemoved(ctx, removalTime) if err != nil { - k.Logger(ctx).Error("failed to retrieve consumers to stop", - "stop time", stopTime, + k.Logger(ctx).Error("failed to retrieve consumers to remove", + "removal time", removalTime, "error", err) continue } @@ -440,13 +463,11 @@ func (k Keeper) GetConsumersReadyToStop(ctx sdk.Context, limit uint32) []string return result } -// StopConsumerChain cleans up the states for the given consumer id -func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan bool) (err error) { - // check that a client for consumerId exists - // TODO (PERMISSIONLESS): change to use phases instead - if _, found := k.GetConsumerClientId(ctx, consumerId); !found { - return errorsmod.Wrap(types.ErrConsumerChainNotFound, - fmt.Sprintf("cannot stop non-existent consumer chain: %s", consumerId)) +// DeleteConsumerChain cleans up the state of the given consumer chain +func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err error) { + phase := k.GetConsumerPhase(ctx, consumerId) + if phase != types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + return fmt.Errorf("cannot delete non-stopped chain: %s", consumerId) } // clean up states @@ -459,19 +480,17 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan // close channel and delete the mappings between chain ID and channel ID if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { - if closeChan { - // Close the channel for the given channel ID on the condition - // that the channel exists and isn't already in the CLOSED state - channel, found := k.channelKeeper.GetChannel(ctx, ccv.ProviderPortID, channelID) - if found && channel.State != channeltypes.CLOSED { - err := k.chanCloseInit(ctx, channelID) - if err != nil { - k.Logger(ctx).Error("channel to consumer chain could not be closed", - "consumerId", consumerId, - "channelID", channelID, - "error", err.Error(), - ) - } + // Close the channel for the given channel ID on the condition + // that the channel exists and isn't already in the CLOSED state + channel, found := k.channelKeeper.GetChannel(ctx, ccv.ProviderPortID, channelID) + if found && channel.State != channeltypes.CLOSED { + err := k.chanCloseInit(ctx, channelID) + if err != nil { + k.Logger(ctx).Error("channel to consumer chain could not be closed", + "consumerId", consumerId, + "channelID", channelID, + "error", err.Error(), + ) } } k.DeleteConsumerIdToChannelId(ctx, consumerId) @@ -493,9 +512,15 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan k.DeleteAllOptedIn(ctx, consumerId) k.DeleteConsumerValSet(ctx, consumerId) + k.DeleteConsumerRewardsAllocation(ctx, consumerId) + k.DeleteConsumerRemovalTime(ctx, consumerId) + // TODO (PERMISSIONLESS) add newly-added state to be deleted + // Note that we do not delete ConsumerIdToChainIdKey and ConsumerIdToPhase, as well + // as consumer metadata, initialization and power-shaping parameters. - k.Logger(ctx).Info("consumer chain removed from provider", "consumerId", consumerId) + k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_DELETED) + k.Logger(ctx).Info("consumer chain deleted from provider", "consumerId", consumerId) return nil } @@ -504,35 +529,35 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, consumerId string, closeChan // Setters and Getters // -// GetConsumerStopTime returns the stop time associated with the to-be-stopped chain with consumer id -func (k Keeper) GetConsumerStopTime(ctx sdk.Context, consumerId string) (time.Time, error) { +// GetConsumerRemovalTime returns the removal time associated with the to-be-removed chain with consumer id +func (k Keeper) GetConsumerRemovalTime(ctx sdk.Context, consumerId string) (time.Time, error) { store := ctx.KVStore(k.storeKey) - buf := store.Get(types.ConsumerIdToStopTimeKey(consumerId)) + buf := store.Get(types.ConsumerIdToRemovalTimeKey(consumerId)) if buf == nil { - return time.Time{}, fmt.Errorf("failed to retrieve stop time for consumer id (%s)", consumerId) + return time.Time{}, fmt.Errorf("failed to retrieve removal time for consumer id (%s)", consumerId) } var time time.Time if err := time.UnmarshalBinary(buf); err != nil { - return time, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) + return time, fmt.Errorf("failed to unmarshal removal time for consumer id (%s): %w", consumerId, err) } return time, nil } -// SetConsumerStopTime sets the stop time associated with this consumer id -func (k Keeper) SetConsumerStopTime(ctx sdk.Context, consumerId string, stopTime time.Time) error { +// SetConsumerRemovalTime sets the removal time associated with this consumer id +func (k Keeper) SetConsumerRemovalTime(ctx sdk.Context, consumerId string, removalTime time.Time) error { store := ctx.KVStore(k.storeKey) - buf, err := stopTime.MarshalBinary() + buf, err := removalTime.MarshalBinary() if err != nil { - return fmt.Errorf("failed to marshal stop time (%+v) for consumer id (%s): %w", stopTime, consumerId, err) + return fmt.Errorf("failed to marshal removal time (%+v) for consumer id (%s): %w", removalTime, consumerId, err) } - store.Set(types.ConsumerIdToStopTimeKey(consumerId), buf) + store.Set(types.ConsumerIdToRemovalTimeKey(consumerId), buf) return nil } -// DeleteConsumerStopTime deletes the stop time associated with this consumer id -func (k Keeper) DeleteConsumerStopTime(ctx sdk.Context, consumerId string) { +// DeleteConsumerRemovalTime deletes the removal time associated with this consumer id +func (k Keeper) DeleteConsumerRemovalTime(ctx sdk.Context, consumerId string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.ConsumerIdToStopTimeKey(consumerId)) + store.Delete(types.ConsumerIdToRemovalTimeKey(consumerId)) } // getConsumerIdsBasedOnTime returns all the consumer ids stored under this specific `key(time)` @@ -632,17 +657,17 @@ func (k Keeper) RemoveConsumerToBeLaunched(ctx sdk.Context, consumerId string, s return k.removeConsumerIdFromTime(ctx, consumerId, types.SpawnTimeToConsumerIdsKey, spawnTime) } -// GetConsumersToBeStopped returns all the consumer ids of chains stored under this stop time -func (k Keeper) GetConsumersToBeStopped(ctx sdk.Context, stopTime time.Time) (types.ConsumerIds, error) { - return k.getConsumerIdsBasedOnTime(ctx, types.StopTimeToConsumerIdsKey, stopTime) +// GetConsumersToBeRemoved returns all the consumer ids of chains stored under this removal time +func (k Keeper) GetConsumersToBeRemoved(ctx sdk.Context, removalTime time.Time) (types.ConsumerIds, error) { + return k.getConsumerIdsBasedOnTime(ctx, types.RemovalTimeToConsumerIdsKey, removalTime) } -// AppendConsumerToBeStopped appends the provider consumer id for the given stop time -func (k Keeper) AppendConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { - return k.appendConsumerIdOnTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) +// AppendConsumerToBeRemoved appends the provider consumer id for the given removal time +func (k Keeper) AppendConsumerToBeRemoved(ctx sdk.Context, consumerId string, removalTime time.Time) error { + return k.appendConsumerIdOnTime(ctx, consumerId, types.RemovalTimeToConsumerIdsKey, removalTime) } -// RemoveConsumerToBeStopped removes consumer id from if stored for this specific stop time -func (k Keeper) RemoveConsumerToBeStopped(ctx sdk.Context, consumerId string, stopTime time.Time) error { - return k.removeConsumerIdFromTime(ctx, consumerId, types.StopTimeToConsumerIdsKey, stopTime) +// RemoveConsumerToBeRemoved removes consumer id from the given removal time +func (k Keeper) RemoveConsumerToBeRemoved(ctx sdk.Context, consumerId string, removalTime time.Time) error { + return k.removeConsumerIdFromTime(ctx, consumerId, types.RemovalTimeToConsumerIdsKey, removalTime) } diff --git a/x/ccv/provider/keeper/consumer_lifecycle_test.go b/x/ccv/provider/keeper/consumer_lifecycle_test.go index 7fc238570c..47e7b4420f 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle_test.go +++ b/x/ccv/provider/keeper/consumer_lifecycle_test.go @@ -648,17 +648,17 @@ func TestBeginBlockStopConsumers(t *testing.T) { chainIds := []string{"chain1", "chain2", "chain3"} consumerIds := []string{"consumerId1", "consumerId2", "consumerId3"} - err := providerKeeper.SetConsumerStopTime(ctx, consumerIds[0], now.Add(-time.Hour)) + err := providerKeeper.SetConsumerRemovalTime(ctx, consumerIds[0], now.Add(-time.Hour)) require.NoError(t, err) - err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[0], now.Add(-time.Hour)) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, consumerIds[0], now.Add(-time.Hour)) require.NoError(t, err) - err = providerKeeper.SetConsumerStopTime(ctx, consumerIds[1], now) + err = providerKeeper.SetConsumerRemovalTime(ctx, consumerIds[1], now) require.NoError(t, err) - err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[1], now) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, consumerIds[1], now) require.NoError(t, err) - err = providerKeeper.SetConsumerStopTime(ctx, consumerIds[2], now.Add(time.Hour)) + err = providerKeeper.SetConsumerRemovalTime(ctx, consumerIds[2], now.Add(time.Hour)) require.NoError(t, err) - err = providerKeeper.AppendConsumerToBeStopped(ctx, consumerIds[2], now.Add(time.Hour)) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, consumerIds[2], now.Add(time.Hour)) require.NoError(t, err) // @@ -674,8 +674,8 @@ func TestBeginBlockStopConsumers(t *testing.T) { expectations = append(expectations, testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, chainId)...) } // Only first two consumer chains should be stopped - expectations = append(expectations, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) - expectations = append(expectations, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + expectations = append(expectations, testkeeper.GetMocksForDeleteConsumerChain(ctx, &mocks)...) + expectations = append(expectations, testkeeper.GetMocksForDeleteConsumerChain(ctx, &mocks)...) gomock.InOrder(expectations...) @@ -703,24 +703,24 @@ func TestBeginBlockStopConsumers(t *testing.T) { err = providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) - // after we have created the consumer client, the chain is considered launched and hence we could later stop the chain - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + // the chain is considered to be stopped and ready for deletion (i.e., `StopAndPrepareForConsumerRemoval` is called) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) } // // Test execution // - providerKeeper.BeginBlockStopConsumers(ctx) + providerKeeper.BeginBlockRemoveConsumers(ctx) // Only the 3rd (final) proposal is still stored as pending phase := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, phase) phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[1]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) - // third chain had a stopTime in the future and hence did not stop + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, phase) + // third chain had a removal time in the future and hence did not get deleted phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) } func TestGetConsumersReadyToStop(t *testing.T) { @@ -730,31 +730,31 @@ func TestGetConsumersReadyToStop(t *testing.T) { // no chains to-be-stopped exist require.Empty(t, providerKeeper.GetConsumersReadyToStop(ctx, 3)) - err := providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", time.Unix(10, 0)) + err := providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId1", time.Unix(10, 0)) require.NoError(t, err) - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", time.Unix(20, 0)) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId2", time.Unix(20, 0)) require.NoError(t, err) - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", time.Unix(30, 0)) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId3", time.Unix(30, 0)) require.NoError(t, err) - // time has not yet reached the stop time of "consumerId1" + // time has not yet reached the removal time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(9, 999999999)) require.Empty(t, providerKeeper.GetConsumersReadyToStop(ctx, 3)) - // time has reached the stop time of "consumerId1" + // time has reached the removal time of "consumerId1" ctx = ctx.WithBlockTime(time.Unix(10, 0)) require.Equal(t, []string{"consumerId1"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) - // time has reached the stop time of "consumerId1" and "consumerId2" + // time has reached the removal time of "consumerId1" and "consumerId2" ctx = ctx.WithBlockTime(time.Unix(20, 0)) require.Equal(t, []string{"consumerId1", "consumerId2"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) - // time has reached the stop time of all chains + // time has reached the removal time of all chains ctx = ctx.WithBlockTime(time.Unix(30, 0)) require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, providerKeeper.GetConsumersReadyToStop(ctx, 3)) } -// Tests the StopConsumerChain method against the spec, +// Tests the DeleteConsumerChain method against the spec, // with more granularity than what's covered in TestHandleLegacyConsumerRemovalProposal, or integration tests. // See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stcc1 // Spec tag: [CCV-PCF-STCC.1] @@ -780,13 +780,13 @@ func TestStopConsumerChain(t *testing.T) { { description: "valid stop of consumer chain, all mock calls hit", setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks, consumerId) + testkeeper.SetupForDeleteConsumerChain(t, ctx, providerKeeper, mocks, consumerId) // set consumer minimum equivocation height providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerId, 1) - // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel - gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + // assert mocks for expected calls to `DeleteConsumerChain` when closing the underlying channel + gomock.InOrder(testkeeper.GetMocksForDeleteConsumerChain(ctx, &mocks)...) }, expErr: false, }, @@ -802,7 +802,7 @@ func TestStopConsumerChain(t *testing.T) { // Setup specific to test case tc.setup(ctx, &providerKeeper, mocks) - err := providerKeeper.StopConsumerChain(ctx, consumerId, true) + err := providerKeeper.DeleteConsumerChain(ctx, consumerId) if tc.expErr { require.Error(t, err, t) @@ -810,7 +810,7 @@ func TestStopConsumerChain(t *testing.T) { require.NoError(t, err) } - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsDeleted(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) ctrl.Finish() } @@ -820,22 +820,22 @@ func TestStopConsumerChain(t *testing.T) { // Setters and Getters // -// TestConsumerStopTime tests the getter, setter, and deletion of the consumer id to stop times methods -func TestConsumerStopTime(t *testing.T) { +// TestConsumerRemovalTime tests the getter, setter, and deletion of the consumer id to removal times methods +func TestConsumerRemovalTime(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - _, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + _, err := providerKeeper.GetConsumerRemovalTime(ctx, "consumerId") require.Error(t, err) - expectedStopTime := time.Unix(1234, 56789) - providerKeeper.SetConsumerStopTime(ctx, "consumerId", expectedStopTime) - actualStopTime, err := providerKeeper.GetConsumerStopTime(ctx, "consumerId") + expectedRemovalTime := time.Unix(1234, 56789) + providerKeeper.SetConsumerRemovalTime(ctx, "consumerId", expectedRemovalTime) + actualRemovalTime, err := providerKeeper.GetConsumerRemovalTime(ctx, "consumerId") require.NoError(t, err) - require.Equal(t, actualStopTime, expectedStopTime) + require.Equal(t, actualRemovalTime, expectedRemovalTime) - providerKeeper.DeleteConsumerStopTime(ctx, "consumerId") - _, err = providerKeeper.GetConsumerStopTime(ctx, "consumerId") + providerKeeper.DeleteConsumerRemovalTime(ctx, "consumerId") + _, err = providerKeeper.GetConsumerRemovalTime(ctx, "consumerId") require.Error(t, err) } @@ -905,68 +905,68 @@ func TestConsumersToBeLaunched(t *testing.T) { require.Equal(t, []string{"consumerId5"}, consumers.Ids) } -// TestConsumersToBeStopped tests `AppendConsumerToBeLaunched`, `GetConsumersToBeLaunched`, and `RemoveConsumerToBeLaunched` -func TestConsumersToBeStopped(t *testing.T) { +// TestConsumersToBeRemoved tests `AppendConsumerToBeRemoved`, `GetConsumersToBeRemoved`, and `RemoveConsumerToBeRemoved` +func TestConsumersToBeRemoved(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - stopTime := time.Now() - err := providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId1", stopTime) + removalTime := time.Now() + err := providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId1", removalTime) require.NoError(t, err) - consumers, err := providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err := providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1"}, consumers.Ids) - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId2", stopTime) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId2", removalTime) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2"}, consumers.Ids) - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId3", stopTime) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId3", removalTime) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId2", "consumerId3"}, consumers.Ids) - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId2", stopTime) + err = providerKeeper.RemoveConsumerToBeRemoved(ctx, "consumerId2", removalTime) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - // also add consumer ids under a different stop time and verify everything under the original stop time is still there - stopTimePlusOneHour := stopTime.Add(time.Hour) - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) + // also add consumer ids under a different removal time and verify everything under the original removal time is still there + removalTimePlusOneHour := removalTime.Add(time.Hour) + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId4", removalTimePlusOneHour) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTimePlusOneHour) require.NoError(t, err) require.Equal(t, []string{"consumerId4"}, consumers.Ids) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId1", "consumerId3"}, consumers.Ids) - // start removing all consumers from `stopTime` - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId3", stopTime) + // start removing all consumers from `removalTime` + err = providerKeeper.RemoveConsumerToBeRemoved(ctx, "consumerId3", removalTime) require.NoError(t, err) - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId1", stopTime) + err = providerKeeper.RemoveConsumerToBeRemoved(ctx, "consumerId1", removalTime) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Empty(t, consumers.Ids) - // remove from `stopTimePlusOneHour` - err = providerKeeper.RemoveConsumerToBeStopped(ctx, "consumerId4", stopTimePlusOneHour) + // remove from `removalTimePlusOneHour` + err = providerKeeper.RemoveConsumerToBeRemoved(ctx, "consumerId4", removalTimePlusOneHour) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTimePlusOneHour) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTimePlusOneHour) require.NoError(t, err) require.Empty(t, consumers.Ids) - // add another consumer for `stopTime` - err = providerKeeper.AppendConsumerToBeStopped(ctx, "consumerId5", stopTime) + // add another consumer for `removalTime` + err = providerKeeper.AppendConsumerToBeRemoved(ctx, "consumerId5", removalTime) require.NoError(t, err) - consumers, err = providerKeeper.GetConsumersToBeStopped(ctx, stopTime) + consumers, err = providerKeeper.GetConsumersToBeRemoved(ctx, removalTime) require.NoError(t, err) require.Equal(t, []string{"consumerId5"}, consumers.Ids) } diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 87a2e5e9e4..db75ff9b6e 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -74,8 +74,10 @@ func (k Keeper) AllocateTokens(ctx sdk.Context) { return } - // Iterate over all launched consumer chains - for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + // Iterate over all launched consumer chains. + // To avoid large iterations over all the consumer IDs, iterate only over + // chains with an IBC client created. + for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { // note that it's possible that no rewards are collected even though the // reward pool isn't empty. This can happen if the reward pool holds some tokens @@ -269,6 +271,12 @@ func (k Keeper) SetConsumerRewardsAllocation(ctx sdk.Context, consumerId string, store.Set(types.ConsumerRewardsAllocationKey(consumerId), b) } +// DeleteConsumerRewardsAllocation deletes the consumer rewards allocation for the given consumer id +func (k Keeper) DeleteConsumerRewardsAllocation(ctx sdk.Context, consumerId string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerRewardsAllocationKey(consumerId)) +} + // GetConsumerRewardsPool returns the balance // of the consumer rewards pool module account func (k Keeper) GetConsumerRewardsPool(ctx sdk.Context) sdk.Coins { diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index 127b15c65a..7e8fd4bb76 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -36,6 +36,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) []abc for _, cs := range genState.ConsumerStates { chainID := cs.ChainId k.SetConsumerClientId(ctx, chainID, cs.ClientId) + k.SetConsumerPhase(ctx, chainID, cs.Phase) if err := k.SetConsumerGenesis(ctx, chainID, cs.ConsumerGenesis); err != nil { // An error here would indicate something is very wrong, // the ConsumerGenesis validated in ConsumerState.Validate(). @@ -118,14 +119,13 @@ func (k Keeper) InitGenesisValUpdates(ctx sdk.Context) []abci.ValidatorUpdate { // ExportGenesis returns the CCV provider module's exported genesis func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - // get a list of all registered consumer chains - registeredConsumerIds := k.GetAllRegisteredConsumerIds(ctx) + launchedConsumerIds := k.GetAllConsumersWithIBCClients(ctx) // export states for each consumer chains var consumerStates []types.ConsumerState - for _, consumerId := range registeredConsumerIds { + for _, consumerId := range launchedConsumerIds { // no need for the second return value of GetConsumerClientId - // as GetAllRegisteredConsumerIds already iterated through + // as GetAllConsumersWithIBCClients already iterated through // the entire prefix range clientId, _ := k.GetConsumerClientId(ctx, consumerId) gen, found := k.GetConsumerGenesis(ctx, consumerId) @@ -138,6 +138,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { ChainId: consumerId, ClientId: clientId, ConsumerGenesis: gen, + Phase: k.GetConsumerPhase(ctx, consumerId), } // try to find channel id for the current consumer chain @@ -157,7 +158,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { // ConsumerAddrsToPrune are added only for registered consumer chains consumerAddrsToPrune := []types.ConsumerAddrsToPruneV2{} - for _, chainID := range registeredConsumerIds { + for _, chainID := range launchedConsumerIds { consumerAddrsToPrune = append(consumerAddrsToPrune, k.GetAllConsumerAddrsToPrune(ctx, chainID)...) } diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index 3f3ec2d240..a9126f9afe 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -51,6 +51,7 @@ func TestInitAndExportGenesis(t *testing.T) { *ccv.DefaultConsumerGenesisState(), []ccv.ValidatorSetChangePacketData{}, []string{"slashedValidatorConsAddress"}, + providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, ), providertypes.NewConsumerStates( cChainIDs[1], @@ -60,6 +61,7 @@ func TestInitAndExportGenesis(t *testing.T) { *ccv.DefaultConsumerGenesisState(), []ccv.ValidatorSetChangePacketData{{ValsetUpdateId: vscID}}, nil, + providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, ), }, params, diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 08c93fae08..3325ffd193 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -424,7 +424,9 @@ func (k Keeper) QueryConsumerChainsValidatorHasToValidate(goCtx context.Context, // get all the consumer chains for which the validator is either already // opted-in, currently a consumer validator or if its voting power is within the TopN validators consumersToValidate := []string{} - for _, consumerId := range k.GetAllLaunchedConsumerIds(ctx) { + // To avoid large iterations over all the consumer IDs, iterate only over + // chains with an IBC client created. + for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { if hasToValidate, err := k.hasToValidate(ctx, provAddr, consumerId); err == nil && hasToValidate { consumersToValidate = append(consumersToValidate, consumerId) } diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index 5c55979dfa..f87c62c375 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -319,6 +319,11 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { resp, err := msgServer.CreateConsumer(ctx, &msg) require.NoError(t, err) consumerId := resp.ConsumerId + + // set a consumer client id, so that `GetAllConsumersWithIBCClients` is non-empty + clientID := "client-" + strconv.Itoa(i) + pk.SetConsumerClientId(ctx, consumerId, clientID) + pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) consumerIds[i] = consumerId } diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 5274753f31..4d60cf8dc9 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -211,13 +211,8 @@ func (k Keeper) DeleteConsumerIdToChannelId(ctx sdk.Context, consumerId string) store.Delete(types.ConsumerIdToChannelIdKey(consumerId)) } -// GetAllRegisteredConsumerIds gets all of the consumer chain IDs, for which the provider module -// created IBC clients. Consumer chains with created clients are also referred to as registered. -// -// Note that the registered consumer chains are stored under keys with the following format: -// ConsumerIdToClientIdKeyPrefix | consumerId -// Thus, the returned array is in ascending order of chainIDs. -func (k Keeper) GetAllRegisteredConsumerIds(ctx sdk.Context) []string { +// GetAllConsumersWithIBCClients returns the ids of all consumer chains that with IBC clients created. +func (k Keeper) GetAllConsumersWithIBCClients(ctx sdk.Context) []string { consumerIds := []string{} store := ctx.KVStore(k.storeKey) @@ -740,18 +735,6 @@ func (k Keeper) GetAllActiveConsumerIds(ctx sdk.Context) []string { return consumerIds } -// GetAllLaunchedConsumerIds returns all the consumer ids of chains that are launched -func (k Keeper) GetAllLaunchedConsumerIds(ctx sdk.Context) []string { - consumerIds := []string{} - for _, consumerId := range k.GetAllConsumerIds(ctx) { - if phase := k.GetConsumerPhase(ctx, consumerId); phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { - continue - } - consumerIds = append(consumerIds, consumerId) - } - return consumerIds -} - func (k Keeper) SetOptedIn( ctx sdk.Context, consumerId string, diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 0a5fe59c97..79d0b7fe8c 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -223,22 +223,28 @@ func TestInitHeight(t *testing.T) { } } -func TestGetAllRegisteredConsumerChainIDs(t *testing.T) { +func TestGetAllConsumersWithIBCClients(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainIDs := []string{"chain-2", "chain-1", "chain-4", "chain-3"} - // GetAllRegisteredConsumerIds iterates over consumerId in lexicographical order - expectedChainIDs := []string{"chain-1", "chain-2", "chain-3", "chain-4"} - - for i, chainID := range chainIDs { - clientID := fmt.Sprintf("client-%d", len(chainIDs)-i) - pk.SetConsumerClientId(ctx, chainID, clientID) + consumerIds := []string{"2", "1", "4", "3"} + for i, consumerId := range consumerIds { + clientId := fmt.Sprintf("client-%d", len(consumerIds)-i) + pk.SetConsumerClientId(ctx, consumerId, clientId) + pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) } - result := pk.GetAllRegisteredConsumerIds(ctx) - require.Len(t, result, len(chainIDs)) - require.Equal(t, expectedChainIDs, result) + actualConsumerIds := pk.GetAllConsumersWithIBCClients(ctx) + require.Len(t, actualConsumerIds, len(consumerIds)) + + // sort the consumer ids before comparing they are equal + sort.Slice(consumerIds, func(i, j int) bool { + return consumerIds[i] < consumerIds[j] + }) + sort.Slice(actualConsumerIds, func(i, j int) bool { + return actualConsumerIds[i] < actualConsumerIds[j] + }) + require.Equal(t, consumerIds, actualConsumerIds) } // TestGetAllChannelToChains tests GetAllChannelToConsumers behaviour correctness diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 83664e369e..b24e09ae4d 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -343,7 +343,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon return &resp, nil } -// UpdateConsumer updates the record of a consumer chain +// UpdateConsumer updates the metadata, power-shaping or initialization parameters of a consumer chain func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateConsumer) (*types.MsgUpdateConsumerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) resp := types.MsgUpdateConsumerResponse{} @@ -469,25 +469,12 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon phase := k.Keeper.GetConsumerPhase(ctx, consumerId) if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { - return nil, errorsmod.Wrapf(types.ErrInvalidPhase, + return &resp, errorsmod.Wrapf(types.ErrInvalidPhase, "chain with consumer id: %s has to be in its launched phase", consumerId) } - previousStopTime, err := k.Keeper.GetConsumerStopTime(ctx, consumerId) - if err == nil { - if err := k.Keeper.RemoveConsumerToBeStopped(ctx, consumerId, previousStopTime); err != nil { - return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot remove previous stop time: %s", err.Error()) - } - } - - if err := k.Keeper.SetConsumerStopTime(ctx, consumerId, msg.StopTime); err != nil { - return &resp, errorsmod.Wrapf(types.ErrInvalidStopTime, "cannot set stop time: %s", err.Error()) - } - if err := k.Keeper.AppendConsumerToBeStopped(ctx, consumerId, msg.StopTime); err != nil { - return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot set consumer to be stopped: %s", err.Error()) - } - - return &resp, nil + err = k.Keeper.StopAndPrepareForConsumerRemoval(ctx, consumerId) + return &resp, err } func (k msgServer) ConsumerAddition(_ context.Context, _ *types.MsgConsumerAddition) (*types.MsgConsumerAdditionResponse, error) { diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index ecedda108d..039b016ffd 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -119,11 +119,11 @@ func (k Keeper) GetConsumerInitializationParameters(ctx sdk.Context, consumerId if bz == nil { return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to retrieve initialization parameters for consumer id (%s)", consumerId) } - var record types.ConsumerInitializationParameters - if err := record.Unmarshal(bz); err != nil { - return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to unmarshal stop time for consumer id (%s): %w", consumerId, err) + var initializationParameters types.ConsumerInitializationParameters + if err := initializationParameters.Unmarshal(bz); err != nil { + return types.ConsumerInitializationParameters{}, fmt.Errorf("failed to unmarshal initialization parameters for consumer id (%s): %w", consumerId, err) } - return record, nil + return initializationParameters, nil } // SetConsumerInitializationParameters sets the initialization parameters associated with this consumer id diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index cbd429c008..f5e5216bb6 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -30,8 +30,7 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac "error", err, ) if consumerId, ok := k.GetChannelIdToConsumerId(ctx, packet.SourceChannel); ok { - // stop consumer chain and release unbonding - return k.StopConsumerChain(ctx, consumerId, false) + return k.StopAndPrepareForConsumerRemoval(ctx, consumerId) } return errorsmod.Wrapf(providertypes.ErrUnknownConsumerChannelId, "recv ErrorAcknowledgement on unknown channel %s", packet.SourceChannel) } @@ -50,9 +49,8 @@ func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) err packet.SourceChannel, ) } - k.Logger(ctx).Info("packet timeout, removing the consumer:", "consumerId", consumerId) - // stop consumer chain and release unbondings - return k.StopConsumerChain(ctx, consumerId, false) + k.Logger(ctx).Info("packet timeout, deleting the consumer:", "consumerId", consumerId) + return k.StopAndPrepareForConsumerRemoval(ctx, consumerId) } // EndBlockVSU contains the EndBlock logic needed for @@ -137,12 +135,19 @@ func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64 { } } -// SendVSCPackets iterates over all registered consumers and sends pending -// VSC packets to the chains with established CCV channels. +// SendVSCPackets iterates over all consumers chains with created IBC clients +// and sends pending VSC packets to the chains with established CCV channels. // If the CCV channel is not established for a consumer chain, // the updates will remain queued until the channel is established +// +// TODO (mpoke): iterate only over consumers with established channel func (k Keeper) SendVSCPackets(ctx sdk.Context) error { - for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { + if k.GetConsumerPhase(ctx, consumerId) != providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + // only send VSCPackets to launched chains + continue + } + // check if CCV channel is established and send if channelID, found := k.GetConsumerIdToChannelId(ctx, consumerId); found { if err := k.SendVSCPacketsToChain(ctx, consumerId, channelID); err != nil { @@ -180,10 +185,11 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId str } // Not able to send packet over IBC! k.Logger(ctx).Error("cannot send VSC, removing consumer:", "consumerId", consumerId, "vscid", data.ValsetUpdateId, "err", err.Error()) - // If this happens, most likely the consumer is malicious; remove it - err := k.StopConsumerChain(ctx, consumerId, true) + + err := k.StopAndPrepareForConsumerRemoval(ctx, consumerId) if err != nil { - return fmt.Errorf("stopping consumer, consumerId(%s): %w", consumerId, err) + k.Logger(ctx).Info("consumer chain failed to stop:", "consumerId", consumerId, "error", err.Error()) + // return fmt.Errorf("stopping consumer, consumerId(%s): %w", consumerId, err) } return nil } @@ -193,7 +199,10 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId str return nil } -// QueueVSCPackets queues latest validator updates for every registered consumer chain +// QueueVSCPackets queues latest validator updates for every consumer chain +// with the IBC client created. +// +// TODO (mpoke): iterate only over consumers with established channel func (k Keeper) QueueVSCPackets(ctx sdk.Context) error { valUpdateID := k.GetValidatorSetUpdateId(ctx) // current valset update ID @@ -209,7 +218,12 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) error { return fmt.Errorf("getting provider active validators: %w", err) } - for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { + if k.GetConsumerPhase(ctx, consumerId) != providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + // only queue VSCPackets to launched chains + continue + } + currentValidators, err := k.GetConsumerValSet(ctx, consumerId) if err != nil { return fmt.Errorf("getting consumer validators, consumerId(%s): %w", consumerId, err) @@ -282,7 +296,7 @@ func (k Keeper) EndBlockCIS(ctx sdk.Context) { k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) // prune previous consumer validator addresses that are no longer needed - for _, consumerId := range k.GetAllRegisteredConsumerIds(ctx) { + for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { k.PruneKeyAssignments(ctx, consumerId) } } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 70effd1753..88ec9159e3 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -4,8 +4,10 @@ import ( "sort" "strings" "testing" + "time" "cosmossdk.io/math" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" @@ -106,8 +108,9 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, valBConsAddr).Return(valB, nil).AnyTimes() testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 2, []stakingtypes.Validator{valA, valB}, -1) - // set a consumer client, so we have a consumer chain (i.e., `k.GetAllConsumerChains(ctx)` is non empty) + // set a consumer client id and its phase, so we have a consumer chain (i.e., `GetAllConsumersWithIBCClients` is non-empty) providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // opt in validator A and set as a consumer validator providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) @@ -487,10 +490,10 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { providerKeeper.SetParams(ctx, providertypes.DefaultParams()) // Append mocks for full consumer setup - mockCalls := testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, "consumerChainID") + mockCalls := testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, "consumerId") // Set 3 pending vsc packets - providerKeeper.AppendPendingVSCPackets(ctx, "consumerChainID", []ccv.ValidatorSetChangePacketData{{}, {}, {}}...) + providerKeeper.AppendPendingVSCPackets(ctx, "consumerId", []ccv.ValidatorSetChangePacketData{{}, {}, {}}...) // append mocks for the channel keeper to return an error mockCalls = append(mockCalls, @@ -498,23 +501,36 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { "CCVChannelID").Return(channeltypes.Channel{}, false).Times(1), ) - // Append mocks for expected call to StopConsumerChain - mockCalls = append(mockCalls, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + // Append mocks for expected call to DeleteConsumerChain + mockCalls = append(mockCalls, testkeeper.GetMocksForDeleteConsumerChain(ctx, &mocks)...) // Assert mock calls hit gomock.InOrder(mockCalls...) // Execute setup - providerKeeper.SetConsumerClientId(ctx, "consumerChainID", "clientID") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") err := providerKeeper.SetConsumerChain(ctx, "channelID") require.NoError(t, err) - // No error should occur, StopConsumerChain should be called - err = providerKeeper.SendVSCPacketsToChain(ctx, "consumerChainID", "CCVChannelID") + unbondingTime := 123 * time.Second + mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Return(unbondingTime, nil).AnyTimes() + + // No error should occur, DeleteConsumerChain should be called + err = providerKeeper.SendVSCPacketsToChain(ctx, "consumerId", "CCVChannelID") + require.NoError(t, err) + + // Verify the chain is about to be deleted + removalTime, err := providerKeeper.GetConsumerRemovalTime(ctx, "consumerId") require.NoError(t, err) + require.Equal(t, ctx.BlockTime().Add(unbondingTime), removalTime) - // Pending VSC packets should be deleted in StopConsumerChain - require.Empty(t, providerKeeper.GetPendingVSCPackets(ctx, "consumerChainID")) + // Increase the block time by `unbondingTime` so the chain actually gets deleted + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(unbondingTime)) + providerKeeper.BeginBlockRemoveConsumers(ctx) + + // Pending VSC packets should be deleted in DeleteConsumerChain + require.Empty(t, providerKeeper.GetPendingVSCPackets(ctx, "consumerId")) + require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, providerKeeper.GetConsumerPhase(ctx, "consumerId")) } // TestOnTimeoutPacketWithNoChainFound tests the `OnTimeoutPacket` method fails when no chain is found @@ -539,15 +555,30 @@ func TestOnTimeoutPacketStopsChain(t *testing.T) { defer ctrl.Finish() providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") + testkeeper.SetupForDeleteConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") + mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), ccv.ProviderPortID, "channelID").Return( + channeltypes.Channel{State: channeltypes.OPEN, + ConnectionHops: []string{"connectionID"}, + }, true, + ).Times(1) + dummyCap := &capabilitytypes.Capability{} + mocks.MockScopedKeeper.EXPECT().GetCapability(gomock.Any(), gomock.Any()).Return(dummyCap, true).Times(1) + mocks.MockChannelKeeper.EXPECT().ChanCloseInit(gomock.Any(), ccv.ProviderPortID, "channelID", dummyCap).Times(1) + + unbondingTime := 123 * time.Second + mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Return(unbondingTime, nil).AnyTimes() packet := channeltypes.Packet{ SourceChannel: "channelID", } err := providerKeeper.OnTimeoutPacket(ctx, packet) - - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) require.NoError(t, err) + + // increase the block time by `unbondingTime` so the chain actually gets deleted + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(unbondingTime)) + providerKeeper.BeginBlockRemoveConsumers(ctx) + + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsDeleted(t, ctx, providerKeeper, "consumerId", "channelID", false) } // TestOnAcknowledgementPacketWithNoAckError tests `OnAcknowledgementPacket` when the underlying ack contains no error @@ -575,15 +606,30 @@ func TestOnAcknowledgementPacketWithAckError(t *testing.T) { require.True(t, strings.Contains(err.Error(), providertypes.ErrUnknownConsumerChannelId.Error())) // test that we stop the consumer chain when `OnAcknowledgementPacket` returns an error and the chain is found - testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") + testkeeper.SetupForDeleteConsumerChain(t, ctx, &providerKeeper, mocks, "consumerId") packet := channeltypes.Packet{ SourceChannel: "channelID", } - err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) + unbondingTime := 123 * time.Second + mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Return(unbondingTime, nil).AnyTimes() + mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), ccv.ProviderPortID, "channelID").Return( + channeltypes.Channel{State: channeltypes.OPEN, + ConnectionHops: []string{"connectionID"}, + }, true, + ).Times(1) + dummyCap := &capabilitytypes.Capability{} + mocks.MockScopedKeeper.EXPECT().GetCapability(gomock.Any(), gomock.Any()).Return(dummyCap, true).Times(1) + mocks.MockChannelKeeper.EXPECT().ChanCloseInit(gomock.Any(), ccv.ProviderPortID, "channelID", dummyCap).Times(1) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) + err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) require.NoError(t, err) + + // increase the block time by `unbondingTime` so the chain actually gets deleted + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(unbondingTime)) + providerKeeper.BeginBlockRemoveConsumers(ctx) + + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsDeleted(t, ctx, providerKeeper, "consumerId", "channelID", false) } // TestEndBlockVSU tests that during `EndBlockVSU`, we only queue VSC packets at the boundaries of an epoch @@ -591,7 +637,7 @@ func TestEndBlockVSU(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - chainID := "consumerId" + consumerId := "0" err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ Top_N: 100, @@ -621,26 +667,28 @@ func TestEndBlockVSU(t *testing.T) { }) mocks.MockStakingKeeper.EXPECT().GetBondedValidatorsByPower(gomock.Any()).Return(lastValidators, nil).AnyTimes() - // set a sample client for a consumer chain so that `GetAllConsumerChains` in `QueueVSCPackets` iterates at least once - providerKeeper.SetConsumerClientId(ctx, chainID, "clientID") + // set a sample client for a launched consumer chain so that `GetAllConsumersWithIBCClients` in `QueueVSCPackets` iterates at least once + providerKeeper.SetConsumerClientId(ctx, consumerId, "clientId") + providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{Top_N: 100}) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // with block height of 1 we do not expect any queueing of VSC packets ctx = ctx.WithBlockHeight(1) _, err = providerKeeper.EndBlockVSU(ctx) require.NoError(t, err) - require.Equal(t, 0, len(providerKeeper.GetPendingVSCPackets(ctx, chainID))) + require.Equal(t, 0, len(providerKeeper.GetPendingVSCPackets(ctx, consumerId))) // with block height of 5 we do not expect any queueing of VSC packets ctx = ctx.WithBlockHeight(5) _, err = providerKeeper.EndBlockVSU(ctx) require.NoError(t, err) - require.Equal(t, 0, len(providerKeeper.GetPendingVSCPackets(ctx, chainID))) + require.Equal(t, 0, len(providerKeeper.GetPendingVSCPackets(ctx, consumerId))) // with block height of 10 we expect the queueing of one VSC packet ctx = ctx.WithBlockHeight(10) _, err = providerKeeper.EndBlockVSU(ctx) require.NoError(t, err) - require.Equal(t, 1, len(providerKeeper.GetPendingVSCPackets(ctx, chainID))) + require.Equal(t, 1, len(providerKeeper.GetPendingVSCPackets(ctx, consumerId))) // With block height of 15 we expect no additional queueing of a VSC packet. // Note that the pending VSC packet is still there because `SendVSCPackets` does not send the packet. We @@ -648,7 +696,7 @@ func TestEndBlockVSU(t *testing.T) { ctx = ctx.WithBlockHeight(15) _, err = providerKeeper.EndBlockVSU(ctx) require.NoError(t, err) - require.Equal(t, 1, len(providerKeeper.GetPendingVSCPackets(ctx, chainID))) + require.Equal(t, 1, len(providerKeeper.GetPendingVSCPackets(ctx, consumerId))) } // TestProviderValidatorUpdates tests that the provider validator updates are correctly calculated, @@ -750,7 +798,8 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 5, []stakingtypes.Validator{valA, valB, valC, valD, valE}, -1) // add a consumer chain - providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") + providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientId") + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ Top_N: 50, // would opt in E diff --git a/x/ccv/provider/migrations/v5/migration_test.go b/x/ccv/provider/migrations/v5/migration_test.go index 1ae0e98a20..498c8b5b98 100644 --- a/x/ccv/provider/migrations/v5/migration_test.go +++ b/x/ccv/provider/migrations/v5/migration_test.go @@ -1,6 +1,7 @@ package v5 import ( + "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" "testing" "github.com/stretchr/testify/require" @@ -13,17 +14,19 @@ func TestMigrateParams(t *testing.T) { provKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) defer ctrl.Finish() - provKeeper.SetConsumerClientId(ctx, "chainID", "clientID") + // set up a launched consumer chain + provKeeper.SetConsumerClientId(ctx, "consumerId", "clientId") + provKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) // initially top N should not exist - _, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "chainID") + _, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.Error(t, err) // migrate MigrateTopNForRegisteredChains(ctx, provKeeper) // after migration, top N should be 95 - powerShapingParameters, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "chainID") + powerShapingParameters, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") require.NoError(t, err) require.Equal(t, uint32(95), powerShapingParameters.Top_N) } diff --git a/x/ccv/provider/migrations/v5/migrations.go b/x/ccv/provider/migrations/v5/migrations.go index 1dca37bbae..4c4ba3a988 100644 --- a/x/ccv/provider/migrations/v5/migrations.go +++ b/x/ccv/provider/migrations/v5/migrations.go @@ -10,9 +10,11 @@ import ( // This migration only takes already registered chains into account. // If a chain is in voting while the upgrade happens, this is not sufficient, // and a migration to rewrite the proposal is needed. +// +// TODO (PERMISSIONLESS): this migration needs to be fix or removed func MigrateTopNForRegisteredChains(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { // Set the topN of each chain to 95 - for _, consumerId := range providerKeeper.GetAllRegisteredConsumerIds(ctx) { + for _, consumerId := range providerKeeper.GetAllConsumersWithIBCClients(ctx) { // TODO (PERMISSIONLESS): this migration already took place and does not make much sense in the Permissionless world // living here for now and we should totally remove providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ diff --git a/x/ccv/provider/migrations/v6/migrations.go b/x/ccv/provider/migrations/v6/migrations.go index efbded3d02..58c48915b9 100644 --- a/x/ccv/provider/migrations/v6/migrations.go +++ b/x/ccv/provider/migrations/v6/migrations.go @@ -16,10 +16,11 @@ func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { paramsSubspace.Set(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, providertypes.DefaultNumberOfEpochsToStartReceivingRewards) } +// TODO (PERMISSIONLESS): this migration needs to be fix or removed func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { // we only get the registered consumer chains and not also the proposed consumer chains because // the minimal power is first set when the consumer chain addition proposal passes - registeredConsumerChains := providerKeeper.GetAllRegisteredConsumerIds(ctx) + registeredConsumerChains := providerKeeper.GetAllConsumersWithIBCClients(ctx) for _, chain := range registeredConsumerChains { // get the top N diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index 30ac49363a..2f089509ee 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -176,7 +176,7 @@ func (am AppModule) BeginBlock(ctx context.Context) error { // Create clients to consumer chains that are due to be spawned am.keeper.BeginBlockLaunchConsumers(sdkCtx) // Stop and remove state for any consumer chains that are due to be stopped - am.keeper.BeginBlockStopConsumers(sdkCtx) + am.keeper.BeginBlockRemoveConsumers(sdkCtx) // Check for replenishing slash meter before any slash packets are processed for this block am.keeper.BeginBlockCIS(sdkCtx) // BeginBlock logic needed for the Reward Distribution sub-protocol diff --git a/x/ccv/provider/types/consumer.go b/x/ccv/provider/types/consumer.go index 37c286422f..ebc1bcbf30 100644 --- a/x/ccv/provider/types/consumer.go +++ b/x/ccv/provider/types/consumer.go @@ -12,6 +12,7 @@ func NewConsumerStates( genesis ccv.ConsumerGenesisState, pendingValsetChanges []ccv.ValidatorSetChangePacketData, slashDowntimeAck []string, + phase ConsumerPhase, ) ConsumerState { return ConsumerState{ ChainId: chainID, @@ -21,5 +22,6 @@ func NewConsumerStates( PendingValsetChanges: pendingValsetChanges, ConsumerGenesis: genesis, SlashDowntimeAck: slashDowntimeAck, + Phase: phase, } } diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index b4fe49942f..933e363f73 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -36,7 +36,7 @@ var ( ErrInvalidTransformToOptIn = errorsmod.Register(ModuleName, 40, "invalid transform to Opt In chain") ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") ErrCannotPrepareForLaunch = errorsmod.Register(ModuleName, 42, "cannot prepare chain for launch") - ErrInvalidStopTime = errorsmod.Register(ModuleName, 43, "invalid stop time") + ErrInvalidRemovalTime = errorsmod.Register(ModuleName, 43, "invalid removal time") ErrInvalidMsgCreateConsumer = errorsmod.Register(ModuleName, 44, "invalid create consumer message") ErrInvalidMsgUpdateConsumer = errorsmod.Register(ModuleName, 45, "invalid update consumer message") ErrInvalidMsgAssignConsumerKey = errorsmod.Register(ModuleName, 46, "invalid assign consumer key message") diff --git a/x/ccv/provider/types/genesis.pb.go b/x/ccv/provider/types/genesis.pb.go index 5dc5b300c4..92a7aa345e 100644 --- a/x/ccv/provider/types/genesis.pb.go +++ b/x/ccv/provider/types/genesis.pb.go @@ -141,6 +141,8 @@ type ConsumerState struct { // consumer chain PendingValsetChanges []types.ValidatorSetChangePacketData `protobuf:"bytes,6,rep,name=pending_valset_changes,json=pendingValsetChanges,proto3" json:"pending_valset_changes"` SlashDowntimeAck []string `protobuf:"bytes,7,rep,name=slash_downtime_ack,json=slashDowntimeAck,proto3" json:"slash_downtime_ack,omitempty"` + // the phase of the consumer chain + Phase ConsumerPhase `protobuf:"varint,9,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` } func (m *ConsumerState) Reset() { *m = ConsumerState{} } @@ -225,6 +227,13 @@ func (m *ConsumerState) GetSlashDowntimeAck() []string { return nil } +func (m *ConsumerState) GetPhase() ConsumerPhase { + if m != nil { + return m.Phase + } + return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED +} + // ValsetUpdateIdToHeight defines the genesis information for the mapping // of each valset update id to a block height type ValsetUpdateIdToHeight struct { @@ -290,53 +299,54 @@ func init() { } var fileDescriptor_48411d9c7900d48e = []byte{ - // 730 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xcd, 0x6e, 0xda, 0x4c, - 0x14, 0xc5, 0xc1, 0x01, 0x33, 0x09, 0x7c, 0x96, 0x15, 0x21, 0x7f, 0x89, 0x4a, 0x10, 0x55, 0x24, - 0xa4, 0xb6, 0x38, 0x50, 0x55, 0xaa, 0xfa, 0xb3, 0x08, 0x89, 0xd4, 0xe2, 0x6e, 0x10, 0x49, 0x53, - 0x29, 0x1b, 0x6b, 0x98, 0x19, 0xc1, 0x08, 0xb0, 0x2d, 0xcf, 0xe0, 0x14, 0x55, 0x95, 0xda, 0x37, - 0xe8, 0xba, 0x2f, 0xd1, 0xd7, 0xc8, 0x32, 0xcb, 0xae, 0xa2, 0x2a, 0x79, 0x83, 0x3e, 0x41, 0xe5, - 0xf1, 0xe0, 0x40, 0x4a, 0x22, 0xd2, 0x9d, 0x7d, 0xcf, 0x9c, 0x7b, 0xcf, 0xfd, 0x05, 0x75, 0xea, - 0x72, 0x12, 0xa0, 0x3e, 0xa4, 0xae, 0xc3, 0x08, 0x1a, 0x07, 0x94, 0x4f, 0x2c, 0x84, 0x42, 0xcb, - 0x0f, 0xbc, 0x90, 0x62, 0x12, 0x58, 0x61, 0xdd, 0xea, 0x11, 0x97, 0x30, 0xca, 0x6a, 0x7e, 0x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, 0x2a, 0xa5, 0x7e, 0x5e, 0x95, 0x52, 0x27, 0xaf, 0x7b, 0x94, 0xf7, 0xc7, 0xdd, 0x1a, 0xf2, - 0x46, 0x16, 0xf2, 0xd8, 0xc8, 0x63, 0xd6, 0x75, 0x41, 0x9e, 0x24, 0xa7, 0x38, 0x7c, 0x66, 0x7d, - 0x9c, 0xbf, 0xc7, 0x7c, 0xe2, 0x13, 0xd6, 0xcd, 0x88, 0x53, 0xfc, 0xf4, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x42, 0x5f, 0xb9, 0x07, 0x87, 0x06, 0x00, 0x00, + // 750 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xdd, 0x6e, 0xda, 0x48, + 0x14, 0xc6, 0xc1, 0x80, 0x99, 0x04, 0xd6, 0xb2, 0x22, 0xe4, 0x4d, 0xb4, 0x04, 0xb1, 0x8a, 0x84, + 0xb4, 0xbb, 0x38, 0xb0, 0xaa, 0x54, 0xf5, 0xe7, 0x22, 0x24, 0x52, 0x83, 0x7b, 0x83, 0x48, 0x9a, + 0x4a, 0xb9, 0xb1, 0x86, 0x99, 0x11, 0x1e, 0x01, 0xb6, 0xe5, 0x19, 0x9c, 0xa2, 0xaa, 0x52, 0xfb, + 0x06, 0x7d, 0x93, 0xbe, 0x46, 0x2e, 0x73, 0xd9, 0xab, 0xa8, 0x4a, 0xfa, 0x04, 0x7d, 0x82, 0xca, + 0xe3, 0x81, 0x40, 0x4a, 0x22, 0xd2, 0x3b, 0xfb, 0x7c, 0xf3, 0x9d, 0xf3, 0x9d, 0x5f, 0xd0, 0xa0, + 0x1e, 0x27, 0x21, 0x72, 0x21, 0xf5, 0x1c, 0x46, 0xd0, 0x38, 0xa4, 0x7c, 0x62, 0x21, 0x14, 0x59, + 0x41, 0xe8, 0x47, 0x14, 0x93, 0xd0, 0x8a, 0x1a, 0x56, 0x9f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2f, 0x00, 0x90, 0x0b, 0x3d, 0x8f, 0x0c, 0x63, 0x70, 0x4d, + 0x80, 0x79, 0x69, 0x69, 0x63, 0x63, 0x1b, 0xe4, 0xd1, 0x90, 0x12, 0x8f, 0xc7, 0x68, 0x5a, 0xa0, + 0x5a, 0x62, 0x68, 0x63, 0x63, 0x17, 0x14, 0xa9, 0x47, 0x39, 0x85, 0xc3, 0xe9, 0x58, 0xab, 0x62, + 0x0f, 0x0b, 0xd2, 0x2a, 0x47, 0x11, 0x02, 0x7d, 0x56, 0x38, 0x79, 0xa3, 0xcc, 0x8c, 0x18, 0xca, + 0xbd, 0x7b, 0xcb, 0x35, 0x57, 0xa5, 0xf9, 0xe5, 0x97, 0x35, 0x9a, 0xad, 0xb5, 0xc4, 0x0c, 0x0e, + 0x4a, 0x01, 0xf1, 0x30, 0xf5, 0xfa, 0x8e, 0x5c, 0xba, 0x38, 0x85, 0x3e, 0x61, 0x66, 0x56, 0xf4, + 0xe5, 0xe9, 0x43, 0x81, 0x66, 0x03, 0x71, 0x4c, 0xf8, 0x81, 0xa0, 0x75, 0x20, 0x1a, 0x10, 0x7e, + 0x08, 0x39, 0x94, 0x01, 0x37, 0xa5, 0xf7, 0x64, 0x15, 0x93, 0x47, 0xcc, 0xf8, 0x17, 0x18, 0x6c, + 0x08, 0x99, 0xeb, 0x60, 0xff, 0xdc, 0xe3, 0x74, 0x44, 0x1c, 0x88, 0x06, 0x66, 0xae, 0x92, 0xae, + 0xe5, 0xbb, 0xba, 0x40, 0x0e, 0x25, 0xb0, 0x8f, 0x06, 0xc6, 0x11, 0xc8, 0x04, 0x2e, 0x64, 0xc4, + 0xcc, 0x57, 0x94, 0x5a, 0xf1, 0x91, 0x37, 0xa8, 0x13, 0x33, 0xbb, 0x89, 0x03, 0x5b, 0xd5, 0x34, + 0x3d, 0x5f, 0x3d, 0x03, 0xa5, 0xe5, 0x97, 0xe1, 0x11, 0x17, 0xb2, 0x04, 0xb2, 0xb2, 0x73, 0x6b, + 0x02, 0x97, 0x7f, 0xad, 0xb7, 0x17, 0xd7, 0x65, 0xe5, 0xf2, 0xba, 0xac, 0x7c, 0xbb, 0x2e, 0x2b, + 0x9f, 0x6f, 0xca, 0xa9, 0xcb, 0x9b, 0x72, 0xea, 0xeb, 0x4d, 0x39, 0x75, 0xf6, 0xb2, 0x4f, 0xb9, + 0x3b, 0xee, 0xd5, 0x91, 0x3f, 0xb2, 0x90, 0xcf, 0x46, 0x3e, 0xb3, 0x6e, 0xf3, 0xf8, 0x6f, 0x76, + 0xd4, 0xa3, 0x27, 0xd6, 0xbb, 0xc5, 0xcb, 0xce, 0x27, 0x01, 0x61, 0xbd, 0xac, 0x38, 0xea, 0xff, + 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x1f, 0x55, 0x38, 0xd1, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -467,6 +477,11 @@ func (m *ConsumerState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Phase != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Phase)) + i-- + dAtA[i] = 0x48 + } if len(m.SlashDowntimeAck) > 0 { for iNdEx := len(m.SlashDowntimeAck) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.SlashDowntimeAck[iNdEx]) @@ -652,6 +667,9 @@ func (m *ConsumerState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if m.Phase != 0 { + n += 1 + sovGenesis(uint64(m.Phase)) + } return n } @@ -1191,6 +1209,25 @@ func (m *ConsumerState) Unmarshal(dAtA []byte) error { } m.SlashDowntimeAck = append(m.SlashDowntimeAck, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Phase", wireType) + } + m.Phase = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Phase |= ConsumerPhase(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index 5f6010d260..ef7eae0172 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -139,11 +139,11 @@ const ( ConsumerIdToPhaseKeyName = "ConsumerIdToPhaseKey" - ConsumerIdToStopTimeKeyName = "ConsumerIdToStopTimeKey" + ConsumerIdToRemovalTimeKeyName = "ConsumerIdToRemovalTimeKey" SpawnTimeToConsumerIdsKeyName = "SpawnTimeToConsumerIdsKeyName" - StopTimeToConsumerIdsKeyName = "StopTimeToConsumerIdsKeyName" + RemovalTimeToConsumerIdsKeyName = "RemovalTimeToConsumerIdsKeyName" ProviderConsAddrToOptedInConsumerIdsKeyName = "ProviderConsAddrToOptedInConsumerIdsKeyName" @@ -364,16 +364,16 @@ func getKeyPrefixes() map[string]byte { // ConsumerIdToPhaseKeyName is the key for storing the phase of a consumer chain with the given consumer id ConsumerIdToPhaseKeyName: 49, - // ConsumerIdToStopTimeKeyName is the key for storing the stop time of a consumer chain that is to be removed - ConsumerIdToStopTimeKeyName: 50, + // ConsumerIdToRemovalTimeKeyName is the key for storing the removal time of a consumer chain that is to be removed + ConsumerIdToRemovalTimeKeyName: 50, // SpawnTimeToConsumerIdKeyName is the key for storing pending initialized consumers that are to be launched. // For a specific spawn time, it might store multiple consumer chain ids for chains that are to be launched. SpawnTimeToConsumerIdsKeyName: 51, - // StopTimeToConsumerIdKeyName is the key for storing pending launched consumers that are to be stopped. - // For a specific stop time, it might store multiple consumer chain ids for chains that are to be stopped. - StopTimeToConsumerIdsKeyName: 52, + // RemovalTimeToConsumerIdsKeyName is the key for storing pending launched consumers that are to be removed. + // For a specific removal time, it might store multiple consumer chain ids for chains that are to be removed. + RemovalTimeToConsumerIdsKeyName: 52, // ProviderConsAddrToOptedInConsumerIdsKeyName is the key for storing all the consumer ids that a validator // is currently opted in to. @@ -665,17 +665,17 @@ func ConsumerIdToMetadataKey(consumerId string) []byte { return StringIdWithLenKey(ConsumerIdToMetadataKeyPrefix(), consumerId) } -// ConsumerIdToInitializationParametersKeyPrefix returns the key prefix for storing consumer initialization records +// ConsumerIdToInitializationParametersKeyPrefix returns the key prefix for storing consumer initialization parameters func ConsumerIdToInitializationParametersKeyPrefix() byte { return mustGetKeyPrefix(ConsumerIdToInitializationParametersKeyName) } -// ConsumerIdToInitializationParametersKey returns the key used to store the initialization record that corresponds to this consumer id +// ConsumerIdToInitializationParametersKey returns the key used to store the initialization parameters that corresponds to this consumer id func ConsumerIdToInitializationParametersKey(consumerId string) []byte { return StringIdWithLenKey(ConsumerIdToInitializationParametersKeyPrefix(), consumerId) } -// ConsumerIdToPowerShapingParametersKey returns the key used to store the update record that corresponds to this consumer id +// ConsumerIdToPowerShapingParametersKey returns the key used to store the power-shaping parameters that corresponds to this consumer id func ConsumerIdToPowerShapingParametersKey(consumerId string) []byte { return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPowerShapingParameters), consumerId) } @@ -685,15 +685,15 @@ func ConsumerIdToPhaseKey(consumerId string) []byte { return StringIdWithLenKey(mustGetKeyPrefix(ConsumerIdToPhaseKeyName), consumerId) } -// ConsumerIdToStopTimeKeyPrefix returns the key prefix for storing the stop times of consumer chains -// that are about to be stopped -func ConsumerIdToStopTimeKeyPrefix() byte { - return mustGetKeyPrefix(ConsumerIdToStopTimeKeyName) +// ConsumerIdToRemovalTimeKeyPrefix returns the key prefix for storing the removal times of consumer chains +// that are about to be removed +func ConsumerIdToRemovalTimeKeyPrefix() byte { + return mustGetKeyPrefix(ConsumerIdToRemovalTimeKeyName) } -// ConsumerIdToStopTimeKey returns the key used to store the stop time that corresponds to a to-be-stopped chain with consumer id -func ConsumerIdToStopTimeKey(consumerId string) []byte { - return StringIdWithLenKey(ConsumerIdToStopTimeKeyPrefix(), consumerId) +// ConsumerIdToRemovalTimeKey returns the key used to store the removal time that corresponds to a to-be-removed chain with consumer id +func ConsumerIdToRemovalTimeKey(consumerId string) []byte { + return StringIdWithLenKey(ConsumerIdToRemovalTimeKeyPrefix(), consumerId) } // SpawnTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be launched @@ -712,17 +712,17 @@ func SpawnTimeToConsumerIdsKey(spawnTime time.Time) []byte { ) } -// StopTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be stopped -func StopTimeToConsumerIdsKeyPrefix() byte { - return mustGetKeyPrefix(StopTimeToConsumerIdsKeyName) +// RemovalTimeToConsumerIdsKeyPrefix returns the key prefix for storing pending chains that are to be removed +func RemovalTimeToConsumerIdsKeyPrefix() byte { + return mustGetKeyPrefix(RemovalTimeToConsumerIdsKeyName) } -// StopTimeToConsumerIdsKey returns the key prefix for storing the stop times of consumer chains -// that are about to be stopped -func StopTimeToConsumerIdsKey(spawnTime time.Time) []byte { +// RemovalTimeToConsumerIdsKey returns the key prefix for storing the removal times of consumer chains +// that are about to be removed +func RemovalTimeToConsumerIdsKey(spawnTime time.Time) []byte { return ccvtypes.AppendMany( // append the prefix - []byte{StopTimeToConsumerIdsKeyPrefix()}, + []byte{RemovalTimeToConsumerIdsKeyPrefix()}, // append the time sdk.FormatTimeBytes(spawnTime), ) diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index 741b036c78..92ec762845 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -134,11 +134,11 @@ func TestPreserveBytePrefix(t *testing.T) { i++ require.Equal(t, byte(49), providertypes.ConsumerIdToPhaseKey("13")[0]) i++ - require.Equal(t, byte(50), providertypes.ConsumerIdToStopTimeKeyPrefix()) + require.Equal(t, byte(50), providertypes.ConsumerIdToRemovalTimeKeyPrefix()) i++ require.Equal(t, byte(51), providertypes.SpawnTimeToConsumerIdsKeyPrefix()) i++ - require.Equal(t, byte(52), providertypes.StopTimeToConsumerIdsKeyPrefix()) + require.Equal(t, byte(52), providertypes.RemovalTimeToConsumerIdsKeyPrefix()) i++ require.Equal(t, byte(53), providertypes.ProviderConsAddrToOptedInConsumerIdsKey(providertypes.NewProviderConsAddress([]byte{0x05}))[0]) i++ @@ -208,9 +208,9 @@ func getAllFullyDefinedKeys() [][]byte { providertypes.ConsumerIdToInitializationParametersKey("13"), providertypes.ConsumerIdToPowerShapingParametersKey("13"), providertypes.ConsumerIdToPhaseKey("13"), - providertypes.ConsumerIdToStopTimeKey("13"), + providertypes.ConsumerIdToRemovalTimeKey("13"), providertypes.SpawnTimeToConsumerIdsKey(time.Time{}), - providertypes.StopTimeToConsumerIdsKey(time.Time{}), + providertypes.RemovalTimeToConsumerIdsKey(time.Time{}), providertypes.ProviderConsAddrToOptedInConsumerIdsKey(providertypes.NewProviderConsAddress([]byte{0x05})), providertypes.ClientIdToConsumerIdKey("clientId"), } diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 361ac79a2c..0ce64b688a 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -3,11 +3,9 @@ package types import ( "encoding/json" "fmt" + cmttypes "github.com/cometbft/cometbft/types" "strconv" "strings" - "time" - - cmttypes "github.com/cometbft/cometbft/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" @@ -360,11 +358,10 @@ func (msg MsgUpdateConsumer) ValidateBasic() error { } // NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance -func NewMsgRemoveConsumer(signer string, consumerId string, stopTime time.Time) (*MsgRemoveConsumer, error) { +func NewMsgRemoveConsumer(signer string, consumerId string) (*MsgRemoveConsumer, error) { return &MsgRemoveConsumer{ Signer: signer, ConsumerId: consumerId, - StopTime: stopTime, }, nil } diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 1c0755344d..bcdf7dd2ab 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -54,6 +54,8 @@ const ( ConsumerPhase_CONSUMER_PHASE_LAUNCHED ConsumerPhase = 3 // STOPPED defines the phase in which a previously-launched chain has stopped. ConsumerPhase_CONSUMER_PHASE_STOPPED ConsumerPhase = 4 + // DELETED defines the phase in which the state of a stopped chain has been deleted. + ConsumerPhase_CONSUMER_PHASE_DELETED ConsumerPhase = 5 ) var ConsumerPhase_name = map[int32]string{ @@ -62,6 +64,7 @@ var ConsumerPhase_name = map[int32]string{ 2: "CONSUMER_PHASE_INITIALIZED", 3: "CONSUMER_PHASE_LAUNCHED", 4: "CONSUMER_PHASE_STOPPED", + 5: "CONSUMER_PHASE_DELETED", } var ConsumerPhase_value = map[string]int32{ @@ -70,6 +73,7 @@ var ConsumerPhase_value = map[string]int32{ "CONSUMER_PHASE_INITIALIZED": 2, "CONSUMER_PHASE_LAUNCHED": 3, "CONSUMER_PHASE_STOPPED": 4, + "CONSUMER_PHASE_DELETED": 5, } func (x ConsumerPhase) String() string { @@ -1826,13 +1830,13 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 2220 bytes of a gzipped FileDescriptorProto + // 2231 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0xbd, 0x6f, 0x1b, 0xc9, 0x15, 0xd7, 0x8a, 0x94, 0x44, 0x3e, 0xea, 0x83, 0x1a, 0xfb, 0x6c, 0x4a, 0xd6, 0x51, 0x34, 0x2f, 0x36, 0x14, 0x3b, 0x26, 0x4f, 0x3a, 0x04, 0x30, 0x9c, 0x1c, 0x0c, 0x99, 0xa4, 0x6d, 0xfa, 0x43, 0x66, 0x96, 0xb4, 0x0e, 0x70, 0x8a, 0xc5, 0x70, 0x77, 0x44, 0x4e, 0xb4, 0xbb, 0xb3, 0xde, 0x19, - 0xd2, 0x66, 0x8a, 0xd4, 0x41, 0x80, 0x00, 0x97, 0x54, 0x87, 0x34, 0xb9, 0x2e, 0x41, 0xaa, 0x14, - 0x41, 0xfe, 0x80, 0x54, 0x87, 0x00, 0x41, 0xae, 0x4c, 0x75, 0x17, 0xd8, 0x45, 0x8a, 0x00, 0x69, + 0xd2, 0x66, 0x8a, 0xd4, 0x41, 0x80, 0x00, 0x97, 0x54, 0x87, 0x34, 0xb9, 0x32, 0x48, 0x95, 0x22, + 0xc8, 0x1f, 0x90, 0x34, 0x87, 0x00, 0x41, 0xae, 0x4c, 0x75, 0x17, 0xd8, 0x45, 0x8a, 0x00, 0x69, 0xd3, 0x06, 0x33, 0xfb, 0xc1, 0xa5, 0x3e, 0x6c, 0x1a, 0xb6, 0xd3, 0x48, 0x3b, 0xef, 0xfd, 0xde, 0x9b, 0x37, 0x33, 0xef, 0x6b, 0x86, 0xb0, 0x43, 0x5d, 0x41, 0x7c, 0xb3, 0x8f, 0xa9, 0x6b, 0x70, 0x62, 0x0e, 0x7c, 0x2a, 0x46, 0x55, 0xd3, 0x1c, 0x56, 0x3d, 0x9f, 0x0d, 0xa9, 0x45, 0xfc, 0xea, @@ -1879,7 +1883,7 @@ var fileDescriptor_f22ec409a72b7b72 = []byte{ 0x24, 0x85, 0xb3, 0x25, 0x6d, 0x2b, 0xad, 0x67, 0x1c, 0xea, 0xb6, 0xe5, 0x18, 0x55, 0xe0, 0x8c, 0xd2, 0x62, 0x50, 0x57, 0x9e, 0xd3, 0x90, 0x18, 0x43, 0x6c, 0xf3, 0xc2, 0x07, 0x25, 0x6d, 0x2b, 0xa3, 0xaf, 0x2a, 0x56, 0x33, 0xe4, 0xec, 0x63, 0x9b, 0xdf, 0xb8, 0xfc, 0xf3, 0x2f, 0x37, 0x67, - 0xbe, 0xf8, 0x72, 0x73, 0xe6, 0xaf, 0x7f, 0xba, 0xb6, 0x1e, 0xa6, 0x9f, 0x1e, 0x1b, 0x56, 0xc2, + 0xbe, 0xf8, 0x72, 0x73, 0xe6, 0xaf, 0x7f, 0xbc, 0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0xe1, 0xd4, 0x1a, 0xe4, 0xef, 0xd8, 0xac, 0x8b, 0xed, @@ -1937,14 +1941,14 @@ var fileDescriptor_f22ec409a72b7b72 = []byte{ 0xa9, 0xe3, 0x0b, 0x28, 0xff, 0x4d, 0x83, 0x73, 0xc9, 0x59, 0x79, 0x87, 0xb5, 0xfc, 0x81, 0x4b, 0xf6, 0x77, 0x5e, 0x35, 0xff, 0x4d, 0xc8, 0x78, 0x12, 0x65, 0x08, 0x1e, 0x1e, 0xd1, 0x74, 0xe5, 0x7a, 0x41, 0x49, 0x75, 0x64, 0x78, 0x2f, 0x4f, 0x2c, 0x80, 0x87, 0x3b, 0xf7, 0xf1, 0x54, 0x01, - 0x97, 0x08, 0x26, 0x7d, 0x29, 0xb9, 0x66, 0x5e, 0xfe, 0xb3, 0x06, 0xe8, 0x78, 0xa6, 0x42, 0xdf, + 0x97, 0x08, 0x26, 0x7d, 0x29, 0xb9, 0x66, 0x5e, 0xfe, 0x93, 0x06, 0xe8, 0x78, 0xa6, 0x42, 0xdf, 0x03, 0x34, 0x91, 0xef, 0x92, 0xfe, 0x97, 0xf7, 0x12, 0x19, 0x4e, 0xed, 0x5c, 0xec, 0x47, 0xb3, 0x09, 0x3f, 0x42, 0x3f, 0x00, 0xf0, 0xd4, 0x21, 0x4e, 0x7d, 0xd2, 0x59, 0x2f, 0xfa, 0x44, 0x9b, 0x90, 0xfb, 0x09, 0xa3, 0x6e, 0xf2, 0x91, 0x22, 0xa5, 0x83, 0x24, 0x05, 0xef, 0x0f, 0xe5, 0x5f, 0x6a, 0xe3, 0x74, 0x18, 0x66, 0xea, 0x5d, 0xdb, 0x0e, 0xfb, 0x3f, 0xe4, 0xc1, 0x42, 0x94, 0xeb, - 0x83, 0x70, 0xdd, 0x38, 0xb1, 0x1e, 0xd5, 0x89, 0xa9, 0x4a, 0xd2, 0x75, 0xb9, 0xe3, 0x7f, 0xf8, + 0x83, 0x70, 0xdd, 0x38, 0xb1, 0x1e, 0xd5, 0x89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e, 0xa3, + 0x9e, 0x9f, 0xbb, 0xf5, 0xd9, 0x57, 0x2f, 0x8a, 0xda, 0xd7, 0x2f, 0x8a, 0xda, 0x3f, 0x5f, 0x14, + 0xb5, 0xcf, 0x5f, 0x16, 0x67, 0xbe, 0x7e, 0x59, 0x9c, 0xf9, 0xc7, 0xcb, 0xe2, 0xcc, 0x93, 0x4f, + 0x8f, 0xe7, 0xf0, 0x71, 0x8d, 0xbc, 0x16, 0xff, 0x8e, 0x31, 0xfc, 0x7e, 0xf5, 0xf9, 0xe4, 0xaf, + 0x24, 0x2a, 0xbd, 0x77, 0xe7, 0x55, 0x78, 0x7e, 0xf2, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x63, + 0x65, 0x8b, 0xc3, 0x56, 0x19, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 88d4b2ac69..cc87ba0443 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -128,7 +128,7 @@ func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisSt type QueryConsumerChainsRequest struct { // The phase of the consumer chains returned (optional) - // Registered=1|Initialized=2|Launched=3|Stopped=4 + // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 Phase ConsumerPhase `protobuf:"varint,1,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` // The limit of consumer chains returned (optional) // default is 100 diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 447ce8d15c..a656dd8f7d 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -771,11 +771,7 @@ var xxx_messageInfo_MsgConsumerRemovalResponse proto.InternalMessageInfo type MsgRemoveConsumer struct { // the consumer id of the consumer chain to be stopped ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` - // the time on the provider chain at which all validators are responsible to - // stop their consumer chain validator node - StopTime time.Time `protobuf:"bytes,2,opt,name=stop_time,json=stopTime,proto3,stdtime" json:"stop_time"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgRemoveConsumer) Reset() { *m = MsgRemoveConsumer{} } @@ -818,13 +814,6 @@ func (m *MsgRemoveConsumer) GetConsumerId() string { return "" } -func (m *MsgRemoveConsumer) GetStopTime() time.Time { - if m != nil { - return m.StopTime - } - return time.Time{} -} - func (m *MsgRemoveConsumer) GetSigner() string { if m != nil { return m.Signer @@ -1692,138 +1681,138 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 2086 bytes of a gzipped FileDescriptorProto + // 2081 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0x4d, 0x70, 0x1c, 0x47, - 0x15, 0xd6, 0xec, 0xae, 0x94, 0xdd, 0x5e, 0xfd, 0xb6, 0xe4, 0x68, 0xb5, 0xb6, 0xb5, 0xb2, 0x08, - 0x89, 0xca, 0x44, 0xb3, 0xb1, 0xc0, 0x0e, 0x08, 0xf3, 0xa3, 0x1f, 0x83, 0x15, 0x90, 0xa5, 0x8c, - 0x8c, 0x53, 0x05, 0x55, 0x4c, 0xf5, 0xce, 0xb4, 0x67, 0xbb, 0xbc, 0x33, 0x3d, 0x35, 0xdd, 0xbb, - 0x8a, 0x38, 0x51, 0x39, 0xf9, 0x68, 0x2a, 0x1c, 0xb8, 0x91, 0x03, 0x1c, 0xa8, 0x02, 0x2a, 0x87, - 0x14, 0x07, 0x8e, 0x9c, 0x52, 0xc5, 0x25, 0xe4, 0x44, 0xe5, 0x60, 0x28, 0xfb, 0x10, 0x2e, 0x5c,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8, 0x3b, 0x9f, 0xbe, 0x7f, - 0x5d, 0x49, 0xad, 0x2e, 0x83, 0x2b, 0x83, 0x5c, 0x37, 0x30, 0xf3, 0xa9, 0xc7, 0xf0, 0xea, 0x33, - 0x0d, 0x5c, 0xdd, 0x67, 0xce, 0x51, 0xbb, 0xe1, 0x12, 0x1e, 0x31, 0xec, 0x13, 0xd6, 0xc0, 0x4d, - 0xd4, 0x21, 0xb4, 0x1d, 0xc0, 0x5b, 0xa0, 0xc4, 0x24, 0x95, 0xe3, 0x40, 0x45, 0xe9, 0x74, 0x63, - 0xbb, 0xac, 0xf0, 0x10, 0x4c, 0xba, 0x09, 0x1c, 0x19, 0xbc, 0xf2, 0xc6, 0xab, 0x3a, 0x69, 0x58, - 0x7a, 0x72, 0x7b, 0xf5, 0xc4, 0x86, 0x76, 0x6e, 0xe8, 0x49, 0xdd, 0x46, 0x0a, 0xa1, 0x37, 0x02, - 0xf9, 0xbe, 0x08, 0xbc, 0x98, 0x8c, 0x40, 0xd7, 0x94, 0xd5, 0x57, 0xc0, 0x17, 0xcf, 0xf4, 0x31, - 0x8e, 0xc6, 0x5f, 0x72, 0x03, 0xa2, 0xb1, 0x4b, 0xdb, 0x8d, 0x16, 0x7e, 0x40, 0x39, 0xf1, 0x9c, - 0x91, 0xa3, 0x61, 0x82, 0x45, 0xbb, 0xed, 0xb7, 0x88, 0x85, 0x38, 0x36, 0x3b, 0x94, 0x63, 0x33, - 0x4a, 0x52, 0x15, 0x98, 0x57, 0x92, 0x71, 0x90, 0x69, 0xac, 0xef, 0x46, 0x02, 0x0f, 0x28, 0xc7, - 0x77, 0x14, 0xbb, 0x71, 0xc9, 0x1e, 0xb4, 0x0c, 0x7f, 0x0c, 0x16, 0x89, 0xf7, 0x30, 0x40, 0x96, - 0x28, 0x02, 0x66, 0xa3, 0x45, 0xad, 0x47, 0x66, 0x13, 0x23, 0x1b, 0x07, 0x32, 0x50, 0xe5, 0x8d, - 0x97, 0xcf, 0x8b, 0xfc, 0x5d, 0xc9, 0x6d, 0x5c, 0xea, 0xc2, 0x6c, 0x0b, 0x94, 0x70, 0xb9, 0x37, - 0xf8, 0x85, 0x0b, 0x05, 0x3f, 0x19, 0xd2, 0x38, 0xf8, 0xbf, 0xd2, 0xc0, 0xcc, 0x3e, 0x73, 0x7e, - 0xe0, 0xdb, 0x88, 0xe3, 0x43, 0x14, 0x20, 0x97, 0x89, 0x70, 0xa3, 0x36, 0x6f, 0x52, 0x51, 0x38, - 0xce, 0x0f, 0x77, 0xcc, 0x0a, 0xf7, 0xc0, 0x84, 0x2f, 0x11, 0x54, 0x74, 0xbf, 0xa4, 0x67, 0x28, - 0xd3, 0x7a, 0xa8, 0x74, 0xbb, 0xf0, 0xe1, 0xd3, 0xda, 0x98, 0xa1, 0x00, 0x36, 0xa7, 0xa5, 0x3f, - 0x31, 0xf4, 0xea, 0x12, 0x58, 0xec, 0xb1, 0x32, 0xf6, 0xe0, 0x93, 0x22, 0x98, 0xdf, 0x67, 0x4e, - 0xe4, 0xe5, 0x96, 0x6d, 0x13, 0x11, 0x46, 0xb8, 0xd4, 0x5b, 0x67, 0xba, 0x35, 0xe6, 0xbb, 0x60, - 0x9a, 0x78, 0x84, 0x13, 0xd4, 0x32, 0x9b, 0x58, 0xec, 0x8d, 0x32, 0xb8, 0x2a, 0x77, 0x4b, 0xd4, - 0x56, 0x5d, 0x55, 0x54, 0xb9, 0x43, 0x82, 0x43, 0xd9, 0x37, 0xa5, 0xe4, 0xc2, 0x45, 0x51, 0x73, - 0x1c, 0xec, 0x61, 0x46, 0x98, 0xd9, 0x44, 0xac, 0x29, 0x37, 0x7d, 0xd2, 0x28, 0xab, 0xb5, 0xbb, - 0x88, 0x35, 0xc5, 0x16, 0x36, 0x88, 0x87, 0x82, 0x93, 0x90, 0xa3, 0x20, 0x39, 0x40, 0xb8, 0x24, - 0x19, 0x76, 0x00, 0x60, 0x3e, 0x3a, 0xf6, 0x4c, 0xd1, 0x6d, 0x64, 0x85, 0x11, 0x86, 0x84, 0x9d, - 0x44, 0x8f, 0x3a, 0x89, 0x7e, 0x3f, 0x6a, 0x45, 0xdb, 0x45, 0x61, 0xc8, 0x93, 0xbf, 0xd5, 0x34, - 0xa3, 0x24, 0xe5, 0x04, 0x05, 0xde, 0x03, 0xb3, 0x6d, 0xaf, 0x41, 0x3d, 0x9b, 0x78, 0x8e, 0xe9, - 0xe3, 0x80, 0x50, 0xbb, 0x32, 0x21, 0xa1, 0x96, 0xfa, 0xa0, 0x76, 0x55, 0xd3, 0x0a, 0x91, 0x7e, - 0x21, 0x90, 0x66, 0x62, 0xe1, 0x43, 0x29, 0x0b, 0xdf, 0x04, 0xd0, 0xb2, 0x3a, 0xd2, 0x24, 0xda, - 0xe6, 0x11, 0xe2, 0x0b, 0xd9, 0x11, 0x67, 0x2d, 0xab, 0x73, 0x3f, 0x94, 0x56, 0x90, 0x3f, 0x02, - 0x8b, 0x3c, 0x40, 0x1e, 0x7b, 0x88, 0x83, 0x5e, 0xdc, 0x62, 0x76, 0xdc, 0x4b, 0x11, 0x46, 0x1a, - 0xfc, 0x2e, 0x58, 0x89, 0x0f, 0x4a, 0x80, 0x6d, 0xc2, 0x78, 0x40, 0x1a, 0x6d, 0x79, 0x2a, 0xa3, - 0x73, 0x55, 0x29, 0xc9, 0x24, 0x58, 0x8e, 0xf8, 0x8c, 0x14, 0xdb, 0x77, 0x14, 0x17, 0x3c, 0x00, - 0x2f, 0xc9, 0x73, 0xcc, 0x84, 0x71, 0x66, 0x0a, 0x49, 0xaa, 0x76, 0x09, 0x63, 0x02, 0x0d, 0xac, - 0x68, 0x6b, 0x79, 0xe3, 0x5a, 0xc8, 0x7b, 0x88, 0x83, 0xdd, 0x04, 0xe7, 0xfd, 0x04, 0x23, 0x5c, - 0x07, 0xb0, 0x49, 0x18, 0xa7, 0x01, 0xb1, 0x50, 0xcb, 0xc4, 0x1e, 0x0f, 0x08, 0x66, 0x95, 0xb2, - 0x14, 0x9f, 0xeb, 0x52, 0xee, 0x84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b, 0x3d, 0xad, 0x6b, + 0xc9, 0x0f, 0xa4, 0xdd, 0x9b, 0x8d, 0x77, 0xb2, 0xbf, 0x92, 0xca, 0xdf, 0x83, 0x9a, 0x13, 0xf2, + 0x55, 0xee, 0xcb, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x02, 0xb5, 0x16, 0xbc, 0xa1, 0x1e, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2968,16 +2957,8 @@ func (m *MsgRemoveConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x1a - } - n11, err11 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.StopTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime):]) - if err11 != nil { - return 0, err11 + dAtA[i] = 0x12 } - i -= n11 - i = encodeVarintTx(dAtA, i, uint64(n11)) - i-- - dAtA[i] = 0x12 if len(m.ConsumerId) > 0 { i -= len(m.ConsumerId) copy(dAtA[i:], m.ConsumerId) @@ -3907,8 +3888,6 @@ func (m *MsgRemoveConsumer) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.StopTime) - n += 1 + l + sovTx(uint64(l)) l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -5995,39 +5974,6 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { m.ConsumerId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StopTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.StopTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } From 68f0ab47303d97191ea1e94ed88e056992e59872 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Wed, 4 Sep 2024 17:36:18 +0200 Subject: [PATCH 31/43] feat: remove provider migration for CV 3 to 6 (#2211) * remove migrations to CV < 7 * add changelog entry * fix version name --- .../provider/2211-deprecate-migration.md | 4 ++ x/ccv/provider/migrations/migrator.go | 16 +++--- .../provider/migrations/v4/migration_test.go | 27 ---------- x/ccv/provider/migrations/v4/migrations.go | 18 ------- .../provider/migrations/v5/migration_test.go | 32 ------------ x/ccv/provider/migrations/v5/migrations.go | 28 ----------- .../provider/migrations/v6/migration_test.go | 27 ---------- x/ccv/provider/migrations/v6/migrations.go | 49 ------------------- 8 files changed, 10 insertions(+), 191 deletions(-) create mode 100644 .changelog/unreleased/features/provider/2211-deprecate-migration.md delete mode 100644 x/ccv/provider/migrations/v4/migration_test.go delete mode 100644 x/ccv/provider/migrations/v4/migrations.go delete mode 100644 x/ccv/provider/migrations/v5/migration_test.go delete mode 100644 x/ccv/provider/migrations/v5/migrations.go delete mode 100644 x/ccv/provider/migrations/v6/migration_test.go delete mode 100644 x/ccv/provider/migrations/v6/migrations.go diff --git a/.changelog/unreleased/features/provider/2211-deprecate-migration.md b/.changelog/unreleased/features/provider/2211-deprecate-migration.md new file mode 100644 index 0000000000..2363098b91 --- /dev/null +++ b/.changelog/unreleased/features/provider/2211-deprecate-migration.md @@ -0,0 +1,4 @@ +- Remove provider migrations to consensus versions lower than 7. + To migrate the provider module from consensus version 3, 4, or 5 to consensus version 7 or higher, + users should use v4.3.x in production to migrate to consensus version 6. + ([\#2211](https://github.com/cosmos/interchain-security/pull/2211)) \ No newline at end of file diff --git a/x/ccv/provider/migrations/migrator.go b/x/ccv/provider/migrations/migrator.go index b2d733de11..edc80ef6ce 100644 --- a/x/ccv/provider/migrations/migrator.go +++ b/x/ccv/provider/migrations/migrator.go @@ -8,9 +8,6 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" - v4 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v4" - v5 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v5" - v6 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v6" v7 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v7" v8 "github.com/cosmos/interchain-security/v5/x/ccv/provider/migrations/v8" ) @@ -55,24 +52,23 @@ func (m Migrator) Migrate2to3(ctx sdktypes.Context) error { // Migrate3to4 migrates x/ccvprovider state from consensus version 3 to 4. // The migration consists of provider chain params additions. func (m Migrator) Migrate3to4(ctx sdktypes.Context) error { - v4.MigrateParams(ctx, m.paramSpace) - return nil + return fmt.Errorf("state migration failed: " + + "first run provider@v4.3.x in production to migrate from consensus version 3 to 4") } // Migrate4to5 migrates x/ccvprovider state from consensus version 4 to 5. // The migration consists of setting a top N of 95 for all registered consumer chains. func (m Migrator) Migrate4to5(ctx sdktypes.Context) error { - v5.MigrateTopNForRegisteredChains(ctx, m.providerKeeper) - return nil + return fmt.Errorf("state migration failed: " + + "first run provider@v4.3.x in production to migrate from consensus version 4 to 5") } // Migrate5to6 migrates x/ccvprovider state from consensus version 5 to 6. // It consists of setting the `NumberOfEpochsToStartReceivingRewards` param, as well as // computing and storing the minimal power in the top N for all registered consumer chains. func (m Migrator) Migrate5to6(ctx sdktypes.Context) error { - v6.MigrateParams(ctx, m.paramSpace) - v6.MigrateMinPowerInTopN(ctx, m.providerKeeper) - return nil + return fmt.Errorf("state migration failed: " + + "first run provider@v4.3.x in production to migrate from consensus version 5 to 6") } // Migrate6to7 migrates x/ccvprovider state from consensus version 6 to 7. diff --git a/x/ccv/provider/migrations/v4/migration_test.go b/x/ccv/provider/migrations/v4/migration_test.go deleted file mode 100644 index 4423842149..0000000000 --- a/x/ccv/provider/migrations/v4/migration_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package v4 - -import ( - "testing" - - "github.com/stretchr/testify/require" - - testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -func TestMigrateParams(t *testing.T) { - inMemParams := testutil.NewInMemKeeperParams(t) - _, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) - defer ctrl.Finish() - - // initially blocks per epoch param does not exist - require.False(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyBlocksPerEpoch)) - - MigrateParams(ctx, *inMemParams.ParamsSubspace) - - // after migration, blocks per epoch param should exist and be equal to default - require.True(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyBlocksPerEpoch)) - var blocksPerEpochParam int64 - inMemParams.ParamsSubspace.Get(ctx, providertypes.KeyBlocksPerEpoch, &blocksPerEpochParam) - require.Equal(t, providertypes.DefaultBlocksPerEpoch, blocksPerEpochParam) -} diff --git a/x/ccv/provider/migrations/v4/migrations.go b/x/ccv/provider/migrations/v4/migrations.go deleted file mode 100644 index e60c98700e..0000000000 --- a/x/ccv/provider/migrations/v4/migrations.go +++ /dev/null @@ -1,18 +0,0 @@ -package v4 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -// MigrateParams adds missing provider chain params to the param store. -func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { - if paramsSubspace.HasKeyTable() { - paramsSubspace.Set(ctx, providertypes.KeyBlocksPerEpoch, providertypes.DefaultBlocksPerEpoch) - } else { - paramsSubspace.WithKeyTable(providertypes.ParamKeyTable()) - paramsSubspace.Set(ctx, providertypes.KeyBlocksPerEpoch, providertypes.DefaultBlocksPerEpoch) - } -} diff --git a/x/ccv/provider/migrations/v5/migration_test.go b/x/ccv/provider/migrations/v5/migration_test.go deleted file mode 100644 index 498c8b5b98..0000000000 --- a/x/ccv/provider/migrations/v5/migration_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package v5 - -import ( - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" - "testing" - - "github.com/stretchr/testify/require" - - testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" -) - -func TestMigrateParams(t *testing.T) { - inMemParams := testutil.NewInMemKeeperParams(t) - provKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) - defer ctrl.Finish() - - // set up a launched consumer chain - provKeeper.SetConsumerClientId(ctx, "consumerId", "clientId") - provKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) - - // initially top N should not exist - _, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.Error(t, err) - - // migrate - MigrateTopNForRegisteredChains(ctx, provKeeper) - - // after migration, top N should be 95 - powerShapingParameters, err := provKeeper.GetConsumerPowerShapingParameters(ctx, "consumerId") - require.NoError(t, err) - require.Equal(t, uint32(95), powerShapingParameters.Top_N) -} diff --git a/x/ccv/provider/migrations/v5/migrations.go b/x/ccv/provider/migrations/v5/migrations.go deleted file mode 100644 index 4c4ba3a988..0000000000 --- a/x/ccv/provider/migrations/v5/migrations.go +++ /dev/null @@ -1,28 +0,0 @@ -package v5 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" - - providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" -) - -// This migration only takes already registered chains into account. -// If a chain is in voting while the upgrade happens, this is not sufficient, -// and a migration to rewrite the proposal is needed. -// -// TODO (PERMISSIONLESS): this migration needs to be fix or removed -func MigrateTopNForRegisteredChains(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { - // Set the topN of each chain to 95 - for _, consumerId := range providerKeeper.GetAllConsumersWithIBCClients(ctx) { - // TODO (PERMISSIONLESS): this migration already took place and does not make much sense in the Permissionless world - // living here for now and we should totally remove - providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{ - Top_N: 95, - }) - } -} - -// // If there are consumer addition proposals in the voting period at the upgrade time, they may need the topN value updated. -// func MigrateTopNForVotingPeriodChains(ctx sdk.Context, govKeeper govkeeper.Keeper, providerKeeper providerkeeper.Keeper) { -// } diff --git a/x/ccv/provider/migrations/v6/migration_test.go b/x/ccv/provider/migrations/v6/migration_test.go deleted file mode 100644 index 9396a3e05d..0000000000 --- a/x/ccv/provider/migrations/v6/migration_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package v6 - -import ( - "testing" - - "github.com/stretchr/testify/require" - - testutil "github.com/cosmos/interchain-security/v5/testutil/keeper" - providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -func TestMigrateParams(t *testing.T) { - inMemParams := testutil.NewInMemKeeperParams(t) - _, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) - defer ctrl.Finish() - - // initially number of epochs param does not exist - require.False(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards)) - - MigrateParams(ctx, *inMemParams.ParamsSubspace) - - // after migration, number of epochs to start receiving rewards param should exist and be equal to default - require.True(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards)) - var numberOfEpochsParam int64 - inMemParams.ParamsSubspace.Get(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, &numberOfEpochsParam) - require.Equal(t, providertypes.DefaultNumberOfEpochsToStartReceivingRewards, numberOfEpochsParam) -} diff --git a/x/ccv/provider/migrations/v6/migrations.go b/x/ccv/provider/migrations/v6/migrations.go deleted file mode 100644 index 58c48915b9..0000000000 --- a/x/ccv/provider/migrations/v6/migrations.go +++ /dev/null @@ -1,49 +0,0 @@ -package v6 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - providerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/provider/keeper" - providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types" -) - -// MigrateParams adds missing provider chain params to the param store. -func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { - if !paramsSubspace.HasKeyTable() { - paramsSubspace.WithKeyTable(providertypes.ParamKeyTable()) - } - paramsSubspace.Set(ctx, providertypes.KeyNumberOfEpochsToStartReceivingRewards, providertypes.DefaultNumberOfEpochsToStartReceivingRewards) -} - -// TODO (PERMISSIONLESS): this migration needs to be fix or removed -func MigrateMinPowerInTopN(ctx sdk.Context, providerKeeper providerkeeper.Keeper) { - // we only get the registered consumer chains and not also the proposed consumer chains because - // the minimal power is first set when the consumer chain addition proposal passes - registeredConsumerChains := providerKeeper.GetAllConsumersWithIBCClients(ctx) - - for _, chain := range registeredConsumerChains { - // get the top N - powerShapingParameters, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, chain) - if err != nil { - providerKeeper.Logger(ctx).Error("failed to get power shaping parameters", "chain", chain, "error", err) - continue - } - if powerShapingParameters.Top_N == 0 { - providerKeeper.Logger(ctx).Info("top N is 0, not setting minimal power", "chain", chain) - } else { - // set the minimal power in the top N - bondedValidators, err := providerKeeper.GetLastBondedValidators(ctx) - if err != nil { - providerKeeper.Logger(ctx).Error("failed to get last bonded validators", "chain", chain, "error", err) - continue - } - minPower, err := providerKeeper.ComputeMinPowerInTopN(ctx, bondedValidators, powerShapingParameters.Top_N) - if err != nil { - providerKeeper.Logger(ctx).Error("failed to compute min power in top N", "chain", chain, "topN", powerShapingParameters.Top_N, "error", err) - continue - } - providerKeeper.SetMinimumPowerInTopN(ctx, chain, minPower) - } - } -} From f85677c46fa65b8dafa05d375953dce3465c5ef6 Mon Sep 17 00:00:00 2001 From: insumity Date: Wed, 4 Sep 2024 18:04:39 +0200 Subject: [PATCH 32/43] fix!: fix migration issue (#2214) * init commit * took into account comments --- x/ccv/provider/migrations/v8/migrations.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index bc1bd85526..abf9cc0225 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -197,7 +197,13 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk rekeyChainIdAndConsAddrKey(store, providertypes.ConsumerCommissionRateKeyPrefix(), chainId, consumerId) // chainId -> MinimumPowerInTopN - rekeyFromChainIdToConsumerId(store, MinimumPowerInTopNKeyPrefix, chainId, consumerId) + oldKey := providertypes.StringIdWithLenKey(MinimumPowerInTopNKeyPrefix, chainId) + value := store.Get(oldKey) + if value != nil { + newKey := providertypes.StringIdWithLenKey(MinimumPowerInTopNKeyPrefix, consumerId) + store.Set(newKey, value) + store.Delete(oldKey) + } // chainId -> ConsumerAddrsToPruneV2 rekeyChainIdAndTsKey(store, providertypes.ConsumerAddrsToPruneV2KeyPrefix(), chainId, consumerId) @@ -211,21 +217,21 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk // Note: InitializationParameters is not needed since the chain is already launched // migrate power shaping params - topNKey := append([]byte{LegacyTopNKeyPrefix}, []byte(chainId)...) + topNKey := providertypes.StringIdWithLenKey(LegacyTopNKeyPrefix, chainId) var topN uint32 = 0 buf := store.Get(topNKey) if buf != nil { topN = binary.BigEndian.Uint32(buf) } - validatorsPowerCapKey := append([]byte{LegacyValidatorsPowerCapKeyPrefix}, []byte(chainId)...) + validatorsPowerCapKey := providertypes.StringIdWithLenKey(LegacyValidatorsPowerCapKeyPrefix, chainId) var validatorsPowerCap uint32 = 0 buf = store.Get(validatorsPowerCapKey) if buf != nil { validatorsPowerCap = binary.BigEndian.Uint32(buf) } - validatorSetCapKey := append([]byte{LegacyValidatorSetCapKeyPrefix}, []byte(chainId)...) + validatorSetCapKey := providertypes.StringIdWithLenKey(LegacyValidatorSetCapKeyPrefix, chainId) var validatorSetCap uint32 = 0 buf = store.Get(validatorSetCapKey) if buf != nil { @@ -235,14 +241,14 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk bech32PrefixConsAddr := sdk.GetConfig().GetBech32ConsensusAddrPrefix() var allowlist []string for _, addr := range pk.GetAllowList(ctx, consumerId) { - foo, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) - allowlist = append(allowlist, foo) + bech32Addr, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) + allowlist = append(allowlist, bech32Addr) } var denylist []string for _, addr := range pk.GetDenyList(ctx, consumerId) { - foo, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) - allowlist = append(allowlist, foo) + bech32Addr, _ := bech32.ConvertAndEncode(bech32PrefixConsAddr, addr.ToSdkConsAddr().Bytes()) + allowlist = append(allowlist, bech32Addr) } powerShapingParameters := providertypes.PowerShapingParameters{ From 954f77c8c6f2eb4b336c51a841927da0da57b5c1 Mon Sep 17 00:00:00 2001 From: insumity Date: Wed, 4 Sep 2024 18:14:13 +0200 Subject: [PATCH 33/43] fix!: register `ConsumerModificationProposal` and others (#2215) init commit --- x/ccv/provider/types/codec.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index 18915de7e7..bc2ec27fa2 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -19,13 +19,15 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*govv1beta1.Content)(nil), &ConsumerAdditionProposal{}, - ) - registry.RegisterImplementations( - (*govv1beta1.Content)(nil), &ConsumerRemovalProposal{}, + &ConsumerModificationProposal{}, + &ChangeRewardDenomsProposal{}, ) registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgConsumerAddition{}, + &MsgConsumerRemoval{}, + &MsgConsumerModification{}, &MsgAssignConsumerKey{}, &MsgCreateConsumer{}, &MsgUpdateConsumer{}, @@ -38,10 +40,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*govv1beta1.Content)(nil), &EquivocationProposal{}, ) - registry.RegisterImplementations( - (*govv1beta1.Content)(nil), - &ChangeRewardDenomsProposal{}, - ) registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgSubmitConsumerMisbehaviour{}, From e7117eef4a4124cbae40d1fc7f4ebb1167dbebcb Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 5 Sep 2024 09:05:08 +0200 Subject: [PATCH 34/43] fix: fix misbehaviour and equivocation evidence CLI commands (#2213) * silent errors in MBT driver * fix misbehaviour and double-signing CLI cmds + few nits * revert changes --- .../ccv/provider/v1/query.proto | 2 +- tests/mbt/driver/core.go | 54 +++++++++---------- tests/mbt/driver/mbt_test.go | 4 +- x/ccv/provider/client/cli/tx.go | 21 ++++---- x/ccv/provider/types/msg.go | 7 ++- x/ccv/provider/types/query.pb.go | 4 +- 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index e6b3c2d8d9..9171cf74eb 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -182,7 +182,7 @@ message Chain { repeated string allowlist = 7; // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. repeated string denylist = 8; - // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + // The phase the consumer chain string phase = 9; // The metadata of the consumer chain ConsumerMetadata metadata = 10 [(gogoproto.nullable) = false ]; diff --git a/tests/mbt/driver/core.go b/tests/mbt/driver/core.go index 8d0332f504..897b713a42 100644 --- a/tests/mbt/driver/core.go +++ b/tests/mbt/driver/core.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/math" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/require" @@ -220,8 +219,8 @@ func (s *Driver) getStateString() string { state.WriteString("\n") state.WriteString("Consumers Chains:\n") - chainIds := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) - state.WriteString(strings.Join(chainIds, ", ")) + // chainIds := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) + // state.WriteString(strings.Join(chainIds, ", ")) state.WriteString("\n\n") for chain := range s.simibcs { @@ -255,24 +254,24 @@ func (s *Driver) getChainStateString(chain ChainId) string { chainInfo.WriteString(fmt.Sprintf(" Running Time: %s\n", runningTime)) chainInfo.WriteString(fmt.Sprintf(" Last Time entered on chain: %s\n", lastTime)) - if !s.isProviderChain(chain) { - // Check whether the chain is in the consumer chains on the provider + // if !s.isProviderChain(chain) { + // Check whether the chain is in the consumer chains on the provider - consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) + // consumerChainIDs := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) - found := false - for _, consumerChainID := range consumerChainIDs { - if consumerChainID == string(chain) { - found = true - } - } + // found := false + // for _, consumerChainID := range consumerChainIDs { + // if consumerChainID == string(chain) { + // found = true + // } + // } - if found { - chainInfo.WriteString("...is currently a consumer chain") - } else { - chainInfo.WriteString("...is currently not a consumer chain") - } - } + // if found { + // chainInfo.WriteString("...is currently a consumer chain") + // } else { + // chainInfo.WriteString("...is currently not a consumer chain") + // } + // } // Build the validator info string var validatorInfo strings.Builder @@ -366,16 +365,16 @@ func (s *Driver) endAndBeginBlock(chain ChainId, timeAdvancement time.Duration) } func (s *Driver) runningConsumerChainIDs() []ChainId { - consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) + // consumerIDsOnProvider := s.providerKeeper().GetAllRegisteredConsumerIds(s.providerCtx()) consumersWithIntactChannel := make([]ChainId, 0) - for _, consumerChainID := range consumerIDsOnProvider { - if s.path(ChainId(consumerChainID)).Path.EndpointA.GetChannel().State == channeltypes.CLOSED || - s.path(ChainId(consumerChainID)).Path.EndpointB.GetChannel().State == channeltypes.CLOSED { - continue - } - consumersWithIntactChannel = append(consumersWithIntactChannel, ChainId(consumerChainID)) - } + // for _, consumerChainID := range consumerIDsOnProvider { + // if s.path(ChainId(consumerChainID)).Path.EndpointA.GetChannel().State == channeltypes.CLOSED || + // s.path(ChainId(consumerChainID)).Path.EndpointB.GetChannel().State == channeltypes.CLOSED { + // continue + // } + // consumersWithIntactChannel = append(consumersWithIntactChannel, ChainId(consumerChainID)) + // } return consumersWithIntactChannel } @@ -452,7 +451,8 @@ func (s *Driver) DeliverAcks() { // stopConsumer stops a given consumer chain. func (s *Driver) stopConsumer(chain ChainId) error { // stop the consumer chain on the provider - return s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true) + // return s.providerKeeper().StopConsumerChain(s.providerCtx(), string(chain), true) + return nil } // newDriver creates a new Driver object. diff --git a/tests/mbt/driver/mbt_test.go b/tests/mbt/driver/mbt_test.go index 35ea2f4e1f..278c276d82 100644 --- a/tests/mbt/driver/mbt_test.go +++ b/tests/mbt/driver/mbt_test.go @@ -404,7 +404,7 @@ func RunItfTrace(t *testing.T, path string) { driver.DeliverPacketToConsumer(ChainId(consumerChain), expectError) // stop the consumer chain - driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError) + // driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError) } else { expectError = false driver.DeliverPacketToConsumer(ChainId(consumerChain), expectError) @@ -421,7 +421,7 @@ func RunItfTrace(t *testing.T, path string) { driver.DeliverPacketFromConsumer(ChainId(consumerChain), expectError) // stop the consumer chain on the provider - driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError) + // driver.providerKeeper().StopConsumerChain(driver.providerCtx(), consumerChain, expectError) } else { expectError = false driver.DeliverPacketFromConsumer(ChainId(consumerChain), expectError) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 9a8a7e5046..03080fc8b3 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -1,12 +1,13 @@ package cli import ( - "cosmossdk.io/math" "encoding/json" "fmt" "os" "strings" + "cosmossdk.io/math" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cobra" @@ -47,7 +48,7 @@ func GetTxCmd() *cobra.Command { func NewAssignConsumerKeyCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "assign-consensus-key [consumer-chain-id] [consumer-pubkey]", + Use: "assign-consensus-key [consumer-id] [consumer-pubkey]", Short: "assign a consensus public key to use for a consumer chain", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -86,7 +87,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { func NewSubmitConsumerMisbehaviourCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "submit-consumer-misbehaviour [misbehaviour]", + Use: "submit-consumer-misbehaviour [consumer-id] [misbehaviour]", Short: "submit an IBC misbehaviour for a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Submit an IBC misbehaviour detected on a consumer chain. @@ -94,9 +95,9 @@ An IBC misbehaviour contains two conflicting IBC client headers, which are used The misbehaviour type definition can be found in the IBC client messages, see ibc-go/proto/ibc/core/client/v1/tx.proto. Example: -%s tx provider submit-consumer-misbehaviour [path/to/misbehaviour.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider submit-consumer-misbehaviour [consumer-id] [path/to/misbehaviour.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -122,7 +123,7 @@ Example: return fmt.Errorf("misbehaviour unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerMisbehaviour(submitter, &misbehaviour) + msg, err := types.NewMsgSubmitConsumerMisbehaviour(args[0], submitter, &misbehaviour) if err != nil { return err } @@ -143,7 +144,7 @@ Example: func NewSubmitConsumerDoubleVotingCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "submit-consumer-double-voting [evidence] [infraction_header]", + Use: "submit-consumer-double-voting [consumer-id] [evidence] [infraction_header]", Short: "submit a double voting evidence for a consumer chain", Long: strings.TrimSpace( fmt.Sprintf(`Submit a Tendermint duplicate vote evidence detected on a consumer chain with @@ -153,9 +154,9 @@ func NewSubmitConsumerDoubleVotingCmd() *cobra.Command { definition can be found in the IBC messages, see ibc-go/proto/ibc/lightclients/tendermint/v1/tendermint.proto. Example: -%s tx provider submit-consumer-double-voting [path/to/evidence.json] [path/to/infraction_header.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider submit-consumer-double-voting [consumer-id] [path/to/evidence.json] [path/to/infraction_header.json] --from node0 --home ../node0 --chain-id $CID `, version.AppName)), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -192,7 +193,7 @@ Example: return fmt.Errorf("infraction IBC header unmarshalling failed: %s", err) } - msg, err := types.NewMsgSubmitConsumerDoubleVoting(submitter, &ev, &header) + msg, err := types.NewMsgSubmitConsumerDoubleVoting(args[0], submitter, &ev, &header) if err != nil { return err } diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 0ce64b688a..78a75cc69a 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -3,10 +3,11 @@ package types import ( "encoding/json" "fmt" - cmttypes "github.com/cometbft/cometbft/types" "strconv" "strings" + cmttypes "github.com/cometbft/cometbft/types" + ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" errorsmod "cosmossdk.io/errors" @@ -126,12 +127,14 @@ func (msg *MsgChangeRewardDenoms) ValidateBasic() error { } func NewMsgSubmitConsumerMisbehaviour( + consumerId string, submitter sdk.AccAddress, misbehaviour *ibctmtypes.Misbehaviour, ) (*MsgSubmitConsumerMisbehaviour, error) { return &MsgSubmitConsumerMisbehaviour{ Submitter: submitter.String(), Misbehaviour: misbehaviour, + ConsumerId: consumerId, }, nil } @@ -148,6 +151,7 @@ func (msg MsgSubmitConsumerMisbehaviour) ValidateBasic() error { } func NewMsgSubmitConsumerDoubleVoting( + consumerId string, submitter sdk.AccAddress, ev *tmtypes.DuplicateVoteEvidence, header *ibctmtypes.Header, @@ -156,6 +160,7 @@ func NewMsgSubmitConsumerDoubleVoting( Submitter: submitter.String(), DuplicateVoteEvidence: ev, InfractionBlockHeader: header, + ConsumerId: consumerId, }, nil } diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index cc87ba0443..7ef6796493 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -128,7 +128,7 @@ func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisSt type QueryConsumerChainsRequest struct { // The phase of the consumer chains returned (optional) - // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 + // All=0|Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 Phase ConsumerPhase `protobuf:"varint,1,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` // The limit of consumer chains returned (optional) // default is 100 @@ -243,7 +243,7 @@ type Chain struct { Allowlist []string `protobuf:"bytes,7,rep,name=allowlist,proto3" json:"allowlist,omitempty"` // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` - // The phase the consumer chain (Registered=0|Initialized=1|FailedToLaunch=2|Launched=3|Stopped=4) + // The phase the consumer chain (Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5) Phase string `protobuf:"bytes,9,opt,name=phase,proto3" json:"phase,omitempty"` // The metadata of the consumer chain Metadata ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata"` From cea97071913b4ee707f8dc9b1dc091924e9e0daf Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 5 Sep 2024 09:37:46 +0200 Subject: [PATCH 35/43] nit: remove type prefix from consumer phase enum (#2220) remove type prefix in consumer phase enum --- .../ccv/provider/v1/provider.proto | 2 + tests/e2e/state.go | 10 +- tests/integration/setup.go | 2 +- tests/integration/stop_consumer.go | 4 +- testutil/ibc_testing/generic_setup.go | 2 +- testutil/keeper/unit_test_helpers.go | 4 +- x/ccv/provider/handler_test.go | 10 +- x/ccv/provider/keeper/consumer_lifecycle.go | 12 +- .../keeper/consumer_lifecycle_test.go | 34 +- x/ccv/provider/keeper/genesis_test.go | 4 +- x/ccv/provider/keeper/grpc_query.go | 10 +- x/ccv/provider/keeper/grpc_query_test.go | 48 +-- x/ccv/provider/keeper/hooks_test.go | 6 +- x/ccv/provider/keeper/keeper_test.go | 2 +- x/ccv/provider/keeper/key_assignment.go | 2 +- x/ccv/provider/keeper/key_assignment_test.go | 18 +- x/ccv/provider/keeper/msg_server.go | 8 +- x/ccv/provider/keeper/msg_server_test.go | 6 +- x/ccv/provider/keeper/partial_set_security.go | 4 +- .../keeper/partial_set_security_test.go | 14 +- x/ccv/provider/keeper/permissionless.go | 8 +- x/ccv/provider/keeper/permissionless_test.go | 10 +- x/ccv/provider/keeper/relay.go | 4 +- x/ccv/provider/keeper/relay_test.go | 8 +- x/ccv/provider/migrations/v8/migrations.go | 2 +- x/ccv/provider/types/genesis.pb.go | 2 +- x/ccv/provider/types/provider.pb.go | 292 +++++++++--------- x/ccv/provider/types/query.pb.go | 6 +- 28 files changed, 268 insertions(+), 266 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 0a96af8cae..f1af229759 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -467,6 +467,8 @@ message ConsumerIds { repeated string ids = 1; } // ConsumerPhase indicates the phases of a consumer chain according to ADR 019 enum ConsumerPhase { + option (gogoproto.goproto_enum_prefix) = false; + // UNSPECIFIED defines an empty phase. CONSUMER_PHASE_UNSPECIFIED = 0; // REGISTERED defines the phase in which a consumer chain has been assigned a unique consumer id. diff --git a/tests/e2e/state.go b/tests/e2e/state.go index cdb25a0907..f6cac89947 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -769,9 +769,9 @@ func (tr Commands) GetConsumerChains(chain ChainID) map[ChainID]bool { chains := make(map[ChainID]bool) for _, c := range arr { phase := c.Get("phase").String() - if phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)] || - phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_REGISTERED)] || - phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED)] { + if phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_INITIALIZED)] || + phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_REGISTERED)] || + phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_LAUNCHED)] { id := c.Get("chain_id").String() chains[ChainID(id)] = true } @@ -1019,8 +1019,8 @@ func (tr Commands) GetProposedConsumerChains(chain ChainID) []string { for _, c := range arr { cid := c.Get("chain_id").String() phase := c.Get("phase").String() - if phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED)] || - phase == types.ConsumerPhase_name[int32(types.ConsumerPhase_CONSUMER_PHASE_REGISTERED)] { + if phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_INITIALIZED)] || + phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_REGISTERED)] { chains = append(chains, cid) } } diff --git a/tests/integration/setup.go b/tests/integration/setup.go index 1a61cbd706..218f6febb0 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -149,7 +149,7 @@ func (suite *CCVTestSuite) SetupTest() { // 1. the consumer chain is added to the coordinator // 2. MakeGenesis is called on the provider chain // 3. ibc/testing sets the tendermint header for the consumer chain app - providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerID, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(suite.providerCtx(), icstestingutils.FirstConsumerID, providertypes.CONSUMER_PHASE_INITIALIZED) preProposalKeyAssignment(suite, icstestingutils.FirstConsumerID) // start consumer chains diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index 6da22d6b66..8ce2e99cbf 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -89,7 +89,7 @@ func (s *CCVTestSuite) TestStopConsumerChain() { } // stop the consumer chain - providerKeeper.SetConsumerPhase(s.providerCtx(), firstBundle.ConsumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(s.providerCtx(), firstBundle.ConsumerId, types.CONSUMER_PHASE_STOPPED) err = providerKeeper.DeleteConsumerChain(s.providerCtx(), firstBundle.ConsumerId) s.Require().NoError(err) @@ -107,7 +107,7 @@ func (s *CCVTestSuite) TestStopConsumerOnChannelClosed() { providerKeeper := s.providerApp.GetProviderKeeper() // stop the consumer chain - providerKeeper.SetConsumerPhase(s.providerCtx(), s.getFirstBundle().ConsumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(s.providerCtx(), s.getFirstBundle().ConsumerId, types.CONSUMER_PHASE_STOPPED) err := providerKeeper.DeleteConsumerChain(s.providerCtx(), s.getFirstBundle().ConsumerId) s.Require().NoError(err) diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 10a5d6abae..84ccf347f2 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -166,7 +166,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( s.Require().NoError(err) err = providerKeeper.SetConsumerPowerShapingParameters(providerChain.GetContext(), consumerId, powerShapingParameters) s.Require().NoError(err) - providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(providerChain.GetContext(), consumerId, providertypes.CONSUMER_PHASE_INITIALIZED) err = providerKeeper.AppendConsumerToBeLaunched(providerChain.GetContext(), consumerId, coordinator.CurrentTime) s.Require().NoError(err) diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 7de405b434..a35670d955 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -240,7 +240,7 @@ func SetupForDeleteConsumerChain(t *testing.T, ctx sdk.Context, require.NoError(t, err) // set the chain to initialized so that we can create a consumer client - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_INITIALIZED) err = providerKeeper.CreateConsumerClient(ctx, consumerId) require.NoError(t, err) @@ -251,7 +251,7 @@ func SetupForDeleteConsumerChain(t *testing.T, ctx sdk.Context, require.NoError(t, err) // set the chain to stopped sto the chain can be deleted - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_STOPPED) } // TestProviderStateIsCleanedAfterConsumerChainIsDeleted executes test assertions for the provider's state being cleaned diff --git a/x/ccv/provider/handler_test.go b/x/ccv/provider/handler_test.go index 0d06ba7dea..40ef5101db 100644 --- a/x/ccv/provider/handler_test.go +++ b/x/ccv/provider/handler_test.go @@ -55,7 +55,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), @@ -88,7 +88,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) gomock.InOrder( mocks.MockStakingKeeper.EXPECT().GetValidator( ctx, providerCryptoId.SDKValOpAddress(), @@ -103,7 +103,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) // Use the consumer key already used by some other validator k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) @@ -127,7 +127,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) // Use the consumer key already k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr) @@ -149,7 +149,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { setup: func(ctx sdk.Context, k keeper.Keeper, mocks testkeeper.MockedKeepers, ) { - k.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) // Use the consumer key already used by some other validator k.SetValidatorByConsumerAddr(ctx, "consumerId", consumerConsAddr, providerConsAddr2) diff --git a/x/ccv/provider/keeper/consumer_lifecycle.go b/x/ccv/provider/keeper/consumer_lifecycle.go index 1dc3ef3d95..9de99f51e3 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle.go +++ b/x/ccv/provider/keeper/consumer_lifecycle.go @@ -42,7 +42,7 @@ func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, pre func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { // a chain that is already launched or stopped cannot launch again phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED || phase == types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + if phase == types.CONSUMER_PHASE_LAUNCHED || phase == types.CONSUMER_PHASE_STOPPED { return time.Time{}, false } @@ -160,7 +160,7 @@ func (k Keeper) LaunchConsumer(ctx sdk.Context, consumerId string) error { return errorsmod.Wrapf(types.ErrInvalidConsumerGenesis, "consumer genesis initial validator set is empty - no validators opted in consumer id: %s", consumerId) } - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) return nil } @@ -174,7 +174,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { } phase := k.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED { + if phase != types.CONSUMER_PHASE_INITIALIZED { return errorsmod.Wrapf(types.ErrInvalidPhase, "cannot create client for consumer chain that is not in the Initialized phase but in phase %d: %s", phase, consumerId) } @@ -359,7 +359,7 @@ func (k Keeper) MakeConsumerGenesis( func (k Keeper) StopAndPrepareForConsumerRemoval(ctx sdk.Context, consumerId string) error { // The phase of the chain is immediately set to stopped, albeit its state is removed later (see below). // Setting the phase here helps in not considering this chain when we look at launched chains (e.g., in `QueueVSCPackets) - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_STOPPED) // state of this chain is removed once UnbondingPeriod elapses unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) @@ -466,7 +466,7 @@ func (k Keeper) GetConsumersReadyToStop(ctx sdk.Context, limit uint32) []string // DeleteConsumerChain cleans up the state of the given consumer chain func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err error) { phase := k.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + if phase != types.CONSUMER_PHASE_STOPPED { return fmt.Errorf("cannot delete non-stopped chain: %s", consumerId) } @@ -519,7 +519,7 @@ func (k Keeper) DeleteConsumerChain(ctx sdk.Context, consumerId string) (err err // Note that we do not delete ConsumerIdToChainIdKey and ConsumerIdToPhase, as well // as consumer metadata, initialization and power-shaping parameters. - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_DELETED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_DELETED) k.Logger(ctx).Info("consumer chain deleted from provider", "consumerId", consumerId) return nil diff --git a/x/ccv/provider/keeper/consumer_lifecycle_test.go b/x/ccv/provider/keeper/consumer_lifecycle_test.go index 47e7b4420f..3d59fec53d 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle_test.go +++ b/x/ccv/provider/keeper/consumer_lifecycle_test.go @@ -61,7 +61,7 @@ func TestCanLaunch(t *testing.T) { require.False(t, canLaunch) // cannot launch a chain without initialization parameters - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) @@ -71,17 +71,17 @@ func TestCanLaunch(t *testing.T) { require.NoError(t, err) // cannot launch a launched chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_LAUNCHED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) // cannot launch a stopped chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_STOPPED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.False(t, canLaunch) // initialized chain can launch - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") require.True(t, canLaunch) @@ -255,7 +255,7 @@ func TestBeginBlockLaunchConsumers(t *testing.T) { err := providerKeeper.SetConsumerInitializationParameters(ctx, fmt.Sprintf("%d", i), r) require.NoError(t, err) // set up the chains in their initialized phase, hence they could launch - providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, fmt.Sprintf("%d", i), providertypes.CONSUMER_PHASE_INITIALIZED) err = providerKeeper.AppendConsumerToBeLaunched(ctx, fmt.Sprintf("%d", i), r.SpawnTime) require.NoError(t, err) } @@ -280,33 +280,33 @@ func TestBeginBlockLaunchConsumers(t *testing.T) { // first chain was successfully launched phase := providerKeeper.GetConsumerPhase(ctx, "0") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_LAUNCHED, phase) _, found := providerKeeper.GetConsumerGenesis(ctx, "0") require.True(t, found) // second chain was successfully launched phase = providerKeeper.GetConsumerPhase(ctx, "1") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_LAUNCHED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "1") require.True(t, found) // third chain was not launched because its spawn time has not passed phase = providerKeeper.GetConsumerPhase(ctx, "2") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "2") require.False(t, found) // fourth chain corresponds to an Opt-In chain with one opted-in validator and hence the chain gets // successfully executed phase = providerKeeper.GetConsumerPhase(ctx, "3") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_LAUNCHED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "3") require.True(t, found) // fifth chain corresponds to an Opt-In chain with no opted-in validators and hence the // chain launch is NOT successful phase = providerKeeper.GetConsumerPhase(ctx, "4") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, phase) _, found = providerKeeper.GetConsumerGenesis(ctx, "4") require.False(t, found) } @@ -362,7 +362,7 @@ func TestCreateConsumerClient(t *testing.T) { { description: "No state mutation, new client should be created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.CONSUMER_PHASE_INITIALIZED) // Valid client creation is asserted with mock expectations here testkeeper.SetupMocksForLastBondedValidatorsExpectation(mocks.MockStakingKeeper, 0, []stakingtypes.Validator{}, 1) // returns empty validator set @@ -375,7 +375,7 @@ func TestCreateConsumerClient(t *testing.T) { { description: "chain for this consumer id has already launched, and hence client was created, NO new one is created", setup: func(providerKeeper *providerkeeper.Keeper, ctx sdk.Context, mocks *testkeeper.MockedKeepers) { - providerKeeper.SetConsumerPhase(ctx, "0", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, "0", providertypes.CONSUMER_PHASE_LAUNCHED) // Expect none of the client creation related calls to happen mocks.MockStakingKeeper.EXPECT().UnbondingTime(gomock.Any()).Times(0) @@ -695,7 +695,7 @@ func TestBeginBlockStopConsumers(t *testing.T) { require.NoError(t, err) err = providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, testkeeper.GetTestPowerShapingParameters()) require.NoError(t, err) - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerClientId(ctx, consumerId, "clientID") err = providerKeeper.CreateConsumerClient(ctx, consumerId) @@ -704,7 +704,7 @@ func TestBeginBlockStopConsumers(t *testing.T) { require.NoError(t, err) // the chain is considered to be stopped and ready for deletion (i.e., `StopAndPrepareForConsumerRemoval` is called) - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_STOPPED) } // @@ -715,12 +715,12 @@ func TestBeginBlockStopConsumers(t *testing.T) { // Only the 3rd (final) proposal is still stored as pending phase := providerKeeper.GetConsumerPhase(ctx, consumerIds[0]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_DELETED, phase) phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[1]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_DELETED, phase) // third chain had a removal time in the future and hence did not get deleted phase = providerKeeper.GetConsumerPhase(ctx, consumerIds[2]) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_STOPPED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_STOPPED, phase) } func TestGetConsumersReadyToStop(t *testing.T) { diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index a9126f9afe..af3e0ea843 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -51,7 +51,7 @@ func TestInitAndExportGenesis(t *testing.T) { *ccv.DefaultConsumerGenesisState(), []ccv.ValidatorSetChangePacketData{}, []string{"slashedValidatorConsAddress"}, - providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, + providertypes.CONSUMER_PHASE_LAUNCHED, ), providertypes.NewConsumerStates( cChainIDs[1], @@ -61,7 +61,7 @@ func TestInitAndExportGenesis(t *testing.T) { *ccv.DefaultConsumerGenesisState(), []ccv.ValidatorSetChangePacketData{{ValsetUpdateId: vscID}}, nil, - providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, + providertypes.CONSUMER_PHASE_LAUNCHED, ), }, params, diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 3325ffd193..170b3ba29b 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -51,7 +51,7 @@ func (k Keeper) QueryConsumerChains(goCtx context.Context, req *types.QueryConsu consumerIds := []string{} for _, consumerID := range k.GetAllConsumerIds(ctx) { phase := k.GetConsumerPhase(ctx, consumerID) - if req.Phase != types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED && req.Phase != phase { + if req.Phase != types.CONSUMER_PHASE_UNSPECIFIED && req.Phase != phase { // ignore consumer chain continue } @@ -308,7 +308,7 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC // get the consumer phase phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + if phase == types.CONSUMER_PHASE_UNSPECIFIED { return nil, status.Errorf(codes.InvalidArgument, "cannot find a phase for consumer: %s", consumerId) } @@ -318,13 +318,13 @@ func (k Keeper) QueryConsumerValidators(goCtx context.Context, req *types.QueryC var err error // if the consumer launched, the consumer valset has been persisted - if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if phase == types.CONSUMER_PHASE_LAUNCHED { consumerValSet, err = k.GetConsumerValSet(ctx, consumerId) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } // if the consumer hasn't been launched or stopped, compute the consumer validator set - } else if phase != types.ConsumerPhase_CONSUMER_PHASE_STOPPED { + } else if phase != types.CONSUMER_PHASE_STOPPED { bondedValidators, err := k.GetLastBondedValidators(ctx) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("failed to get last validators: %s", err)) @@ -572,7 +572,7 @@ func (k Keeper) QueryConsumerChain(goCtx context.Context, req *types.QueryConsum } phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + if phase == types.CONSUMER_PHASE_UNSPECIFIED { return nil, status.Errorf(codes.InvalidArgument, "cannot retrieve phase for consumer id: %s", consumerId) } diff --git a/x/ccv/provider/keeper/grpc_query_test.go b/x/ccv/provider/keeper/grpc_query_test.go index f87c62c375..3ba2cc9059 100644 --- a/x/ccv/provider/keeper/grpc_query_test.go +++ b/x/ccv/provider/keeper/grpc_query_test.go @@ -85,7 +85,7 @@ func TestQueryConsumerChainOptedInValidators(t *testing.T) { require.Error(t, err) pk.FetchAndIncrementConsumerId(ctx) - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) @@ -114,7 +114,7 @@ func TestQueryConsumerValidators(t *testing.T) { require.Error(t, err) // set the consumer to the "registered" phase - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_REGISTERED) // set power shaping params err = pk.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{}) @@ -233,13 +233,13 @@ func TestQueryConsumerValidators(t *testing.T) { require.Equal(t, &expRes, res) // expect same result when consumer is in "initialized" phase - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) res, err = pk.QueryConsumerValidators(ctx, &req) require.NoError(t, err) require.Equal(t, &expRes, res) // set consumer to the "launched" phase - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) // expect an empty consumer valset // since neither QueueVSCPackets or MakeConsumerGenesis was called at this point @@ -324,7 +324,7 @@ func TestQueryConsumerChainsValidatorHasToValidate(t *testing.T) { clientID := "client-" + strconv.Itoa(i) pk.SetConsumerClientId(ctx, consumerId, clientID) - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) consumerIds[i] = consumerId } @@ -374,7 +374,7 @@ func TestQueryValidatorConsumerCommissionRate(t *testing.T) { require.Error(t, err) pk.FetchAndIncrementConsumerId(ctx) - pk.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + pk.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) // validator with set consumer commission rate expectedCommissionRate := math.LegacyMustNewDecFromStr("0.123") @@ -545,7 +545,7 @@ func TestQueryConsumerChain(t *testing.T) { _, err = providerKeeper.QueryConsumerChain(ctx, &req) require.Error(t, err) - providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + providerKeeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_REGISTERED) // expect error when consumer doesn't have metadata _, err = providerKeeper.QueryConsumerChain(ctx, &req) @@ -558,7 +558,7 @@ func TestQueryConsumerChain(t *testing.T) { ChainId: chainId, OwnerAddress: providerKeeper.GetAuthority(), Metadata: types.ConsumerMetadata{Name: chainId}, - Phase: types.ConsumerPhase_CONSUMER_PHASE_REGISTERED.String(), + Phase: types.CONSUMER_PHASE_REGISTERED.String(), InitParams: &types.ConsumerInitializationParameters{}, PowerShapingParams: &types.PowerShapingParameters{}, } @@ -623,10 +623,10 @@ func TestQueryConsumerChains(t *testing.T) { msgServer := keeper.NewMsgServerImpl(&pk) phases := []types.ConsumerPhase{ - types.ConsumerPhase_CONSUMER_PHASE_REGISTERED, - types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, - types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, - types.ConsumerPhase_CONSUMER_PHASE_STOPPED, + types.CONSUMER_PHASE_REGISTERED, + types.CONSUMER_PHASE_INITIALIZED, + types.CONSUMER_PHASE_LAUNCHED, + types.CONSUMER_PHASE_STOPPED, } // create four consumer chains in different phase @@ -678,37 +678,37 @@ func TestQueryConsumerChains(t *testing.T) { { name: "expect registered consumers when phase filter is set to Registered", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[0].Phase = types.ConsumerPhase_CONSUMER_PHASE_REGISTERED.String() - pk.SetConsumerPhase(ctx, consumerIds[0], types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + consumers[0].Phase = types.CONSUMER_PHASE_REGISTERED.String() + pk.SetConsumerPhase(ctx, consumerIds[0], types.CONSUMER_PHASE_REGISTERED) }, - phase_filter: types.ConsumerPhase_CONSUMER_PHASE_REGISTERED, + phase_filter: types.CONSUMER_PHASE_REGISTERED, expConsumers: consumers[0:1], }, { name: "expect initialized consumers when phase is set to Initialized", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[1].Phase = types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED.String() - pk.SetConsumerPhase(ctx, consumerIds[1], types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + consumers[1].Phase = types.CONSUMER_PHASE_INITIALIZED.String() + pk.SetConsumerPhase(ctx, consumerIds[1], types.CONSUMER_PHASE_INITIALIZED) }, - phase_filter: types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, + phase_filter: types.CONSUMER_PHASE_INITIALIZED, expConsumers: consumers[1:2], }, { name: "expect launched consumers when phase is set to Launched", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[2].Phase = types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED.String() - pk.SetConsumerPhase(ctx, consumerIds[2], types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + consumers[2].Phase = types.CONSUMER_PHASE_LAUNCHED.String() + pk.SetConsumerPhase(ctx, consumerIds[2], types.CONSUMER_PHASE_LAUNCHED) }, - phase_filter: types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, + phase_filter: types.CONSUMER_PHASE_LAUNCHED, expConsumers: consumers[2:3], }, { name: "expect stopped consumers when phase is set to Stopped", setup: func(ctx sdk.Context, pk keeper.Keeper) { - consumers[3].Phase = types.ConsumerPhase_CONSUMER_PHASE_STOPPED.String() - pk.SetConsumerPhase(ctx, consumerIds[3], types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + consumers[3].Phase = types.CONSUMER_PHASE_STOPPED.String() + pk.SetConsumerPhase(ctx, consumerIds[3], types.CONSUMER_PHASE_STOPPED) }, - phase_filter: types.ConsumerPhase_CONSUMER_PHASE_STOPPED, + phase_filter: types.CONSUMER_PHASE_STOPPED, expConsumers: consumers[3:], }, } diff --git a/x/ccv/provider/keeper/hooks_test.go b/x/ccv/provider/keeper/hooks_test.go index bc6450923f..e76eece5ad 100644 --- a/x/ccv/provider/keeper/hooks_test.go +++ b/x/ccv/provider/keeper/hooks_test.go @@ -32,7 +32,7 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { name: "in use by another validator", setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "0", types.CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator @@ -49,8 +49,8 @@ func TestValidatorConsensusKeyInUse(t *testing.T) { setup: func(ctx sdk.Context, k providerkeeper.Keeper) { k.FetchAndIncrementConsumerId(ctx) k.FetchAndIncrementConsumerId(ctx) - k.SetConsumerPhase(ctx, "0", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) - k.SetConsumerPhase(ctx, "1", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "0", types.CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, "1", types.CONSUMER_PHASE_INITIALIZED) // We are trying to add a new validator, but its address has already been used // by another validator, of which there are several, across potentially several chains diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 79d0b7fe8c..9485c9efd7 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -231,7 +231,7 @@ func TestGetAllConsumersWithIBCClients(t *testing.T) { for i, consumerId := range consumerIds { clientId := fmt.Sprintf("client-%d", len(consumerIds)-i) pk.SetConsumerClientId(ctx, consumerId, clientId) - pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_LAUNCHED) } actualConsumerIds := pk.GetAllConsumersWithIBCClients(ctx) diff --git a/x/ccv/provider/keeper/key_assignment.go b/x/ccv/provider/keeper/key_assignment.go index 47a890098a..f2f10dd368 100644 --- a/x/ccv/provider/keeper/key_assignment.go +++ b/x/ccv/provider/keeper/key_assignment.go @@ -460,7 +460,7 @@ func (k Keeper) AssignConsumerKey( // check whether the consumer chain has already launched (i.e., a client to the consumer was already created) phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if phase == types.CONSUMER_PHASE_LAUNCHED { // mark the old consumer address as prunable once UnbondingPeriod elapses; // note: this state is removed on EndBlock unbondingPeriod, err := k.stakingKeeper.UnbondingTime(ctx) diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index 9779b727ca..fced8ad7a7 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -393,7 +393,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -420,7 +420,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(sdkCtx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(sdkCtx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + k.SetConsumerPhase(sdkCtx, consumerId, types.CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(sdkCtx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -450,7 +450,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -477,7 +477,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), @@ -495,7 +495,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -520,7 +520,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -550,7 +550,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[0].SDKStakingValidator(), consumerIdentities[0].TMProtoCryptoPublicKey(), @@ -577,7 +577,7 @@ func TestAssignConsensusKeyForConsumerChain(t *testing.T) { ) }, doActions: func(ctx sdk.Context, k providerkeeper.Keeper) { - k.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) err := k.AssignConsumerKey(ctx, consumerId, providerIdentities[1].SDKStakingValidator(), providerIdentities[0].TMProtoCryptoPublicKey(), @@ -613,7 +613,7 @@ func TestCannotReassignDefaultKeyAssignment(t *testing.T) { providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.CONSUMER_PHASE_INITIALIZED) // Mock that the validator is validating with the single key, as confirmed by provider's staking keeper gomock.InOrder( diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index b24e09ae4d..088be381e4 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -291,7 +291,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) k.Keeper.SetConsumerChainId(ctx, consumerId, msg.ChainId) - k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_REGISTERED) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_REGISTERED) if err := k.Keeper.SetConsumerMetadata(ctx, consumerId, msg.Metadata); err != nil { return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, @@ -326,7 +326,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) @@ -441,7 +441,7 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon } if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, "cannot prepare chain with consumer id (%s) for launch", consumerId) @@ -468,7 +468,7 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon } phase := k.Keeper.GetConsumerPhase(ctx, consumerId) - if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if phase != types.CONSUMER_PHASE_LAUNCHED { return &resp, errorsmod.Wrapf(types.ErrInvalidPhase, "chain with consumer id: %s has to be in its launched phase", consumerId) } diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index b6f9bb1f71..994c4a6fd0 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -34,7 +34,7 @@ func TestCreateConsumer(t *testing.T) { require.NoError(t, err) require.Equal(t, "signer", ownerAddress) phase := providerKeeper.GetConsumerPhase(ctx, "0") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) consumerMetadata = providertypes.ConsumerMetadata{ Name: "chain name", @@ -54,7 +54,7 @@ func TestCreateConsumer(t *testing.T) { require.NoError(t, err) require.Equal(t, "signer2", ownerAddress) phase = providerKeeper.GetConsumerPhase(ctx, "1") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_REGISTERED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) } func TestUpdateConsumer(t *testing.T) { @@ -134,7 +134,7 @@ func TestUpdateConsumer(t *testing.T) { // assert phase phase := providerKeeper.GetConsumerPhase(ctx, consumerId) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, phase) // assert that chain is set to launch consumerIds, err := providerKeeper.GetConsumersToBeLaunched(ctx, expectedInitializationParameters.SpawnTime) diff --git a/x/ccv/provider/keeper/partial_set_security.go b/x/ccv/provider/keeper/partial_set_security.go index 95667a1d4c..5d654516ab 100644 --- a/x/ccv/provider/keeper/partial_set_security.go +++ b/x/ccv/provider/keeper/partial_set_security.go @@ -67,13 +67,13 @@ func (k Keeper) HandleOptIn(ctx sdk.Context, consumerId string, providerAddr typ // Note that the validator only opts out at the end of an epoch. func (k Keeper) HandleOptOut(ctx sdk.Context, consumerId string, providerAddr types.ProviderConsAddress) error { phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED { + if phase == types.CONSUMER_PHASE_UNSPECIFIED { return errorsmod.Wrapf( types.ErrUnknownConsumerId, "opting out of an unknown consumer chain, consumerId(%s)", consumerId, ) } - if phase != types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if phase != types.CONSUMER_PHASE_LAUNCHED { // A validator can only opt out from a running chain return errorsmod.Wrapf( types.ErrInvalidPhase, diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index b29ff94a47..c9ef563914 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -37,10 +37,10 @@ func TestHandleOptIn(t *testing.T) { require.Error(t, providerKeeper.HandleOptIn(ctx, "unknownConsumerId", providerAddr, "")) // trying to opt in to a stopped consumer chain - providerKeeper.SetConsumerPhase(ctx, "stoppedConsumerId", types.ConsumerPhase_CONSUMER_PHASE_STOPPED) + providerKeeper.SetConsumerPhase(ctx, "stoppedConsumerId", types.CONSUMER_PHASE_STOPPED) require.Error(t, providerKeeper.HandleOptIn(ctx, "stoppedConsumerId", providerAddr, "")) - providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId", "chainId") require.False(t, providerKeeper.IsOptedIn(ctx, "consumerId", providerAddr)) err := providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, "") @@ -49,7 +49,7 @@ func TestHandleOptIn(t *testing.T) { // validator tries to opt in to another chain with chain id ("chainId") while it is already opted in to // a different chain with the same chain id - providerKeeper.SetConsumerPhase(ctx, "consumerId2", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId2", types.CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId2", "chainId") err = providerKeeper.HandleOptIn(ctx, "consumerId2", providerAddr, "") require.ErrorContains(t, err, "validator is already opted in to a chain") @@ -88,7 +88,7 @@ func TestHandleOptInWithConsumerKey(t *testing.T) { expectedConsumerPubKey, err := providerKeeper.ParseConsumerKey(consumerKey) require.NoError(t, err) - providerKeeper.SetConsumerPhase(ctx, "consumerId", types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", types.CONSUMER_PHASE_INITIALIZED) providerKeeper.SetConsumerChainId(ctx, "consumerId", "consumerId") err = providerKeeper.HandleOptIn(ctx, "consumerId", providerAddr, consumerKey) require.NoError(t, err) @@ -117,7 +117,7 @@ func TestHandleOptOut(t *testing.T) { require.Error(t, providerKeeper.HandleOptOut(ctx, "unknownChainID", providerAddr)) // set the phase and power shaping params - providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) err := providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, types.PowerShapingParameters{}) require.NoError(t, err) @@ -138,7 +138,7 @@ func TestHandleOptOutFromTopNChain(t *testing.T) { consumerId := "consumerId" // set the phase - providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_LAUNCHED) // set the chain as Top 50 and create 4 validators with 10%, 20%, 30%, and 40% of the total voting power // respectively @@ -210,7 +210,7 @@ func TestHandleSetConsumerCommissionRate(t *testing.T) { // setup a pending consumer chain consumerId := "0" providerKeeper.FetchAndIncrementConsumerId(ctx) - providerKeeper.SetConsumerPhase(ctx, consumerId, types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) // check that there's no commission rate set for the validator yet _, found := providerKeeper.GetConsumerCommissionRate(ctx, consumerId, providerAddr) diff --git a/x/ccv/provider/keeper/permissionless.go b/x/ccv/provider/keeper/permissionless.go index 039b016ffd..aa32b496a4 100644 --- a/x/ccv/provider/keeper/permissionless.go +++ b/x/ccv/provider/keeper/permissionless.go @@ -148,7 +148,7 @@ func (k Keeper) GetConsumerPhase(ctx sdk.Context, consumerId string) types.Consu store := ctx.KVStore(k.storeKey) buf := store.Get(types.ConsumerIdToPhaseKey(consumerId)) if buf == nil { - return types.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED + return types.CONSUMER_PHASE_UNSPECIFIED } phase := types.ConsumerPhase(binary.BigEndian.Uint32(buf)) return phase @@ -171,9 +171,9 @@ func (k Keeper) DeleteConsumerPhase(ctx sdk.Context, consumerId string) { // IsConsumerActive checks if a consumer chain is either registered, initialized, or launched. func (k Keeper) IsConsumerActive(ctx sdk.Context, consumerId string) bool { phase := k.GetConsumerPhase(ctx, consumerId) - return phase == types.ConsumerPhase_CONSUMER_PHASE_REGISTERED || - phase == types.ConsumerPhase_CONSUMER_PHASE_INITIALIZED || - phase == types.ConsumerPhase_CONSUMER_PHASE_LAUNCHED + return phase == types.CONSUMER_PHASE_REGISTERED || + phase == types.CONSUMER_PHASE_INITIALIZED || + phase == types.CONSUMER_PHASE_LAUNCHED } // GetOptedInConsumerIds returns all the consumer ids where the given validator is opted in diff --git a/x/ccv/provider/keeper/permissionless_test.go b/x/ccv/provider/keeper/permissionless_test.go index 049b5d92c1..dbb86cb4d4 100644 --- a/x/ccv/provider/keeper/permissionless_test.go +++ b/x/ccv/provider/keeper/permissionless_test.go @@ -185,15 +185,15 @@ func TestConsumerPhase(t *testing.T) { defer ctrl.Finish() phase := providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_UNSPECIFIED, phase) - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) phase = providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_INITIALIZED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, phase) - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_LAUNCHED) phase = providerKeeper.GetConsumerPhase(ctx, "consumerId") - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED, phase) + require.Equal(t, providertypes.CONSUMER_PHASE_LAUNCHED, phase) } // TestOptedInConsumerIds tests the `GetOptedInConsumerIds`, `AppendOptedInConsumerId`, and `RemoveOptedInConsumerId` methods diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index f5e5216bb6..5abb074c22 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -143,7 +143,7 @@ func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64 { // TODO (mpoke): iterate only over consumers with established channel func (k Keeper) SendVSCPackets(ctx sdk.Context) error { for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { - if k.GetConsumerPhase(ctx, consumerId) != providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if k.GetConsumerPhase(ctx, consumerId) != providertypes.CONSUMER_PHASE_LAUNCHED { // only send VSCPackets to launched chains continue } @@ -219,7 +219,7 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) error { } for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { - if k.GetConsumerPhase(ctx, consumerId) != providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED { + if k.GetConsumerPhase(ctx, consumerId) != providertypes.CONSUMER_PHASE_LAUNCHED { // only queue VSCPackets to launched chains continue } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 88ec9159e3..753700214b 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -110,7 +110,7 @@ func TestQueueVSCPacketsDoesNotResetConsumerValidatorsHeights(t *testing.T) { // set a consumer client id and its phase, so we have a consumer chain (i.e., `GetAllConsumersWithIBCClients` is non-empty) providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientID") - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_LAUNCHED) // opt in validator A and set as a consumer validator providerKeeper.SetOptedIn(ctx, "consumerId", providertypes.NewProviderConsAddress(valAConsAddr)) @@ -530,7 +530,7 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { // Pending VSC packets should be deleted in DeleteConsumerChain require.Empty(t, providerKeeper.GetPendingVSCPackets(ctx, "consumerId")) - require.Equal(t, providertypes.ConsumerPhase_CONSUMER_PHASE_DELETED, providerKeeper.GetConsumerPhase(ctx, "consumerId")) + require.Equal(t, providertypes.CONSUMER_PHASE_DELETED, providerKeeper.GetConsumerPhase(ctx, "consumerId")) } // TestOnTimeoutPacketWithNoChainFound tests the `OnTimeoutPacket` method fails when no chain is found @@ -670,7 +670,7 @@ func TestEndBlockVSU(t *testing.T) { // set a sample client for a launched consumer chain so that `GetAllConsumersWithIBCClients` in `QueueVSCPackets` iterates at least once providerKeeper.SetConsumerClientId(ctx, consumerId, "clientId") providerKeeper.SetConsumerPowerShapingParameters(ctx, consumerId, providertypes.PowerShapingParameters{Top_N: 100}) - providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_LAUNCHED) // with block height of 1 we do not expect any queueing of VSC packets ctx = ctx.WithBlockHeight(1) @@ -799,7 +799,7 @@ func TestQueueVSCPacketsWithPowerCapping(t *testing.T) { // add a consumer chain providerKeeper.SetConsumerClientId(ctx, "consumerId", "clientId") - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_LAUNCHED) err := providerKeeper.SetConsumerPowerShapingParameters(ctx, "consumerId", providertypes.PowerShapingParameters{ Top_N: 50, // would opt in E diff --git a/x/ccv/provider/migrations/v8/migrations.go b/x/ccv/provider/migrations/v8/migrations.go index abf9cc0225..c7ace6eb3f 100644 --- a/x/ccv/provider/migrations/v8/migrations.go +++ b/x/ccv/provider/migrations/v8/migrations.go @@ -267,7 +267,7 @@ func MigrateLaunchedConsumerChains(ctx sdk.Context, store storetypes.KVStore, pk } // set phase to launched - pk.SetConsumerPhase(ctx, consumerId, providertypes.ConsumerPhase_CONSUMER_PHASE_LAUNCHED) + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_LAUNCHED) // This is to migrate everything under `ProviderConsAddrToOptedInConsumerIdsKey` // `OptedIn` was already re-keyed earlier (see above) and hence we can use `consumerId` here. diff --git a/x/ccv/provider/types/genesis.pb.go b/x/ccv/provider/types/genesis.pb.go index 92a7aa345e..bbf069fec6 100644 --- a/x/ccv/provider/types/genesis.pb.go +++ b/x/ccv/provider/types/genesis.pb.go @@ -231,7 +231,7 @@ func (m *ConsumerState) GetPhase() ConsumerPhase { if m != nil { return m.Phase } - return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED + return CONSUMER_PHASE_UNSPECIFIED } // ValsetUpdateIdToHeight defines the genesis information for the mapping diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index bcdf7dd2ab..77d0dc6d98 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -42,20 +42,20 @@ type ConsumerPhase int32 const ( // UNSPECIFIED defines an empty phase. - ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED ConsumerPhase = 0 + CONSUMER_PHASE_UNSPECIFIED ConsumerPhase = 0 // REGISTERED defines the phase in which a consumer chain has been assigned a unique consumer id. // A chain in this phase cannot yet launch. - ConsumerPhase_CONSUMER_PHASE_REGISTERED ConsumerPhase = 1 + CONSUMER_PHASE_REGISTERED ConsumerPhase = 1 // INITIALIZED defines the phase in which a consumer chain has set all the needed parameters to launch but // has not yet launched (e.g., because the `spawnTime` of the consumer chain has not yet been reached). - ConsumerPhase_CONSUMER_PHASE_INITIALIZED ConsumerPhase = 2 + CONSUMER_PHASE_INITIALIZED ConsumerPhase = 2 // LAUNCHED defines the phase in which a consumer chain is running and consuming a subset of the validator // set of the provider. - ConsumerPhase_CONSUMER_PHASE_LAUNCHED ConsumerPhase = 3 + CONSUMER_PHASE_LAUNCHED ConsumerPhase = 3 // STOPPED defines the phase in which a previously-launched chain has stopped. - ConsumerPhase_CONSUMER_PHASE_STOPPED ConsumerPhase = 4 + CONSUMER_PHASE_STOPPED ConsumerPhase = 4 // DELETED defines the phase in which the state of a stopped chain has been deleted. - ConsumerPhase_CONSUMER_PHASE_DELETED ConsumerPhase = 5 + CONSUMER_PHASE_DELETED ConsumerPhase = 5 ) var ConsumerPhase_name = map[int32]string{ @@ -1830,147 +1830,147 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 2231 bytes of a gzipped FileDescriptorProto + // 2238 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0xbd, 0x6f, 0x1b, 0xc9, - 0x15, 0xd7, 0x8a, 0x94, 0x44, 0x3e, 0xea, 0x83, 0x1a, 0xfb, 0x6c, 0x4a, 0xd6, 0x51, 0x34, 0x2f, - 0x36, 0x14, 0x3b, 0x26, 0x4f, 0x3a, 0x04, 0x30, 0x9c, 0x1c, 0x0c, 0x99, 0xa4, 0x6d, 0xfa, 0x43, - 0x66, 0x96, 0xb4, 0x0e, 0x70, 0x8a, 0xc5, 0x70, 0x77, 0x44, 0x4e, 0xb4, 0xbb, 0xb3, 0xde, 0x19, - 0xd2, 0x66, 0x8a, 0xd4, 0x41, 0x80, 0x00, 0x97, 0x54, 0x87, 0x34, 0xb9, 0x32, 0x48, 0x95, 0x22, - 0xc8, 0x1f, 0x90, 0x34, 0x87, 0x00, 0x41, 0xae, 0x4c, 0x75, 0x17, 0xd8, 0x45, 0x8a, 0x00, 0x69, - 0xd3, 0x06, 0x33, 0xfb, 0xc1, 0xa5, 0x3e, 0x6c, 0x1a, 0xb6, 0xd3, 0x48, 0x3b, 0xef, 0xfd, 0xde, - 0x9b, 0x37, 0x33, 0xef, 0x6b, 0x86, 0xb0, 0x43, 0x5d, 0x41, 0x7c, 0xb3, 0x8f, 0xa9, 0x6b, 0x70, - 0x62, 0x0e, 0x7c, 0x2a, 0x46, 0x55, 0xd3, 0x1c, 0x56, 0x3d, 0x9f, 0x0d, 0xa9, 0x45, 0xfc, 0xea, - 0x70, 0x3b, 0xfe, 0xae, 0x78, 0x3e, 0x13, 0x0c, 0x7d, 0x74, 0x82, 0x4c, 0xc5, 0x34, 0x87, 0x95, - 0x18, 0x37, 0xdc, 0x5e, 0xbf, 0x74, 0x9a, 0xe2, 0xe1, 0x76, 0xf5, 0x19, 0xf5, 0x49, 0xa0, 0x6b, - 0xfd, 0x6c, 0x8f, 0xf5, 0x98, 0xfa, 0xac, 0xca, 0xaf, 0x90, 0xba, 0xd9, 0x63, 0xac, 0x67, 0x93, - 0xaa, 0x1a, 0x75, 0x07, 0x07, 0x55, 0x41, 0x1d, 0xc2, 0x05, 0x76, 0xbc, 0x10, 0x50, 0x3c, 0x0a, - 0xb0, 0x06, 0x3e, 0x16, 0x94, 0xb9, 0x91, 0x02, 0xda, 0x35, 0xab, 0x26, 0xf3, 0x49, 0xd5, 0xb4, - 0x29, 0x71, 0x85, 0x9c, 0x35, 0xf8, 0x0a, 0x01, 0x55, 0x09, 0xb0, 0x69, 0xaf, 0x2f, 0x02, 0x32, - 0xaf, 0x0a, 0xe2, 0x5a, 0xc4, 0x77, 0x68, 0x00, 0x1e, 0x8f, 0x42, 0x81, 0x8d, 0x04, 0xdf, 0xf4, - 0x47, 0x9e, 0x60, 0xd5, 0x43, 0x32, 0xe2, 0x21, 0xf7, 0xb2, 0xc9, 0xb8, 0xc3, 0x78, 0x95, 0xc8, - 0xf5, 0xbb, 0x26, 0xa9, 0x0e, 0xb7, 0xbb, 0x44, 0xe0, 0xed, 0x98, 0x10, 0xd9, 0x1d, 0xe2, 0xba, - 0x98, 0x8f, 0x31, 0x26, 0xa3, 0x91, 0xdd, 0x6b, 0x01, 0xdf, 0x08, 0x76, 0x24, 0x18, 0x84, 0xac, - 0x55, 0xec, 0x50, 0x97, 0x55, 0xd5, 0xdf, 0x80, 0x54, 0xfe, 0x6f, 0x06, 0x0a, 0x35, 0xe6, 0xf2, - 0x81, 0x43, 0xfc, 0x5d, 0xcb, 0xa2, 0x72, 0x03, 0x5a, 0x3e, 0xf3, 0x18, 0xc7, 0x36, 0x3a, 0x0b, - 0x73, 0x82, 0x0a, 0x9b, 0x14, 0xb4, 0x92, 0xb6, 0x95, 0xd5, 0x83, 0x01, 0x2a, 0x41, 0xce, 0x22, -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 0x94, 0xa3, 0xd7, 0xf5, 0x15, 0x73, 0x82, 0x60, - 0xa1, 0x22, 0xe4, 0x68, 0xd7, 0x34, 0x38, 0x79, 0x6a, 0xb8, 0x03, 0x47, 0xc5, 0x45, 0x5a, 0xcf, - 0xd2, 0xae, 0xd9, 0x26, 0x4f, 0xf7, 0x06, 0x0e, 0xfa, 0x04, 0xce, 0x45, 0xcd, 0xa4, 0xf4, 0x24, - 0x43, 0xca, 0xcb, 0xed, 0xf2, 0x55, 0xa8, 0x2c, 0xea, 0x67, 0x22, 0xee, 0x3e, 0xb6, 0xe5, 0x64, - 0xbb, 0x96, 0xe5, 0x97, 0xff, 0x33, 0x07, 0xf3, 0x2d, 0xec, 0x63, 0x87, 0xa3, 0x0e, 0xac, 0x08, - 0xe2, 0x78, 0x36, 0x16, 0xc4, 0x08, 0x5a, 0x92, 0x70, 0xa5, 0x57, 0x55, 0xab, 0x92, 0x6c, 0xfc, - 0x2a, 0x89, 0x56, 0x6f, 0xb8, 0x5d, 0xa9, 0x29, 0x6a, 0x5b, 0x60, 0x41, 0xf4, 0xe5, 0x48, 0x47, - 0x40, 0x44, 0xd7, 0xa1, 0x20, 0xfc, 0x01, 0x17, 0xe3, 0x66, 0x61, 0x5c, 0x25, 0x83, 0xb3, 0x3e, - 0x17, 0xf1, 0x83, 0xfa, 0x1a, 0x57, 0xc7, 0x93, 0xfb, 0x82, 0xd4, 0xdb, 0xf4, 0x05, 0x16, 0x6c, - 0x70, 0x79, 0xa8, 0x86, 0x43, 0x84, 0xaa, 0xde, 0x9e, 0x4d, 0x5c, 0xca, 0xfb, 0x91, 0xf2, 0xf9, - 0xe9, 0x95, 0xaf, 0x29, 0x45, 0x0f, 0xa5, 0x1e, 0x3d, 0x52, 0x13, 0xce, 0x52, 0x83, 0xe2, 0xc9, - 0xb3, 0xc4, 0x0b, 0x5f, 0x50, 0x0b, 0xbf, 0x70, 0x82, 0x8a, 0x78, 0xf5, 0x1c, 0x2e, 0x27, 0xba, - 0x0c, 0x19, 0x4d, 0x86, 0x72, 0x64, 0xc3, 0x27, 0x3d, 0x59, 0x8a, 0x71, 0xd0, 0x70, 0x10, 0x12, - 0x77, 0x4a, 0xa1, 0x4f, 0xcb, 0x36, 0x39, 0xe1, 0xd4, 0xd4, 0x0d, 0xdb, 0xc9, 0xf2, 0xb8, 0x19, - 0x89, 0x63, 0x53, 0x4f, 0xe8, 0xba, 0x4d, 0x88, 0x8c, 0xa2, 0x44, 0x43, 0x42, 0x3c, 0x66, 0xf6, - 0x55, 0x3e, 0x4a, 0xe9, 0xcb, 0x71, 0xf3, 0xd1, 0x90, 0x54, 0xf4, 0x04, 0xae, 0xba, 0x03, 0xa7, - 0x4b, 0x7c, 0x83, 0x1d, 0x04, 0x40, 0x15, 0x79, 0x5c, 0x60, 0x5f, 0x18, 0x3e, 0x31, 0x09, 0x1d, - 0xca, 0x13, 0x0f, 0x2c, 0xe7, 0xaa, 0x1f, 0x4a, 0xe9, 0x97, 0x02, 0x91, 0x47, 0x07, 0x4a, 0x07, - 0xef, 0xb0, 0xb6, 0x84, 0xeb, 0x11, 0x3a, 0x30, 0x8c, 0xa3, 0x26, 0x5c, 0x74, 0xf0, 0x73, 0x23, - 0x76, 0x66, 0x69, 0x38, 0x71, 0xf9, 0x80, 0x1b, 0xe3, 0x44, 0x1e, 0xf6, 0x44, 0x45, 0x07, 0x3f, - 0x6f, 0x85, 0xb8, 0x5a, 0x04, 0xdb, 0x8f, 0x51, 0xf7, 0xd2, 0x99, 0x74, 0x7e, 0xee, 0x5e, 0x3a, - 0x33, 0x97, 0x9f, 0xbf, 0x97, 0xce, 0x64, 0xf2, 0xd9, 0xf2, 0x77, 0x21, 0xab, 0xe2, 0x7a, 0xd7, - 0x3c, 0xe4, 0x2a, 0xb3, 0x5b, 0x96, 0x4f, 0x38, 0x27, 0xbc, 0xa0, 0x85, 0x99, 0x3d, 0x22, 0x94, - 0x05, 0xac, 0x9d, 0x76, 0x53, 0xe0, 0xe8, 0x33, 0x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, 0x45, 0xfc, + 0xea, 0x70, 0x3b, 0xfe, 0xae, 0x78, 0x3e, 0x13, 0x0c, 0x7d, 0x78, 0x82, 0x4c, 0xc5, 0x34, 0x87, + 0x95, 0x18, 0x37, 0xdc, 0x5e, 0xbf, 0x78, 0x9a, 0xe2, 0xe1, 0x76, 0xf5, 0x29, 0xf5, 0x49, 0xa0, + 0x6b, 0xfd, 0x6c, 0x8f, 0xf5, 0x98, 0xfa, 0xac, 0xca, 0xaf, 0x90, 0xba, 0xd9, 0x63, 0xac, 0x67, + 0x93, 0xaa, 0x1a, 0x75, 0x07, 0x07, 0x55, 0x41, 0x1d, 0xc2, 0x05, 0x76, 0xbc, 0x10, 0x50, 0x3c, + 0x0a, 0xb0, 0x06, 0x3e, 0x16, 0x94, 0xb9, 0x91, 0x02, 0xda, 0x35, 0xab, 0x26, 0xf3, 0x49, 0xd5, + 0xb4, 0x29, 0x71, 0x85, 0x9c, 0x35, 0xf8, 0x0a, 0x01, 0x55, 0x09, 0xb0, 0x69, 0xaf, 0x2f, 0x02, + 0x32, 0xaf, 0x0a, 0xe2, 0x5a, 0xc4, 0x77, 0x68, 0x00, 0x1e, 0x8f, 0x42, 0x81, 0x8d, 0x04, 0xdf, + 0xf4, 0x47, 0x9e, 0x60, 0xd5, 0x43, 0x32, 0xe2, 0x21, 0xf7, 0x92, 0xc9, 0xb8, 0xc3, 0x78, 0x95, + 0xc8, 0xf5, 0xbb, 0x26, 0xa9, 0x0e, 0xb7, 0xbb, 0x44, 0xe0, 0xed, 0x98, 0x10, 0xd9, 0x1d, 0xe2, + 0xba, 0x98, 0x8f, 0x31, 0x26, 0xa3, 0x91, 0xdd, 0x6b, 0x01, 0xdf, 0x08, 0x76, 0x24, 0x18, 0x84, + 0xac, 0x55, 0xec, 0x50, 0x97, 0x55, 0xd5, 0xdf, 0x80, 0x54, 0xfe, 0x6f, 0x06, 0x0a, 0x35, 0xe6, + 0xf2, 0x81, 0x43, 0xfc, 0x5d, 0xcb, 0xa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x4a, 0x99, 0x3f, + 0x75, 0x30, 0x49, 0x31, 0x55, 0x36, 0x6f, 0xc0, 0x6a, 0x5c, 0x36, 0x62, 0xe7, 0x56, 0xab, 0xbd, + 0x79, 0xe6, 0xf9, 0x37, 0x9b, 0x2b, 0x51, 0x20, 0xd5, 0x94, 0xa3, 0xd7, 0xf5, 0x15, 0x73, 0x82, + 0x60, 0xa1, 0x22, 0xe4, 0x68, 0xd7, 0x34, 0x38, 0x79, 0x62, 0xb8, 0x03, 0x47, 0xc5, 0x45, 0x5a, + 0xcf, 0xd2, 0xae, 0xd9, 0x26, 0x4f, 0xf6, 0x06, 0x0e, 0xfa, 0x18, 0xce, 0x45, 0xcd, 0xa4, 0xf4, + 0x24, 0x43, 0xca, 0xcb, 0xed, 0xf2, 0x55, 0xa8, 0x2c, 0xea, 0x67, 0x22, 0xee, 0x3e, 0xb6, 0xe5, + 0x64, 0xbb, 0x96, 0xe5, 0x97, 0xff, 0x33, 0x07, 0xf3, 0x2d, 0xec, 0x63, 0x87, 0xa3, 0x0e, 0xac, + 0x08, 0xe2, 0x78, 0x36, 0x16, 0xc4, 0x08, 0x5a, 0x92, 0x70, 0xa5, 0x57, 0x54, 0xab, 0x92, 0x6c, + 0xfc, 0x2a, 0x89, 0x56, 0x6f, 0xb8, 0x5d, 0xa9, 0x29, 0x6a, 0x5b, 0x60, 0x41, 0xf4, 0xe5, 0x48, + 0x47, 0x40, 0x44, 0xd7, 0xa0, 0x20, 0xfc, 0x01, 0x17, 0xe3, 0x66, 0x61, 0x5c, 0x25, 0x83, 0xb3, + 0x3e, 0x17, 0xf1, 0x83, 0xfa, 0x1a, 0x57, 0xc7, 0x93, 0xfb, 0x82, 0xd4, 0x9b, 0xf4, 0x05, 0x16, + 0x6c, 0x70, 0x79, 0xa8, 0x86, 0x43, 0x84, 0xaa, 0xde, 0x9e, 0x4d, 0x5c, 0xca, 0xfb, 0x91, 0xf2, + 0xf9, 0xe9, 0x95, 0xaf, 0x29, 0x45, 0x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, 0x51, 0xee, 0x11, 0xba, 0x0e, 0xe0, 0xf9, 0x64, 0x68, 0x98, 0xc6, 0x21, 0x19, + 0xa9, 0xf5, 0xe4, 0x76, 0x36, 0x92, 0x09, 0x31, 0xb8, 0xe9, 0x56, 0x5a, 0x83, 0xae, 0x4d, 0xcd, + 0x7b, 0x64, 0xa4, 0x67, 0x24, 0xbe, 0x76, 0x8f, 0x8c, 0x64, 0x05, 0x54, 0xcd, 0x89, 0xca, 0x62, + 0x29, 0x3d, 0x18, 0x94, 0x7f, 0xad, 0xc1, 0xf9, 0x78, 0x01, 0xd1, 0x59, 0xb5, 0x06, 0x5d, 0x29, + 0x91, 0xdc, 0x3b, 0x6d, 0xb2, 0x13, 0x3a, 0x66, 0xed, 0xec, 0x09, 0xd6, 0xde, 0x80, 0xc5, 0x38, + 0x8d, 0x48, 0x7b, 0x53, 0x53, 0xd8, 0x9b, 0x8b, 0x24, 0xee, 0x91, 0x51, 0xf9, 0x67, 0x09, 0xdb, + 0x6e, 0x8e, 0x12, 0xee, 0xeb, 0xbf, 0xc2, 0xb6, 0x78, 0xda, 0xa4, 0x6d, 0x66, 0x52, 0xfe, 0xd8, + 0x02, 0x52, 0xc7, 0x17, 0x50, 0xfe, 0x9b, 0x06, 0xe7, 0x92, 0xb3, 0xf2, 0x0e, 0x6b, 0xf9, 0x03, + 0x97, 0xec, 0xef, 0xbc, 0x6c, 0xfe, 0x1b, 0x90, 0xf1, 0x24, 0xca, 0x10, 0x3c, 0x3c, 0xa2, 0xe9, + 0xca, 0xf5, 0x82, 0x92, 0xea, 0xc8, 0xf0, 0x5e, 0x9e, 0x58, 0x00, 0x0f, 0x77, 0xee, 0xa3, 0xa9, + 0x02, 0x2e, 0x11, 0x4c, 0xfa, 0x52, 0x72, 0xcd, 0xbc, 0xfc, 0x27, 0x0d, 0xd0, 0xf1, 0x4c, 0x85, + 0xbe, 0x07, 0x68, 0x22, 0xdf, 0x25, 0xfd, 0x2f, 0xef, 0x25, 0x32, 0x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b, 0x9d, 0x87, 0xad, 0x56, 0xa3, 0x9e, 0x4f, 0x9f, 0xc0, 0xab, 0x37, 0xee, 0x37, 0x3a, + 0x8d, 0x7a, 0x7e, 0x6e, 0x3d, 0xfd, 0xd9, 0x6f, 0x8b, 0x33, 0x37, 0x3f, 0xfd, 0xea, 0x79, 0x51, + 0xfb, 0xfa, 0x79, 0x51, 0xfb, 0xe7, 0xf3, 0xa2, 0xf6, 0xf9, 0x8b, 0xe2, 0xcc, 0xd7, 0x2f, 0x8a, + 0x33, 0xff, 0x78, 0x51, 0x9c, 0x79, 0xfc, 0xc9, 0xf1, 0x4c, 0x3e, 0xae, 0x94, 0x57, 0xe3, 0x5f, + 0x33, 0x86, 0xdf, 0xaf, 0x3e, 0x9b, 0xfc, 0xad, 0x44, 0x25, 0xf9, 0xee, 0xbc, 0x0a, 0xd2, 0x8f, + 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0x79, 0x8b, 0xb8, 0x2d, 0x5c, 0x19, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 7ef6796493..6ef50117a7 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -128,7 +128,7 @@ func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisSt type QueryConsumerChainsRequest struct { // The phase of the consumer chains returned (optional) - // All=0|Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 + // Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5 Phase ConsumerPhase `protobuf:"varint,1,opt,name=phase,proto3,enum=interchain_security.ccv.provider.v1.ConsumerPhase" json:"phase,omitempty"` // The limit of consumer chains returned (optional) // default is 100 @@ -172,7 +172,7 @@ func (m *QueryConsumerChainsRequest) GetPhase() ConsumerPhase { if m != nil { return m.Phase } - return ConsumerPhase_CONSUMER_PHASE_UNSPECIFIED + return CONSUMER_PHASE_UNSPECIFIED } func (m *QueryConsumerChainsRequest) GetLimit() int32 { @@ -243,7 +243,7 @@ type Chain struct { Allowlist []string `protobuf:"bytes,7,rep,name=allowlist,proto3" json:"allowlist,omitempty"` // Corresponds to a list of provider consensus addresses of validators that CANNOT validate the consumer chain. Denylist []string `protobuf:"bytes,8,rep,name=denylist,proto3" json:"denylist,omitempty"` - // The phase the consumer chain (Registered=1|Initialized=2|Launched=3|Stopped=4|Deleted=5) + // The phase the consumer chain Phase string `protobuf:"bytes,9,opt,name=phase,proto3" json:"phase,omitempty"` // The metadata of the consumer chain Metadata ConsumerMetadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata"` From 6dc36bc5cdf2686c12b670e81c2cfc25dc7ec297 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 5 Sep 2024 13:08:03 +0200 Subject: [PATCH 36/43] refactor: stop using signer field in messages (#2219) * remove error check * stop using signer field in messages * expand TODO comment * replace signer with submitter * fix UTs --- .../ccv/provider/v1/tx.proto | 45 +- tests/e2e/actions.go | 6 +- testutil/keeper/unit_test_helpers.go | 2 +- x/ccv/provider/client/cli/tx.go | 4 - x/ccv/provider/keeper/msg_server.go | 10 +- x/ccv/provider/keeper/msg_server_test.go | 18 +- x/ccv/provider/keeper/relay.go | 4 +- x/ccv/provider/types/msg.go | 36 +- x/ccv/provider/types/msg_test.go | 12 +- x/ccv/provider/types/tx.pb.go | 404 +++++++++--------- 10 files changed, 269 insertions(+), 272 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 8f2d7b5c1c..d4f4eace11 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -44,7 +44,7 @@ service Msg { message MsgAssignConsumerKey { - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "submitter"; option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -58,8 +58,7 @@ message MsgAssignConsumerKey { // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` string consumer_key = 3; - // Tx signer address - string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string submitter = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to assign a consensus public key to string consumer_id = 5; @@ -109,7 +108,7 @@ message MsgSubmitConsumerDoubleVotingResponse {} message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; - // signer is the address of the governance account. + // authority is the address of the governance account. string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the x/provider parameters to update. @@ -224,11 +223,12 @@ message MsgConsumerRemovalResponse {} // MsgRemoveConsumer defines the message used to remove (and stop) a consumer chain. // If it passes, all the consumer chain's state is eventually removed from the provider chain. message MsgRemoveConsumer { - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "owner"; // the consumer id of the consumer chain to be stopped string consumer_id = 1; - string signer = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // the address of the owner of the consumer chain to be stopped + string owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } // MsgRemoveConsumerResponse defines response type for MsgRemoveConsumer messages @@ -245,7 +245,7 @@ message MsgChangeRewardDenoms { repeated string denoms_to_add = 1; // the list of consumer reward denoms to remove repeated string denoms_to_remove = 2; - // signer address + // authority is the address of the governance account string authority = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } @@ -256,7 +256,7 @@ message MsgChangeRewardDenomsResponse {} message MsgOptIn { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "submitter"; // [DEPRECATED] use `consumer_id` instead string chain_id = 1 [deprecated = true]; // the validator address on the provider @@ -266,8 +266,8 @@ message MsgOptIn { // This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the // consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. string consumer_key = 3; - // signer address - string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // submitter address + string submitter = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to opt in to string consumer_id = 5; } @@ -277,13 +277,13 @@ message MsgOptInResponse {} message MsgOptOut { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "submitter"; // [DEPRECATED] use `consumer_id` instead string chain_id = 1 [deprecated = true]; // the validator address on the provider string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; - // signer address - string signer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // submitter address + string submitter = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to opt out from string consumer_id = 4; } @@ -295,7 +295,7 @@ message MsgOptOutResponse {} message MsgSetConsumerCommissionRate { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "submitter"; // The validator address on the provider string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; @@ -308,8 +308,8 @@ message MsgSetConsumerCommissionRate { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // signer address - string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // submitter address + string submitter = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to set the commission rate string consumer_id = 5; } @@ -358,10 +358,11 @@ message MsgConsumerModificationResponse {} // MsgCreateConsumer defines the message that creates a consumer chain message MsgCreateConsumer { - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "submitter"; - // signer address - string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // Submitter address. If the message is successfully handled, the ownership of + // the consumer chain will given to this address. + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the chain id of the new consumer chain string chain_id = 2; @@ -380,10 +381,10 @@ message MsgCreateConsumerResponse { // MsgUpdateConsumer defines the message used to modify a consumer chain. message MsgUpdateConsumer { - option (cosmos.msg.v1.signer) = "signer"; + option (cosmos.msg.v1.signer) = "owner"; - // signer address - string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // the address of the owner of the consumer chain to be updated + string owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // the consumer id of the consumer chain to be updated string consumer_id = 2; diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index b1356814eb..18f1c6de4a 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -591,7 +591,7 @@ func (tr Chain) submitConsumerAdditionProposal( // - set PowerShaping params TopN > 0 for consumer chain update.PowerShapingParameters.Top_N = action.TopN - update.Signer = authority + update.Owner = authority update.NewOwnerAddress = "" update.InitializationParameters = &initializationParameters update.InitializationParameters.SpawnTime = spawnTime @@ -761,7 +761,7 @@ func (tr Chain) submitConsumerRemovalProposal( msg := types.MsgRemoveConsumer{ ConsumerId: consumerId, - Signer: authority, + Owner: authority, } jsonStr := e2e.GenerateGovProposalContent(title, summary, metadata, deposit, description, expedited, &msg) @@ -881,7 +881,7 @@ func (tr Chain) submitConsumerModificationProposal( authority := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" msg := types.MsgUpdateConsumer{ - Signer: authority, + Owner: authority, ConsumerId: consumerId, PowerShapingParameters: &types.PowerShapingParameters{ Top_N: action.TopN, diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index a35670d955..1c11c2c7e9 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -317,7 +317,7 @@ func GetTestPowerShapingParameters() providertypes.PowerShapingParameters { func GetTestMsgUpdateConsumer() providertypes.MsgUpdateConsumer { return providertypes.MsgUpdateConsumer{ - Signer: "signer", + Owner: "owner", ConsumerId: "consumerId", NewOwnerAddress: "newOwnerAddress", } diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 03080fc8b3..d8fe3f973c 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -424,10 +424,6 @@ Example: signer := clientCtx.GetFromAddress().String() consumerId := args[0] - if err != nil { - return err - } - msg, err := types.NewMsgRemoveConsumer(signer, consumerId) if err != nil { return err diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 088be381e4..bf4d7c93d5 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -289,7 +289,7 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon consumerId := k.Keeper.FetchAndIncrementConsumerId(ctx) - k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Signer) + k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Submitter) k.Keeper.SetConsumerChainId(ctx, consumerId, msg.ChainId) k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_REGISTERED) @@ -360,8 +360,8 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) } - if msg.Signer != ownerAddress { - return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + if msg.Owner != ownerAddress { + return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Owner) } // The new owner address can be empty, in which case the consumer chain does not change its owner. @@ -463,8 +463,8 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) } - if msg.Signer != ownerAddress { - return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Signer) + if msg.Owner != ownerAddress { + return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Owner) } phase := k.Keeper.GetConsumerPhase(ctx, consumerId) diff --git a/x/ccv/provider/keeper/msg_server_test.go b/x/ccv/provider/keeper/msg_server_test.go index 994c4a6fd0..66ddaefff9 100644 --- a/x/ccv/provider/keeper/msg_server_test.go +++ b/x/ccv/provider/keeper/msg_server_test.go @@ -22,7 +22,7 @@ func TestCreateConsumer(t *testing.T) { Description: "description", } response, err := msgServer.CreateConsumer(ctx, - &providertypes.MsgCreateConsumer{Signer: "signer", ChainId: "chainId", Metadata: consumerMetadata, + &providertypes.MsgCreateConsumer{Submitter: "submitter", ChainId: "chainId", Metadata: consumerMetadata, InitializationParameters: &providertypes.ConsumerInitializationParameters{}, PowerShapingParameters: &providertypes.PowerShapingParameters{}}) require.NoError(t, err) @@ -32,7 +32,7 @@ func TestCreateConsumer(t *testing.T) { require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err := providerKeeper.GetConsumerOwnerAddress(ctx, "0") require.NoError(t, err) - require.Equal(t, "signer", ownerAddress) + require.Equal(t, "submitter", ownerAddress) phase := providerKeeper.GetConsumerPhase(ctx, "0") require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) @@ -41,7 +41,7 @@ func TestCreateConsumer(t *testing.T) { Description: "description2", } response, err = msgServer.CreateConsumer(ctx, - &providertypes.MsgCreateConsumer{Signer: "signer2", ChainId: "chainId", Metadata: consumerMetadata, + &providertypes.MsgCreateConsumer{Submitter: "submitter2", ChainId: "chainId", Metadata: consumerMetadata, InitializationParameters: &providertypes.ConsumerInitializationParameters{}, PowerShapingParameters: &providertypes.PowerShapingParameters{}}) require.NoError(t, err) @@ -52,7 +52,7 @@ func TestCreateConsumer(t *testing.T) { require.Equal(t, consumerMetadata, actualMetadata) ownerAddress, err = providerKeeper.GetConsumerOwnerAddress(ctx, "1") require.NoError(t, err) - require.Equal(t, "signer2", ownerAddress) + require.Equal(t, "submitter2", ownerAddress) phase = providerKeeper.GetConsumerPhase(ctx, "1") require.Equal(t, providertypes.CONSUMER_PHASE_REGISTERED, phase) } @@ -65,7 +65,7 @@ func TestUpdateConsumer(t *testing.T) { // try to update a non-existing (i.e., no consumer id exists) _, err := msgServer.UpdateConsumer(ctx, - &providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: "0", NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + &providertypes.MsgUpdateConsumer{Owner: "owner", ConsumerId: "0", NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", Metadata: nil, InitializationParameters: nil, PowerShapingParameters: nil, @@ -74,7 +74,7 @@ func TestUpdateConsumer(t *testing.T) { // create a chain before updating it createConsumerResponse, err := msgServer.CreateConsumer(ctx, - &providertypes.MsgCreateConsumer{Signer: "signer", ChainId: "chainId", + &providertypes.MsgCreateConsumer{Submitter: "submitter", ChainId: "chainId", Metadata: providertypes.ConsumerMetadata{ Name: "name", Description: "description", @@ -88,7 +88,7 @@ func TestUpdateConsumer(t *testing.T) { mocks.MockAccountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() _, err = msgServer.UpdateConsumer(ctx, - &providertypes.MsgUpdateConsumer{Signer: "wrong signer", ConsumerId: consumerId, NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + &providertypes.MsgUpdateConsumer{Owner: "wrong owner", ConsumerId: consumerId, NewOwnerAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", Metadata: nil, InitializationParameters: nil, PowerShapingParameters: nil, @@ -106,7 +106,7 @@ func TestUpdateConsumer(t *testing.T) { expectedOwnerAddress := "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la" _, err = msgServer.UpdateConsumer(ctx, - &providertypes.MsgUpdateConsumer{Signer: "signer", ConsumerId: consumerId, NewOwnerAddress: expectedOwnerAddress, + &providertypes.MsgUpdateConsumer{Owner: "submitter", ConsumerId: consumerId, NewOwnerAddress: expectedOwnerAddress, Metadata: &expectedConsumerMetadata, InitializationParameters: &expectedInitializationParameters, PowerShapingParameters: &expectedPowerShapingParameters}) @@ -148,7 +148,7 @@ func TestUpdateConsumer(t *testing.T) { updatedSpawnTime := expectedInitializationParameters.SpawnTime.Add(time.Hour) expectedInitializationParameters.SpawnTime = updatedSpawnTime _, err = msgServer.UpdateConsumer(ctx, - &providertypes.MsgUpdateConsumer{Signer: expectedOwnerAddress, ConsumerId: consumerId, + &providertypes.MsgUpdateConsumer{Owner: expectedOwnerAddress, ConsumerId: consumerId, Metadata: &expectedConsumerMetadata, InitializationParameters: &expectedInitializationParameters, PowerShapingParameters: &expectedPowerShapingParameters}) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 5abb074c22..8fc0c08500 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -140,7 +140,7 @@ func (k Keeper) BlocksUntilNextEpoch(ctx sdk.Context) int64 { // If the CCV channel is not established for a consumer chain, // the updates will remain queued until the channel is established // -// TODO (mpoke): iterate only over consumers with established channel +// TODO (mpoke): iterate only over consumers with established channel -- GetAllChannelToConsumers func (k Keeper) SendVSCPackets(ctx sdk.Context) error { for _, consumerId := range k.GetAllConsumersWithIBCClients(ctx) { if k.GetConsumerPhase(ctx, consumerId) != providertypes.CONSUMER_PHASE_LAUNCHED { @@ -202,7 +202,7 @@ func (k Keeper) SendVSCPacketsToChain(ctx sdk.Context, consumerId, channelId str // QueueVSCPackets queues latest validator updates for every consumer chain // with the IBC client created. // -// TODO (mpoke): iterate only over consumers with established channel +// TODO (mpoke): iterate only over consumers with established channel -- GetAllChannelToConsumers func (k Keeper) QueueVSCPackets(ctx sdk.Context) error { valUpdateID := k.GetValidatorSetUpdateId(ctx) // current valset update ID diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 07fdb18b04..66517ca773 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -60,13 +60,13 @@ var ( // NewMsgAssignConsumerKey creates a new MsgAssignConsumerKey instance. // Delegator address and validator address are the same. func NewMsgAssignConsumerKey(consumerId string, providerValidatorAddress sdk.ValAddress, - consumerConsensusPubKey, signer string, + consumerConsensusPubKey, submitter string, ) (*MsgAssignConsumerKey, error) { return &MsgAssignConsumerKey{ ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, - Signer: signer, + Submitter: submitter, }, nil } @@ -80,7 +80,7 @@ func (msg MsgAssignConsumerKey) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ConsumerId: %s", err.Error()) } - if err := validateProviderAddress(msg.ProviderAddr, msg.Signer); err != nil { + if err := validateProviderAddress(msg.ProviderAddr, msg.Submitter); err != nil { return errorsmod.Wrapf(ErrInvalidMsgAssignConsumerKey, "ProviderAddr: %s", err.Error()) } @@ -186,12 +186,12 @@ func (msg MsgSubmitConsumerDoubleVoting) ValidateBasic() error { } // NewMsgOptIn creates a new NewMsgOptIn instance. -func NewMsgOptIn(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, signer string) (*MsgOptIn, error) { +func NewMsgOptIn(consumerId string, providerValidatorAddress sdk.ValAddress, consumerConsensusPubKey, submitter string) (*MsgOptIn, error) { return &MsgOptIn{ ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), ConsumerKey: consumerConsensusPubKey, - Signer: signer, + Submitter: submitter, }, nil } @@ -205,7 +205,7 @@ func (msg MsgOptIn) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ConsumerId: %s", err.Error()) } - if err := validateProviderAddress(msg.ProviderAddr, msg.Signer); err != nil { + if err := validateProviderAddress(msg.ProviderAddr, msg.Submitter); err != nil { return errorsmod.Wrapf(ErrInvalidMsgOptIn, "ProviderAddr: %s", err.Error()) } @@ -218,11 +218,11 @@ func (msg MsgOptIn) ValidateBasic() error { } // NewMsgOptOut creates a new NewMsgOptIn instance. -func NewMsgOptOut(consumerId string, providerValidatorAddress sdk.ValAddress, signer string) (*MsgOptOut, error) { +func NewMsgOptOut(consumerId string, providerValidatorAddress sdk.ValAddress, submitter string) (*MsgOptOut, error) { return &MsgOptOut{ ConsumerId: consumerId, ProviderAddr: providerValidatorAddress.String(), - Signer: signer, + Submitter: submitter, }, nil } @@ -236,7 +236,7 @@ func (msg MsgOptOut) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMsgOptOut, "ConsumerId: %s", err.Error()) } - if err := validateProviderAddress(msg.ProviderAddr, msg.Signer); err != nil { + if err := validateProviderAddress(msg.ProviderAddr, msg.Submitter); err != nil { return errorsmod.Wrapf(ErrInvalidMsgOptOut, "ProviderAddr: %s", err.Error()) } @@ -248,13 +248,13 @@ func NewMsgSetConsumerCommissionRate( consumerId string, commission math.LegacyDec, providerValidatorAddress sdk.ValAddress, - signer string, + submitter string, ) *MsgSetConsumerCommissionRate { return &MsgSetConsumerCommissionRate{ ConsumerId: consumerId, Rate: commission, ProviderAddr: providerValidatorAddress.String(), - Signer: signer, + Submitter: submitter, } } @@ -268,7 +268,7 @@ func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "ConsumerId: %s", err.Error()) } - if err := validateProviderAddress(msg.ProviderAddr, msg.Signer); err != nil { + if err := validateProviderAddress(msg.ProviderAddr, msg.Submitter); err != nil { return errorsmod.Wrapf(ErrInvalidMsgSetConsumerCommissionRate, "ProviderAddr: %s", err.Error()) } @@ -280,10 +280,10 @@ func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { } // NewMsgCreateConsumer creates a new MsgCreateConsumer instance -func NewMsgCreateConsumer(signer string, chainId string, metadata ConsumerMetadata, +func NewMsgCreateConsumer(submitter string, chainId string, metadata ConsumerMetadata, initializationParameters *ConsumerInitializationParameters, powerShapingParameters *PowerShapingParameters) (*MsgCreateConsumer, error) { return &MsgCreateConsumer{ - Signer: signer, + Submitter: submitter, ChainId: chainId, Metadata: metadata, InitializationParameters: initializationParameters, @@ -321,10 +321,10 @@ func (msg MsgCreateConsumer) ValidateBasic() error { } // NewMsgUpdateConsumer creates a new MsgUpdateConsumer instance -func NewMsgUpdateConsumer(signer string, consumerId string, ownerAddress string, metadata *ConsumerMetadata, +func NewMsgUpdateConsumer(owner string, consumerId string, ownerAddress string, metadata *ConsumerMetadata, initializationParameters *ConsumerInitializationParameters, powerShapingParameters *PowerShapingParameters) (*MsgUpdateConsumer, error) { return &MsgUpdateConsumer{ - Signer: signer, + Owner: owner, ConsumerId: consumerId, NewOwnerAddress: ownerAddress, Metadata: metadata, @@ -363,9 +363,9 @@ func (msg MsgUpdateConsumer) ValidateBasic() error { } // NewMsgRemoveConsumer creates a new MsgRemoveConsumer instance -func NewMsgRemoveConsumer(signer string, consumerId string) (*MsgRemoveConsumer, error) { +func NewMsgRemoveConsumer(owner string, consumerId string) (*MsgRemoveConsumer, error) { return &MsgRemoveConsumer{ - Signer: signer, + Owner: owner, ConsumerId: consumerId, }, nil } diff --git a/x/ccv/provider/types/msg_test.go b/x/ccv/provider/types/msg_test.go index e7c8ebb85d..72e4712f59 100644 --- a/x/ccv/provider/types/msg_test.go +++ b/x/ccv/provider/types/msg_test.go @@ -456,7 +456,7 @@ func TestMsgAssignConsumerKeyValidateBasic(t *testing.T) { name string chainId string providerAddr string - signer string + submitter string consumerKey string consumerId string expErr bool @@ -488,24 +488,24 @@ func TestMsgAssignConsumerKeyValidateBasic(t *testing.T) { expErr: true, }, { - name: "invalid: provider address != signer address", + name: "invalid: provider address != submitter address", consumerId: "1", providerAddr: valOpAddr1.String(), - signer: acc2, + submitter: acc2, expErr: true, }, { name: "invalid: consumer pubkey empty", consumerId: "1", providerAddr: valOpAddr1.String(), - signer: acc1, + submitter: acc1, expErr: true, }, { name: "valid", consumerId: "1", providerAddr: valOpAddr1.String(), - signer: acc1, + submitter: acc1, consumerKey: "{\"@type\": \"/cosmos.crypto.ed25519.PubKey\", \"key\": \"e3BehnEIlGUAnJYn9V8gBXuMh4tXO8xxlxyXD1APGyk=\"}", expErr: false, }, @@ -518,7 +518,7 @@ func TestMsgAssignConsumerKeyValidateBasic(t *testing.T) { ChainId: tc.chainId, ConsumerKey: tc.consumerKey, ProviderAddr: tc.providerAddr, - Signer: tc.signer, + Submitter: tc.submitter, ConsumerId: tc.consumerId, } diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index a656dd8f7d..999fffef8a 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -51,8 +51,7 @@ type MsgAssignConsumerKey struct { // in json string format corresponding to proto-any, ex: // `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}` ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` - // Tx signer address - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + Submitter string `protobuf:"bytes,4,opt,name=submitter,proto3" json:"submitter,omitempty"` // the consumer id of the consumer chain to assign a consensus public key to ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } @@ -290,7 +289,7 @@ var xxx_messageInfo_MsgSubmitConsumerDoubleVotingResponse proto.InternalMessageI // MsgUpdateParams is the Msg/UpdateParams request type type MsgUpdateParams struct { - // signer is the address of the governance account. + // authority is the address of the governance account. Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` // params defines the x/provider parameters to update. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` @@ -771,7 +770,8 @@ var xxx_messageInfo_MsgConsumerRemovalResponse proto.InternalMessageInfo type MsgRemoveConsumer struct { // the consumer id of the consumer chain to be stopped ConsumerId string `protobuf:"bytes,1,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` - Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + // the address of the owner of the consumer chain to be stopped + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` } func (m *MsgRemoveConsumer) Reset() { *m = MsgRemoveConsumer{} } @@ -814,9 +814,9 @@ func (m *MsgRemoveConsumer) GetConsumerId() string { return "" } -func (m *MsgRemoveConsumer) GetSigner() string { +func (m *MsgRemoveConsumer) GetOwner() string { if m != nil { - return m.Signer + return m.Owner } return "" } @@ -867,7 +867,7 @@ type MsgChangeRewardDenoms struct { DenomsToAdd []string `protobuf:"bytes,1,rep,name=denoms_to_add,json=denomsToAdd,proto3" json:"denoms_to_add,omitempty"` // the list of consumer reward denoms to remove DenomsToRemove []string `protobuf:"bytes,2,rep,name=denoms_to_remove,json=denomsToRemove,proto3" json:"denoms_to_remove,omitempty"` - // signer address + // authority is the address of the governance account Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"` } @@ -972,8 +972,8 @@ type MsgOptIn struct { // This field is optional and can remain empty (i.e., `consumer_key = ""`). A validator can always change the // consumer public key at a later stage by issuing a `MsgAssignConsumerKey` message. ConsumerKey string `protobuf:"bytes,3,opt,name=consumer_key,json=consumerKey,proto3" json:"consumer_key,omitempty"` - // signer address - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // submitter address + Submitter string `protobuf:"bytes,4,opt,name=submitter,proto3" json:"submitter,omitempty"` // the consumer id of the consumer chain to opt in to ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } @@ -1052,8 +1052,8 @@ type MsgOptOut struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` // Deprecated: Do not use. // the validator address on the provider ProviderAddr string `protobuf:"bytes,2,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` + // submitter address + Submitter string `protobuf:"bytes,3,opt,name=submitter,proto3" json:"submitter,omitempty"` // the consumer id of the consumer chain to opt out from ConsumerId string `protobuf:"bytes,4,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } @@ -1137,8 +1137,8 @@ type MsgSetConsumerCommissionRate struct { // The rate to charge delegators on the consumer chain, as a fraction // TODO: migrate rate from sdk.Dec to math.LegacyDec Rate cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"rate"` - // signer address - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // submitter address + Submitter string `protobuf:"bytes,4,opt,name=submitter,proto3" json:"submitter,omitempty"` // the consumer id of the consumer chain to set the commission rate ConsumerId string `protobuf:"bytes,5,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` } @@ -1395,8 +1395,9 @@ var xxx_messageInfo_MsgConsumerModificationResponse proto.InternalMessageInfo // MsgCreateConsumer defines the message that creates a consumer chain type MsgCreateConsumer struct { - // signer address - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // Submitter address. If the message is successfully handled, the ownership of + // the consumer chain will given to this address. + Submitter string `protobuf:"bytes,1,opt,name=submitter,proto3" json:"submitter,omitempty"` // the chain id of the new consumer chain ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Metadata ConsumerMetadata `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata"` @@ -1437,9 +1438,9 @@ func (m *MsgCreateConsumer) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateConsumer proto.InternalMessageInfo -func (m *MsgCreateConsumer) GetSigner() string { +func (m *MsgCreateConsumer) GetSubmitter() string { if m != nil { - return m.Signer + return m.Submitter } return "" } @@ -1519,8 +1520,8 @@ func (m *MsgCreateConsumerResponse) GetConsumerId() string { // MsgUpdateConsumer defines the message used to modify a consumer chain. type MsgUpdateConsumer struct { - // signer address - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // the address of the owner of the consumer chain to be updated + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` // the consumer id of the consumer chain to be updated ConsumerId string `protobuf:"bytes,2,opt,name=consumer_id,json=consumerId,proto3" json:"consumer_id,omitempty"` // the new owner of the consumer when updated @@ -1566,9 +1567,9 @@ func (m *MsgUpdateConsumer) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateConsumer proto.InternalMessageInfo -func (m *MsgUpdateConsumer) GetSigner() string { +func (m *MsgUpdateConsumer) GetOwner() string { if m != nil { - return m.Signer + return m.Owner } return "" } @@ -1681,138 +1682,137 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 2081 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0x4d, 0x70, 0x1c, 0x47, - 0x15, 0xd6, 0xec, 0xae, 0xe4, 0xdd, 0x5e, 0x59, 0x3f, 0x2d, 0x39, 0x1a, 0xad, 0x6d, 0xad, 0x2c, - 0x42, 0xa2, 0x32, 0xd1, 0x6c, 0x2c, 0xb0, 0x03, 0xc2, 0xfc, 0xe8, 0xc7, 0x60, 0x05, 0x64, 0x29, - 0x23, 0xe3, 0x54, 0x41, 0x15, 0x53, 0xbd, 0x33, 0xed, 0xd9, 0x2e, 0xef, 0x4c, 0x4f, 0x4d, 0xf7, - 0xae, 0x22, 0x4e, 0x54, 0x4e, 0x3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x00, - 0x00, + // 2075 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x59, 0xcb, 0x6f, 0x1c, 0x49, + 0x19, 0x77, 0xcf, 0x8c, 0xbd, 0x33, 0xe5, 0x77, 0xdb, 0x59, 0xb7, 0x27, 0x89, 0xc7, 0x31, 0xcb, + 0xae, 0x15, 0xd6, 0x3d, 0xc4, 0x90, 0x5d, 0x30, 0xe1, 0xe1, 0x47, 0x20, 0x5e, 0x70, 0xec, 0x6d, + 0x87, 0xac, 0x04, 0x12, 0xad, 0x9a, 0xee, 0x4a, 0x4f, 0x29, 0xdd, 0x5d, 0xad, 0xae, 0x9a, 0xf1, + 0x9a, 0x13, 0x8a, 0x84, 0x94, 0x63, 0xd0, 0x72, 0xe0, 0xc6, 0x1e, 0xb8, 0x20, 0x01, 0xda, 0xc3, + 0x9e, 0xf8, 0x0b, 0x56, 0xe2, 0xb2, 0xac, 0x38, 0xa0, 0x3d, 0x04, 0x94, 0x1c, 0x96, 0x33, 0x07, + 0xce, 0xa8, 0x1e, 0xdd, 0x33, 0x3d, 0x33, 0x76, 0x7a, 0xc6, 0x2c, 0x1c, 0xb8, 0x8c, 0xba, 0xeb, + 0xfb, 0x7d, 0xbf, 0xef, 0x51, 0x55, 0xdf, 0x57, 0xd5, 0x03, 0x5e, 0xc7, 0x21, 0x43, 0xb1, 0xd3, + 0x84, 0x38, 0xb4, 0x29, 0x72, 0x5a, 0x31, 0x66, 0xa7, 0x75, 0xc7, 0x69, 0xd7, 0xa3, 0x98, 0xb4, + 0xb1, 0x8b, 0xe2, 0x7a, 0xfb, 0x46, 0x9d, 0xbd, 0x6b, 0x46, 0x31, 0x61, 0x44, 0xff, 0xc2, 0x00, + 0xb4, 0xe9, 0x38, 0x6d, 0x33, 0x41, 0x9b, 0xed, 0x1b, 0xd5, 0x79, 0x18, 0xe0, 0x90, 0xd4, 0xc5, + 0xaf, 0x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0xf7, 0x52, 0xc2, 0x91, 0x25, 0xbf, 0x03, 0x56, + 0xd3, 0x8d, 0x12, 0x23, 0x17, 0x53, 0x16, 0xe3, 0x46, 0x4b, 0xec, 0xca, 0x64, 0x5f, 0x19, 0x15, + 0xb1, 0x08, 0x56, 0x12, 0x9c, 0x95, 0x81, 0x7d, 0x57, 0xa1, 0xf4, 0x43, 0xf0, 0x8a, 0xd8, 0xc7, + 0x94, 0x3b, 0x67, 0x67, 0x98, 0x84, 0xe9, 0x00, 0x53, 0xca, 0xd9, 0xc0, 0xaa, 0xb6, 0x5e, 0xb4, + 0xae, 0x49, 0xec, 0x11, 0x8a, 0xf7, 0xba, 0x90, 0xf7, 0xba, 0x80, 0xfa, 0x06, 0xd0, 0x9b, 0x98, + 0x32, 0x12, 0x63, 0x07, 0xfa, 0x36, 0x0a, 0x59, 0x8c, 0x11, 0x35, 0x26, 0x85, 0xfa, 0x7c, 0x47, + 0x72, 0x5b, 0x0a, 0xf4, 0xb7, 0xc0, 0xb5, 0x33, 0x8d, 0xda, 0x4e, 0x13, 0x86, 0x21, 0xf2, 0x8d, + 0x29, 0x11, 0x4a, 0xcd, 0x3d, 0xc3, 0xe6, 0xae, 0x84, 0xe9, 0x0b, 0x60, 0x9c, 0x91, 0xc8, 0xbe, + 0x6b, 0x4c, 0xaf, 0x6a, 0xeb, 0xd3, 0x56, 0x89, 0x91, 0xe8, 0xae, 0xfe, 0x65, 0xb0, 0xd8, 0x86, + 0x3e, 0x76, 0x21, 0x23, 0x31, 0xb5, 0x23, 0x72, 0x82, 0x62, 0xdb, 0x81, 0x91, 0x31, 0x23, 0x30, + 0x7a, 0x47, 0x76, 0xc4, 0x45, 0xbb, 0x30, 0xd2, 0xaf, 0x83, 0xf9, 0x74, 0xd4, 0xa6, 0x88, 0x09, + 0xf8, 0xac, 0x80, 0xcf, 0xa6, 0x82, 0x63, 0xc4, 0x38, 0xf6, 0x0a, 0xa8, 0x40, 0xdf, 0x27, 0x27, + 0x3e, 0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 0xdb, 0x79, 0xe7, 0xa3, + 0x67, 0x2b, 0xda, 0xc7, 0xcf, 0x56, 0xb4, 0xbf, 0x3f, 0x5b, 0xd1, 0x9e, 0x3c, 0x5f, 0x19, 0xfb, + 0xf8, 0xf9, 0xca, 0xd8, 0x5f, 0x9f, 0xaf, 0x8c, 0xfd, 0xe8, 0x9b, 0x1e, 0x66, 0xcd, 0x56, 0xc3, + 0x74, 0x48, 0xa0, 0xfe, 0x88, 0xad, 0x77, 0xac, 0x6e, 0xa4, 0xff, 0xa3, 0xb6, 0x6f, 0xd6, 0xdf, + 0xcd, 0xfe, 0x99, 0x2a, 0xfe, 0x2d, 0x6a, 0x4c, 0x88, 0x6f, 0x76, 0x5f, 0xf9, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x72, 0x99, 0x09, 0x26, 0xc8, 0x1e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2393,10 +2393,10 @@ func (m *MsgAssignConsumerKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) i-- dAtA[i] = 0x22 } @@ -2952,10 +2952,10 @@ func (m *MsgRemoveConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) i-- dAtA[i] = 0x12 } @@ -3090,10 +3090,10 @@ func (m *MsgOptIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) i-- dAtA[i] = 0x22 } @@ -3171,10 +3171,10 @@ func (m *MsgOptOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) i-- dAtA[i] = 0x1a } @@ -3245,10 +3245,10 @@ func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, e i-- dAtA[i] = 0x2a } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) i-- dAtA[i] = 0x22 } @@ -3485,10 +3485,10 @@ func (m *MsgCreateConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Submitter))) i-- dAtA[i] = 0xa } @@ -3595,10 +3595,10 @@ func (m *MsgUpdateConsumer) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintTx(dAtA, i, uint64(len(m.Owner))) i-- dAtA[i] = 0xa } @@ -3657,7 +3657,7 @@ func (m *MsgAssignConsumerKey) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Signer) + l = len(m.Submitter) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -3888,7 +3888,7 @@ func (m *MsgRemoveConsumer) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Signer) + l = len(m.Owner) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -3956,7 +3956,7 @@ func (m *MsgOptIn) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Signer) + l = len(m.Submitter) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -3990,7 +3990,7 @@ func (m *MsgOptOut) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Signer) + l = len(m.Submitter) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -4026,7 +4026,7 @@ func (m *MsgSetConsumerCommissionRate) Size() (n int) { } l = m.Rate.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) + l = len(m.Submitter) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -4113,7 +4113,7 @@ func (m *MsgCreateConsumer) Size() (n int) { } var l int _ = l - l = len(m.Signer) + l = len(m.Submitter) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -4153,7 +4153,7 @@ func (m *MsgUpdateConsumer) Size() (n int) { } var l int _ = l - l = len(m.Signer) + l = len(m.Owner) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -4322,7 +4322,7 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4350,7 +4350,7 @@ func (m *MsgAssignConsumerKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -5975,7 +5975,7 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6003,7 +6003,7 @@ func (m *MsgRemoveConsumer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -6399,7 +6399,7 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6427,7 +6427,7 @@ func (m *MsgOptIn) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -6627,7 +6627,7 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6655,7 +6655,7 @@ func (m *MsgOptOut) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -6889,7 +6889,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6917,7 +6917,7 @@ func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { @@ -7441,7 +7441,7 @@ func (m *MsgCreateConsumer) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7469,7 +7469,7 @@ func (m *MsgCreateConsumer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -7742,7 +7742,7 @@ func (m *MsgUpdateConsumer) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7770,7 +7770,7 @@ func (m *MsgUpdateConsumer) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { From 2278726dc9878c0add940cca1c8dae94919de514 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 5 Sep 2024 17:14:00 +0200 Subject: [PATCH 37/43] chore: update TX CLI help (#2222) * update CLI help * apply review suggestions --- x/ccv/provider/client/cli/tx.go | 44 +++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index d8fe3f973c..1b64678766 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -57,7 +57,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { return err } - signer := clientCtx.GetFromAddress().String() + submitter := clientCtx.GetFromAddress().String() txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) if err != nil { return err @@ -66,7 +66,7 @@ func NewAssignConsumerKeyCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], signer) + msg, err := types.NewMsgAssignConsumerKey(args[0], sdk.ValAddress(providerValAddr), args[1], submitter) if err != nil { return err } @@ -224,7 +224,7 @@ changed by updating the consumer chain. Example: %s tx provider create-consumer [path/to/create_consumer.json] --from node0 --home ../node0 --chain-id $CID -where create_consumer.json content: +where create_consumer.json has the following structure: { "chain_id": "consu", "metadata": { @@ -259,6 +259,9 @@ where create_consumer.json content: } } +Note that both 'chain_id' and 'metadata' are mandatory; +and both 'initialization_parameters' and 'power_shaping_parameters' are optional. +The parameters not provided are set to their zero value. `, version.AppName)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -273,7 +276,7 @@ where create_consumer.json content: } txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - signer := clientCtx.GetFromAddress().String() + submitter := clientCtx.GetFromAddress().String() consCreateJson, err := os.ReadFile(args[0]) if err != nil { @@ -284,7 +287,7 @@ where create_consumer.json content: return fmt.Errorf("consumer data unmarshalling failed: %w", err) } - msg, err := types.NewMsgCreateConsumer(signer, consCreate.ChainId, consCreate.Metadata, consCreate.InitializationParameters, consCreate.PowerShapingParameters) + msg, err := types.NewMsgCreateConsumer(submitter, consCreate.ChainId, consCreate.Metadata, consCreate.InitializationParameters, consCreate.PowerShapingParameters) if err != nil { return err } @@ -312,10 +315,9 @@ func NewUpdateConsumerCmd() *cobra.Command { Note that only the owner of the chain can initialize it. Example: - %s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID - - where consumer-update.json contains parameters for 'power_shaping', 'initialization' and 'metadata': +%s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID +where create_consumer.json has the following structure: { "consumer_id": "0", "new_owner_address": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", @@ -350,6 +352,12 @@ Example: "allow_inactive_vals": false } } + +Note that only 'consumer_id' is mandatory. The others are optional. +Not providing one of them will leave the existing values unchanged. +Providing one of 'metadata', 'initialization_parameters' or 'power_shaping_parameters', +will update all the containing fields. +If one of the fields is missing, it will be set to its zero value. `, version.AppName)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -364,7 +372,7 @@ Example: } txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - signer := clientCtx.GetFromAddress().String() + owner := clientCtx.GetFromAddress().String() consUpdateJson, err := os.ReadFile(args[0]) if err != nil { @@ -380,7 +388,7 @@ Example: return fmt.Errorf("consumer_id can't be empty") } - msg, err := types.NewMsgUpdateConsumer(signer, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters) + msg, err := types.NewMsgUpdateConsumer(owner, consUpdate.ConsumerId, consUpdate.NewOwnerAddress, consUpdate.Metadata, consUpdate.InitializationParameters, consUpdate.PowerShapingParameters) if err != nil { return err } @@ -421,10 +429,10 @@ Example: } txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - signer := clientCtx.GetFromAddress().String() + owner := clientCtx.GetFromAddress().String() consumerId := args[0] - msg, err := types.NewMsgRemoveConsumer(signer, consumerId) + msg, err := types.NewMsgRemoveConsumer(owner, consumerId) if err != nil { return err } @@ -471,8 +479,8 @@ func NewOptInCmd() *cobra.Command { consumerPubKey = "" } - signer := clientCtx.GetFromAddress().String() - msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey, signer) + submitter := clientCtx.GetFromAddress().String() + msg, err := types.NewMsgOptIn(args[0], sdk.ValAddress(providerValAddr), consumerPubKey, submitter) if err != nil { return err } @@ -510,8 +518,8 @@ func NewOptOutCmd() *cobra.Command { providerValAddr := clientCtx.GetFromAddress() - signer := clientCtx.GetFromAddress().String() - msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr), signer) + submitter := clientCtx.GetFromAddress().String() + msg, err := types.NewMsgOptOut(args[0], sdk.ValAddress(providerValAddr), submitter) if err != nil { return err } @@ -559,8 +567,8 @@ func NewSetConsumerCommissionRateCmd() *cobra.Command { if err != nil { return err } - signer := clientCtx.GetFromAddress().String() - msg := types.NewMsgSetConsumerCommissionRate(args[0], commission, sdk.ValAddress(providerValAddr), signer) + submitter := clientCtx.GetFromAddress().String() + msg := types.NewMsgSetConsumerCommissionRate(args[0], commission, sdk.ValAddress(providerValAddr), submitter) if err := msg.ValidateBasic(); err != nil { return err } From be2deeef8faa660ceccec5c7ce76022eaa86757b Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Thu, 5 Sep 2024 17:19:25 +0200 Subject: [PATCH 38/43] feat!: add events for provider messages (#2221) * add events for CreateConsumer * add events for UpdateConsumer * add events for RemoveConsumer * add events for the rest of the messages * apply review suggestions * Id instead of ID * fix events --- .../provider/keeper/consumer_equivocation.go | 3 + x/ccv/provider/keeper/consumer_lifecycle.go | 3 +- x/ccv/provider/keeper/keeper.go | 3 +- x/ccv/provider/keeper/msg_server.go | 208 ++++++++++++++++-- x/ccv/provider/types/events.go | 13 +- x/ccv/types/events.go | 2 - 6 files changed, 206 insertions(+), 26 deletions(-) diff --git a/x/ccv/provider/keeper/consumer_equivocation.go b/x/ccv/provider/keeper/consumer_equivocation.go index c4c307b167..7bd7bac45c 100644 --- a/x/ccv/provider/keeper/consumer_equivocation.go +++ b/x/ccv/provider/keeper/consumer_equivocation.go @@ -84,6 +84,8 @@ func (k Keeper) HandleConsumerDoubleVoting( k.Logger(ctx).Info( "confirmed equivocation", + "consumerId", consumerId, + "chainId", chainId, "byzantine validator address", providerAddr.String(), ) @@ -214,6 +216,7 @@ func (k Keeper) HandleConsumerMisbehaviour(ctx sdk.Context, consumerId string, m logger.Info( "confirmed equivocation light client attack", + "consumerId", consumerId, "byzantine validators slashed, jailed and tombstoned", provAddrs, ) diff --git a/x/ccv/provider/keeper/consumer_lifecycle.go b/x/ccv/provider/keeper/consumer_lifecycle.go index 9de99f51e3..7c1817abd0 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle.go +++ b/x/ccv/provider/keeper/consumer_lifecycle.go @@ -233,7 +233,8 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, consumerId string) error { sdk.NewEvent( types.EventTypeConsumerClientCreated, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(ccv.AttributeChainID, consumerId), + sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(clienttypes.AttributeKeyClientID, clientID), sdk.NewAttribute(types.AttributeInitialHeight, initializationRecord.InitialHeight.String()), sdk.NewAttribute(types.AttributeTrustingPeriod, clientState.TrustingPeriod.String()), diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 4d60cf8dc9..3d624f10f3 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -387,7 +387,8 @@ func (k Keeper) SetConsumerChain(ctx sdk.Context, channelID string) error { sdk.NewEvent( ccv.EventTypeChannelEstablished, sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName), - sdk.NewAttribute(ccv.AttributeChainID, chainID), + sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainID), sdk.NewAttribute(conntypes.AttributeKeyClientID, clientID), sdk.NewAttribute(channeltypes.AttributeKeyChannelID, channelID), sdk.NewAttribute(conntypes.AttributeKeyConnectionID, connectionID), diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index bf4d7c93d5..9414ffc93e 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -70,19 +70,30 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign if err := k.Keeper.AssignConsumerKey(ctx, msg.ConsumerId, validator, consumerTMPublicKey); err != nil { return nil, err } - k.Logger(ctx).Info("assigned consumer key", - "consumer id", msg.ConsumerId, + + chainId, err := k.GetConsumerChainId(ctx, msg.ConsumerId) + if err != nil { + return nil, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + + k.Logger(ctx).Info("validator assigned consumer key", + "consumerId", msg.ConsumerId, + "chainId", chainId, "validator operator addr", msg.ProviderAddr, "consumer public key", msg.ConsumerKey, ) - ctx.EventManager().EmitEvents(sdk.Events{ + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeAssignConsumerKey, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), sdk.NewAttribute(types.AttributeConsumerConsensusPubKey, msg.ConsumerKey), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgAssignConsumerKeyResponse{}, nil } @@ -113,16 +124,19 @@ func (k msgServer) SubmitConsumerMisbehaviour(goCtx context.Context, msg *types. return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + ctx.EventManager().EmitEvent( sdk.NewEvent( ccvtypes.EventTypeSubmitConsumerMisbehaviour, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, msg.Misbehaviour.Header1.Header.ChainID), sdk.NewAttribute(ccvtypes.AttributeConsumerMisbehaviour, msg.Misbehaviour.String()), - sdk.NewAttribute(ccvtypes.AttributeSubmitterAddress, msg.Submitter), sdk.NewAttribute(ccvtypes.AttributeMisbehaviourClientId, msg.Misbehaviour.ClientId), sdk.NewAttribute(ccvtypes.AttributeMisbehaviourHeight1, msg.Misbehaviour.Header1.GetHeight().String()), sdk.NewAttribute(ccvtypes.AttributeMisbehaviourHeight2, msg.Misbehaviour.Header2.GetHeight().String()), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgSubmitConsumerMisbehaviourResponse{}, nil } @@ -164,14 +178,16 @@ func (k msgServer) SubmitConsumerDoubleVoting(goCtx context.Context, msg *types. return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + ctx.EventManager().EmitEvent( sdk.NewEvent( ccvtypes.EventTypeSubmitConsumerDoubleVoting, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, msg.InfractionBlockHeader.Header.ChainID), sdk.NewAttribute(ccvtypes.AttributeConsumerDoubleVoting, msg.DuplicateVoteEvidence.String()), - sdk.NewAttribute(ccvtypes.AttributeChainID, msg.InfractionBlockHeader.Header.ChainID), - sdk.NewAttribute(ccvtypes.AttributeSubmitterAddress, msg.Submitter), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgSubmitConsumerDoubleVotingResponse{}, nil } @@ -201,13 +217,29 @@ func (k msgServer) OptIn(goCtx context.Context, msg *types.MsgOptIn) (*types.Msg return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + chainId, err := k.GetConsumerChainId(ctx, msg.ConsumerId) + if err != nil { + return nil, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + + k.Logger(ctx).Info("validator opted in", + "consumerId", msg.ConsumerId, + "chainId", chainId, + "validator operator addr", msg.ProviderAddr, + "consumer public key", msg.ConsumerKey, + ) + + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeOptIn, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), sdk.NewAttribute(types.AttributeConsumerConsensusPubKey, msg.ConsumerKey), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgOptInResponse{}, nil } @@ -237,12 +269,27 @@ func (k msgServer) OptOut(goCtx context.Context, msg *types.MsgOptOut) (*types.M return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + chainId, err := k.GetConsumerChainId(ctx, msg.ConsumerId) + if err != nil { + return nil, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + + k.Logger(ctx).Info("validator opted out", + "consumerId", msg.ConsumerId, + "chainId", chainId, + "validator operator addr", msg.ProviderAddr, + ) + + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeOptOut, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgOptOutResponse{}, nil } @@ -270,14 +317,29 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M return nil, err } - ctx.EventManager().EmitEvents(sdk.Events{ + chainId, err := k.GetConsumerChainId(ctx, msg.ConsumerId) + if err != nil { + return nil, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + + k.Logger(ctx).Info("validator set commission rate on consumer", + "consumerId", msg.ConsumerId, + "chainId", chainId, + "validator operator addr", msg.ProviderAddr, + "rate", msg.Rate, + ) + + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSetConsumerCommissionRate, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(types.AttributeConsumerId, msg.ConsumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), sdk.NewAttribute(types.AttributeConsumerCommissionRate, msg.Rate.String()), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), ), - }) + ) return &types.MsgSetConsumerCommissionRateResponse{}, nil } @@ -287,6 +349,9 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon ctx := sdk.UnwrapSDKContext(goCtx) resp := types.MsgCreateConsumerResponse{} + // initialize an empty slice to store event attributes + eventAttributes := []sdk.Attribute{} + consumerId := k.Keeper.FetchAndIncrementConsumerId(ctx) k.Keeper.SetConsumerOwnerAddress(ctx, consumerId, msg.Submitter) @@ -298,6 +363,16 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon "cannot set consumer metadata: %s", err.Error()) } + // add event attributes + eventAttributes = append(eventAttributes, []sdk.Attribute{ + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, msg.ChainId), + sdk.NewAttribute(types.AttributeConsumerName, msg.Metadata.Name), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Submitter), + sdk.NewAttribute(types.AttributeConsumerOwner, msg.Submitter), + }...) + // initialization parameters are optional and hence could be nil; // in that case, set the default initializationParameters := types.ConsumerInitializationParameters{} // default params @@ -308,6 +383,11 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, "cannot set consumer initialization parameters: %s", err.Error()) } + if !initializationParameters.SpawnTime.IsZero() { + // add SpawnTime event attribute + eventAttributes = append(eventAttributes, + sdk.NewAttribute(types.AttributeConsumerSpawnTime, initializationParameters.SpawnTime.String())) + } // power-shaping parameters are optional and hence could be nil; // in that case, set the default @@ -333,11 +413,24 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon } } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent(ccvtypes.EventTypeConsumerCreation, - sdk.NewAttribute(ccvtypes.AttributeConsumerID, consumerId), + // add Phase event attribute + phase := k.GetConsumerPhase(ctx, consumerId) + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeConsumerPhase, phase.String())) + + k.Logger(ctx).Info("created consumer", + "consumerId", consumerId, + "chainId", msg.ChainId, + "owner", msg.Submitter, + "phase", phase, + "spawn time", initializationParameters.SpawnTime, + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCreateConsumer, + eventAttributes..., ), - }) + ) resp.ConsumerId = consumerId return &resp, nil @@ -348,6 +441,9 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon ctx := sdk.UnwrapSDKContext(goCtx) resp := types.MsgUpdateConsumerResponse{} + // initialize an empty slice to store event attributes + eventAttributes := []sdk.Attribute{} + consumerId := msg.ConsumerId if !k.Keeper.IsConsumerActive(ctx, consumerId) { @@ -364,6 +460,19 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Owner) } + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + + // add event attributes + eventAttributes = append(eventAttributes, []sdk.Attribute{ + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Owner), + }...) + // The new owner address can be empty, in which case the consumer chain does not change its owner. // However, if the new owner address is not empty, we verify that it's a valid account address. if strings.TrimSpace(msg.NewOwnerAddress) != "" { @@ -379,6 +488,9 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerMetadata, "cannot set consumer metadata: %s", err.Error()) } + + // add Name event attribute + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeConsumerName, msg.Metadata.Name)) } // get the previous spawn time so that we can use it in `PrepareConsumerForLaunch` @@ -394,6 +506,12 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrInvalidConsumerInitializationParameters, "cannot set consumer initialization parameters: %s", err.Error()) } + + if !msg.InitializationParameters.SpawnTime.IsZero() { + // add SpawnTime event attribute + eventAttributes = append(eventAttributes, + sdk.NewAttribute(types.AttributeConsumerSpawnTime, msg.InitializationParameters.SpawnTime.String())) + } } if msg.PowerShapingParameters != nil { @@ -421,6 +539,10 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon return &resp, errorsmod.Wrapf(types.ErrCannotUpdateMinimumPowerInTopN, "could not update minimum power in top N, oldTopN: %d, newTopN: %d, error: %s", oldTopN, msg.PowerShapingParameters.Top_N, err.Error()) } + + // add TopN event attribute + eventAttributes = append(eventAttributes, + sdk.NewAttribute(types.AttributeConsumerTopN, fmt.Sprintf("%v", msg.PowerShapingParameters.Top_N))) } // A Top N cannot change its owner address to something different from the gov module if the chain @@ -448,6 +570,28 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon } } + // add Owner event attribute + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeConsumerOwner, currentOwnerAddress)) + + // add Phase event attribute + phase := k.GetConsumerPhase(ctx, consumerId) + eventAttributes = append(eventAttributes, sdk.NewAttribute(types.AttributeConsumerPhase, phase.String())) + + k.Logger(ctx).Info("updated consumer", + "consumerId", consumerId, + "chainId", chainId, + "owner", currentOwnerAddress, + "phase", phase, + "topN", currentPowerShapingParameters.Top_N, + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeUpdateConsumer, + eventAttributes..., + ), + ) + return &resp, nil } @@ -463,6 +607,11 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon return &resp, errorsmod.Wrapf(types.ErrNoOwnerAddress, "cannot retrieve owner address %s", ownerAddress) } + chainId, err := k.GetConsumerChainId(ctx, consumerId) + if err != nil { + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot get consumer chain ID: %s", err.Error()) + } + if msg.Owner != ownerAddress { return &resp, errorsmod.Wrapf(types.ErrUnauthorized, "expected owner address %s, got %s", ownerAddress, msg.Owner) } @@ -474,6 +623,23 @@ func (k msgServer) RemoveConsumer(goCtx context.Context, msg *types.MsgRemoveCon } err = k.Keeper.StopAndPrepareForConsumerRemoval(ctx, consumerId) + + k.Logger(ctx).Info("stopped consumer", + "consumerId", consumerId, + "chainId", chainId, + "phase", phase, + ) + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRemoveConsumer, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeConsumerId, consumerId), + sdk.NewAttribute(types.AttributeConsumerChainId, chainId), + sdk.NewAttribute(types.AttributeSubmitterAddress, msg.Owner), + ), + ) + return &resp, err } diff --git a/x/ccv/provider/types/events.go b/x/ccv/provider/types/events.go index d539d695e2..77992a7e02 100644 --- a/x/ccv/provider/types/events.go +++ b/x/ccv/provider/types/events.go @@ -9,6 +9,10 @@ const ( EventTypeSetConsumerCommissionRate = "set_consumer_commission_rate" EventTypeOptIn = "opt_in" EventTypeOptOut = "opt_out" + EventTypeCreateConsumer = "create_consumer" + EventTypeUpdateConsumer = "update_consumer" + EventTypeRemoveConsumer = "remove_consumer" + AttributeInfractionHeight = "infraction_height" AttributeInitialHeight = "initial_height" AttributeTrustingPeriod = "trusting_period" @@ -17,6 +21,13 @@ const ( AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" AttributeAddConsumerRewardDenom = "add_consumer_reward_denom" AttributeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" + AttributeSubmitterAddress = "submitter_address" AttributeConsumerCommissionRate = "consumer_commission_rate" - AttributeConsumerId = "consumer_chain_id" + AttributeConsumerId = "consumer_id" + AttributeConsumerChainId = "consumer_chain_id" + AttributeConsumerName = "consumer_name" + AttributeConsumerOwner = "consumer_owner" + AttributeConsumerSpawnTime = "consumer_spawn_time" + AttributeConsumerPhase = "consumer_phase" + AttributeConsumerTopN = "consumer_topn" ) diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index 0be5b1a7d8..3c63fd7954 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -15,7 +15,6 @@ const ( EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" EventTypeFeeDistribution = "fee_distribution" EventTypeConsumerSlashRequest = "consumer_slash_request" - EventTypeConsumerCreation = "consumer_creation" AttributeKeyAckSuccess = "success" AttributeKeyAck = "acknowledgement" @@ -35,7 +34,6 @@ const ( AttributeMisbehaviourHeight1 = "misbehaviour_height_1" AttributeMisbehaviourHeight2 = "misbehaviour_height_2" AttributeConsumerDoubleVoting = "consumer_double_voting" - AttributeConsumerID = "consumer_id" AttributeChainID = "chain_id" AttributeValidatorAddress = "validator_address" AttributeInfractionType = "infraction_type" From 96b9bcf6f3c1a67520aa61c05eb307a24e1cc574 Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 5 Sep 2024 17:28:32 +0200 Subject: [PATCH 39/43] fix UT --- x/ccv/provider/handler_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/ccv/provider/handler_test.go b/x/ccv/provider/handler_test.go index 40ef5101db..e8fa15d4d2 100644 --- a/x/ccv/provider/handler_test.go +++ b/x/ccv/provider/handler_test.go @@ -175,6 +175,7 @@ func TestAssignConsensusKeyMsgHandling(t *testing.T) { k, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) tc.setup(ctx, k, mocks) + k.SetConsumerChainId(ctx, tc.consumerId, tc.name) msg, err := providertypes.NewMsgAssignConsumerKey(tc.consumerId, providerCryptoId.SDKValOpAddress(), consumerKey, From 7994f3050a2821a3234f571a889b87c8d27a294c Mon Sep 17 00:00:00 2001 From: mpoke Date: Thu, 5 Sep 2024 17:33:47 +0200 Subject: [PATCH 40/43] remove duplicate AttributeSubmitterAddress --- x/ccv/types/events.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index 3c63fd7954..8ee8388eb3 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -28,7 +28,6 @@ const ( AttributeUnbondingPeriod = "unbonding_period" AttributeProviderValidatorAddress = "provider_validator_address" AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" - AttributeSubmitterAddress = "submitter_address" AttributeConsumerMisbehaviour = "consumer_misbehaviour" AttributeMisbehaviourClientId = "misbehaviour_client_id" AttributeMisbehaviourHeight1 = "misbehaviour_height_1" From 4660b49d5e15ffa22fa9780f807ff593a19f7140 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 5 Sep 2024 19:24:07 +0200 Subject: [PATCH 41/43] fix: fix queries' API endpoints (#2226) * endpoint fixes * Update proto/interchain_security/ccv/provider/v1/query.proto Co-authored-by: MSalopek * Update proto/interchain_security/ccv/provider/v1/query.proto Co-authored-by: MSalopek * generate proto --------- Co-authored-by: MSalopek --- .../ccv/provider/v1/query.proto | 4 +- x/ccv/provider/types/query.pb.go | 301 +++++++++--------- x/ccv/provider/types/query.pb.gw.go | 132 ++++++-- 3 files changed, 259 insertions(+), 178 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 9171cf74eb..2b2b0dc60e 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -36,7 +36,7 @@ service Query { rpc QueryValidatorConsumerAddr(QueryValidatorConsumerAddrRequest) returns (QueryValidatorConsumerAddrResponse) { option (google.api.http).get = - "/interchain_security/ccv/provider/validator_consumer_addr"; + "/interchain_security/ccv/provider/validator_consumer_addr/{consumer_id}/{provider_address}"; } // QueryProviderAddr returns the provider chain validator @@ -44,7 +44,7 @@ service Query { rpc QueryValidatorProviderAddr(QueryValidatorProviderAddrRequest) returns (QueryValidatorProviderAddrResponse) { option (google.api.http).get = - "/interchain_security/ccv/provider/validator_provider_addr"; + "/interchain_security/ccv/provider/validator_provider_addr/{consumer_id}/{consumer_address}"; } // QueryThrottleState returns the main on-chain state relevant to currently diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index 6ef50117a7..fa0c569918 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -1833,156 +1833,157 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 2371 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0xcd, 0x6f, 0xdc, 0xc6, - 0x15, 0x17, 0x57, 0x1f, 0x5e, 0x8d, 0x2c, 0x25, 0x1e, 0xcb, 0xf6, 0x7a, 0x65, 0x6b, 0x65, 0x3a, - 0x06, 0x14, 0x3b, 0x5e, 0x4a, 0x5b, 0xb8, 0x49, 0x9c, 0xfa, 0x43, 0xbb, 0x96, 0xec, 0x85, 0x63, - 0x5b, 0xa1, 0x14, 0x07, 0x70, 0xe0, 0xb2, 0x14, 0x39, 0xd9, 0x9d, 0x8a, 0x4b, 0xd2, 0x9c, 0xd9, - 0xb5, 0xb7, 0xaa, 0x2e, 0x3d, 0xe5, 0xd0, 0x02, 0x29, 0x8a, 0x9e, 0x1b, 0xf4, 0xd2, 0x6b, 0x51, - 0x04, 0xfd, 0x1b, 0x72, 0x6b, 0x9a, 0x5e, 0x8a, 0x02, 0x75, 0x0b, 0xbb, 0x05, 0x7a, 0x29, 0xd0, - 0xa6, 0xed, 0xbd, 0x98, 0xe1, 0x90, 0xbb, 0xa4, 0xb9, 0x2b, 0x52, 0xd2, 0x6d, 0x39, 0xf3, 0xde, - 0xef, 0x7d, 0xcc, 0x9b, 0x37, 0xef, 0x3d, 0x09, 0x28, 0xd8, 0xa6, 0xc8, 0x33, 0x9a, 0x3a, 0xb6, - 0x35, 0x82, 0x8c, 0xb6, 0x87, 0x69, 0x57, 0x31, 0x8c, 0x8e, 0xe2, 0x7a, 0x4e, 0x07, 0x9b, 0xc8, - 0x53, 0x3a, 0xcb, 0xca, 0x93, 0x36, 0xf2, 0xba, 0x65, 0xd7, 0x73, 0xa8, 0x03, 0xcf, 0x27, 0x30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0xe5, 0x59, 0xac, 0xf6, 0xec, 0xba, 0x88, 0x6c, 0x4d, - 0xf0, 0x3f, 0xf1, 0x7d, 0xeb, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x1f, 0xf9, 0xd9, 0x95, - 0x23, 0x00, 0x00, + // 2386 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x5a, 0xcd, 0x73, 0xdb, 0xc6, + 0x15, 0x17, 0xa8, 0x0f, 0x53, 0x2b, 0x4b, 0x8e, 0xd7, 0xb2, 0x4d, 0x53, 0xb6, 0x28, 0xc3, 0xf1, + 0x8c, 0x62, 0xc7, 0x84, 0xa4, 0x8e, 0x9b, 0xc4, 0xa9, 0x3f, 0x44, 0x5a, 0xb2, 0x39, 0x8e, 0x6d, + 0x05, 0x52, 0x9c, 0x19, 0xa7, 0x2e, 0x0a, 0x01, 0x1b, 0x72, 0x2b, 0x10, 0x80, 0xb1, 0x4b, 0xda, + 0xac, 0xea, 0x4b, 0x4f, 0x39, 0xb4, 0x33, 0xc9, 0x74, 0x7a, 0x6e, 0xa6, 0x7f, 0x41, 0xa7, 0x93, + 0xe9, 0xdf, 0x90, 0x5b, 0xd3, 0xf4, 0xd2, 0xe9, 0x4c, 0xdd, 0x8e, 0xdd, 0xce, 0xb4, 0x87, 0x1e, + 0x9a, 0xb6, 0xf7, 0xcc, 0x2e, 0x16, 0x20, 0x01, 0x83, 0x24, 0x20, 0xe9, 0x46, 0xec, 0xbe, 0xf7, + 0x7b, 0x1f, 0xfb, 0xf6, 0xed, 0x7b, 0x4f, 0x02, 0x0a, 0xb6, 0x29, 0xf2, 0x8c, 0x86, 0x8e, 0x6d, + 0x8d, 0x20, 0xa3, 0xe5, 0x61, 0xda, 0x51, 0x0c, 0xa3, 0xad, 0xb8, 0x9e, 0xd3, 0xc6, 0x26, 0xf2, + 0x94, 0xf6, 0xb2, 0xf2, 0xb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9a, 0x3a, 0x6d, 0x94, 0xdf, 0x43, 0x75, 0xdd, 0xe8, + 0xdc, 0x44, 0x46, 0x41, 0x52, 0x39, 0x0b, 0x3c, 0x0f, 0x66, 0x42, 0xad, 0x7c, 0xf4, 0x71, 0x9e, + 0x5f, 0xa7, 0x83, 0x55, 0x5e, 0xf2, 0xc0, 0x47, 0xa0, 0x10, 0x92, 0x19, 0x4e, 0xb3, 0x89, 0x09, + 0xc1, 0x8e, 0xad, 0x71, 0xa9, 0x13, 0x5c, 0xea, 0xb9, 0x14, 0x52, 0xd5, 0x13, 0x01, 0x48, 0x35, + 0xc4, 0x50, 0x99, 0x16, 0x8f, 0x40, 0x21, 0x74, 0x6d, 0x1c, 0xfe, 0x50, 0x06, 0xf8, 0x00, 0x24, + 0x06, 0x7f, 0x07, 0x4c, 0x99, 0x88, 0x18, 0x1e, 0x76, 0x59, 0xe7, 0x54, 0xc8, 0x73, 0xcf, 0x9f, + 0x2b, 0x8b, 0x56, 0x22, 0x68, 0x16, 0x44, 0xf3, 0x50, 0xbe, 0xd9, 0x25, 0x15, 0x77, 0xa5, 0x97, + 0x1b, 0x3e, 0x02, 0xa7, 0x42, 0x5d, 0x1d, 0x17, 0x79, 0xbc, 0x04, 0x0c, 0xe2, 0x81, 0x17, 0x6a, + 0x95, 0xb3, 0x5f, 0x7f, 0x71, 0xe9, 0x8c, 0x40, 0x0f, 0xe3, 0x47, 0xc4, 0xc1, 0x26, 0xf5, 0xb0, + 0x5d, 0x57, 0x4f, 0x06, 0x18, 0xf7, 0x05, 0x44, 0x10, 0x26, 0x27, 0xc0, 0xc4, 0x8f, 0x74, 0x6c, + 0x21, 0x93, 0xd7, 0x76, 0x79, 0x55, 0x7c, 0xc1, 0x2b, 0x60, 0x82, 0x35, 0x17, 0x2d, 0xc2, 0x2b, + 0xb3, 0x99, 0x15, 0xb9, 0x9f, 0xfa, 0x15, 0xc7, 0x36, 0x37, 0x39, 0xa5, 0x2a, 0x38, 0xe0, 0x16, + 0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 0x1f, 0xf9, 0xd3, 0xcb, + 0xf9, 0x91, 0x87, 0x57, 0xeb, 0x98, 0x36, 0x5a, 0xdb, 0x65, 0xc3, 0x69, 0x8a, 0xff, 0x1b, 0xe9, + 0x11, 0x75, 0x29, 0x14, 0xd5, 0xbe, 0xac, 0x3c, 0x8d, 0xd5, 0x9e, 0x1d, 0x17, 0x91, 0xed, 0x09, + 0xfe, 0x47, 0xc2, 0xef, 0x7c, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x64, 0xaa, 0xd9, 0x88, 0xd7, 0x23, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 92f8f09f5a..e6fdfc5f76 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -169,19 +169,37 @@ func local_request_Query_QueryConsumerChains_0(ctx context.Context, marshaler ru } -var ( - filter_Query_QueryValidatorConsumerAddr_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Query_QueryValidatorConsumerAddr_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryValidatorConsumerAddrRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") + } + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerAddr_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") + } + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } msg, err := client.QueryValidatorConsumerAddr(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -193,11 +211,33 @@ func local_request_Query_QueryValidatorConsumerAddr_0(ctx context.Context, marsh var protoReq QueryValidatorConsumerAddrRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorConsumerAddr_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + val, ok = pathParams["provider_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "provider_address") + } + + protoReq.ProviderAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "provider_address", err) } msg, err := server.QueryValidatorConsumerAddr(ctx, &protoReq) @@ -205,19 +245,37 @@ func local_request_Query_QueryValidatorConsumerAddr_0(ctx context.Context, marsh } -var ( - filter_Query_QueryValidatorProviderAddr_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - func request_Query_QueryValidatorProviderAddr_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryValidatorProviderAddrRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorProviderAddr_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + val, ok = pathParams["consumer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_address") + } + + protoReq.ConsumerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_address", err) } msg, err := client.QueryValidatorProviderAddr(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -229,11 +287,33 @@ func local_request_Query_QueryValidatorProviderAddr_0(ctx context.Context, marsh var protoReq QueryValidatorProviderAddrRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["consumer_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_id") } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryValidatorProviderAddr_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + + protoReq.ConsumerId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_id", err) + } + + val, ok = pathParams["consumer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "consumer_address") + } + + protoReq.ConsumerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "consumer_address", err) } msg, err := server.QueryValidatorProviderAddr(ctx, &protoReq) @@ -1413,9 +1493,9 @@ var ( pattern_Query_QueryConsumerChains_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "consumer_chains", "phase", "limit"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryValidatorConsumerAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "validator_consumer_addr"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryValidatorConsumerAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "validator_consumer_addr", "consumer_id", "provider_address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryValidatorProviderAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "validator_provider_addr"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryValidatorProviderAddr_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"interchain_security", "ccv", "provider", "validator_provider_addr", "consumer_id", "consumer_address"}, "", 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", "provider", "throttle_state"}, "", runtime.AssumeColonVerbOpt(false))) From d13fbb060bcf58768e1006af13e0e85291a26dce Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Fri, 6 Sep 2024 10:18:54 +0200 Subject: [PATCH 42/43] fix!: replace CanLaunch with InitializeConsumer (#2224) replace CanLaunch with InitializeConsumer --- x/ccv/provider/keeper/consumer_lifecycle.go | 26 ++-- .../keeper/consumer_lifecycle_test.go | 112 ++++++++++++------ x/ccv/provider/keeper/msg_server.go | 10 +- x/ccv/provider/types/errors.go | 1 - x/ccv/provider/types/msg.go | 4 - x/ccv/provider/types/msg_test.go | 2 +- 6 files changed, 92 insertions(+), 63 deletions(-) diff --git a/x/ccv/provider/keeper/consumer_lifecycle.go b/x/ccv/provider/keeper/consumer_lifecycle.go index 7c1817abd0..20014c3c35 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle.go +++ b/x/ccv/provider/keeper/consumer_lifecycle.go @@ -36,13 +36,12 @@ func (k Keeper) PrepareConsumerForLaunch(ctx sdk.Context, consumerId string, pre return k.AppendConsumerToBeLaunched(ctx, consumerId, spawnTime) } -// CanLaunch checks on whether the consumer with `consumerId` has set all the initialization parameters set and hence -// is ready to launch and at what spawn time -// TODO (PERMISSIONLESS): could remove, all fields should be there because we validate the initialization parameters -func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) { - // a chain that is already launched or stopped cannot launch again +// InitializeConsumer tries to move a consumer with `consumerId` to the initialized phase. +// If successfull, it returns the spawn time and true. +func (k Keeper) InitializeConsumer(ctx sdk.Context, consumerId string) (time.Time, bool) { + // a chain needs to be in the registered or initialized phase phase := k.GetConsumerPhase(ctx, consumerId) - if phase == types.CONSUMER_PHASE_LAUNCHED || phase == types.CONSUMER_PHASE_STOPPED { + if phase != types.CONSUMER_PHASE_REGISTERED && phase != types.CONSUMER_PHASE_INITIALIZED { return time.Time{}, false } @@ -51,17 +50,14 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool) return time.Time{}, false } - spawnTimeIsNotZero := !initializationParameters.SpawnTime.Equal(time.Time{}) - - genesisHashSet := initializationParameters.GenesisHash != nil - binaryHashSet := initializationParameters.BinaryHash != nil + // the spawn time needs to be positive + if initializationParameters.SpawnTime.IsZero() { + return time.Time{}, false + } - consumerRedistributionFractionSet := initializationParameters.ConsumerRedistributionFraction != "" - blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0 - historicalEntriesSet := initializationParameters.HistoricalEntries > 0 + k.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) - return initializationParameters.SpawnTime, spawnTimeIsNotZero && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet && - blocksPerDistributionTransmissionSet && historicalEntriesSet + return initializationParameters.SpawnTime, true } // BeginBlockLaunchConsumers launches initialized consumers that are ready to launch diff --git a/x/ccv/provider/keeper/consumer_lifecycle_test.go b/x/ccv/provider/keeper/consumer_lifecycle_test.go index 3d59fec53d..76d654c0c3 100644 --- a/x/ccv/provider/keeper/consumer_lifecycle_test.go +++ b/x/ccv/provider/keeper/consumer_lifecycle_test.go @@ -52,45 +52,85 @@ func TestPrepareConsumerForLaunch(t *testing.T) { require.Equal(t, providertypes.ConsumerIds{Ids: []string{"consumerId"}}, consumers) } -func TestCanLaunch(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // cannot launch an unknown chain - _, canLaunch := providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // cannot launch a chain without initialization parameters - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) - - // set valid initialization parameters - initializationParameters := testkeeper.GetTestInitializationParameters() - err := providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) - require.NoError(t, err) - - // cannot launch a launched chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_LAUNCHED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) +func TestInitializeConsumer(t *testing.T) { + now := time.Now().UTC() + consumerId := "13" + + testCases := []struct { + name string + spawnTime time.Time + setup func(*providerkeeper.Keeper, sdk.Context, time.Time) + expInitialized bool + }{ + { + name: "valid", + spawnTime: now, + setup: func(pk *providerkeeper.Keeper, ctx sdk.Context, spawnTime time.Time) { + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_REGISTERED) + err := pk.SetConsumerInitializationParameters(ctx, consumerId, + providertypes.ConsumerInitializationParameters{ + SpawnTime: spawnTime, + }) + require.NoError(t, err) + }, + expInitialized: true, + }, + { + name: "invalid: no phase", + spawnTime: now, + setup: func(pk *providerkeeper.Keeper, ctx sdk.Context, spawnTime time.Time) { + }, + expInitialized: false, + }, + { + name: "invalid: wrong phase", + spawnTime: now, + setup: func(pk *providerkeeper.Keeper, ctx sdk.Context, spawnTime time.Time) { + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_LAUNCHED) + err := pk.SetConsumerInitializationParameters(ctx, consumerId, + providertypes.ConsumerInitializationParameters{ + SpawnTime: spawnTime, + }) + require.NoError(t, err) + }, + expInitialized: false, + }, + { + name: "invalid: no init params", + spawnTime: now, + setup: func(pk *providerkeeper.Keeper, ctx sdk.Context, spawnTime time.Time) { + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_REGISTERED) + }, + expInitialized: false, + }, + { + name: "invalid: zero spawn time", + spawnTime: now, + setup: func(pk *providerkeeper.Keeper, ctx sdk.Context, spawnTime time.Time) { + pk.SetConsumerPhase(ctx, consumerId, providertypes.CONSUMER_PHASE_REGISTERED) + err := pk.SetConsumerInitializationParameters(ctx, consumerId, + providertypes.ConsumerInitializationParameters{ + SpawnTime: time.Time{}, + }) + require.NoError(t, err) + }, + expInitialized: false, + }, + } - // cannot launch a stopped chain - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_STOPPED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.False(t, canLaunch) + for _, tc := range testCases { + pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() - // initialized chain can launch - providerKeeper.SetConsumerPhase(ctx, "consumerId", providertypes.CONSUMER_PHASE_INITIALIZED) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.True(t, canLaunch) + tc.setup(&pk, ctx, tc.spawnTime) - // chain cannot launch without a genesis hash - initializationParameters.GenesisHash = nil - err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters) - _, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId") - require.NoError(t, err) - require.False(t, canLaunch) + spawnTime, initialized := pk.InitializeConsumer(ctx, consumerId) + require.Equal(t, tc.expInitialized, initialized, tc.name) + if initialized { + require.Equal(t, tc.spawnTime, spawnTime, tc.name) + require.Equal(t, providertypes.CONSUMER_PHASE_INITIALIZED, pk.GetConsumerPhase(ctx, consumerId)) + } + } } // TestBeginBlockInit directly tests BeginBlockLaunchConsumers against the spec using helpers defined above. diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 9414ffc93e..e5148b5a37 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -405,10 +405,9 @@ func (k msgServer) CreateConsumer(goCtx context.Context, msg *types.MsgCreateCon "cannot set power shaping parameters") } - if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) + if spawnTime, initialized := k.Keeper.InitializeConsumer(ctx, consumerId); initialized { if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, time.Time{}, spawnTime); err != nil { - return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot prepare chain with consumer id (%s) for launch", consumerId) } } @@ -562,10 +561,9 @@ func (k msgServer) UpdateConsumer(goCtx context.Context, msg *types.MsgUpdateCon "a move to a new owner address that is not the gov module can only be done if `Top N` is set to 0") } - if spawnTime, canLaunch := k.Keeper.CanLaunch(ctx, consumerId); canLaunch { - k.Keeper.SetConsumerPhase(ctx, consumerId, types.CONSUMER_PHASE_INITIALIZED) + if spawnTime, initialized := k.Keeper.InitializeConsumer(ctx, consumerId); initialized { if err := k.Keeper.PrepareConsumerForLaunch(ctx, consumerId, previousSpawnTime, spawnTime); err != nil { - return &resp, errorsmod.Wrapf(types.ErrCannotPrepareForLaunch, + return &resp, errorsmod.Wrapf(ccvtypes.ErrInvalidConsumerState, "cannot prepare chain with consumer id (%s) for launch", consumerId) } } diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 933e363f73..2d87ee1345 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -35,7 +35,6 @@ var ( ErrInvalidTransformToTopN = errorsmod.Register(ModuleName, 39, "invalid transform to Top N chain") ErrInvalidTransformToOptIn = errorsmod.Register(ModuleName, 40, "invalid transform to Opt In chain") ErrCannotCreateTopNChain = errorsmod.Register(ModuleName, 41, "cannot create Top N chain outside permissionlessly") - ErrCannotPrepareForLaunch = errorsmod.Register(ModuleName, 42, "cannot prepare chain for launch") ErrInvalidRemovalTime = errorsmod.Register(ModuleName, 43, "invalid removal time") ErrInvalidMsgCreateConsumer = errorsmod.Register(ModuleName, 44, "invalid create consumer message") ErrInvalidMsgUpdateConsumer = errorsmod.Register(ModuleName, 45, "invalid update consumer message") diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 66517ca773..f7ddd1ad4a 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -533,10 +533,6 @@ func ValidateInitializationParameters(initializationParameters ConsumerInitializ return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "BinaryHash: %s", err.Error()) } - if initializationParameters.SpawnTime.IsZero() { - return errorsmod.Wrap(ErrInvalidConsumerInitializationParameters, "SpawnTime cannot be zero") - } - if err := ccvtypes.ValidateStringFraction(initializationParameters.ConsumerRedistributionFraction); err != nil { return errorsmod.Wrapf(ErrInvalidConsumerInitializationParameters, "ConsumerRedistributionFraction: %s", err.Error()) } diff --git a/x/ccv/provider/types/msg_test.go b/x/ccv/provider/types/msg_test.go index 72e4712f59..c05a628ac4 100644 --- a/x/ccv/provider/types/msg_test.go +++ b/x/ccv/provider/types/msg_test.go @@ -159,7 +159,7 @@ func TestValidateInitializationParameters(t *testing.T) { HistoricalEntries: 10000, DistributionTransmissionChannel: "", }, - valid: false, + valid: true, }, { name: "invalid - zero duration", From 129164c31d796125fcab3d1d7ff54f941dc6b6a4 Mon Sep 17 00:00:00 2001 From: insumity Date: Fri, 6 Sep 2024 12:15:30 +0200 Subject: [PATCH 43/43] fix: improve commands' description (#2227) init commit --- x/ccv/provider/client/cli/tx.go | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 1b64678766..17414bc5ef 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -229,23 +229,23 @@ where create_consumer.json has the following structure: "chain_id": "consu", "metadata": { "name": "chain consumer", - "description": "no description", - "metadata": "no metadata" + "description": "description", + "metadata": "metadata" }, "initialization_parameters": { "initial_height": { - "revision_number": "0", - "revision_height": "1" + "revision_number": 0, + "revision_height": 1 }, "genesis_hash": "Z2VuX2hhc2g=", "binary_hash": "YmluX2hhc2g=", "spawn_time": "2024-08-29T12:26:16.529913Z", - "unbonding_period": "1209600s", - "ccv_timeout_period": "2419200s", - "transfer_timeout_period": "3600s", + "unbonding_period": 1728000000000000, + "ccv_timeout_period": 2419200000000000, + "transfer_timeout_period": 1800000000000, "consumer_redistribution_fraction": "0.75", - "blocks_per_distribution_transmission": "1000", - "historical_entries": "10000", + "blocks_per_distribution_transmission": 1000, + "historical_entries": 10000, "distribution_transmission_channel": "" }, "power_shaping_parameters": { @@ -315,31 +315,31 @@ func NewUpdateConsumerCmd() *cobra.Command { Note that only the owner of the chain can initialize it. Example: -%s tx provider update-consumer [path/to/consumer-update.json] --from node0 --home ../node0 --chain-id $CID +%s tx provider update-consumer [path/to/update_consumer.json] --from node0 --home ../node0 --chain-id $CID -where create_consumer.json has the following structure: +where update_consumer.json has the following structure: { "consumer_id": "0", "new_owner_address": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", "metadata": { "name": "chain consumer", - "description": "no description", - "metadata": "no metadata" + "description": "description", + "metadata": "metadata" }, "initialization_parameters": { "initial_height": { - "revision_number": "0", - "revision_height": "1" + "revision_number": 0, + "revision_height": 1 }, "genesis_hash": "Z2VuX2hhc2g=", "binary_hash": "YmluX2hhc2g=", "spawn_time": "2024-08-29T12:26:16.529913Z", - "unbonding_period": "1209600s", - "ccv_timeout_period": "2419200s", - "transfer_timeout_period": "3600s", + "unbonding_period": 1728000000000000, + "ccv_timeout_period": 2419200000000000, + "transfer_timeout_period": 1800000000000, "consumer_redistribution_fraction": "0.75", - "blocks_per_distribution_transmission": "1000", - "historical_entries": "10000", + "blocks_per_distribution_transmission": 1000, + "historical_entries": 10000, "distribution_transmission_channel": "" }, "power_shaping_parameters": {