From 6fd5159cc4e4bb5e8487bf3a71d379e36d7fd872 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 17 Feb 2023 15:09:22 +0100 Subject: [PATCH 01/11] initial commit --- testing/simapp/upgrades/v5/upgrades.go | 6 ++++++ testing/simapp/upgrades/v7.1/upgrades.go | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 testing/simapp/upgrades/v5/upgrades.go create mode 100644 testing/simapp/upgrades/v7.1/upgrades.go diff --git a/testing/simapp/upgrades/v5/upgrades.go b/testing/simapp/upgrades/v5/upgrades.go new file mode 100644 index 00000000000..bb4f76acefb --- /dev/null +++ b/testing/simapp/upgrades/v5/upgrades.go @@ -0,0 +1,6 @@ +package v5 + +const ( + // UpgradeName defines the on-chain upgrade name for the SimApp v5 upgrade. + UpgradeName = "v5" +) diff --git a/testing/simapp/upgrades/v7.1/upgrades.go b/testing/simapp/upgrades/v7.1/upgrades.go new file mode 100644 index 00000000000..6120b3726e9 --- /dev/null +++ b/testing/simapp/upgrades/v7.1/upgrades.go @@ -0,0 +1,6 @@ +package v71 + +const ( + // UpgradeName defines the on-chain upgrade name for the SimApp v7.1 upgrade. + UpgradeName = "v7.1 - localhost" +) From f032767e2351be2800a4492b31ff4352d36b9be7 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 17 Feb 2023 15:42:22 +0100 Subject: [PATCH 02/11] adding e2e upgrade test for localhost v7.1 --- e2e/tests/upgrades/upgrade_test.go | 35 +++++++++++++++++++++++++++-- e2e/testsuite/grpc_query.go | 14 ++++++++++++ e2e/testsuite/testsuite.go | 35 ++++++++++++++++------------- testing/simapp/app.go | 9 +++++++- testing/simapp/upgrades/upgrades.go | 5 ----- 5 files changed, 74 insertions(+), 24 deletions(-) diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index e9d912e6594..f84304cff1d 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -26,11 +26,13 @@ import ( icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" v7migrations "github.com/cosmos/ibc-go/v7/modules/core/02-client/migrations/v7" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v7/testing" - simappupgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades" + v5 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v5" v7upgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7" + v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1" ) const ( @@ -150,7 +152,7 @@ func (s *UpgradeTestSuite) TestV4ToV5ChainUpgrade() { s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks") t.Run("upgrade chainA", func(t *testing.T) { - s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, simappupgrades.DefaultUpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag) + s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, v5.UpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag) }) t.Run("restart relayer", func(t *testing.T) { @@ -549,6 +551,35 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() { }) } +func (s *UpgradeTestSuite) TestV7ChainUpgradeAddLocalhost() { + t := s.T() + testCfg := testconfig.FromEnv() + + ctx := context.Background() + _, _ = s.SetupChainsRelayerAndChannel(ctx) + chain, _ := s.GetChains() + + s.Require().NoError(test.WaitForBlocks(ctx, 5, chain), "failed to wait for blocks") + + t.Run("upgrade chain", func(t *testing.T) { + govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + s.UpgradeChain(ctx, chain, govProposalWallet, v71.UpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag) + }) + + t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) { + status, err := s.QueryClientStatus(ctx, chain, exported.Localhost) + s.Require().NoError(err) + s.Require().Equal(exported.Active.String(), status) + + connectionEnd, err := s.QueryConnection(ctx, chain, connectiontypes.LocalhostID) + s.Require().NoError(err) + s.Require().Equal(connectiontypes.OPEN, connectionEnd.State) + s.Require().Equal(exported.Localhost, connectionEnd.ClientId) + s.Require().Equal(exported.Localhost, connectionEnd.Counterparty.ClientId) + s.Require().Equal(connectiontypes.LocalhostID, connectionEnd.Counterparty.ConnectionId) + }) +} + // RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain. func (s *UpgradeTestSuite) RegisterInterchainAccount(ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, msgRegisterAccount *intertxtypes.MsgRegisterAccount) error { txResp, err := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index ff38ae0f09e..04eb45f4244 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -12,6 +12,7 @@ import ( controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ) @@ -47,6 +48,19 @@ func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, c return res.Status, nil } +// QueryConnection queries +func (s *E2ETestSuite) QueryConnection(ctx context.Context, chain ibc.Chain, connectionID string) (connectiontypes.ConnectionEnd, error) { + queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient + res, err := queryClient.Connection(ctx, &connectiontypes.QueryConnectionRequest{ + ConnectionId: connectionID, + }) + if err != nil { + return connectiontypes.ConnectionEnd{}, err + } + + return *res.Connection, nil +} + // QueryChannel queries the channel on a given chain for the provided portID and channelID func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) { queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 51b9e621711..32d68c89237 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -39,6 +39,7 @@ import ( feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ) @@ -70,11 +71,12 @@ type E2ETestSuite struct { // These should typically be used for query clients only. If we need to make changes, we should // use E2ETestSuite.BroadcastMessages to broadcast transactions instead. type GRPCClients struct { - ClientQueryClient clienttypes.QueryClient - ChannelQueryClient channeltypes.QueryClient - FeeQueryClient feetypes.QueryClient - ICAQueryClient controllertypes.QueryClient - InterTxQueryClient intertxtypes.QueryClient + ClientQueryClient clienttypes.QueryClient + ConnectionQueryClient connectiontypes.QueryClient + ChannelQueryClient channeltypes.QueryClient + FeeQueryClient feetypes.QueryClient + ICAQueryClient controllertypes.QueryClient + InterTxQueryClient intertxtypes.QueryClient // SDK query clients GovQueryClient govtypesv1beta1.QueryClient @@ -382,17 +384,18 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) { } s.grpcClients[chain.Config().ChainID] = GRPCClients{ - ClientQueryClient: clienttypes.NewQueryClient(grpcConn), - ChannelQueryClient: channeltypes.NewQueryClient(grpcConn), - FeeQueryClient: feetypes.NewQueryClient(grpcConn), - ICAQueryClient: controllertypes.NewQueryClient(grpcConn), - InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn), - GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn), - GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn), - GroupsQueryClient: grouptypes.NewQueryClient(grpcConn), - ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn), - AuthQueryClient: authtypes.NewQueryClient(grpcConn), - AuthZQueryClient: authz.NewQueryClient(grpcConn), + ClientQueryClient: clienttypes.NewQueryClient(grpcConn), + ConnectionQueryClient: connectiontypes.NewQueryClient(grpcConn), + ChannelQueryClient: channeltypes.NewQueryClient(grpcConn), + FeeQueryClient: feetypes.NewQueryClient(grpcConn), + ICAQueryClient: controllertypes.NewQueryClient(grpcConn), + InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn), + GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn), + GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn), + GroupsQueryClient: grouptypes.NewQueryClient(grpcConn), + ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn), + AuthQueryClient: authtypes.NewQueryClient(grpcConn), + AuthZQueryClient: authz.NewQueryClient(grpcConn), } } diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 48450a021e5..20810dfef16 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -122,8 +122,10 @@ import ( ibcmock "github.com/cosmos/ibc-go/v7/testing/mock" simappparams "github.com/cosmos/ibc-go/v7/testing/simapp/params" simappupgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades" + v5 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v5" v6 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v6" v7 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7" + v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1" ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" ) @@ -929,7 +931,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // setupUpgradeHandlers sets all necessary upgrade handlers for testing purposes func (app *SimApp) setupUpgradeHandlers() { app.UpgradeKeeper.SetUpgradeHandler( - simappupgrades.DefaultUpgradeName, + v5.UpgradeName, simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), ) @@ -960,6 +962,11 @@ func (app *SimApp) setupUpgradeHandlers() { app.ParamsKeeper, ), ) + + app.UpgradeKeeper.SetUpgradeHandler( + v71.UpgradeName, + simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), + ) } // setupUpgradeStoreLoaders sets all necessary store loaders required by upgrades. diff --git a/testing/simapp/upgrades/upgrades.go b/testing/simapp/upgrades/upgrades.go index adc81349bdd..14609be730e 100644 --- a/testing/simapp/upgrades/upgrades.go +++ b/testing/simapp/upgrades/upgrades.go @@ -6,11 +6,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -const ( - // DefaultUpgradeName is the default upgrade name used for upgrade tests which do not require special handling. - DefaultUpgradeName = "normal upgrade" -) - // CreateDefaultUpgradeHandler creates an upgrade handler which can be used for regular upgrade tests // that do not require special logic func CreateDefaultUpgradeHandler( From c79dc38f59becef272d6ef9cc61c9640a1017df8 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 17 Feb 2023 15:47:28 +0100 Subject: [PATCH 03/11] update the v5 upgrade name --- testing/simapp/upgrades/v5/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/simapp/upgrades/v5/upgrades.go b/testing/simapp/upgrades/v5/upgrades.go index bb4f76acefb..d665e42ac30 100644 --- a/testing/simapp/upgrades/v5/upgrades.go +++ b/testing/simapp/upgrades/v5/upgrades.go @@ -2,5 +2,5 @@ package v5 const ( // UpgradeName defines the on-chain upgrade name for the SimApp v5 upgrade. - UpgradeName = "v5" + UpgradeName = "normal upgrade" // NOTE: keeping as "normal upgrade" as existing tags depend on this name ) From ade4411e46f69f22fcfca174e2ce73cfc78a70da Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 17 Feb 2023 16:02:06 +0100 Subject: [PATCH 04/11] adding test workflow yaml --- .github/workflows/e2e-upgrade.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index 18494d3a07b..d3e48a9cc15 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -25,6 +25,12 @@ jobs: chain-a-tag: v6.1.0 chain-b-tag: v6.1.0 chain-upgrade-tag: v7.0.0-rc0 # TODO: needs v7.0.0-rc1 when cut + - test: TestV7ChainUpgradeAddLocalhost + chain-image: ghcr.io/cosmos/ibc-go-simd + chain-binary: simd + chain-a-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut + chain-b-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut + chain-upgrade-tag: pr-3164 # TODO: needs v7.1.0 when cut steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 From aa33f22ce7f0e4bf2c6dcd024a029002bc3fd36f Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 17 Feb 2023 20:25:19 +0100 Subject: [PATCH 05/11] update workflow --- .github/workflows/e2e-upgrade.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index d3e48a9cc15..0d423bd7c43 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -24,7 +24,7 @@ jobs: chain-binary: simd chain-a-tag: v6.1.0 chain-b-tag: v6.1.0 - chain-upgrade-tag: v7.0.0-rc0 # TODO: needs v7.0.0-rc1 when cut + chain-upgrade-tag: pr-3136 # TODO: needs v7.0.0-rc1 when cut - test: TestV7ChainUpgradeAddLocalhost chain-image: ghcr.io/cosmos/ibc-go-simd chain-binary: simd From 6cca97f2c0d5195e122ac6bd6e1dbde2f7913634 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 12:59:36 +0100 Subject: [PATCH 06/11] Update e2e/testsuite/grpc_query.go Co-authored-by: Cian Hatton --- e2e/testsuite/grpc_query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/testsuite/grpc_query.go b/e2e/testsuite/grpc_query.go index 04eb45f4244..a7449de94ec 100644 --- a/e2e/testsuite/grpc_query.go +++ b/e2e/testsuite/grpc_query.go @@ -48,7 +48,7 @@ func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, c return res.Status, nil } -// QueryConnection queries +// QueryConnection queries the connection end using the given chain and connection id. func (s *E2ETestSuite) QueryConnection(ctx context.Context, chain ibc.Chain, connectionID string) (connectiontypes.ConnectionEnd, error) { queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient res, err := queryClient.Connection(ctx, &connectiontypes.QueryConnectionRequest{ From 06bbe620f683821cab59349d0266598a30424461 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 15:18:58 +0100 Subject: [PATCH 07/11] refactor the upgrades pkg in simapp --- .github/workflows/e2e-upgrade.yaml | 2 +- testing/simapp/app.go | 24 ++++----- testing/simapp/upgrades/upgrades.go | 63 ++++++++++++++++++++++++ testing/simapp/upgrades/v5/upgrades.go | 6 --- testing/simapp/upgrades/v6/upgrades.go | 36 -------------- testing/simapp/upgrades/v7.1/upgrades.go | 6 --- testing/simapp/upgrades/v7/upgrades.go | 42 ---------------- 7 files changed, 74 insertions(+), 105 deletions(-) delete mode 100644 testing/simapp/upgrades/v5/upgrades.go delete mode 100644 testing/simapp/upgrades/v6/upgrades.go delete mode 100644 testing/simapp/upgrades/v7.1/upgrades.go delete mode 100644 testing/simapp/upgrades/v7/upgrades.go diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index e1255de2799..bbe40871402 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -50,6 +50,6 @@ jobs: chain-a-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut chain-b-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut chain-upgrade-tag: pr-3164 # TODO: needs v7.1.0 when cut - upgrade-plan-name: "v7.1 - localhost" + upgrade-plan-name: "v7.1" test-entry-point: "TestUpgradeTestSuite" test: "TestV7ChainUpgradeAddLocalhost" diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 20810dfef16..f378364f731 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -121,11 +121,7 @@ import ( localhost "github.com/cosmos/ibc-go/v7/modules/light-clients/09-localhost" ibcmock "github.com/cosmos/ibc-go/v7/testing/mock" simappparams "github.com/cosmos/ibc-go/v7/testing/simapp/params" - simappupgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades" - v5 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v5" - v6 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v6" - v7 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7" - v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1" + "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades" ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" ) @@ -931,8 +927,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // setupUpgradeHandlers sets all necessary upgrade handlers for testing purposes func (app *SimApp) setupUpgradeHandlers() { app.UpgradeKeeper.SetUpgradeHandler( - v5.UpgradeName, - simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), + upgrades.V5, + upgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), ) // NOTE: The moduleName arg of v6.CreateUpgradeHandler refers to the auth module ScopedKeeper name to which the channel capability should be migrated from. @@ -940,8 +936,8 @@ func (app *SimApp) setupUpgradeHandlers() { // TODO: update git tag in link below // See: https://github.com/cosmos/ibc-go/blob/v5.0.0-rc2/testing/simapp/app.go#L304 app.UpgradeKeeper.SetUpgradeHandler( - v6.UpgradeName, - v6.CreateUpgradeHandler( + upgrades.V6, + upgrades.CreateV6UpgradeHandler( app.mm, app.configurator, app.appCodec, @@ -952,8 +948,8 @@ func (app *SimApp) setupUpgradeHandlers() { ) app.UpgradeKeeper.SetUpgradeHandler( - v7.UpgradeName, - v7.CreateUpgradeHandler( + upgrades.V7, + upgrades.CreateV7UpgradeHandler( app.mm, app.configurator, app.appCodec, @@ -964,8 +960,8 @@ func (app *SimApp) setupUpgradeHandlers() { ) app.UpgradeKeeper.SetUpgradeHandler( - v71.UpgradeName, - simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), + upgrades.V7_1, + upgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator), ) } @@ -976,7 +972,7 @@ func (app *SimApp) setupUpgradeStoreLoaders() { tmos.Exit(fmt.Sprintf("failed to read upgrade info from disk %s", err)) } - if upgradeInfo.Name == v7.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + if upgradeInfo.Name == upgrades.V7 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ Added: []string{ consensusparamtypes.StoreKey, diff --git a/testing/simapp/upgrades/upgrades.go b/testing/simapp/upgrades/upgrades.go index 14609be730e..3730b0f3e6c 100644 --- a/testing/simapp/upgrades/upgrades.go +++ b/testing/simapp/upgrades/upgrades.go @@ -1,9 +1,31 @@ package upgrades import ( + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + consensusparamskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + v6 "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/migrations/v6" + clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" + ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" +) + +const ( + // V5 defines the upgrade name for the ibc-go/v5 upgrade handler. + V5 = "normal upgrade" // NOTE: keeping as "normal upgrade" as existing tags depend on this name + // V6 defines the upgrade name for the ibc-go/v6 upgrade handler. + V6 = "v6" + // V7 defines the upgrade name for the ibc-go/v7 upgrade handler. + V7 = "v7" + // V7_1 defines the upgrade name for the ibc-go/v7.1 upgrade handler. + V7_1 = "v7.1" ) // CreateDefaultUpgradeHandler creates an upgrade handler which can be used for regular upgrade tests @@ -16,3 +38,44 @@ func CreateDefaultUpgradeHandler( return mm.RunMigrations(ctx, configurator, vm) } } + +// CreateV6UpgradeHandler creates an upgrade handler for the ibc-go/v6 SimApp upgrade. +// NOTE: The v6.MigrateICS27ChannelCapabiliity function can be omitted if chains do not yet implement an ICS27 controller module +func CreateV6UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + cdc codec.BinaryCodec, + capabilityStoreKey *storetypes.KVStoreKey, + capabilityKeeper *capabilitykeeper.Keeper, + moduleName string, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + if err := v6.MigrateICS27ChannelCapability(ctx, cdc, capabilityStoreKey, capabilityKeeper, moduleName); err != nil { + return nil, err + } + + return mm.RunMigrations(ctx, configurator, vm) + } +} + +// CreateV7UpgradeHandler creates an upgrade handler for the ibc-go/v7 SimApp upgrade. +func CreateV7UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + cdc codec.BinaryCodec, + clientKeeper clientkeeper.Keeper, + consensusParamsKeeper consensusparamskeeper.Keeper, + paramsKeeper paramskeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + // OPTIONAL: prune expired tendermint consensus states to save storage space + if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, cdc, clientKeeper); err != nil { + return nil, err + } + + legacyBaseAppSubspace := paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) + baseapp.MigrateParams(ctx, legacyBaseAppSubspace, &consensusParamsKeeper) + + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/testing/simapp/upgrades/v5/upgrades.go b/testing/simapp/upgrades/v5/upgrades.go deleted file mode 100644 index d665e42ac30..00000000000 --- a/testing/simapp/upgrades/v5/upgrades.go +++ /dev/null @@ -1,6 +0,0 @@ -package v5 - -const ( - // UpgradeName defines the on-chain upgrade name for the SimApp v5 upgrade. - UpgradeName = "normal upgrade" // NOTE: keeping as "normal upgrade" as existing tags depend on this name -) diff --git a/testing/simapp/upgrades/v6/upgrades.go b/testing/simapp/upgrades/v6/upgrades.go deleted file mode 100644 index 953bccf37e9..00000000000 --- a/testing/simapp/upgrades/v6/upgrades.go +++ /dev/null @@ -1,36 +0,0 @@ -package v6 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - v6 "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/migrations/v6" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the SimApp v6 upgrade. - UpgradeName = "v6" -) - -// CreateUpgradeHandler creates an upgrade handler for the v6 SimApp upgrade. -// NOTE: The v6.MigrateICS27ChannelCapabiliity function can be omitted if chains do not yet implement an ICS27 controller module -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - cdc codec.BinaryCodec, - capabilityStoreKey *storetypes.KVStoreKey, - capabilityKeeper *capabilitykeeper.Keeper, - moduleName string, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - if err := v6.MigrateICS27ChannelCapability(ctx, cdc, capabilityStoreKey, capabilityKeeper, moduleName); err != nil { - return nil, err - } - - return mm.RunMigrations(ctx, configurator, vm) - } -} diff --git a/testing/simapp/upgrades/v7.1/upgrades.go b/testing/simapp/upgrades/v7.1/upgrades.go deleted file mode 100644 index 6120b3726e9..00000000000 --- a/testing/simapp/upgrades/v7.1/upgrades.go +++ /dev/null @@ -1,6 +0,0 @@ -package v71 - -const ( - // UpgradeName defines the on-chain upgrade name for the SimApp v7.1 upgrade. - UpgradeName = "v7.1 - localhost" -) diff --git a/testing/simapp/upgrades/v7/upgrades.go b/testing/simapp/upgrades/v7/upgrades.go deleted file mode 100644 index 4621c06339b..00000000000 --- a/testing/simapp/upgrades/v7/upgrades.go +++ /dev/null @@ -1,42 +0,0 @@ -package v7 - -import ( - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - consensusparamskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" - ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations" -) - -const ( - // UpgradeName defines the on-chain upgrade name for the SimApp v7 upgrade. - UpgradeName = "v7" -) - -// CreateUpgradeHandler creates an upgrade handler for the v7 SimApp upgrade. -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - cdc codec.BinaryCodec, - clientKeeper clientkeeper.Keeper, - consensusParamsKeeper consensusparamskeeper.Keeper, - paramsKeeper paramskeeper.Keeper, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - // OPTIONAL: prune expired tendermint consensus states to save storage space - if _, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, cdc, clientKeeper); err != nil { - return nil, err - } - - legacyBaseAppSubspace := paramsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()) - baseapp.MigrateParams(ctx, legacyBaseAppSubspace, &consensusParamsKeeper) - - return mm.RunMigrations(ctx, configurator, vm) - } -} From d0574b789cf67e67504ee89cf7e5248db5a7a8c8 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 15:19:50 +0100 Subject: [PATCH 08/11] rename workflow job --- .github/workflows/e2e-upgrade.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index bbe40871402..16a599c4629 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -42,7 +42,7 @@ jobs: test-entry-point: "TestUpgradeTestSuite" test: "TestV6ToV7ChainUpgrade" - upgrade-v7-localhost: + upgrade-v7.1: uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main with: chain-image: ghcr.io/cosmos/ibc-go-simd From b617092d7b5702d97cc382bf33236e23c0833c2e Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 15:21:18 +0100 Subject: [PATCH 09/11] fixing workflow job naming... dots not allowed --- .github/workflows/e2e-upgrade.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-upgrade.yaml b/.github/workflows/e2e-upgrade.yaml index 16a599c4629..79415380b5c 100644 --- a/.github/workflows/e2e-upgrade.yaml +++ b/.github/workflows/e2e-upgrade.yaml @@ -42,7 +42,7 @@ jobs: test-entry-point: "TestUpgradeTestSuite" test: "TestV6ToV7ChainUpgrade" - upgrade-v7.1: + upgrade-v7_1: uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main with: chain-image: ghcr.io/cosmos/ibc-go-simd From 1cd5f4b6775f6b45aaa71da49aea6926695e3858 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 16:42:03 +0100 Subject: [PATCH 10/11] use upgrade plan name from config --- e2e/tests/upgrades/upgrade_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index b60563f5139..46aee7b5878 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -618,7 +618,7 @@ func (s *UpgradeTestSuite) TestV7ChainUpgradeAddLocalhost() { t.Run("upgrade chain", func(t *testing.T) { govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) - s.UpgradeChain(ctx, chain, govProposalWallet, v71.UpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag) + s.UpgradeChain(ctx, chain, govProposalWallet, testCfg.UpgradePlanName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag) }) t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) { From 1c165be43da706840cc6e1eebd13f0d2bfba50d3 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 20 Feb 2023 17:05:51 +0100 Subject: [PATCH 11/11] removing unused import --- e2e/tests/upgrades/upgrade_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/tests/upgrades/upgrade_test.go b/e2e/tests/upgrades/upgrade_test.go index 46aee7b5878..08a0635c91d 100644 --- a/e2e/tests/upgrades/upgrade_test.go +++ b/e2e/tests/upgrades/upgrade_test.go @@ -29,7 +29,6 @@ import ( "github.com/cosmos/ibc-go/v7/modules/core/exported" solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v7/testing" - v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1" ) const (