Skip to content

Commit

Permalink
chore: add upgrade handler to simapp for v6 -> v7 (#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
charleenfei committed Nov 30, 2022
1 parent 788cc7c commit a5e3249
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core/24-host) [\#2820](https://github.com/cosmos/ibc-go/pull/2820) Add `MustParseClientStatePath` which parses the clientID from a client state key path.
* (apps/27-interchain-accounts) [\#2147](https://github.com/cosmos/ibc-go/pull/2147) Adding a `SubmitTx` gRPC endpoint for the ICS27 Controller module which allows owners of interchain accounts to submit transactions. This replaces the previously existing need for authentication modules to implement this standard functionality.
* (testing/simapp) [\#2190](https://github.com/cosmos/ibc-go/pull/2190) Adding the new `x/group` cosmos-sdk module to simapp.
* (testing/simapp) [\#2842](https://github.com/cosmos/ibc-go/pull/2842) Adding the new upgrade handler for v6 -> v7 to simapp which prunes expired Tendermint consensus states.

### Bug Fixes

Expand Down
11 changes: 11 additions & 0 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import (
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"
v7 "github.com/cosmos/ibc-go/v6/testing/simapp/upgrades/v7"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"
)

Expand Down Expand Up @@ -891,4 +892,14 @@ func (app *SimApp) setupUpgradeHandlers() {
ibcmock.ModuleName+icacontrollertypes.SubModuleName,
),
)

app.UpgradeKeeper.SetUpgradeHandler(
v7.UpgradeName,
v7.CreateUpgradeHandler(
app.mm,
app.configurator,
app.appCodec,
app.keys[ibchost.StoreKey],
),
)
}
32 changes: 32 additions & 0 deletions testing/simapp/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v7

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"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

ibctm "github.com/cosmos/ibc-go/v6/modules/light-clients/07-tendermint"
)

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,
hostStoreKey *storetypes.KVStoreKey,
) 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 := ibctm.PruneTendermintConsensusStates(ctx, cdc, hostStoreKey); err != nil {
return nil, err
}
return mm.RunMigrations(ctx, configurator, vm)
}
}

0 comments on commit a5e3249

Please sign in to comment.