diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bdb28e97f3..1dd314cf1b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/testing/simapp/app.go b/testing/simapp/app.go index ac2a0be5fb9..633199155e7 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -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" ) @@ -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], + ), + ) } diff --git a/testing/simapp/upgrades/v7/upgrades.go b/testing/simapp/upgrades/v7/upgrades.go new file mode 100644 index 00000000000..a9072ed63a2 --- /dev/null +++ b/testing/simapp/upgrades/v7/upgrades.go @@ -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) + } +}