diff --git a/app/app.go b/app/app.go index 530ad9854..b0eb44d42 100644 --- a/app/app.go +++ b/app/app.go @@ -207,7 +207,7 @@ import ( cwasm "github.com/comdex-official/comdex/app/wasm" mv13 "github.com/comdex-official/comdex/app/upgrades/mainnet/v13" - tv14 "github.com/comdex-official/comdex/app/upgrades/testnet/v14" + mv14 "github.com/comdex-official/comdex/app/upgrades/mainnet/v14" ) const ( @@ -1544,8 +1544,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { func (a *App) registerUpgradeHandlers() { a.UpgradeKeeper.SetUpgradeHandler( - tv14.UpgradeName, - tv14.CreateUpgradeHandlerV14(a.mm, a.configurator, a.AuctionKeeperSkip, a.LendKeeper, a.WasmKeeper, *a.StakingKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper), + mv14.UpgradeName, + mv14.CreateUpgradeHandlerV14(a.mm, a.configurator, a.AuctionKeeperSkip, a.LendKeeper), ) // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it @@ -1579,7 +1579,7 @@ func upgradeHandlers(upgradeInfo upgradetypes.Plan, a *App, storeUpgrades *store ibcfeetypes.StoreKey, }, } - case upgradeInfo.Name == tv14.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): + case upgradeInfo.Name == mv14.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): storeUpgrades = &storetypes.StoreUpgrades{ Added: []string{ auctionmoduleskiptypes.StoreKey, diff --git a/app/upgrades/mainnet/v14/constants.go b/app/upgrades/mainnet/v14/constants.go new file mode 100644 index 000000000..00ec22b4c --- /dev/null +++ b/app/upgrades/mainnet/v14/constants.go @@ -0,0 +1,15 @@ +package v14 + +const ( + UpgradeName = "v14.1.0" + UpgradeHeight = "" + UpgradeInfo = `'{ + "binaries": { + "darwin/arm64":"", + "darwin/x86_64":"", + "linux/arm64":"", + "linux/x86_64":"", + "windows/x86_64":"" + } + }'` +) diff --git a/app/upgrades/mainnet/v14/upgrade_test.go b/app/upgrades/mainnet/v14/upgrade_test.go new file mode 100644 index 000000000..a289ca414 --- /dev/null +++ b/app/upgrades/mainnet/v14/upgrade_test.go @@ -0,0 +1,39 @@ +package v14_test + +import ( + "github.com/comdex-official/comdex/app" + v14 "github.com/comdex-official/comdex/app/upgrades/mainnet/v14" + "github.com/stretchr/testify/suite" + "testing" +) + +type UpgradeTestSuite struct { + app.KeeperTestHelper +} + +func (s *UpgradeTestSuite) SetupTest() { + s.Setup() +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +// Ensures the test does not error out. +func (s *UpgradeTestSuite) TestUpgrade() { + s.Setup() + + preUpgradeChecks(s) + + upgradeHeight := int64(5) + s.ConfirmUpgradeSucceeded(v14.UpgradeName, upgradeHeight) + + postUpgradeChecks(s) +} + +func preUpgradeChecks(s *UpgradeTestSuite) { +} + +func postUpgradeChecks(s *UpgradeTestSuite) { + +} diff --git a/app/upgrades/mainnet/v14/upgrades.go b/app/upgrades/mainnet/v14/upgrades.go new file mode 100644 index 000000000..51abbe345 --- /dev/null +++ b/app/upgrades/mainnet/v14/upgrades.go @@ -0,0 +1,68 @@ +package v14 + +import ( + lendkeeper "github.com/comdex-official/comdex/x/lend/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + auctionkeeperskip "github.com/skip-mev/block-sdk/x/auction/keeper" + auctionmoduleskiptypes "github.com/skip-mev/block-sdk/x/auction/types" + "strings" +) + +func CreateUpgradeHandlerV14( + mm *module.Manager, + configurator module.Configurator, + auctionkeeperskip auctionkeeperskip.Keeper, + lendKeeper lendkeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + + ctx.Logger().Info("Applying main net upgrade - v14.1.0") + vm, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return vm, err + } + + ctx.Logger().Info("setting default params for MEV module (x/auction)") + if err = setDefaultMEVParams(ctx, auctionkeeperskip); err != nil { + return nil, err + } + + ctx.Logger().Info("updating lend params") + UpdateLendParams(ctx, lendKeeper) + return vm, err + } +} + +func setDefaultMEVParams(ctx sdk.Context, auctionkeeperskip auctionkeeperskip.Keeper) error { + nativeDenom := getChainBondDenom(ctx.ChainID()) + + // Skip MEV (x/auction) + return auctionkeeperskip.SetParams(ctx, auctionmoduleskiptypes.Params{ + MaxBundleSize: auctionmoduleskiptypes.DefaultMaxBundleSize, + EscrowAccountAddress: authtypes.NewModuleAddress(auctionmoduleskiptypes.ModuleName), // TODO: revisit + ReserveFee: sdk.NewCoin(nativeDenom, sdk.NewInt(10)), + MinBidIncrement: sdk.NewCoin(nativeDenom, sdk.NewInt(5)), + FrontRunningProtection: auctionmoduleskiptypes.DefaultFrontRunningProtection, + ProposerFee: auctionmoduleskiptypes.DefaultProposerFee, + }) +} + +// getChainBondDenom returns expected bond denom based on chainID. +func getChainBondDenom(chainID string) string { + if strings.HasPrefix(chainID, "comdex-") { + return "ucmdx" + } + return "stake" +} + +func UpdateLendParams( + ctx sdk.Context, + lendKeeper lendkeeper.Keeper, +) { + assetRatesParamsStAtom, _ := lendKeeper.GetAssetRatesParams(ctx, 14) + assetRatesParamsStAtom.CAssetID = 23 + lendKeeper.SetAssetRatesParams(ctx, assetRatesParamsStAtom) +} diff --git a/app/upgrades/testnet/v14/upgrade_test.go b/app/upgrades/testnet/v14/upgrade_test.go index 9d5d7e0de..31db98140 100644 --- a/app/upgrades/testnet/v14/upgrade_test.go +++ b/app/upgrades/testnet/v14/upgrade_test.go @@ -3,7 +3,7 @@ package v14_test import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/comdex-official/comdex/app" - v14 "github.com/comdex-official/comdex/app/upgrades/testnet/v14" + // v14 "github.com/comdex-official/comdex/app/upgrades/testnet/v14" "github.com/stretchr/testify/suite" "testing" ) @@ -22,14 +22,14 @@ func TestKeeperTestSuite(t *testing.T) { // Ensures the test does not error out. func (s *UpgradeTestSuite) TestUpgrade() { - s.Setup() + // s.Setup() - preUpgradeChecks(s) + // preUpgradeChecks(s) - upgradeHeight := int64(5) - s.ConfirmUpgradeSucceeded(v14.UpgradeName, upgradeHeight) + // upgradeHeight := int64(5) + // s.ConfirmUpgradeSucceeded(v14.UpgradeName, upgradeHeight) - postUpgradeChecks(s) + // postUpgradeChecks(s) } func preUpgradeChecks(s *UpgradeTestSuite) {