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!: Permissionless ICS #2171

Merged
merged 46 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c32da7f
feat: first iteration on Permissionless ICS (#2117)
insumity Aug 26, 2024
2d404f0
fixed bug on removing previous spawn time & added tests
insumity Aug 26, 2024
d124ada
added some additional tests
insumity Aug 26, 2024
2c20186
added tests on the hooks
insumity Aug 27, 2024
25f6b82
removed check that spawn time is in the future
insumity Aug 27, 2024
88a6375
feat: refactor consumer validator set computation (#2175)
sainoe Aug 27, 2024
2ca28cd
fix!: ConsumerModificationProposal is needed in Gaia upgrade handler …
mpoke Aug 27, 2024
8fdfad9
fix: allow the owner of a chain to remove the chain (#2178)
insumity Aug 27, 2024
50475e6
refactor: add proto enum for ConsumerPhase (#2182)
mpoke Aug 28, 2024
3ea2923
feat: extend `consumer_validators` query to return consumer valset be…
sainoe Aug 28, 2024
adaef80
resolve merge conflict
mpoke Aug 28, 2024
a9b39dd
fix build
mpoke Aug 28, 2024
289e05c
tests: fix integration test setup (#2183)
mpoke Aug 28, 2024
aec6c93
feat: add consumer chain query (#2179)
sainoe Aug 29, 2024
4ed2723
feat: extend consumer chains query (#2172)
sainoe Aug 29, 2024
7aa6db9
feat!: migrations for permissionless (#2174)
mpoke Aug 29, 2024
43ecf10
feat: update `consumer_chains` REST endpoint (#2188)
sainoe Aug 29, 2024
29b1bf4
fix: permissionless added event + cli changes (#2185)
bermuell Aug 29, 2024
1135770
fix!: several permissionless changes (#2189)
mpoke Aug 29, 2024
1c63e3e
fix: fix consumer chain query CLI (#2190)
sainoe Aug 29, 2024
4c30f6b
fix!: fix store.set nil values (#2193)
mpoke Aug 29, 2024
45c5fce
fix!: msgs validation (#2195)
mpoke Aug 30, 2024
b874510
fix: fix queries' API REST endpoint path (#2196)
sainoe Aug 30, 2024
9bbd274
fix: permissionless query (#2191)
bermuell Aug 30, 2024
6262e42
refactor: mostly refactors (#2194)
mpoke Aug 30, 2024
e1b1dc2
fix!: provider msg validation (#2197)
mpoke Sep 2, 2024
4f2194c
test: fix e2e tests + PSS e2e tests use permissionless (#2192)
bermuell Sep 3, 2024
5f1a27c
refactor: power shaping (#2207)
mpoke Sep 3, 2024
92102af
fix merge conflicts
mpoke Sep 3, 2024
cb6b525
fix merge conflicts
mpoke Sep 3, 2024
7301916
feat: fix queries (#2209)
mpoke Sep 4, 2024
3cc9ba2
fix!: remove `stopTime` from `MsgRemoveConsumer` (#2208)
insumity Sep 4, 2024
68f0ab4
feat: remove provider migration for CV 3 to 6 (#2211)
mpoke Sep 4, 2024
f85677c
fix!: fix migration issue (#2214)
insumity Sep 4, 2024
954f77c
fix!: register `ConsumerModificationProposal` and others (#2215)
insumity Sep 4, 2024
e7117ee
fix: fix misbehaviour and equivocation evidence CLI commands (#2213)
sainoe Sep 5, 2024
cea9707
nit: remove type prefix from consumer phase enum (#2220)
sainoe Sep 5, 2024
ffd3ae0
resolve merge conflicts
mpoke Sep 5, 2024
6dc36bc
refactor: stop using signer field in messages (#2219)
mpoke Sep 5, 2024
2278726
chore: update TX CLI help (#2222)
mpoke Sep 5, 2024
be2deee
feat!: add events for provider messages (#2221)
mpoke Sep 5, 2024
96b9bcf
fix UT
mpoke Sep 5, 2024
7994f30
remove duplicate AttributeSubmitterAddress
mpoke Sep 5, 2024
4660b49
fix: fix queries' API endpoints (#2226)
sainoe Sep 5, 2024
d13fbb0
fix!: replace CanLaunch with InitializeConsumer (#2224)
mpoke Sep 6, 2024
129164c
fix: improve commands' description (#2227)
insumity Sep 6, 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
Original file line number Diff line number Diff line change
@@ -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))
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
14 changes: 8 additions & 6 deletions proto/interchain_security/ccv/provider/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
import "interchain_security/ccv/provider/v1/provider.proto";

// GenesisState defines the CCV provider chain genesis state
message GenesisState {

Check failure on line 13 in proto/interchain_security/ccv/provider/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "6" with name "consumer_addition_proposals" on message "GenesisState" was deleted.

Check failure on line 13 in proto/interchain_security/ccv/provider/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present field "7" with name "consumer_removal_proposals" on message "GenesisState" was deleted.
// Reserve 3rd slot for removed unbonding_ops field
reserved 3;

// 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;

Expand All @@ -36,12 +42,6 @@
// 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
Expand Down Expand Up @@ -78,6 +78,8 @@
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
Expand Down
123 changes: 123 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`.
mpoke marked this conversation as resolved.
Show resolved Hide resolved
// 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`.
mpoke marked this conversation as resolved.
Show resolved Hide resolved
// 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`.
mpoke marked this conversation as resolved.
Show resolved Hide resolved
// 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 {
mpoke marked this conversation as resolved.
Show resolved Hide resolved
string channel_id = 1;
Expand Down Expand Up @@ -362,3 +366,122 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a comment that this is just a string. It can be a JSON string etc. The chain shouldnot care if it's a URL or not.

string metadata = 3;
mpoke marked this conversation as resolved.
Show resolved Hide resolved
}

// 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; }

// 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.
// 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;
// DELETED defines the phase in which the state of a stopped chain has been deleted.
CONSUMER_PHASE_DELETED = 5;
}
Loading
Loading