Skip to content

Commit

Permalink
v20 upgrade handler scaffolding (#1148)
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-stride authored Mar 20, 2024
1 parent e1408d1 commit 2f3d39d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
v18 "github.com/Stride-Labs/stride/v19/app/upgrades/v18"
v19 "github.com/Stride-Labs/stride/v19/app/upgrades/v19"
v2 "github.com/Stride-Labs/stride/v19/app/upgrades/v2"
v20 "github.com/Stride-Labs/stride/v19/app/upgrades/v20"
v3 "github.com/Stride-Labs/stride/v19/app/upgrades/v3"
v4 "github.com/Stride-Labs/stride/v19/app/upgrades/v4"
v5 "github.com/Stride-Labs/stride/v19/app/upgrades/v5"
Expand Down Expand Up @@ -263,6 +264,16 @@ func (app *StrideApp) setupUpgradeHandlers(appOpts servertypes.AppOptions) {
),
)

// v20 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v20.UpgradeName,
v20.CreateUpgradeHandler(
app.mm,
app.configurator,
app.StakeibcKeeper,
),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err))
Expand Down
42 changes: 42 additions & 0 deletions app/upgrades/v20/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package v20

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

stakeibckeeper "github.com/Stride-Labs/stride/v19/x/stakeibc/keeper"
)

const (
UpgradeName = "v20"
dydxCPTreasuryAddress = "dydx15ztc7xy42tn2ukkc0qjthkucw9ac63pgp70urn"
dydxChainId = "dydx-mainnet-1"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v20
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
stakeIbcKeeper stakeibckeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting upgrade v20...")

ctx.Logger().Info("Adding DYDX Community Pool Treasury Address...")

return mm.RunMigrations(ctx, configurator, vm)
}
}

// Write the Community Pool Treasury Address to the DYDX host_zone struct
func SetDydxCommunityPoolTreasuryAddress(ctx sdk.Context, stakeIbcKeeper stakeibckeeper.Keeper) error {

// Get the dydx host_zone

// Set the treasury address

// Save the dydx host_zone

return nil
}
24 changes: 24 additions & 0 deletions app/upgrades/v20/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package v20_test

import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/Stride-Labs/stride/v19/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() {
}

0 comments on commit 2f3d39d

Please sign in to comment.