Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test updated ICS consumer versions.
Browse files Browse the repository at this point in the history
fastfadingviolets committed Oct 16, 2024
1 parent cf3a80d commit 436153c
Showing 5 changed files with 154 additions and 88 deletions.
12 changes: 6 additions & 6 deletions tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
@@ -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),
57 changes: 34 additions & 23 deletions tests/interchain/chainsuite/config.go
Original file line number Diff line number Diff line change
@@ -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
89 changes: 62 additions & 27 deletions tests/interchain/consumer_launch_test.go
Original file line number Diff line number Diff line change
@@ -3,16 +3,20 @@ package interchain_test
import (
"testing"

"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/stretchr/testify/suite"
"golang.org/x/mod/semver"

"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 {
@@ -30,10 +34,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)
@@ -53,6 +68,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 +84,62 @@ 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) {
preUpgrade := "v4.4.1"
if semver.Compare(chainsuite.GetEnvironment().OldGaiaImageVersion, "v21.0.0") >= 0 {
preUpgrade = "v4.5.0"
}
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: preUpgrade,
OtherChainVersionPostUpgrade: "v4.5.0",
ShouldCopyProviderKey: noProviderKeysCopied(),
}
suite.Run(t, s)
}

func TestICS33ConsumerAllKeysChainLaunch(t *testing.T) {
func TestICS6ConsumerAllKeysChainLaunch(t *testing.T) {
preUpgrade := "v6.0.0"
if semver.Compare(chainsuite.GetEnvironment().OldGaiaImageVersion, "v21.0.0") >= 0 {
preUpgrade = "v6.2.1"
}
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: preUpgrade,
OtherChainVersionPostUpgrade: "v6.2.1",
ShouldCopyProviderKey: allProviderKeysCopied(),
}
suite.Run(t, s)
}

func TestICS33ConsumerSomeKeysChainLaunch(t *testing.T) {
func TestICS6ConsumerSomeKeysChainLaunch(t *testing.T) {
preUpgrade := "v6.0.0"
if semver.Compare(chainsuite.GetEnvironment().OldGaiaImageVersion, "v21.0.0") >= 0 {
preUpgrade = "v6.2.1"
}
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: preUpgrade,
OtherChainVersionPostUpgrade: "v6.2.1",
ShouldCopyProviderKey: someProviderKeysCopied(),
}
suite.Run(t, s)
}

func TestICS33ConsumerNoKeysChainLaunch(t *testing.T) {
func TestICS6ConsumerNoKeysChainLaunch(t *testing.T) {
preUpgrade := "v6.0.0"
if semver.Compare(chainsuite.GetEnvironment().OldGaiaImageVersion, "v21.0.0") >= 0 {
preUpgrade = "v6.2.1"
}
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: preUpgrade,
OtherChainVersionPostUpgrade: "v6.2.1",
ShouldCopyProviderKey: noProviderKeysCopied(),
}
suite.Run(t, s)
}
@@ -112,11 +149,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,
7 changes: 7 additions & 0 deletions tests/interchain/lsm_test.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import (
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"golang.org/x/mod/semver"
"golang.org/x/sync/errgroup"
)

@@ -455,6 +456,12 @@ func (s *LSMSuite) setupLSMWallets() {

func (s *LSMSuite) SetupSuite() {
s.Suite.SetupSuite()
// This is slightly broken while stride is still in the process of being upgraded, so skip if
// going from v21 -> v21
if semver.Major(s.Env.OldGaiaImageVersion) == semver.Major(s.Env.NewGaiaImageVersion) &&
semver.Major(s.Env.OldGaiaImageVersion) == "v21" {
s.T().Skip("Skipping LSM when going from v21 -> v21")
}
stride, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, chainsuite.ConsumerConfig{
ChainName: "stride",
Version: chainsuite.StrideVersion,
77 changes: 45 additions & 32 deletions tests/interchain/permissionless_test.go
Original file line number Diff line number Diff line change
@@ -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",
@@ -676,6 +678,45 @@ func (s *PermissionlessConsumersSuite) TestRewardsWithChangeover() {
s.Require().True(rewards.GT(sdkmath.NewInt(0)), "rewards: %s", rewards.String())
}

func TestPermissionlessConsumers(t *testing.T) {
genesis := chainsuite.DefaultGenesis()
genesis = append(genesis,
cosmos.NewGenesisKV("app_state.gov.params.max_deposit_period", permissionlessDepositPeriod.String()),
)
s := &PermissionlessConsumersSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
Scope: chainsuite.ChainScopeTest,
ChainSpec: &interchaintest.ChainSpec{
ChainConfig: ibc.ChainConfig{
ModifyGenesis: cosmos.ModifyGenesis(genesis),
},
},
}),
consumerCfg: chainsuite.ConsumerConfig{
ChainName: "ics-consumer",
Version: "v4.5.0",
ShouldCopyProviderKey: allProviderKeysCopied(),
Denom: chainsuite.Ucon,
TopN: 100,
AllowInactiveVals: true,
MinStake: 1_000_000,
Spec: &interchaintest.ChainSpec{
ChainConfig: ibc.ChainConfig{
Images: []ibc.DockerImage{
{
Repository: chainsuite.HyphaICSRepo,
Version: "v4.5.0",
UidGid: chainsuite.ICSUidGuid,
},
},
},
},
},
}
suite.Run(t, s)
}

func (s *PermissionlessConsumersSuite) changeSovereignToConsumer(consumer *chainsuite.Chain, transferCh *ibc.ChannelOutput) {
cfg := s.consumerCfg
cfg.TopN = 0
@@ -771,34 +812,6 @@ func (s *PermissionlessConsumersSuite) changeSovereignToConsumer(consumer *chain
s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer, s.Relayer, 1_000_000, 0, 1))
}

func TestPermissionlessConsumers(t *testing.T) {
genesis := chainsuite.DefaultGenesis()
genesis = append(genesis,
cosmos.NewGenesisKV("app_state.gov.params.max_deposit_period", permissionlessDepositPeriod.String()),
)
s := &PermissionlessConsumersSuite{
Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{
CreateRelayer: true,
Scope: chainsuite.ChainScopeTest,
ChainSpec: &interchaintest.ChainSpec{
ChainConfig: ibc.ChainConfig{
ModifyGenesis: cosmos.ModifyGenesis(genesis),
},
},
}),
consumerCfg: chainsuite.ConsumerConfig{
ChainName: "ics-consumer",
Version: "v5.0.0",
ShouldCopyProviderKey: allProviderKeysCopied(),
Denom: chainsuite.Ucon,
TopN: 100,
AllowInactiveVals: true,
MinStake: 1_000_000,
},
}
suite.Run(t, s)
}

func (s *PermissionlessConsumersSuite) submitChangeRewardDenoms(consumer *chainsuite.Chain) (string, string) {
consumerCh, err := s.Relayer.GetTransferChannel(s.GetContext(), s.Chain, consumer)
s.Require().NoError(err)

0 comments on commit 436153c

Please sign in to comment.