Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v13.2.0 upgrade handler #868

Merged
merged 14 commits into from
Dec 8, 2023
Prev Previous commit
Next Next commit
3sec BT, permissionless removed from current upgrade
  • Loading branch information
cgsingh33 committed Dec 7, 2023
commit 1d96d5937bb63fbc80d17f7c04e4deae63998836
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ func (a *App) ModuleAccountsPermissions() map[string][]string {
func (a *App) registerUpgradeHandlers() {
a.UpgradeKeeper.SetUpgradeHandler(
mv13.UpgradeName,
mv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.WasmKeeper, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.ICQKeeper, a.GovKeeper, a.MintKeeper, a.SlashingKeeper, a.BandoracleKeeper, a.AssetKeeper, a.LendKeeper, a.NewliqKeeper, a.NewaucKeeper),
mv13.CreateUpgradeHandlerV13(a.mm, a.configurator, a.cdc, a.ParamsKeeper, a.ConsensusParamsKeeper, *a.IbcKeeper, a.ICQKeeper, a.GovKeeper, a.AssetKeeper, a.LendKeeper, a.NewliqKeeper, a.NewaucKeeper),
)
// 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
Expand Down
19 changes: 0 additions & 19 deletions app/upgrades/mainnet/v13/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/suite"

"github.com/comdex-official/comdex/app"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
v13 "github.com/comdex-official/comdex/app/upgrades/mainnet/v13"
)

Expand Down Expand Up @@ -36,29 +35,11 @@ func (s *UpgradeTestSuite) TestUpgrade() {

func preUpgradeChecks(s *UpgradeTestSuite) {

mp := s.App.MintKeeper.GetParams(s.Ctx)
s.Require().Equal(mp.BlocksPerYear, uint64(6311520))

sp := s.App.SlashingKeeper.GetParams(s.Ctx)
s.Require().Equal(sp.SignedBlocksWindow, int64(100))

}

func postUpgradeChecks(s *UpgradeTestSuite) {

// Ensure the gov params have MinInitialDepositRatio added
gp := s.App.GovKeeper.GetParams(s.Ctx)
s.Require().Equal(gp.MinInitialDepositRatio, "0.200000000000000000")

// Ensure the mint params have doubled
mp := s.App.MintKeeper.GetParams(s.Ctx)
s.Require().Equal(mp.BlocksPerYear, uint64(6311520*2))

// Ensure the slashing params have doubled
sp := s.App.SlashingKeeper.GetParams(s.Ctx)
s.Require().Equal(sp.SignedBlocksWindow, int64(100*2))

// Ensure the wasm Permissionless
wp := s.App.WasmKeeper.GetParams(s.Ctx)
s.Require().Equal(wp.CodeUploadAccess, wasmtypes.AllowEverybody)
}
43 changes: 0 additions & 43 deletions app/upgrades/mainnet/v13/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package v13

import (
"fmt"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
assetkeeper "github.com/comdex-official/comdex/x/asset/keeper"
assettypes "github.com/comdex-official/comdex/x/asset/types"
auctionV2keeper "github.com/comdex-official/comdex/x/auctionsV2/keeper"
auctionsV2types "github.com/comdex-official/comdex/x/auctionsV2/types"
bandoraclemodulekeeper "github.com/comdex-official/comdex/x/bandoracle/keeper"
lendkeeper "github.com/comdex-official/comdex/x/lend/keeper"
lendtypes "github.com/comdex-official/comdex/x/lend/types"
liquidationV2keeper "github.com/comdex-official/comdex/x/liquidationsV2/keeper"
Expand All @@ -19,10 +16,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icqkeeper "github.com/cosmos/ibc-apps/modules/async-icq/v7/keeper"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"
Expand All @@ -35,15 +30,11 @@ func CreateUpgradeHandlerV13(
mm *module.Manager,
configurator module.Configurator,
cdc codec.Codec,
wasmKeeper wasmkeeper.Keeper,
paramsKeeper paramskeeper.Keeper,
consensusParamsKeeper consensusparamkeeper.Keeper,
IBCKeeper ibckeeper.Keeper,
icqkeeper *icqkeeper.Keeper,
GovKeeper govkeeper.Keeper,
MintKeeper mintkeeper.Keeper,
SlashingKeeper slashingkeeper.Keeper,
bandoracleKeeper bandoraclemodulekeeper.Keeper,
assetKeeper assetkeeper.Keeper,
lendKeeper lendkeeper.Keeper,
liquidationV2Keeper liquidationV2keeper.Keeper,
Expand All @@ -63,7 +54,6 @@ func CreateUpgradeHandlerV13(
// https://github.com/cosmos/ibc-go/blob/v7.1.0/docs/migrations/v4-to-v5.md
// -- nothing --

// TODO: check if v5-v6 is required ??
// https://github.com/cosmos/ibc-go/blob/v7.1.0/docs/migrations/v5-to-v6.md

// ibc v6-to-v7
Expand Down Expand Up @@ -95,7 +85,6 @@ func CreateUpgradeHandlerV13(
}
logger.Info(fmt.Sprintf("post migrate version map: %v", vm))

//TODO: confirm the initial deposit
// update gov params to use a 20% initial deposit ratio, allowing us to remote the ante handler
govParams := GovKeeper.GetParams(ctx)
govParams.MinInitialDepositRatio = sdk.NewDec(20).Quo(sdk.NewDec(100)).String()
Expand All @@ -104,38 +93,6 @@ func CreateUpgradeHandlerV13(
}
logger.Info(fmt.Sprintf("updated gov params to %v", govParams))

// x/Mint
// Double blocks per year (from 6 seconds to 3 = 2x blocks per year)
mintParams := MintKeeper.GetParams(ctx)
mintParams.BlocksPerYear *= 2
if err = MintKeeper.SetParams(ctx, mintParams); err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("updated minted blocks per year logic to %v", mintParams))

// x/Slashing
// Double slashing window due to double blocks per year
slashingParams := SlashingKeeper.GetParams(ctx)
slashingParams.SignedBlocksWindow *= 2
if err := SlashingKeeper.SetParams(ctx, slashingParams); err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("updated slashing params to %v", slashingParams))

// update wasm to permissionless
wasmParams := wasmKeeper.GetParams(ctx)
wasmParams.CodeUploadAccess = wasmtypes.AllowEverybody
wasmKeeper.SetParams(ctx, wasmParams)
logger.Info(fmt.Sprintf("updated wasm params to %v", wasmParams))

// update discard BH of oracle
bandData := bandoracleKeeper.GetFetchPriceMsg(ctx)
if bandData.Size() > 0 {
bandData.AcceptedHeightDiff = 6000
bandoracleKeeper.SetFetchPriceMsg(ctx, bandData)
logger.Info(fmt.Sprintf("updated bandData to %v", bandData))
}

UpdateLendParams(ctx, lendKeeper, assetKeeper)
InitializeStates(ctx, liquidationV2Keeper, auctionV2Keeper)

Expand Down
12 changes: 6 additions & 6 deletions cmd/comdex/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"os"
"path/filepath"
"time"
// "time"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
Expand Down Expand Up @@ -76,13 +76,13 @@ func NewRootCmd() (*cobra.Command, comdex.EncodingConfig) {
return err
}
// 2 seconds + 1 second tendermint = 3 second blocks
timeoutCommit := 2 * time.Second
// timeoutCommit := 2 * time.Second

customAppTemplate, customAppConfig := initAppConfig()
customTMConfig := initTendermintConfig(timeoutCommit)
customTMConfig := initTendermintConfig()

// Force faster block times
os.Setenv("COMDEX_CONSENSUS_TIMEOUT_COMMIT", cast.ToString(timeoutCommit))
// os.Setenv("COMDEX_CONSENSUS_TIMEOUT_COMMIT", cast.ToString(timeoutCommit))

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig)
},
Expand All @@ -92,15 +92,15 @@ func NewRootCmd() (*cobra.Command, comdex.EncodingConfig) {
return root, encodingConfig
}

func initTendermintConfig(timeoutCommit time.Duration) *tmcfg.Config {
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()

// these values put a higher strain on node memory
// cfg.P2P.MaxNumInboundPeers = 100
// cfg.P2P.MaxNumOutboundPeers = 40

// While this is set, it only applies to new configs.
cfg.Consensus.TimeoutCommit = timeoutCommit
// cfg.Consensus.TimeoutCommit = timeoutCommit

return cfg
}
Expand Down
4 changes: 2 additions & 2 deletions x/bandoracle/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) {

block := k.GetLastBlockHeight(ctx)
if block != types.Int64Zero {
// if ctx.BlockHeight()%types.Int64Forty == types.Int64Zero && ctx.BlockHeight() != block {
if ctx.BlockHeight()%types.Int64Forty == types.Int64Zero {
// if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero && ctx.BlockHeight() != block {
if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero {
if !k.GetCheckFlag(ctx) {
msg := k.GetFetchPriceMsg(ctx)
_, err := k.FetchPrice(ctx, msg)
Expand Down
4 changes: 2 additions & 2 deletions x/market/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper, ba
if bandKeeper.GetOracleValidationResult(ctx) {
block := bandKeeper.GetLastBlockHeight(ctx)
if block != types.Int64Zero {
// if ctx.BlockHeight()%types.Int64Forty == types.Int64Zero && ctx.BlockHeight() != block && bandKeeper.GetCheckFlag(ctx) {
if ctx.BlockHeight()%types.Int64Forty == types.Int64Zero {
// if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero && ctx.BlockHeight() != block && bandKeeper.GetCheckFlag(ctx) {
if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero {
discardData := bandKeeper.GetDiscardData(ctx)
if discardData.DiscardBool {
allTwa := k.GetAllTwa(ctx)
Expand Down
Loading