Skip to content

Commit

Permalink
added v22 upgrade handler (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs authored Apr 12, 2024
1 parent 6e1d739 commit 9cc869f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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))
Expand Down
23 changes: 23 additions & 0 deletions app/upgrades/v22/upgrades.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
27 changes: 27 additions & 0 deletions app/upgrades/v22/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 9cc869f

Please sign in to comment.