From 9cc869f347a9a937e5641fdd1a232f214aa8d70f Mon Sep 17 00:00:00 2001 From: sampocs Date: Fri, 12 Apr 2024 10:50:54 -0500 Subject: [PATCH] added v22 upgrade handler (#1174) --- app/upgrades.go | 13 +++++++++++-- app/upgrades/v22/upgrades.go | 23 +++++++++++++++++++++++ app/upgrades/v22/upgrades_test.go | 27 +++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 app/upgrades/v22/upgrades.go create mode 100644 app/upgrades/v22/upgrades_test.go diff --git a/app/upgrades.go b/app/upgrades.go index 26f2be573d..5fcdf47cc1 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -4,6 +4,7 @@ import ( "fmt" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" authz "github.com/cosmos/cosmos-sdk/x/authz" @@ -15,8 +16,6 @@ import ( consumertypes "github.com/cosmos/interchain-security/v4/x/ccv/consumer/types" evmosvestingtypes "github.com/evmos/vesting/x/vesting/types" - ratelimittypes "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/types" - v10 "github.com/Stride-Labs/stride/v21/app/upgrades/v10" v11 "github.com/Stride-Labs/stride/v21/app/upgrades/v11" v12 "github.com/Stride-Labs/stride/v21/app/upgrades/v12" @@ -30,6 +29,7 @@ import ( v2 "github.com/Stride-Labs/stride/v21/app/upgrades/v2" v20 "github.com/Stride-Labs/stride/v21/app/upgrades/v20" v21 "github.com/Stride-Labs/stride/v21/app/upgrades/v21" + v22 "github.com/Stride-Labs/stride/v21/app/upgrades/v22" v3 "github.com/Stride-Labs/stride/v21/app/upgrades/v3" v4 "github.com/Stride-Labs/stride/v21/app/upgrades/v4" v5 "github.com/Stride-Labs/stride/v21/app/upgrades/v5" @@ -285,6 +285,15 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) { ), ) + // v22 upgrade handler + app.UpgradeKeeper.SetUpgradeHandler( + v22.UpgradeName, + v22.CreateUpgradeHandler( + app.mm, + app.configurator, + ), + ) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err)) diff --git a/app/upgrades/v22/upgrades.go b/app/upgrades/v22/upgrades.go new file mode 100644 index 0000000000..9631d49367 --- /dev/null +++ b/app/upgrades/v22/upgrades.go @@ -0,0 +1,23 @@ +package v22 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +const ( + UpgradeName = "v22" +) + +// CreateUpgradeHandler creates an SDK upgrade handler for v22 +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting upgrade v22...") + ctx.Logger().Info("Running module migrations...") + return mm.RunMigrations(ctx, configurator, vm) + } +} diff --git a/app/upgrades/v22/upgrades_test.go b/app/upgrades/v22/upgrades_test.go new file mode 100644 index 0000000000..7942740033 --- /dev/null +++ b/app/upgrades/v22/upgrades_test.go @@ -0,0 +1,27 @@ +package v22_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/Stride-Labs/stride/v21/app/apptesting" +) + +type UpgradeTestSuite struct { + apptesting.AppTestHelper +} + +func (s *UpgradeTestSuite) SetupTest() { + s.Setup() +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (s *UpgradeTestSuite) TestUpgrade() { + dummyUpgradeHeight := int64(5) + + s.ConfirmUpgradeSucceededs("v22", dummyUpgradeHeight) +}