Skip to content

Commit

Permalink
Test updated ICS consumer versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfadingviolets committed Oct 16, 2024
1 parent cf3a80d commit eb0e35a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 60 deletions.
12 changes: 6 additions & 6 deletions tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down
57 changes: 34 additions & 23 deletions tests/interchain/chainsuite/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 47 additions & 27 deletions tests/interchain/consumer_launch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ 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"
)

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 {
Expand All @@ -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)
Expand All @@ -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))
Expand All @@ -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)
Expand All @@ -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)
}
Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions tests/interchain/permissionless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down

0 comments on commit eb0e35a

Please sign in to comment.