diff --git a/tests/interchain/chainsuite/chain_ics.go b/tests/interchain/chainsuite/chain_ics.go index 51bf18d7cf..0795fceebe 100644 --- a/tests/interchain/chainsuite/chain_ics.go +++ b/tests/interchain/chainsuite/chain_ics.go @@ -15,7 +15,6 @@ import ( "github.com/tidwall/gjson" "github.com/tidwall/sjson" "go.uber.org/multierr" - "golang.org/x/mod/semver" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" @@ -126,11 +125,12 @@ func (p *Chain) AddConsumerChain(ctx context.Context, relayer *Relayer, config C } } - if config.Spec == nil { - config.Spec = p.DefaultConsumerChainSpec(ctx, chainID, config, spawnTime, proposalWaiter) - } - if semver.Compare(p.GetNode().ICSVersion(ctx), "v4.1.0") > 0 && config.Spec.InterchainSecurityConfig.ProviderVerOverride == "" { - config.Spec.InterchainSecurityConfig.ProviderVerOverride = "v4.1.0" + defaultSpec := p.DefaultConsumerChainSpec(ctx, chainID, config, spawnTime, proposalWaiter) + config.Spec = MergeChainSpecs(defaultSpec, config.Spec) + providerICS := p.GetNode().ICSVersion(ctx) + if config.Spec.InterchainSecurityConfig.ConsumerVerOverride == "" { + // This will disable the genesis transform + config.Spec.InterchainSecurityConfig.ConsumerVerOverride = providerICS } cf := interchaintest.NewBuiltinChainFactory( GetLogger(ctx), diff --git a/tests/interchain/chainsuite/config.go b/tests/interchain/chainsuite/config.go index 8703a6a282..0ff1ef2f22 100644 --- a/tests/interchain/chainsuite/config.go +++ b/tests/interchain/chainsuite/config.go @@ -50,33 +50,44 @@ const ( SlashingWindowConsumer = 20 BlocksPerDistribution = 10 StrideVersion = "v22.0.0" + NeutronVersion = "v3.0.2" TransferPortID = "transfer" + // This is needed because not every ics image is in the default heighliner registry + HyphaICSRepo = "ghcr.io/hyphacoop/ics" + ICSUidGuid = "1025:1025" ) -func (c SuiteConfig) Merge(other SuiteConfig) SuiteConfig { - if c.ChainSpec == nil { - c.ChainSpec = other.ChainSpec - } else if other.ChainSpec != nil { - c.ChainSpec.ChainConfig = c.ChainSpec.MergeChainSpecConfig(other.ChainSpec.ChainConfig) - if other.ChainSpec.Name != "" { - c.ChainSpec.Name = other.ChainSpec.Name - } - if other.ChainSpec.ChainName != "" { - c.ChainSpec.ChainName = other.ChainSpec.ChainName - } - if other.ChainSpec.Version != "" { - c.ChainSpec.Version = other.ChainSpec.Version - } - if other.ChainSpec.NoHostMount != nil { - c.ChainSpec.NoHostMount = other.ChainSpec.NoHostMount - } - if other.ChainSpec.NumValidators != nil { - c.ChainSpec.NumValidators = other.ChainSpec.NumValidators - } - if other.ChainSpec.NumFullNodes != nil { - c.ChainSpec.NumFullNodes = other.ChainSpec.NumFullNodes - } +func MergeChainSpecs(spec, other *interchaintest.ChainSpec) *interchaintest.ChainSpec { + if spec == nil { + return other + } + if other == nil { + return spec + } + spec.ChainConfig = spec.MergeChainSpecConfig(other.ChainConfig) + if other.Name != "" { + spec.Name = other.Name + } + if other.ChainName != "" { + spec.ChainName = other.ChainName + } + if other.Version != "" { + spec.Version = other.Version + } + if other.NoHostMount != nil { + spec.NoHostMount = other.NoHostMount } + if other.NumValidators != nil { + spec.NumValidators = other.NumValidators + } + if other.NumFullNodes != nil { + spec.NumFullNodes = other.NumFullNodes + } + return spec +} + +func (c SuiteConfig) Merge(other SuiteConfig) SuiteConfig { + c.ChainSpec = MergeChainSpecs(c.ChainSpec, other.ChainSpec) c.UpgradeOnSetup = other.UpgradeOnSetup c.CreateRelayer = other.CreateRelayer c.Scope = other.Scope diff --git a/tests/interchain/consumer_launch_test.go b/tests/interchain/consumer_launch_test.go index 5990aa546c..b0684691e0 100644 --- a/tests/interchain/consumer_launch_test.go +++ b/tests/interchain/consumer_launch_test.go @@ -3,6 +3,8 @@ package interchain_test import ( "testing" + "github.com/strangelove-ventures/interchaintest/v8" + "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/stretchr/testify/suite" "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" @@ -10,9 +12,10 @@ import ( type ConsumerLaunchSuite struct { *chainsuite.Suite - OtherChain string - OtherChainVersion string - ShouldCopyProviderKey [chainsuite.ValidatorCount]bool + OtherChain string + OtherChainVersionPreUpgrade string + OtherChainVersionPostUpgrade string + ShouldCopyProviderKey [chainsuite.ValidatorCount]bool } func noProviderKeysCopied() [chainsuite.ValidatorCount]bool { @@ -30,10 +33,21 @@ func someProviderKeysCopied() [chainsuite.ValidatorCount]bool { func (s *ConsumerLaunchSuite) TestChainLaunch() { cfg := chainsuite.ConsumerConfig{ ChainName: s.OtherChain, - Version: s.OtherChainVersion, + Version: s.OtherChainVersionPreUpgrade, ShouldCopyProviderKey: s.ShouldCopyProviderKey, Denom: chainsuite.Ucon, TopN: 94, + Spec: &interchaintest.ChainSpec{ + ChainConfig: ibc.ChainConfig{ + Images: []ibc.DockerImage{ + { + Repository: chainsuite.HyphaICSRepo, + Version: s.OtherChainVersionPreUpgrade, + UidGid: chainsuite.ICSUidGuid, + }, + }, + }, + }, } consumer, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg) s.Require().NoError(err) @@ -42,6 +56,8 @@ func (s *ConsumerLaunchSuite) TestChainLaunch() { s.UpgradeChain() + s.Require().NoError(consumer.ReplaceImagesAndRestart(s.GetContext(), s.OtherChainVersionPostUpgrade)) + err = s.Chain.CheckCCV(s.GetContext(), consumer, s.Relayer, 1_000_000, 0, 1) s.Require().NoError(err) s.Require().NoError(chainsuite.SendSimpleIBCTx(s.GetContext(), s.Chain, consumer, s.Relayer)) @@ -53,6 +69,8 @@ func (s *ConsumerLaunchSuite) TestChainLaunch() { s.Require().NoError(err) s.Require().False(jailed, "validator 5 should not be jailed for downtime") + cfg.Version = s.OtherChainVersionPostUpgrade + cfg.Spec.ChainConfig.Images[0].Version = s.OtherChainVersionPostUpgrade consumer2, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg) s.Require().NoError(err) err = s.Chain.CheckCCV(s.GetContext(), consumer2, s.Relayer, 1_000_000, 0, 1) @@ -67,42 +85,46 @@ func (s *ConsumerLaunchSuite) TestChainLaunch() { s.Require().False(jailed, "validator 5 should not be jailed for downtime") } -func TestICS40ChainLaunch(t *testing.T) { +func TestICS4ChainLaunch(t *testing.T) { s := &ConsumerLaunchSuite{ - Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), - OtherChain: "ics-consumer", - OtherChainVersion: "v4.0.0", - ShouldCopyProviderKey: noProviderKeysCopied(), + Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), + OtherChain: "ics-consumer", + OtherChainVersionPreUpgrade: "v4.4.1", + OtherChainVersionPostUpgrade: "v4.5.0", + ShouldCopyProviderKey: noProviderKeysCopied(), } suite.Run(t, s) } -func TestICS33ConsumerAllKeysChainLaunch(t *testing.T) { +func TestICS6ConsumerAllKeysChainLaunch(t *testing.T) { s := &ConsumerLaunchSuite{ - Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), - OtherChain: "ics-consumer", - OtherChainVersion: "v3.3.0", - ShouldCopyProviderKey: allProviderKeysCopied(), + Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), + OtherChain: "ics-consumer", + OtherChainVersionPreUpgrade: "v6.0.0", + OtherChainVersionPostUpgrade: "v6.2.1", + ShouldCopyProviderKey: allProviderKeysCopied(), } suite.Run(t, s) } -func TestICS33ConsumerSomeKeysChainLaunch(t *testing.T) { +func TestICS6ConsumerSomeKeysChainLaunch(t *testing.T) { s := &ConsumerLaunchSuite{ - Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), - OtherChain: "ics-consumer", - OtherChainVersion: "v3.3.0", - ShouldCopyProviderKey: someProviderKeysCopied(), + Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), + OtherChain: "ics-consumer", + OtherChainVersionPreUpgrade: "v6.0.0", + OtherChainVersionPostUpgrade: "v6.2.1", + ShouldCopyProviderKey: someProviderKeysCopied(), } suite.Run(t, s) } -func TestICS33ConsumerNoKeysChainLaunch(t *testing.T) { +func TestICS6ConsumerNoKeysChainLaunch(t *testing.T) { s := &ConsumerLaunchSuite{ - Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), - OtherChain: "ics-consumer", - OtherChainVersion: "v3.3.0", - ShouldCopyProviderKey: noProviderKeysCopied(), + Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{CreateRelayer: true}), + OtherChain: "ics-consumer", + OtherChainVersionPreUpgrade: "v6.0.0", + OtherChainVersionPostUpgrade: "v6.2.1", + ShouldCopyProviderKey: noProviderKeysCopied(), } suite.Run(t, s) } @@ -112,11 +134,9 @@ type MainnetConsumerChainsSuite struct { } func (s *MainnetConsumerChainsSuite) TestMainnetConsumerChainsAfterUpgrade() { - const neutronVersion = "v3.0.2" - neutron, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, chainsuite.ConsumerConfig{ ChainName: "neutron", - Version: neutronVersion, + Version: chainsuite.NeutronVersion, ShouldCopyProviderKey: allProviderKeysCopied(), Denom: chainsuite.NeutronDenom, TopN: 95, diff --git a/tests/interchain/permissionless_test.go b/tests/interchain/permissionless_test.go index 2ab438dc95..db2be9d5d6 100644 --- a/tests/interchain/permissionless_test.go +++ b/tests/interchain/permissionless_test.go @@ -607,8 +607,10 @@ func (s *PermissionlessConsumersSuite) TestRewardsWithChangeover() { cosmos.NewGenesisKV("app_state.gov.params.min_deposit.0.amount", strconv.Itoa(chainsuite.GovMinDepositAmount)), } spec := &interchaintest.ChainSpec{ - Name: "ics-consumer", - ChainName: "ics-consumer", + Name: "ics-consumer", + ChainName: "ics-consumer", + // Unfortunately, this rc is a bit of a bespoke version; it corresponds to an rc + // in hypha's fork that has a fix for sovereign -> consumer changeovers Version: "v6.2.0-rc1", NumValidators: &validators, NumFullNodes: &fullNodes, @@ -625,9 +627,9 @@ func (s *PermissionlessConsumersSuite) TestRewardsWithChangeover() { Bin: "interchain-security-sd", Images: []ibc.DockerImage{ { - Repository: "ghcr.io/hyphacoop/ics", + Repository: chainsuite.HyphaICSRepo, Version: "v6.2.0-rc1", - UidGid: "1025:1025", + UidGid: chainsuite.ICSUidGuid, }, }, Bech32Prefix: "consumer",