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!: enable standalone consumers to reuse existing clients for ICS #2400

Merged
merged 33 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
34409d7
add connection_id to init params
mpoke Nov 4, 2024
d496224
add message validation
mpoke Nov 4, 2024
29c8d9a
add preCCV and connection_id to ProviderInfo
mpoke Nov 4, 2024
85e9a53
move preccv and connId to ConsumerGenesisState
mpoke Nov 5, 2024
0540cbf
fix merge conflicts
mpoke Nov 7, 2024
049dd9e
add provider logic for non-empty connId
mpoke Nov 11, 2024
6c50702
Merge branch 'main' into marius/894-preccv
mpoke Nov 11, 2024
fa189f5
validate consumer genesis
mpoke Nov 13, 2024
81536d8
initiate CCV channel handshake
mpoke Nov 13, 2024
b07b3ab
fix UT
mpoke Nov 13, 2024
940596d
add changelog entries
mpoke Nov 13, 2024
5241586
fix merge conflicts
mpoke Nov 13, 2024
bc51f31
add TODO
mpoke Nov 13, 2024
1fa7866
fix indent
mpoke Nov 13, 2024
c3f1891
Merge branch 'main' into marius/894-preccv
stana-miric Dec 11, 2024
72e4064
changeover test
stana-miric Dec 12, 2024
4e034e1
Merge branch 'main' into marius/894-preccv
stana-miric Dec 23, 2024
d5c766a
remove setting preccv in app.go
mpoke Jan 2, 2025
57503fa
Merge branch 'main' into marius/894-preccv
mpoke Jan 2, 2025
226f710
Merge branch 'main' into marius/894-preccv
mpoke Jan 2, 2025
fad5f5b
add todos for genesis transformation
mpoke Jan 2, 2025
4d59eb2
interchain test desc added to testing.md
stana-miric Jan 6, 2025
7deec2d
update genesis transformation
stana-miric Jan 6, 2025
add1b5e
update changeover procedure docs
mpoke Jan 7, 2025
1dc3ea1
Update docs/docs/consumer-development/changeover-procedure.md
mpoke Jan 7, 2025
75a9826
Update docs/docs/consumer-development/changeover-procedure.md
mpoke Jan 7, 2025
c061b27
Update docs/docs/consumer-development/changeover-procedure.md
mpoke Jan 7, 2025
88f24ea
Update docs/docs/consumer-development/changeover-procedure.md
mpoke Jan 7, 2025
0c378eb
Update docs/docs/consumer-development/changeover-procedure.md
mpoke Jan 7, 2025
015037d
tests: remove unused e2e changeover [replaced by interchaintest]
MSalopek Jan 7, 2025
479421e
apply review suggestions
mpoke Jan 7, 2025
530b52d
Merge branch 'marius/894-preccv' of github.com:cosmos/interchain-secu…
mpoke Jan 7, 2025
36515a2
do not remove preCCV from consumer genesis state
mpoke Jan 7, 2025
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
12 changes: 12 additions & 0 deletions .changelog/unreleased/api-breaking/2400-preccv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- Enable existing (standalone) chains to use the existing client (and connection)
to the provider chain when becoming a consumer chain. This feature introduces
the following API-breaking changes.
([\#2400](https://github.com/cosmos/interchain-security/pull/2400))

- Add `connection_id` and `preCCV` to `ConsumerGenesisState`, the consumer
mpoke marked this conversation as resolved.
Show resolved Hide resolved
genesis state created by the provider chain. If the `connection_id` is not empty,
`preCCV` is set to true and both `provider.client_state` and `provider.consensus_state`
are set to nil (as the consumer doesn't need to create a new provider client).
As a result, for older versions of consumers, the `connection_id` in
`ConsumerInitializationParameters` must be empty and the resulting `ConsumerGenesisState`
needs to be adapted, i.e., both `connection_id` and `preCCV` need to be removed.
13 changes: 13 additions & 0 deletions .changelog/unreleased/features/2400-preccv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- Enable existing (standalone) chains to use the existing client (and connection)
to the provider chain when becoming a consumer chain. This feature introduces
the following changes.
([\#2400](https://github.com/cosmos/interchain-security/pull/2400))

- Add `connection_id` to `ConsumerInitializationParameters`, the ID of
the connection end _on the provider chain_ on top of which the CCV channel will
be established. Consumer chain owners can set `connection_id` to a valid ID in
order to reuse the underlying clients.
- Add `connection_id` to the consumer genesis state, the ID of the connection
end _on the consumer chain_ on top of which the CCV channel will be established.
If `connection_id` is a valid ID, then the consumer chain will use the underlying
client as the provider client and it will initiate the channel handshake.
3 changes: 3 additions & 0 deletions .changelog/unreleased/state-breaking/2400-preccv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Enable existing (standalone) chains to use the existing client (and connection)
to the provider chain when becoming a consumer chain.
([\#2400](https://github.com/cosmos/interchain-security/pull/2400))
37 changes: 19 additions & 18 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

The following table indicates the major ICS features available in the [currently active releases](./RELEASES.md#version-matrix):

| Feature | `v4.0.0` | `v4.4.0` | `v4.5.0` | `v5.0.0` | `v5.2.0` | `v6.1.0` | `v6.3.0` |
|---------|---------:|---------:|---------:|---------:|----------:|---------:|---------:|
| Feature | `v4.0.0` | `v4.4.0` | `v4.5.0` | `v5.0.0` | `v5.2.0` | `v6.1.0` | `v6.3.0` | `v6.4.0` |
|---------|---------:|---------:|---------:|---------:|----------:|---------:|---------:|---------:|
| [Channel initialization: new chains](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#channel-initialization-new-chains) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Validator set update](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#validator-set-update) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Completion of unbonding operations](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#completion-of-unbonding-operations) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Consumer initiated slashing](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#consumer-initiated-slashing) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Reward distribution](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#reward-distribution) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Consumer chain removal](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#consumer-chain-removal) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Key assignment](https://github.com/cosmos/interchain-security/issues/26) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Jail throttling](https://github.com/cosmos/interchain-security/issues/404) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Soft opt-out](https://github.com/cosmos/interchain-security/issues/851) | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
| [Channel initialization: existing chains](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#channel-initialization-existing-chains) (aka [Standalone to consumer changeover](https://github.com/cosmos/interchain-security/issues/756)) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Cryptographic verification of equivocation](https://github.com/cosmos/interchain-security/issues/732) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Jail throttling with retries](https://github.com/cosmos/interchain-security/issues/713) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [ICS epochs](https://cosmos.github.io/interchain-security/adrs/adr-014-epochs) | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Partial Set Security](https://cosmos.github.io/interchain-security/adrs/adr-015-partial-set-security) | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| [Inactive Provider Validators](https://cosmos.github.io/interchain-security/adrs/adr-017-allowing-inactive-validators) | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
| [Permissionless](https://cosmos.github.io/interchain-security/adrs/adr-019-permissionless-ics) | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
| [ICS Rewards in non-native denoms](https://github.com/cosmos/interchain-security/issues/1634) | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ |
| [Validator set update](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#validator-set-update) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Completion of unbonding operations](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#completion-of-unbonding-operations) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
| [Consumer initiated slashing](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#consumer-initiated-slashing) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Reward distribution](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#reward-distribution) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Consumer chain removal](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#consumer-chain-removal) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Key assignment](https://github.com/cosmos/interchain-security/issues/26) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Jail throttling](https://github.com/cosmos/interchain-security/issues/404) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Soft opt-out](https://github.com/cosmos/interchain-security/issues/851) | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
| [Channel initialization: existing chains](https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/overview_and_basic_concepts.md#channel-initialization-existing-chains) (aka [Standalone to consumer changeover](https://github.com/cosmos/interchain-security/issues/756)) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Cryptographic verification of equivocation](https://github.com/cosmos/interchain-security/issues/732) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Jail throttling with retries](https://github.com/cosmos/interchain-security/issues/713) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [ICS epochs](https://cosmos.github.io/interchain-security/adrs/adr-014-epochs) | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Partial Set Security](https://cosmos.github.io/interchain-security/adrs/adr-015-partial-set-security) | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
| [Inactive Provider Validators](https://cosmos.github.io/interchain-security/adrs/adr-017-allowing-inactive-validators) | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| [Permissionless](https://cosmos.github.io/interchain-security/adrs/adr-019-permissionless-ics) | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| [ICS Rewards in non-native denoms](https://github.com/cosmos/interchain-security/issues/1634) | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ |
| [Customizable Slashing and Jailing](https://cosmos.github.io/interchain-security/adrs/adr-020-cutomizable_slashing_and_jailing) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ test-integration-cov:
go test ./tests/integration/... -timeout 30m -coverpkg=./... -coverprofile=integration-profile.out -covermode=atomic

# run interchain tests
# we can use PROVIDER_IMAGE_TAG and PROVIDER_IMAGE_NAME to run tests with a desired docker image,
# including a locally built one that, for example, contains some of our changes that are not yet on the main branch.
# if not provided, default value for PROVIDER_IMAGE_TAG is "latest" and for PROVIDER_IMAGE_NAME "ghcr.io/cosmos/interchain-security"
# we can use PROVIDER_IMAGE_TAG, PROVIDER_IMAGE_NAME, SOUVEREIGN_IMAGE_TAG, and SOUVEREIGN_IMAGE_NAME to run tests with desired docker images,
# including locally built ones that, for example, contain some of our changes that are not yet on the main branch.
# if not provided, default value for PROVIDER_IMAGE_TAG and SOUVEREIGN_IMAGE_TAG is "latest" and for PROVIDER_IMAGE_NAME
# and SOUVEREIGN_IMAGE_NAME is "ghcr.io/cosmos/interchain-security"
test-interchain:
cd tests/interchain && PROVIDER_IMAGE_NAME=$(PROVIDER_IMAGE_NAME) PROVIDER_IMAGE_TAG=$(PROVIDER_IMAGE_TAG) go test ./... -timeout 30m
cd tests/interchain && \
PROVIDER_IMAGE_NAME=$(PROVIDER_IMAGE_NAME) \
PROVIDER_IMAGE_TAG=$(PROVIDER_IMAGE_TAG) \
SOUVEREIGN_IMAGE_NAME=$(SOUVEREIGN_IMAGE_NAME) \
SOUVEREIGN_IMAGE_TAG=$(SOUVEREIGN_IMAGE_TAG) \
go test ./... -timeout 30m

# run mbt tests
test-mbt:
Expand Down
19 changes: 11 additions & 8 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ All missing minor release versions have been discontinued.
| `v5.2.x` | May 9, 2025 |
| `v6.1.x` | Sep 13, 2025 |
| `v6.3.x` | Sep 13, 2025 |
| `v6.4.x` | Sep 13, 2025 |

## Version Matrix

Expand All @@ -80,6 +81,7 @@ Versions of Golang, IBC, Cosmos SDK and CometBFT used by ICS in the currently ac
| [v5.2.0](https://github.com/cosmos/interchain-security/releases/tag/v5.2.0) | 1.22 | v8.3.2 | v0.50.8 | v0.38.9 | |
| [v6.1.0](https://github.com/cosmos/interchain-security/releases/tag/v6.1.0) | 1.22 | v8.5.0 | v0.50.9 | v0.38.11 | |
| [v6.3.0](https://github.com/cosmos/interchain-security/releases/tag/v6.3.0) | 1.22 | v8.5.1 | v0.50.9 | v0.38.11 | |
| [v6.4.0](https://github.com/cosmos/interchain-security/releases/tag/v6.4.0) | 1.22 | v8.5.2 | v0.50.11 | v0.38.15 | |

**Note:** For a list of major ICS features available in the currently active releases, see [FEATURES.md](./FEATURES.md).

Expand All @@ -89,14 +91,15 @@ A MAJOR version of ICS will always be backwards compatible with the previous MAJ

The following table indicates the compatibility of currently active releases:

| Consumer | Provider | `v5.2.0` | `v6.1.0` | `v6.3.0` |
| -------- | -------- | -------- | -------- | -------- |
| `v4.0.0` | | ✅ | ✅ | ✅ (1) |
| `v4.4.0` | | ✅ | ✅ | ✅ (1) |
| `v4.5.0` | | ✅ | ✅ | ✅ |
| `v5.0.0` | | ✅ | ✅ | ✅ (1) |
| `v5.2.0` | | ✅ | ✅ | ✅ (1) |
| `v6.3.0` | | ✅ | ✅ | ✅ |
| Consumer | Provider | `v5.2.0` | `v6.1.0` | `v6.3.0` | `v6.4.0` |
| ------------------- | -------- | -------- | -------- | -------- | -------- |
| `v4.0.0` | | ✅ | ✅ | ✅ (1) | ✅ (1) |
| `v4.4.0` | | ✅ | ✅ | ✅ (1) | ✅ (1) |
| `v4.5.0` | | ✅ | ✅ | ✅ | ✅ (1) |
| `v5.0.0` | | ✅ | ✅ | ✅ (1) | ✅ (1) |
| `v5.2.0` | | ✅ | ✅ | ✅ (1) | ✅ (1) |
| `v6.2.0` / `v6.3.0` | | ✅ | ✅ | ✅ | ✅ (1) |
| `v6.4.0` | | ✅ | ✅ | ✅ | ✅ |

#### Notes
The following adjustments must be made to the CCV consumer genesis state that is obtained from the provider chain after the spawn time is reached in order for the consumer chain to start without errors.
Expand Down
2 changes: 0 additions & 2 deletions app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,6 @@ func New(

consumerGenesis := consumertypes.GenesisState{}
appCodec.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis)

consumerGenesis.PreCCV = true
app.ConsumerKeeper.InitGenesis(sdkCtx, &consumerGenesis)

app.Logger().Info("start to run module migrations...")
Expand Down
23 changes: 14 additions & 9 deletions app/consumer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ type GenesisState map[string]json.RawMessage
type IcsVersion string

const (
v4_x_x IcsVersion = "v4.x"
v5_x_x IcsVersion = "v5.x"
v4_x_x IcsVersion = "<v4.5.x" // all v4 versions < v4.5.0
v4_5_x IcsVersion = "v4.5.x"
v5_x_x IcsVersion = "v5.x" // all v5 version
v6_x_x IcsVersion = "<v6.4.x" // all v6 versions < v6.4.0
)

var TransformationVersions map[string]IcsVersion = map[string]IcsVersion{
"v4.x": v4_x_x,
"v5.x": v5_x_x,
"<v4.5.x": v4_x_x,
"v4.5.x": v4_5_x,
"v5.x": v5_x_x,
"<v6.4.x": v6_x_x,
}

// Remove a parameter from a JSON object
Expand All @@ -56,7 +60,7 @@ func removeParameterFromParams(params json.RawMessage, param string) (json.RawMe
// Transformation of consumer genesis content as it is exported by provider version >= v6.2.x
// to a format supported by consumer chains version with either SDK v0.47 and ICS < v4.5.0 or SDK v0.50 and ICS < v6.2.0
// This transformation removes the 'consumer_id' parameter from the 'params' field introduced in ICS v6.2.x
func transformToV5(jsonRaw []byte, ctx client.Context) (json.RawMessage, error) {
func removeConsumerID(jsonRaw []byte, ctx client.Context) (json.RawMessage, error) {
srcConGen := types.ConsumerGenesisState{}
err := ctx.Codec.UnmarshalJSON(jsonRaw, &srcConGen)
if err != nil {
Expand Down Expand Up @@ -100,7 +104,8 @@ func transformGenesis(ctx client.Context, targetVersion IcsVersion, jsonRaw []by

switch targetVersion {
case v4_x_x, v5_x_x:
newConsumerGenesis, err = transformToV5(jsonRaw, ctx)
newConsumerGenesis, err = removeConsumerID(jsonRaw, ctx)
// TODO: in addition, remove both `connection_id` and `preCCV` fields if target is v4_5_x or v6_x_x
mpoke marked this conversation as resolved.
Show resolved Hide resolved
default:
err = fmt.Errorf("unsupported target version '%s'. Run %s --help",
targetVersion, version.AppName)
Expand Down Expand Up @@ -165,17 +170,17 @@ func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
func GetConsumerGenesisTransformCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "transform [-to version] genesis-file",
Short: "Transform CCV consumer genesis data exported to a specific target format",
Short: "Transform consumer module genesis data exported to a specific target format",
Long: strings.TrimSpace(
fmt.Sprintf(`
Transform the consumer genesis data exported from a provider version v5.x v6.x to a specified consumer target version.
Transform the consumer genesis data exported from a provider version >= v6.3.x to a specified consumer target version.
The result is printed to STDOUT.

Note: Content to be transformed is not the consumer genesis file itself but the exported content from provider chain which is used to patch the consumer genesis file!

Example:
$ %s transform /path/to/ccv_consumer_genesis.json
$ %s --to v2.x transform /path/to/ccv_consumer_genesis.json
$ %s --to v5.x transform /path/to/ccv_consumer_genesis.json
`, version.AppName, version.AppName),
),
Args: cobra.RangeArgs(1, 2),
Expand Down
Loading
Loading