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 21, 2024
1 parent acc3788 commit 1016954
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/interchain-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
matrix:
${{fromJson(needs.prepare-matrix.outputs.matrix)}}
fail-fast: false
max-parallel: 10
max-parallel: 3
steps:
- name: Check out repository code
uses: actions/checkout@v4
Expand Down
14 changes: 7 additions & 7 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 Expand Up @@ -576,7 +576,7 @@ func (p *Chain) CheckCCV(ctx context.Context, consumer *Chain, relayer *Relayer,
}
}

tCtx, tCancel := context.WithTimeout(ctx, 5*time.Minute)
tCtx, tCancel := context.WithTimeout(ctx, 15*time.Minute)
defer tCancel()
var retErr error
for tCtx.Err() == nil {
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
23 changes: 18 additions & 5 deletions tests/interchain/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"testing"

"github.com/cosmos/gaia/v21/tests/interchain/chainsuite"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/tidwall/gjson"
Expand Down Expand Up @@ -91,12 +93,23 @@ func (s *ConsensusSuite) SetupSuite() {

cfg := chainsuite.ConsumerConfig{
ChainName: "ics-consumer",
Version: "v5.0.0",
Version: "v6.2.1",
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: "v6.2.1",
UidGid: chainsuite.ICSUidGuid,
},
},
},
},
}
consumer, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg)
s.Require().NoError(err)
Expand All @@ -116,7 +129,7 @@ func (s *ConsensusSuite) Test0ValidatorSets() {
s.Require().Equal(s.Chain.ValidatorWallets[i].ValConsAddress, valCons)
}

vals, err = s.Consumer.QueryJSON(s.GetContext(), "validators", "comet-validator-set")
vals, err = s.Consumer.QueryJSON(s.GetContext(), "validators", "tendermint-validator-set")
s.Require().NoError(err)
s.Require().Equal(maxProviderConsensusValidators, len(vals.Array()), vals)
for i := 0; i < maxProviderConsensusValidators; i++ {
Expand Down Expand Up @@ -168,7 +181,7 @@ func (s *ConsensusSuite) TestOptInInactive() {
s.Require().NoError(err)
s.Relayer.ClearCCVChannel(s.GetContext(), s.Chain, s.Consumer)
s.Require().EventuallyWithT(func(c *assert.CollectT) {
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "comet-validator-set")
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "tendermint-validator-set")
assert.NoError(c, err)
assert.Equal(c, maxProviderConsensusValidators, len(vals.Array()), vals)
}, 10*chainsuite.CommitTimeout, chainsuite.CommitTimeout)
Expand All @@ -178,7 +191,7 @@ func (s *ConsensusSuite) TestOptInInactive() {
}()
s.Require().NoError(s.Relayer.ClearCCVChannel(s.GetContext(), s.Chain, s.Consumer))
s.Require().EventuallyWithT(func(c *assert.CollectT) {
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "comet-validator-set")
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "tendermint-validator-set")
assert.NoError(c, err)
assert.Equal(c, maxProviderConsensusValidators+1, len(vals.Array()), vals)
}, 10*chainsuite.CommitTimeout, chainsuite.CommitTimeout)
Expand All @@ -189,7 +202,7 @@ func (s *ConsensusSuite) TestOptInInactive() {
_, err = s.Chain.Validators[5].ExecTx(s.GetContext(), s.Chain.ValidatorWallets[5].Moniker, "provider", "opt-in", consumerID)
s.Require().NoError(err)
s.Require().NoError(s.Relayer.ClearCCVChannel(s.GetContext(), s.Chain, s.Consumer))
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "comet-validator-set")
vals, err := s.Consumer.QueryJSON(s.GetContext(), "validators", "tendermint-validator-set")
s.Require().NoError(err)
s.Require().Equal(maxProviderConsensusValidators+1, len(vals.Array()), vals)
jailed, err = s.Chain.IsValidatorJailedForConsumerDowntime(s.GetContext(), s.Relayer, s.Consumer, 5)
Expand Down
84 changes: 57 additions & 27 deletions tests/interchain/consumer_launch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -67,42 +84,53 @@ func (s *ConsumerLaunchSuite) TestChainLaunch() {
s.Require().False(jailed, "validator 5 should not be jailed for downtime")
}

func TestICS40ChainLaunch(t *testing.T) {
func selectConsumerVersion(preV21, postV21 string) string {
if semver.Compare(semver.Major(chainsuite.GetEnvironment().OldGaiaImageVersion), "v21") >= 0 {
return postV21
}
return preV21
}

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: selectConsumerVersion("v4.4.1", "v4.5.0"),
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: selectConsumerVersion("v6.0.0", "v6.2.1"),
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: selectConsumerVersion("v6.0.0", "v6.2.1"),
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: selectConsumerVersion("v6.0.0", "v6.2.1"),
OtherChainVersionPostUpgrade: "v6.2.1",
ShouldCopyProviderKey: noProviderKeysCopied(),
}
suite.Run(t, s)
}
Expand All @@ -112,11 +140,13 @@ type MainnetConsumerChainsSuite struct {
}

func (s *MainnetConsumerChainsSuite) TestMainnetConsumerChainsAfterUpgrade() {
const neutronVersion = "v3.0.2"

// We can't do these consumer launches yet because the chains aren't compatible with launching on v21 yet
if semver.Major(s.Env.OldGaiaImageVersion) == s.Env.UpgradeName && s.Env.UpgradeName == "v21" {
s.T().Skip("Skipping Consumer Launch tests when going from v21 -> v21")
}
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
6 changes: 6 additions & 0 deletions tests/interchain/lsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -455,6 +456,11 @@ 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) == s.Env.UpgradeName && s.Env.UpgradeName == "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,
Expand Down
4 changes: 4 additions & 0 deletions tests/interchain/matrix_tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand/v2"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -105,6 +106,9 @@ func GetTestList() ([]string, error) {
retval = append(retval, line)
}
}
rand.Shuffle(len(retval), func(i, j int) {
retval[i], retval[j] = retval[j], retval[i]
})
return retval, nil
}

Expand Down
Loading

0 comments on commit 1016954

Please sign in to comment.