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: extend consumer_validators query to return consumer valset before launch #2164

Merged
merged 61 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1edbf8e
(partially) renamed chain ids to consumer ids
insumity Jul 30, 2024
3ba933f
renamed proposal messages
insumity Jul 30, 2024
489cefa
removed global slash entry
insumity Jul 30, 2024
2d2c41e
fixed unit tests
insumity Jul 30, 2024
f2ad00a
added new messages
insumity Jul 30, 2024
c7b5386
introduced new state
insumity Jul 30, 2024
010db3a
added functionality for the register and initialize messages
insumity Jul 31, 2024
ecb89c0
renamed (partially) chainIds to consumerIds
insumity Jul 31, 2024
758c52f
set consumerId to chainId association during registration
insumity Jul 31, 2024
e055f0f
added extra check in the initialization so unknokwn, launched, or sto…
insumity Jul 31, 2024
e692a22
added initial work on traversing initialized chains that are to-be-la…
insumity Jul 31, 2024
fda23de
fixed rebase issues after bringing the VSCMaturedPackets work in
insumity Aug 1, 2024
1146509
made it so we traverse initialization records instead of addition pro…
insumity Aug 2, 2024
2256ab3
renamed more chainIDs to consumerIds
insumity Aug 2, 2024
caa91b7
removed ClientIdToChainId state because chainId already resides on th…
insumity Aug 2, 2024
e969fe3
nit fixes in go docs
insumity Aug 2, 2024
cef3be7
removed MsgConsumerAddition
insumity Aug 2, 2024
2385aca
added CLI commands for new messages
insumity Aug 2, 2024
8a0ba7d
removed consumer modification proposal
insumity Aug 2, 2024
d6f890a
removed (partially) consumer removal proposal
insumity Aug 5, 2024
64ed6e7
rebased to pick up the inactive-validators work (PR #2079)
insumity Aug 6, 2024
1f76f20
introduced consumerId in the equivocation messages (and a useful quer…
insumity Aug 6, 2024
f95b248
added safeguard so that a validator cannot opt-in to two different ch…
insumity Aug 6, 2024
e40449f
renamed some chainIDs to consumerIds
insumity Aug 6, 2024
3d5dbb1
updated based on comments
insumity Aug 13, 2024
8a0b825
fixed integration tests
insumity Aug 14, 2024
96b5706
rebased to pick up the removal of legacy proposals (#2130) and re-int…
insumity Aug 15, 2024
a9b05a3
changes messages to only have MsgCreateConsumer and MsgUpdateConsumer…
insumity Aug 19, 2024
1ac674f
cleaned up slightly a few things (mostly committing & pushing) so peo…
insumity Aug 20, 2024
739bd21
fixed the CreateConsumer and UpdateConsumer logic and made most of th…
insumity Aug 20, 2024
5e5480f
fixed hooks and the code around proposalId to consumerId
insumity Aug 21, 2024
7c43f6d
pre-spawn query
sainoe Aug 21, 2024
73ce1f6
rebase
sainoe Aug 22, 2024
9e4fbde
nits
sainoe Aug 22, 2024
da3cbb2
feat: extend consumer validator query to return commission rate (back…
sainoe Aug 22, 2024
e5cbcd0
remove panics
sainoe Aug 22, 2024
db8b887
renamed some chainIds to consumerIds
insumity Aug 21, 2024
4744bdc
took into account comments and also added safeguard to reject new pro…
insumity Aug 22, 2024
715bbbc
Update x/ccv/provider/types/msg.go
insumity Aug 22, 2024
96029ca
removed double-gas charge on MsgCreateConsumer and imroved the logic …
insumity Aug 23, 2024
8beffdc
added PopulateMinimumPowerInTopN tested
insumity Aug 23, 2024
ec5ccec
took into account comments (using protos for marshalling string slice…
insumity Aug 23, 2024
b733bd7
update logic
sainoe Aug 23, 2024
96ef414
took into account comments (using protos for marshalling string slice…
insumity Aug 23, 2024
7580046
Merge branch 'insumity/rename-chain-id' into sainoe/consu-valset-query
sainoe Aug 23, 2024
563774b
feat: add fields to consumer validators query (#2167)
sainoe Aug 23, 2024
6992a00
order consumer validators
sainoe Aug 26, 2024
6c551f8
nits
sainoe Aug 26, 2024
05fd5f3
feat: first iteration on Permissionless ICS (#2117)
insumity Aug 26, 2024
ad5288d
Merge branch 'feat/permissionless' into sainoe/consu-valset-query
sainoe Aug 26, 2024
fca239b
cover stopped phase case
sainoe Aug 26, 2024
29d790c
fixed bug on removing previous spawn time & added tests
insumity Aug 26, 2024
a400de1
added some additional tests
insumity Aug 26, 2024
84565ab
added tests on the hooks
insumity Aug 27, 2024
0fc6968
removed check that spawn time is in the future
insumity Aug 27, 2024
19be098
feat: refactor consumer validator set computation (#2175)
sainoe Aug 27, 2024
cc4f6b9
Merge branch 'feat/permissionless' into sainoe/consu-valset-query
sainoe Aug 27, 2024
43baef1
nit
sainoe Aug 28, 2024
06bdfc4
nits
sainoe Aug 28, 2024
7b48b97
Merge branch 'feat/permissionless' into sainoe/consu-valset-query
sainoe Aug 28, 2024
9403c26
nit
sainoe Aug 28, 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