Skip to content

Commit

Permalink
Merge pull request #828 from neutron-org/feat/v5.1.0-upgrade-handler
Browse files Browse the repository at this point in the history
fix upgrade handler
  • Loading branch information
pr0n00gler authored Feb 7, 2025
2 parents 469f962 + 21c411c commit ad20842
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/upgrades/v5.1.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.1.0"
UpgradeName = "v5.1.0"
MarketMapAuthorityMultisig = "neutron1ldvrvhyvtssm0ptdq23hhaltprx8ctmjh92kzfs55sz2z997n76s72wr86"
)

var Upgrade = upgrades.Upgrade{
Expand Down
19 changes: 18 additions & 1 deletion app/upgrades/v5.1.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import (
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
adminmoduletypes "github.com/cosmos/admin-module/v2/x/adminmodule/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
marketmapkeeper "github.com/skip-mev/slinky/x/marketmap/keeper"
marketmaptypes "github.com/skip-mev/slinky/x/marketmap/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ *upgrades.UpgradeKeepers,
keepers *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
Expand All @@ -29,7 +33,20 @@ func CreateUpgradeHandler(
return vm, err
}

err = setMarketMapParams(ctx, keepers.MarketmapKeeper)
if err != nil {
return nil, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}

func setMarketMapParams(ctx sdk.Context, marketmapKeeper *marketmapkeeper.Keeper) error {
marketmapParams := marketmaptypes.Params{
MarketAuthorities: []string{authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), MarketMapAuthorityMultisig},
Admin: authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
}
return marketmapKeeper.SetParams(ctx, marketmapParams)
}
8 changes: 7 additions & 1 deletion app/upgrades/v5.1.0/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
func (suite *UpgradeTestSuite) TestUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()
Expand All @@ -34,4 +34,10 @@ func (suite *UpgradeTestSuite) TestOracleUpgrade() {
Height: 100,
}
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))

params, err := app.MarketMapKeeper.GetParams(ctx)
suite.Require().NoError(err)
suite.Require().Equal(params.MarketAuthorities[0], "neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z")
suite.Require().Equal(params.MarketAuthorities[1], v510.MarketMapAuthorityMultisig)
suite.Require().Equal(params.Admin, "neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z")
}

0 comments on commit ad20842

Please sign in to comment.