Skip to content

Commit

Permalink
chore: add v6 upgrade handler to simapp (#2383) (#2443)
Browse files Browse the repository at this point in the history
* renaming ica migrations handler pkg version

* adding v6 upgrade handler to simapp

* removing whitespace

* adding inline doc comments

(cherry picked from commit ecee40f)

# Conflicts:
#	testing/simapp/app.go

Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
mergify[bot] and damiannolan authored Sep 29, 2022
1 parent 1fd6edb commit 770b57f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ require (
github.com/cosmos/cosmos-sdk v0.46.1
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.2
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.5.0
Expand Down Expand Up @@ -148,7 +150,5 @@ require (

require (
github.com/gin-gonic/gin v1.7.0 // indirect
github.com/gorilla/mux v1.8.0
github.com/rakyll/statik v0.1.7
github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect
)
17 changes: 17 additions & 0 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import (
ibcmock "github.com/cosmos/ibc-go/v6/testing/mock"
simappparams "github.com/cosmos/ibc-go/v6/testing/simapp/params"
simappupgrades "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades"
v6 "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades/v6"
)

const appName = "SimApp"
Expand Down Expand Up @@ -870,4 +871,20 @@ func (app *SimApp) setupUpgradeHandlers() {
simappupgrades.DefaultUpgradeName,
simappupgrades.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.
// This should be the same string value provided upon instantiation of the ScopedKeeper with app.CapabilityKeeper.ScopeToModule()
// 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(
app.mm,
app.configurator,
app.appCodec,
app.keys[capabilitytypes.ModuleName],
app.CapabilityKeeper,
ibcmock.ModuleName+icacontrollertypes.SubModuleName,
),
)
}
36 changes: 36 additions & 0 deletions testing/simapp/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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/v6/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)
}
}

0 comments on commit 770b57f

Please sign in to comment.