Skip to content

Commit

Permalink
ci: clean up upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Jun 18, 2024
1 parent 3eec461 commit 4bf307b
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ package app
import (
"fmt"

"cosmossdk.io/math"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
m "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
tiermoduletypes "github.com/elys-network/elys/x/tier/types"
)

func SetupHandlers(app *ElysApp) {
Expand All @@ -27,35 +22,6 @@ func setUpgradeHandler(app *ElysApp) {
func(ctx sdk.Context, plan upgradetypes.Plan, vm m.VersionMap) (m.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + version.Version)

if version.Version == "v0.32.0" || version.Version == "v999.999.999" {
// Since invariant is broken sending missing amount to bonded pool
sumOfValTokens := math.ZeroInt()
app.EstakingKeeper.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool {
sumOfValTokens = sumOfValTokens.Add(validator.GetTokens())
return false
})

totalBondedTokens := app.EstakingKeeper.TotalBondedTokens(ctx)
if totalBondedTokens.LT(sumOfValTokens) {
missingAmount := sumOfValTokens.Sub(totalBondedTokens)
missingCoins := sdk.Coins{sdk.NewCoin("uelys", missingAmount)}
err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, missingCoins)
if err != nil {
panic(err)
}
err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, stakingtypes.BondedPoolName, missingCoins)
if err != nil {
panic(err)
}
}

app.Logger().Info("Deleting proposals with ID <= 193")
store := ctx.KVStore(app.keys[govtypes.StoreKey])
for i := uint64(1); i <= 193; i++ {
store.Delete(govtypes.ProposalKey(i))
}
}

return app.mm.RunMigrations(ctx, app.configurator, vm)
},
)
Expand All @@ -71,7 +37,8 @@ func loadUpgradeStore(app *ElysApp) {

if shouldLoadUpgradeStore(app, upgradeInfo) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{tiermoduletypes.StoreKey},
// Added: []string{},
// Deleted: []string{},
}
fmt.Printf("Setting store loader with height %d and store upgrades: %+v\n", upgradeInfo.Height, storeUpgrades)

Expand Down

0 comments on commit 4bf307b

Please sign in to comment.