-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
132 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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":"" | ||
} | ||
}'` | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters