Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: first iteration on Permissionless ICS #2117

Merged
merged 41 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bd4b88a
(partially) renamed chain ids to consumer ids
insumity Jul 30, 2024
27936c5
renamed proposal messages
insumity Jul 30, 2024
008553d
removed global slash entry
insumity Jul 30, 2024
da27847
fixed unit tests
insumity Jul 30, 2024
8366967
added new messages
insumity Jul 30, 2024
47f2a3e
introduced new state
insumity Jul 30, 2024
a117b1a
added functionality for the register and initialize messages
insumity Jul 31, 2024
90db064
renamed (partially) chainIds to consumerIds
insumity Jul 31, 2024
995a6e4
set consumerId to chainId association during registration
insumity Jul 31, 2024
13d3e9f
added extra check in the initialization so unknokwn, launched, or sto…
insumity Jul 31, 2024
a1a1321
added initial work on traversing initialized chains that are to-be-la…
insumity Jul 31, 2024
e253917
fixed rebase issues after bringing the VSCMaturedPackets work in
insumity Aug 1, 2024
337298a
made it so we traverse initialization records instead of addition pro…
insumity Aug 2, 2024
b60271b
renamed more chainIDs to consumerIds
insumity Aug 2, 2024
600e276
removed ClientIdToChainId state because chainId already resides on th…
insumity Aug 2, 2024
2994136
nit fixes in go docs
insumity Aug 2, 2024
ff5ef0a
removed MsgConsumerAddition
insumity Aug 2, 2024
2854568
added CLI commands for new messages
insumity Aug 2, 2024
34d9164
removed consumer modification proposal
insumity Aug 2, 2024
9c51962
removed (partially) consumer removal proposal
insumity Aug 5, 2024
cfa8a1a
rebased to pick up the inactive-validators work (PR #2079)
insumity Aug 6, 2024
5de11fd
introduced consumerId in the equivocation messages (and a useful quer…
insumity Aug 6, 2024
0c3d3b6
added safeguard so that a validator cannot opt-in to two different ch…
insumity Aug 6, 2024
2cee3e9
renamed some chainIDs to consumerIds
insumity Aug 6, 2024
c7461ed
updated based on comments
insumity Aug 13, 2024
e86d44d
fixed integration tests
insumity Aug 14, 2024
60a6cee
rebased to pick up the removal of legacy proposals (#2130) and re-int…
insumity Aug 15, 2024
3e1b726
changes messages to only have MsgCreateConsumer and MsgUpdateConsumer…
insumity Aug 19, 2024
06081be
cleaned up slightly a few things (mostly committing & pushing) so peo…
insumity Aug 20, 2024
da6e001
fixed the CreateConsumer and UpdateConsumer logic and made most of th…
insumity Aug 20, 2024
55da067
fixed hooks and the code around proposalId to consumerId
insumity Aug 21, 2024
81e51f0
feat: extend consumer validator query to return commission rate (back…
sainoe Aug 22, 2024
1891737
renamed some chainIds to consumerIds
insumity Aug 21, 2024
22fcb6d
took into account comments and also added safeguard to reject new pro…
insumity Aug 22, 2024
f66831a
Update x/ccv/provider/types/msg.go
insumity Aug 22, 2024
76e0370
removed double-gas charge on MsgCreateConsumer and imroved the logic …
insumity Aug 23, 2024
59e27e9
added PopulateMinimumPowerInTopN tested
insumity Aug 23, 2024
cde883b
took into account comments (using protos for marshalling string slice…
insumity Aug 23, 2024
e182d49
feat: add fields to consumer validators query (#2167)
sainoe Aug 23, 2024
35b4140
modified the way we verify the new owner address, as well as nit refa…
insumity Aug 26, 2024
b54c6e4
fixed some rebase issues and changed a proto to be backward-compatible
insumity Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -271,4 +271,4 @@ build-docs-local:
###############################################################################

e2e-traces:
cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v
cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v
12 changes: 7 additions & 5 deletions docs/docs/adrs/adr-019-permissionless-ics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
102 changes: 102 additions & 0 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
Loading
Loading