Skip to content

Commit

Permalink
feat: make the repo for the genesis-transform command configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfadingviolets committed Jan 8, 2025
1 parent ed0a63d commit ec3fbb4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
36 changes: 32 additions & 4 deletions chain/cosmos/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
const (
icsVer330 = "v3.3.0"
icsVer400 = "v4.0.0"
icsVer450 = "v4.5.0"
icsVer640 = "v6.4.0"
)

// FinishICSProviderSetup sets up the base of an ICS connection with respect to the relayer, provider actions, and flushing of packets.
Expand Down Expand Up @@ -447,9 +449,31 @@ func (c *CosmosChain) transformCCVState(ctx context.Context, ccvState []byte, co
if semver.Compare(providerVersion, icsVer400) > 0 {
imageVersion = providerVersion
}
toVersion = semver.Major(consumerVersion)
if toVersion == "v3" {
toVersion = semver.MajorMinor(consumerVersion)
if (semver.Major(providerVersion) == "v4" && semver.Compare(providerVersion, icsVer450) > 0) ||
(semver.Major(providerVersion) == "v6" && semver.Compare(providerVersion, icsVer640) > 0) {
switch semver.Major(consumerVersion) {
case "v4":
if semver.Compare("v4.5.0", consumerVersion) >= 0 {
toVersion = "v4.5"
} else {
toVersion = "<v4.5"
}
case "v5":
toVersion = "v5"
case "v6":
toVersion = "<v6.4"
}
} else {
switch semver.Major(consumerVersion) {
case "v5":
toVersion = "v5"
case "v4":
toVersion = "v4"
case "v3":
toVersion = semver.MajorMinor(consumerVersion)
case "v2":
toVersion = "v2"
}
}
} else {
imageVersion = consumerVersion
Expand All @@ -461,8 +485,12 @@ func (c *CosmosChain) transformCCVState(ctx context.Context, ccvState []byte, co
if err != nil {
return nil, fmt.Errorf("failed to write ccv state to file: %w", err)
}
repo := icsCfg.ICSImageRepo
if repo == "" {
repo = "ghcr.io/strangelove-ventures/heighliner/ics"
}
job := dockerutil.NewImage(c.log, c.GetNode().DockerClient, c.GetNode().NetworkID,
c.GetNode().TestName, "ghcr.io/strangelove-ventures/heighliner/ics", imageVersion,
c.GetNode().TestName, repo, imageVersion,
)
cmd := []string{"interchain-security-cd", "genesis", "transform"}
if toVersion != "" {
Expand Down
1 change: 1 addition & 0 deletions ibc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ type ICSConfig struct {
ProviderVerOverride string `yaml:"provider,omitempty" json:"provider,omitempty"`
ConsumerVerOverride string `yaml:"consumer,omitempty" json:"consumer,omitempty"`
ConsumerCopyProviderKey func(int) bool `yaml:"-" json:"-"`
ICSImageRepo string `yaml:"ics-image-repo,omitempty" json:"ics-image-repo,omitempty"`
}

// GenesisConfig is used to start a chain from a pre-defined genesis state.
Expand Down

0 comments on commit ec3fbb4

Please sign in to comment.