From 441854b5a863c9bde1686dca3f6fc0ecb23cef47 Mon Sep 17 00:00:00 2001 From: violet Date: Tue, 8 Oct 2024 12:01:39 -0400 Subject: [PATCH] ci: Test that rewards work with sovereign -> consumer changeovers --- .github/workflows/interchain-test.yml | 2 +- tests/interchain/chainsuite/chain.go | 4 +- tests/interchain/chainsuite/chain_ics.go | 137 ++++----------- tests/interchain/chainsuite/config.go | 57 +++--- tests/interchain/chainsuite/relayer.go | 133 +++++++++++--- tests/interchain/consensus_test.go | 23 ++- tests/interchain/consumer_launch_test.go | 84 ++++++--- tests/interchain/feemarket_test.go | 2 +- tests/interchain/go.mod | 4 +- tests/interchain/go.sum | 4 +- tests/interchain/ica_controller_test.go | 2 +- tests/interchain/lsm_test.go | 8 +- tests/interchain/matrix_tool/main.go | 4 + tests/interchain/permissionless_test.go | 214 ++++++++++++++++++++++- tests/interchain/pfm_test.go | 18 +- tests/interchain/unbonding_test.go | 13 +- 16 files changed, 501 insertions(+), 208 deletions(-) diff --git a/.github/workflows/interchain-test.yml b/.github/workflows/interchain-test.yml index 8de73e3264e..38b16906b1c 100644 --- a/.github/workflows/interchain-test.yml +++ b/.github/workflows/interchain-test.yml @@ -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 diff --git a/tests/interchain/chainsuite/chain.go b/tests/interchain/chainsuite/chain.go index 5a859817f77..cd1e6b5808f 100644 --- a/tests/interchain/chainsuite/chain.go +++ b/tests/interchain/chainsuite/chain.go @@ -237,10 +237,10 @@ func (c *Chain) GetValidatorHex(ctx context.Context, val int) (string, error) { } func getValidatorWallets(ctx context.Context, chain *Chain) ([]ValidatorWallet, error) { - wallets := make([]ValidatorWallet, ValidatorCount) + wallets := make([]ValidatorWallet, len(chain.Validators)) lock := new(sync.Mutex) eg := new(errgroup.Group) - for i := 0; i < ValidatorCount; i++ { + for i := range chain.Validators { i := i eg.Go(func() error { // This moniker is hardcoded into the chain's genesis process. diff --git a/tests/interchain/chainsuite/chain_ics.go b/tests/interchain/chainsuite/chain_ics.go index 6f0e15a1d17..03f0652ffa0 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" @@ -29,18 +28,20 @@ import ( type ConsumerBootstrapCb func(ctx context.Context, consumer *cosmos.CosmosChain) type ConsumerConfig struct { - ChainName string - Version string - Denom string - ShouldCopyProviderKey [ValidatorCount]bool - TopN int - ValidatorSetCap int - ValidatorPowerCap int - AllowInactiveVals bool - MinStake uint64 - Allowlist []string - Denylist []string - spec *interchaintest.ChainSpec + ChainName string + Version string + Denom string + ShouldCopyProviderKey [ValidatorCount]bool + TopN int + ValidatorSetCap int + ValidatorPowerCap int + AllowInactiveVals bool + MinStake uint64 + Allowlist []string + Denylist []string + InitialHeight uint64 + DistributionTransmissionChannel string + Spec *interchaintest.ChainSpec DuringDepositPeriod ConsumerBootstrapCb DuringVotingPeriod ConsumerBootstrapCb @@ -124,15 +125,16 @@ 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), - []*interchaintest.ChainSpec{config.spec}, + []*interchaintest.ChainSpec{config.Spec}, ) chains, err := cf.Chains(p.GetNode().TestName) if err != nil { @@ -203,7 +205,7 @@ func (p *Chain) AddConsumerChain(ctx context.Context, relayer *Relayer, config C if err := relayer.StartRelayer(ctx, rep); err != nil { return nil, err } - err = connectProviderConsumer(ctx, p, consumer, relayer) + err = relayer.ConnectProviderConsumer(ctx, p, consumer) if err != nil { return nil, err } @@ -212,10 +214,14 @@ func (p *Chain) AddConsumerChain(ctx context.Context, relayer *Relayer, config C } func (p *Chain) CreateConsumerPermissionless(ctx context.Context, chainID string, config ConsumerConfig, spawnTime time.Time) error { + revisionHeight := config.InitialHeight + if revisionHeight == 0 { + revisionHeight = 1 + } initParams := &providertypes.ConsumerInitializationParameters{ - InitialHeight: clienttypes.Height{RevisionNumber: clienttypes.ParseChainID(chainID), RevisionHeight: 1}, + InitialHeight: clienttypes.Height{RevisionNumber: clienttypes.ParseChainID(chainID), RevisionHeight: revisionHeight}, SpawnTime: spawnTime, - BlocksPerDistributionTransmission: 1000, + BlocksPerDistributionTransmission: BlocksPerDistribution, CcvTimeoutPeriod: 2419200000000000, TransferTimeoutPeriod: 3600000000000, ConsumerRedistributionFraction: "0.75", @@ -223,6 +229,7 @@ func (p *Chain) CreateConsumerPermissionless(ctx context.Context, chainID string UnbondingPeriod: 1728000000000000, GenesisHash: []byte("Z2VuX2hhc2g="), BinaryHash: []byte("YmluX2hhc2g="), + DistributionTransmissionChannel: config.DistributionTransmissionChannel, } powerShapingParams := &providertypes.PowerShapingParameters{ Top_N: 0, @@ -453,83 +460,6 @@ func (p *Chain) DefaultConsumerChainSpec(ctx context.Context, chainID string, co } } -func connectProviderConsumer(ctx context.Context, provider *Chain, consumer *Chain, relayer *Relayer) error { - icsPath := relayerICSPathFor(provider, consumer) - rep := GetRelayerExecReporter(ctx) - if err := relayer.GeneratePath(ctx, rep, consumer.Config().ChainID, provider.Config().ChainID, icsPath); err != nil { - return err - } - - consumerClients, err := relayer.GetClients(ctx, rep, consumer.Config().ChainID) - if err != nil { - return err - } - - var consumerClient *ibc.ClientOutput - for _, client := range consumerClients { - if client.ClientState.ChainID == provider.Config().ChainID { - consumerClient = client - break - } - } - if consumerClient == nil { - return fmt.Errorf("consumer chain %s does not have a client tracking the provider chain %s", consumer.Config().ChainID, provider.Config().ChainID) - } - consumerClientID := consumerClient.ClientID - - providerClients, err := relayer.GetClients(ctx, rep, provider.Config().ChainID) - if err != nil { - return err - } - - var providerClient *ibc.ClientOutput - for _, client := range providerClients { - if client.ClientState.ChainID == consumer.Config().ChainID { - providerClient = client - break - } - } - if providerClient == nil { - return fmt.Errorf("provider chain %s does not have a client tracking the consumer chain %s for path %s on relayer %s", - provider.Config().ChainID, consumer.Config().ChainID, icsPath, relayer) - } - providerClientID := providerClient.ClientID - - if err := relayer.UpdatePath(ctx, rep, icsPath, ibc.PathUpdateOptions{ - SrcClientID: &consumerClientID, - DstClientID: &providerClientID, - }); err != nil { - return err - } - - if err := relayer.CreateConnections(ctx, rep, icsPath); err != nil { - return err - } - - if err := relayer.CreateChannel(ctx, rep, icsPath, ibc.CreateChannelOptions{ - SourcePortName: "consumer", - DestPortName: "provider", - Order: ibc.Ordered, - Version: "1", - }); err != nil { - return err - } - - tCtx, tCancel := context.WithTimeout(ctx, 30*CommitTimeout) - defer tCancel() - for tCtx.Err() == nil { - var ch *ibc.ChannelOutput - ch, err = relayer.GetTransferChannel(ctx, provider, consumer) - if err == nil && ch != nil { - break - } else if err == nil { - err = fmt.Errorf("channel not found") - } - time.Sleep(CommitTimeout) - } - return err -} - func (p *Chain) SubmitConsumerAdditionProposal(ctx context.Context, chainID string, config ConsumerConfig, spawnTime time.Time) (*proposalWaiter, chan error, error) { propWaiter := newProposalWaiter() prop := p.buildConsumerAdditionJSON(chainID, config, spawnTime) @@ -577,7 +507,7 @@ func (p *Chain) buildConsumerAdditionJSON(chainID string, config ConsumerConfig, BinaryHash: []byte("bin_hash"), SpawnTime: spawnTime, - BlocksPerDistributionTransmission: 1000, + BlocksPerDistributionTransmission: BlocksPerDistribution, CcvTimeoutPeriod: 2419200000000000, TransferTimeoutPeriod: 3600000000000, ConsumerRedistributionFraction: "0.75", @@ -646,6 +576,13 @@ func (p *Chain) CheckCCV(ctx context.Context, consumer *Chain, relayer *Relayer, } } + if err := relayer.ClearCCVChannel(ctx, p, consumer); err != nil { + return err + } + if err := testutil.WaitForBlocks(ctx, 2, p, consumer); err != nil { + return err + } + tCtx, tCancel := context.WithTimeout(ctx, 15*time.Minute) defer tCancel() var retErr error diff --git a/tests/interchain/chainsuite/config.go b/tests/interchain/chainsuite/config.go index 8703a6a2828..0ff1ef2f222 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/chainsuite/relayer.go b/tests/interchain/chainsuite/relayer.go index b13add4f7ad..26a64d48891 100644 --- a/tests/interchain/chainsuite/relayer.go +++ b/tests/interchain/chainsuite/relayer.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "fmt" + "sort" + "time" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" @@ -49,37 +51,30 @@ func (r *Relayer) GetChannelWithPort(ctx context.Context, chain, counterparty *C if err != nil { return nil, err } - var client *ibc.ClientOutput for _, c := range clients { if c.ClientState.ChainID == counterparty.Config().ChainID { - client = c - break - } - } - if client == nil { - return nil, fmt.Errorf("no client found for chain %s", counterparty.Config().ChainID) - } - - stdout, _, err := chain.GetNode().ExecQuery(ctx, "ibc", "connection", "connections") - if err != nil { - return nil, fmt.Errorf("error querying connections: %w", err) - } - connections := gjson.GetBytes(stdout, fmt.Sprintf("connections.#(client_id==\"%s\")#.id", client.ClientID)).Array() - if len(connections) == 0 { - return nil, fmt.Errorf("no connections found for client %s", client.ClientID) - } - for _, connID := range connections { - stdout, _, err := chain.GetNode().ExecQuery(ctx, "ibc", "channel", "connections", connID.String()) - if err != nil { - return nil, err - } - channelJSON := gjson.GetBytes(stdout, fmt.Sprintf("channels.#(port_id==\"%s\")", portID)).String() - if channelJSON != "" { - channelOutput := &ibc.ChannelOutput{} - if err := json.Unmarshal([]byte(channelJSON), channelOutput); err != nil { - return nil, fmt.Errorf("error unmarshalling channel output %s: %w", channelJSON, err) + stdout, _, err := chain.GetNode().ExecQuery(ctx, "ibc", "connection", "connections") + if err != nil { + return nil, fmt.Errorf("error querying connections: %w", err) + } + connections := gjson.GetBytes(stdout, fmt.Sprintf("connections.#(client_id==\"%s\")#.id", c.ClientID)).Array() + if len(connections) == 0 { + continue + } + for _, connID := range connections { + stdout, _, err := chain.GetNode().ExecQuery(ctx, "ibc", "channel", "connections", connID.String()) + if err != nil { + return nil, err + } + channelJSON := gjson.GetBytes(stdout, fmt.Sprintf("channels.#(port_id==\"%s\")", portID)).String() + if channelJSON != "" { + channelOutput := &ibc.ChannelOutput{} + if err := json.Unmarshal([]byte(channelJSON), channelOutput); err != nil { + return nil, fmt.Errorf("error unmarshalling channel output %s: %w", channelJSON, err) + } + return channelOutput, nil + } } - return channelOutput, nil } } return nil, fmt.Errorf("no channel found for port %s", portID) @@ -116,6 +111,88 @@ func (r *Relayer) ClearTransferChannel(ctx context.Context, chainA, chainB *Chai return nil } +func (r *Relayer) ConnectProviderConsumer(ctx context.Context, provider *Chain, consumer *Chain) error { + icsPath := relayerICSPathFor(provider, consumer) + rep := GetRelayerExecReporter(ctx) + if err := r.GeneratePath(ctx, rep, consumer.Config().ChainID, provider.Config().ChainID, icsPath); err != nil { + return err + } + + consumerClients, err := r.GetClients(ctx, rep, consumer.Config().ChainID) + if err != nil { + return err + } + sort.Slice(consumerClients, func(i, j int) bool { + return consumerClients[i].ClientID > consumerClients[j].ClientID + }) + var consumerClient *ibc.ClientOutput + for _, client := range consumerClients { + if client.ClientState.ChainID == provider.Config().ChainID { + consumerClient = client + break + } + } + if consumerClient == nil { + return fmt.Errorf("consumer chain %s does not have a client tracking the provider chain %s", consumer.Config().ChainID, provider.Config().ChainID) + } + consumerClientID := consumerClient.ClientID + + providerClients, err := r.GetClients(ctx, rep, provider.Config().ChainID) + if err != nil { + return err + } + sort.Slice(providerClients, func(i, j int) bool { + return providerClients[i].ClientID > providerClients[j].ClientID + }) + + var providerClient *ibc.ClientOutput + for _, client := range providerClients { + if client.ClientState.ChainID == consumer.Config().ChainID { + providerClient = client + break + } + } + if providerClient == nil { + return fmt.Errorf("provider chain %s does not have a client tracking the consumer chain %s for path %s on relayer %s", + provider.Config().ChainID, consumer.Config().ChainID, icsPath, r) + } + providerClientID := providerClient.ClientID + + if err := r.UpdatePath(ctx, rep, icsPath, ibc.PathUpdateOptions{ + SrcClientID: &consumerClientID, + DstClientID: &providerClientID, + }); err != nil { + return err + } + + if err := r.CreateConnections(ctx, rep, icsPath); err != nil { + return err + } + + if err := r.CreateChannel(ctx, rep, icsPath, ibc.CreateChannelOptions{ + SourcePortName: "consumer", + DestPortName: "provider", + Order: ibc.Ordered, + Version: "1", + }); err != nil { + return err + } + + tCtx, tCancel := context.WithTimeout(ctx, 30*CommitTimeout) + defer tCancel() + for tCtx.Err() == nil { + var ch *ibc.ChannelOutput + ch, err = r.GetTransferChannel(ctx, provider, consumer) + if err == nil && ch != nil { + break + } else if err == nil { + err = fmt.Errorf("channel not found") + } + time.Sleep(CommitTimeout) + } + return err +} + func relayerICSPathFor(chainA, chainB *Chain) string { return fmt.Sprintf("ics-%s-%s", chainA.Config().ChainID, chainB.Config().ChainID) } diff --git a/tests/interchain/consensus_test.go b/tests/interchain/consensus_test.go index 88c35ab7916..a256731e4b9 100644 --- a/tests/interchain/consensus_test.go +++ b/tests/interchain/consensus_test.go @@ -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" @@ -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) @@ -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++ { @@ -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) @@ -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) @@ -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) diff --git a/tests/interchain/consumer_launch_test.go b/tests/interchain/consumer_launch_test.go index 5990aa546cd..ae4c343adc8 100644 --- a/tests/interchain/consumer_launch_test.go +++ b/tests/interchain/consumer_launch_test.go @@ -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,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) } @@ -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, diff --git a/tests/interchain/feemarket_test.go b/tests/interchain/feemarket_test.go index 79e2dd6ef77..473915832ac 100644 --- a/tests/interchain/feemarket_test.go +++ b/tests/interchain/feemarket_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/cosmos/gaia/v20/tests/interchain/chainsuite" + "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v8/testutil" diff --git a/tests/interchain/go.mod b/tests/interchain/go.mod index b5355dc503d..d116fea5d8c 100644 --- a/tests/interchain/go.mod +++ b/tests/interchain/go.mod @@ -23,6 +23,7 @@ require ( cosmossdk.io/math v1.3.0 github.com/cometbft/cometbft v0.38.11 github.com/cosmos/cosmos-sdk v0.50.9 + github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-go/v8 v8.5.0 github.com/cosmos/interchain-security/v5 v5.1.1 github.com/docker/docker v27.1.2+incompatible @@ -95,7 +96,6 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/gogoproto v1.7.0 // indirect github.com/cosmos/iavl v1.3.0 // indirect github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect @@ -292,4 +292,4 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -replace github.com/strangelove-ventures/interchaintest/v8 => github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240904201357-3a54d751e08d +replace github.com/strangelove-ventures/interchaintest/v8 => github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c diff --git a/tests/interchain/go.sum b/tests/interchain/go.sum index 827bcf254c0..b2d2be54de8 100644 --- a/tests/interchain/go.sum +++ b/tests/interchain/go.sum @@ -773,8 +773,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240904201357-3a54d751e08d h1:3LXY5EWY78Qxh2t4h2rtcm/XpJdryN7bML2Nb0VfUjc= -github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20240904201357-3a54d751e08d/go.mod h1:/4eZW5g+Gm5E7fCJvNVyjSlEyFkAfMzap4i8E6iqyyU= +github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c h1:zTsxQIsnbocbpjqA6yEpM7nYYrqlF7EjWWFgHUEQtCE= +github.com/hyphacoop/interchaintest/v8 v8.2.1-0.20241007153747-ed0a63d6cc1c/go.mod h1:/4eZW5g+Gm5E7fCJvNVyjSlEyFkAfMzap4i8E6iqyyU= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= diff --git a/tests/interchain/ica_controller_test.go b/tests/interchain/ica_controller_test.go index 9ebda85bdf1..3e972bfcd4e 100644 --- a/tests/interchain/ica_controller_test.go +++ b/tests/interchain/ica_controller_test.go @@ -11,7 +11,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/gaia/v20/tests/interchain/chainsuite" + "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" "github.com/cosmos/gogoproto/proto" icatypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/types" "github.com/strangelove-ventures/interchaintest/v8" diff --git a/tests/interchain/lsm_test.go b/tests/interchain/lsm_test.go index 5998d337d3e..d99d5d3e482 100644 --- a/tests/interchain/lsm_test.go +++ b/tests/interchain/lsm_test.go @@ -8,12 +8,13 @@ import ( "time" sdkmath "cosmossdk.io/math" - "github.com/cosmos/gaia/v20/tests/interchain/chainsuite" + "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" "github.com/strangelove-ventures/interchaintest/v8" "github.com/strangelove-ventures/interchaintest/v8/ibc" "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,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, diff --git a/tests/interchain/matrix_tool/main.go b/tests/interchain/matrix_tool/main.go index 244a691c396..92172ba3f50 100644 --- a/tests/interchain/matrix_tool/main.go +++ b/tests/interchain/matrix_tool/main.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "math/rand/v2" "os" "os/exec" "path" @@ -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 } diff --git a/tests/interchain/permissionless_test.go b/tests/interchain/permissionless_test.go index f892ff48d99..18ed527cab6 100644 --- a/tests/interchain/permissionless_test.go +++ b/tests/interchain/permissionless_test.go @@ -7,11 +7,13 @@ import ( "path" "path/filepath" "strconv" + "strings" "testing" "time" sdkmath "cosmossdk.io/math" - govtypes "github.cogaia/v21/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" ccvclient "github.com/cosmos/interchain-security/v5/x/ccv/provider/client" @@ -21,6 +23,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/testutil" "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" "github.com/tidwall/sjson" "golang.org/x/mod/semver" "golang.org/x/sync/errgroup" @@ -352,7 +355,7 @@ func (s *PermissionlessConsumersSuite) TestChangePowerShaping() { s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer, s.Relayer, 1_000_000, 0, 1)) - vals, err := consumer.QueryJSON(s.GetContext(), "validators", "comet-validator-set") + vals, err := consumer.QueryJSON(s.GetContext(), "validators", "tendermint-validator-set") s.Require().NoError(err) s.Require().Equal(newValidatorCount, len(vals.Array()), vals) for i := 0; i < newValidatorCount; i++ { @@ -373,10 +376,28 @@ func (s *PermissionlessConsumersSuite) TestConsumerCommissionRate() { _, err = s.Chain.Validators[0].ExecTx(s.GetContext(), s.Chain.ValidatorWallets[0].Moniker, "provider", "opt-in", consumerID) s.Require().NoError(err) } + + images := []ibc.DockerImage{ + { + Repository: "ghcr.io/hyphacoop/ics", + Version: "v4.5.0", + UidGid: "1025:1025", + }, + } + chainID := fmt.Sprintf("%s-test-%d", cfg.ChainName, len(s.Chain.Consumers)+1) + spawnTime := time.Now().Add(chainsuite.ChainSpawnWait) + cfg.Spec = s.Chain.DefaultConsumerChainSpec(s.GetContext(), chainID, cfg, spawnTime, nil) + cfg.Spec.Version = "v4.5.0" + cfg.Spec.Images = images consumer1, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg) s.Require().NoError(err) s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer1, s.Relayer, 1_000_000, 0, 1)) + chainID = fmt.Sprintf("%s-test-%d", cfg.ChainName, len(s.Chain.Consumers)+1) + spawnTime = time.Now().Add(chainsuite.ChainSpawnWait) + cfg.Spec = s.Chain.DefaultConsumerChainSpec(s.GetContext(), chainID, cfg, spawnTime, nil) + cfg.Spec.Version = "v4.5.0" + cfg.Spec.Images = images consumer2, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg) s.Require().NoError(err) s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer2, s.Relayer, 1_000_000, 0, 1)) @@ -574,6 +595,87 @@ func (s *PermissionlessConsumersSuite) TestLaunchWithAllowListThenModify() { s.Require().Equal(4, len(validators.Array())) } +func (s *PermissionlessConsumersSuite) TestRewardsWithChangeover() { + validators := 1 + fullNodes := 0 + genesisChanges := []cosmos.GenesisKV{ + cosmos.NewGenesisKV("app_state.gov.params.voting_period", chainsuite.GovVotingPeriod.String()), + cosmos.NewGenesisKV("app_state.gov.params.max_deposit_period", chainsuite.GovDepositPeriod.String()), + cosmos.NewGenesisKV("app_state.gov.params.min_deposit.0.denom", chainsuite.Ucon), + cosmos.NewGenesisKV("app_state.gov.params.min_deposit.0.amount", strconv.Itoa(chainsuite.GovMinDepositAmount)), + } + spec := &interchaintest.ChainSpec{ + 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, + ChainConfig: ibc.ChainConfig{ + Denom: chainsuite.Ucon, + GasPrices: "0.025" + chainsuite.Ucon, + GasAdjustment: 2.0, + Gas: "auto", + ConfigFileOverrides: map[string]any{ + "config/config.toml": chainsuite.DefaultConfigToml(), + }, + ModifyGenesisAmounts: chainsuite.DefaultGenesisAmounts(chainsuite.Ucon), + ModifyGenesis: cosmos.ModifyGenesis(genesisChanges), + Bin: "interchain-security-sd", + Images: []ibc.DockerImage{ + { + Repository: chainsuite.HyphaICSRepo, + Version: "v6.2.0-rc1", + UidGid: chainsuite.ICSUidGuid, + }, + }, + Bech32Prefix: "consumer", + }, + } + consumer, err := s.Chain.AddLinkedChain(s.GetContext(), s.T(), s.Relayer, spec) + s.Require().NoError(err) + + transferCh, err := s.Relayer.GetTransferChannel(s.GetContext(), s.Chain, consumer) + s.Require().NoError(err) + rewardDenom := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", transferCh.ChannelID, consumer.Config().Denom)).IBCDenom() + + s.UpgradeChain() + + s.changeSovereignToConsumer(consumer, transferCh) + + govAuthority, err := s.Chain.GetGovernanceAddress(s.GetContext()) + s.Require().NoError(err) + rewardDenomsProp := providertypes.MsgChangeRewardDenoms{ + DenomsToAdd: []string{rewardDenom}, + Authority: govAuthority, + } + prop, err := s.Chain.BuildProposal([]cosmos.ProtoMessage{&rewardDenomsProp}, + "add denoms to list of registered reward denoms", + "add denoms to list of registered reward denoms", + "", chainsuite.GovDepositAmount, "", false) + s.Require().NoError(err) + propResult, err := s.Chain.SubmitProposal(s.GetContext(), s.Chain.ValidatorWallets[0].Moniker, prop) + s.Require().NoError(err) + s.Require().NoError(s.Chain.PassProposal(s.GetContext(), propResult.ProposalID)) + + faucetAddrBts, err := consumer.GetAddress(s.GetContext(), interchaintest.FaucetAccountKeyName) + s.Require().NoError(err) + faucetAddr := types.MustBech32ifyAddressBytes(consumer.Config().Bech32Prefix, faucetAddrBts) + _, err = consumer.Validators[0].ExecTx(s.GetContext(), interchaintest.FaucetAccountKeyName, "bank", "send", string(faucetAddr), consumer.ValidatorWallets[0].Address, "1"+consumer.Config().Denom, "--fees", "100000000"+consumer.Config().Denom) + s.Require().NoError(err) + + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), chainsuite.BlocksPerDistribution+2, s.Chain, consumer)) + s.Require().NoError(s.Relayer.ClearTransferChannel(s.GetContext(), s.Chain, consumer)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 2, s.Chain, consumer)) + + rewardStr, err := s.Chain.QueryJSON(s.GetContext(), fmt.Sprintf("total.#(%%\"*%s\")", rewardDenom), "distribution", "rewards", s.Chain.ValidatorWallets[0].Address) + s.Require().NoError(err) + rewards, err := chainsuite.StrToSDKInt(rewardStr.String()) + s.Require().NoError(err) + s.Require().True(rewards.GT(sdkmath.NewInt(0)), "rewards: %s", rewards.String()) +} + func TestPermissionlessConsumers(t *testing.T) { genesis := chainsuite.DefaultGenesis() genesis = append(genesis, @@ -591,17 +693,123 @@ func TestPermissionlessConsumers(t *testing.T) { }), consumerCfg: chainsuite.ConsumerConfig{ ChainName: "ics-consumer", - Version: "v5.0.0", + 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 + currentHeight, err := consumer.Height(s.GetContext()) + s.Require().NoError(err) + initialHeight := uint64(currentHeight) + 60 + cfg.InitialHeight = initialHeight + spawnTime := time.Now().Add(60 * time.Second) + cfg.DistributionTransmissionChannel = transferCh.ChannelID + + err = s.Chain.CreateConsumerPermissionless(s.GetContext(), consumer.Config().ChainID, cfg, spawnTime) + s.Require().NoError(err) + + consumerChains, _, err := s.Chain.GetNode().ExecQuery(s.GetContext(), "provider", "list-consumer-chains") + s.Require().NoError(err) + consumerChain := gjson.GetBytes(consumerChains, fmt.Sprintf("chains.#(chain_id=%q)", consumer.Config().ChainID)) + consumerID := consumerChain.Get("consumer_id").String() + + eg := errgroup.Group{} + for i := range consumer.Validators { + i := i + eg.Go(func() error { + key, _, err := consumer.Validators[i].ExecBin(s.GetContext(), "tendermint", "show-validator") + if err != nil { + return err + } + keyStr := strings.TrimSpace(string(key)) + _, err = s.Chain.Validators[i].ExecTx(s.GetContext(), s.Chain.ValidatorWallets[i].Moniker, "provider", "opt-in", consumerID, keyStr) + return err + }) + } + s.Require().NoError(eg.Wait()) + + s.Require().NoError(err) + time.Sleep(time.Until(spawnTime)) + s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 2, s.Chain)) + + proposal := cosmos.SoftwareUpgradeProposal{ + Deposit: "5000000" + chainsuite.Ucon, + Title: "Changeover", + Name: "sovereign-changeover", + Description: "Changeover", + Height: int64(initialHeight) - 3, + } + upgradeTx, err := consumer.UpgradeProposal(s.GetContext(), interchaintest.FaucetAccountKeyName, proposal) + s.Require().NoError(err) + err = consumer.PassProposal(s.GetContext(), upgradeTx.ProposalID) + s.Require().NoError(err) + + currentHeight, err = consumer.Height(s.GetContext()) + s.Require().NoError(err) + + timeoutCtx, timeoutCtxCancel := context.WithTimeout(s.GetContext(), (time.Duration(int64(initialHeight)-currentHeight)+10)*chainsuite.CommitTimeout) + defer timeoutCtxCancel() + err = testutil.WaitForBlocks(timeoutCtx, int(int64(initialHeight)-currentHeight)+3, consumer) + s.Require().Error(err) + + s.Require().NoError(consumer.StopAllNodes(s.GetContext())) + + genesis, err := consumer.GetNode().GenesisFileContent(s.GetContext()) + s.Require().NoError(err) + + ccvState, _, err := s.Chain.GetNode().ExecQuery(s.GetContext(), "provider", "consumer-genesis", consumerID) + s.Require().NoError(err) + genesis, err = sjson.SetRawBytes(genesis, "app_state.ccvconsumer", ccvState) + s.Require().NoError(err) + + genesis, err = sjson.SetBytes(genesis, "app_state.slashing.params.signed_blocks_window", strconv.Itoa(chainsuite.SlashingWindowConsumer)) + s.Require().NoError(err) + genesis, err = sjson.SetBytes(genesis, "app_state.ccvconsumer.params.reward_denoms", []string{chainsuite.Ucon}) + s.Require().NoError(err) + genesis, err = sjson.SetBytes(genesis, "app_state.ccvconsumer.params.provider_reward_denoms", []string{s.Chain.Config().Denom}) + s.Require().NoError(err) + genesis, err = sjson.SetBytes(genesis, "app_state.ccvconsumer.params.blocks_per_distribution_transmission", chainsuite.BlocksPerDistribution) + s.Require().NoError(err) + + for _, val := range consumer.Validators { + val := val + eg.Go(func() error { + if err := val.OverwriteGenesisFile(s.GetContext(), []byte(genesis)); err != nil { + return err + } + return val.WriteFile(s.GetContext(), []byte(genesis), ".sovereign/config/genesis.json") + }) + } + s.Require().NoError(eg.Wait()) + + consumer.ChangeBinary(s.GetContext(), "interchain-security-cdd") + s.Require().NoError(consumer.StartAllNodes(s.GetContext())) + s.Require().NoError(s.Relayer.ConnectProviderConsumer(s.GetContext(), s.Chain, consumer)) + s.Require().NoError(s.Relayer.StopRelayer(s.GetContext(), chainsuite.GetRelayerExecReporter(s.GetContext()))) + s.Require().NoError(s.Relayer.StartRelayer(s.GetContext(), chainsuite.GetRelayerExecReporter(s.GetContext()))) + s.Require().NoError(s.Chain.CheckCCV(s.GetContext(), consumer, s.Relayer, 1_000_000, 0, 1)) +} + func (s *PermissionlessConsumersSuite) submitChangeRewardDenoms(consumer *chainsuite.Chain) (string, string) { consumerCh, err := s.Relayer.GetTransferChannel(s.GetContext(), s.Chain, consumer) s.Require().NoError(err) diff --git a/tests/interchain/pfm_test.go b/tests/interchain/pfm_test.go index 39d40ddb79b..867102bb0b0 100644 --- a/tests/interchain/pfm_test.go +++ b/tests/interchain/pfm_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/cosmos/gaia/v20/tests/interchain/chainsuite" + "github.com/cosmos/gaia/v21/tests/interchain/chainsuite" transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/stretchr/testify/assert" @@ -84,11 +84,9 @@ func (s *PFMSuite) TestPFMHappyPath() { s.Require().EventuallyWithT(func(c *assert.CollectT) { dEndBalance, err := s.Chains[3].GetBalance(s.GetContext(), dWallet1.Address, targetDenomAD) assert.NoError(c, err) - balances, err := s.Chains[3].BankQueryAllBalances(s.GetContext(), dWallet1.Address) - assert.NoError(c, err) - assert.Truef(c, dEndBalance.GT(dStartBalance), "expected %d > %d in %s; balances are: %+v", - dEndBalance, dStartBalance, targetDenomAD, balances) - }, 15*chainsuite.CommitTimeout, chainsuite.CommitTimeout, "chain D balance has not increased") + assert.Truef(c, dEndBalance.Sub(dStartBalance).IsPositive(), "expected %d - %d > 0 (it was %d) in %s", + dEndBalance, dStartBalance, dEndBalance.Sub(dStartBalance), targetDenomAD) + }, 30*chainsuite.CommitTimeout, chainsuite.CommitTimeout, "chain D balance has not increased") aStartBalance, err := s.Chains[0].GetBalance(s.GetContext(), aWallet1.Address, targetDenomDA) s.Require().NoError(err) @@ -119,11 +117,9 @@ func (s *PFMSuite) TestPFMHappyPath() { s.Require().EventuallyWithT(func(c *assert.CollectT) { aEndBalance, err := s.Chains[0].GetBalance(s.GetContext(), aWallet1.Address, targetDenomDA) assert.NoError(c, err) - balances, err := s.Chains[0].BankQueryAllBalances(s.GetContext(), aWallet1.Address) - assert.NoError(c, err) - assert.Truef(c, aEndBalance.GT(aStartBalance), "expected %d > %d in %s; balances are: %+v", - aEndBalance, aStartBalance, targetDenomDA, balances) - }, 15*chainsuite.CommitTimeout, chainsuite.CommitTimeout, "chain A balance has not increased") + assert.Truef(c, aEndBalance.Sub(aStartBalance).IsPositive(), "expected %d - %d > 0 (it was %d) in %s", + aEndBalance, aStartBalance, aEndBalance.Sub(aStartBalance), targetDenomDA) + }, 30*chainsuite.CommitTimeout, chainsuite.CommitTimeout, "chain A balance has not increased") } diff --git a/tests/interchain/unbonding_test.go b/tests/interchain/unbonding_test.go index dfe0b069788..105d5dbbb57 100644 --- a/tests/interchain/unbonding_test.go +++ b/tests/interchain/unbonding_test.go @@ -32,10 +32,21 @@ func (s *UnbondingSuite) SetupSuite() { s.Suite.SetupSuite() cfg := chainsuite.ConsumerConfig{ ChainName: "ics-consumer", - Version: "v5.0.0", + Version: selectConsumerVersion("v6.0.0", "v6.2.1"), ShouldCopyProviderKey: allProviderKeysCopied(), Denom: chainsuite.Ucon, TopN: 100, + Spec: &interchaintest.ChainSpec{ + ChainConfig: ibc.ChainConfig{ + Images: []ibc.DockerImage{ + { + Repository: chainsuite.HyphaICSRepo, + Version: selectConsumerVersion("v6.0.0", "v6.2.1"), + UidGid: chainsuite.ICSUidGuid, + }, + }, + }, + }, } consumer, err := s.Chain.AddConsumerChain(s.GetContext(), s.Relayer, cfg) s.Require().NoError(err)