mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-20 15:05:21 +00:00
Set the CDP Block Interval to 100 during v0.26.x upgrade (#1865)
* set CDP block interval to 100 to only run interest synchronization for risky cdps every 100 blocks instead of every block * refactor and use constant for setting to improve clarity; update block interval to 50 instead of 100. This will decrease risk by running around every 6 minutes instead of 12 mintues for current mainnet block times.
This commit is contained in:
parent
8f93ca2048
commit
c9d900be2c
@ -27,6 +27,8 @@ import (
|
||||
const (
|
||||
UpgradeName_Mainnet = "v0.26.0"
|
||||
UpgradeName_Testnet = "v0.26.0-alpha.0"
|
||||
|
||||
CDPLiquidationBlockInterval = int64(50)
|
||||
)
|
||||
|
||||
// RegisterUpgradeHandlers registers the upgrade handlers for the app.
|
||||
@ -123,6 +125,16 @@ func upgradeHandler(
|
||||
// dedicated x/consensus module.
|
||||
baseapp.MigrateParams(ctx, baseAppLegacySS, &app.consensusParamsKeeper)
|
||||
|
||||
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||
// run migrations for all modules and return new consensus version map
|
||||
versionMap, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
|
||||
|
||||
// Set risky CDP's to sync interest and liquidate every 100 blocks instead
|
||||
// of every block. This significantly improves performance as this cdp
|
||||
// process is a signification porition of time spent during block execution.
|
||||
cdpParams := app.cdpKeeper.GetParams(ctx)
|
||||
cdpParams.LiquidationBlockInterval = CDPLiquidationBlockInterval
|
||||
app.cdpKeeper.SetParams(ctx, cdpParams)
|
||||
|
||||
return versionMap, err
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
cdptypes "github.com/kava-labs/kava/x/cdp/types"
|
||||
)
|
||||
|
||||
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
||||
@ -98,6 +99,26 @@ func (suite *IntegrationTestSuite) TestUpgradeParams_Consensus() {
|
||||
suite.Require().Equal(expectedParams, *paramsAfter.Params, "x/consensus params after upgrade should be as expected")
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) TestUpgradeParams_CDP_Interval() {
|
||||
suite.SkipIfUpgradeDisabled()
|
||||
|
||||
beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||
|
||||
grpcClient := suite.Kava.Grpc
|
||||
|
||||
paramsBefore, err := grpcClient.Query.Cdp.Params(beforeUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||
suite.Require().NoError(err)
|
||||
paramsAfter, err := grpcClient.Query.Cdp.Params(afterUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expectedParams := paramsBefore.Params
|
||||
expectedParams.LiquidationBlockInterval = int64(50)
|
||||
|
||||
suite.Require().Equal(expectedParams, paramsAfter.Params,
|
||||
"expected cdp parameters to equal previous parameters with a liquidation block interval of 100")
|
||||
}
|
||||
|
||||
func mustParseDuration(s string) *time.Duration {
|
||||
d, err := time.ParseDuration(s)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user