Skip to content

Commit

Permalink
update market map admin
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Sep 26, 2024
1 parent bd950f6 commit dc65431
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
marketmapkeeper "github.com/skip-mev/slinky/x/marketmap/keeper"

dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"

dynamicfeeskeeper "github.com/neutron-org/neutron/v5/x/dynamicfees/keeper"

contractmanagerkeeper "github.com/neutron-org/neutron/v5/x/contractmanager/keeper"
Expand Down
3 changes: 3 additions & 0 deletions app/upgrades/v5.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package v500

import (
storetypes "cosmossdk.io/store/types"

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

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.0"

MarketMapAuthorityMultisig = "neutron1anjpluecd0tdc0n8xzc3l5hua4h93wyq0x7v56"
)

var Upgrade = upgrades.Upgrade{
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v5.0.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ 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"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
)
Expand Down Expand Up @@ -37,6 +42,11 @@ func CreateUpgradeHandler(
}
}

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

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
Expand All @@ -57,3 +67,11 @@ func upgradeDexPause(ctx sdk.Context, k dexkeeper.Keeper) error {

return 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)
}
20 changes: 20 additions & 0 deletions app/upgrades/v5.0.0/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v500 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.0"
Expand All @@ -27,6 +28,25 @@ func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext()
t := suite.T()

upgrade := upgradetypes.Plan{
Name: v500.UpgradeName,
Info: "some text here",
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], v500.MarketMapAuthorityMultisig)
suite.Require().Equal(params.Admin, "neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z")
}

func (suite *UpgradeTestSuite) TestUpgradeDexPause() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
Expand Down

0 comments on commit dc65431

Please sign in to comment.