Skip to content

Commit

Permalink
upgrades : set governance parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnfoo committed Jun 18, 2024
1 parent 9d42dd8 commit 7dd355c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (app *WasmApp) RegisterUpgradeHandlers() {
CapabilityKeeper: app.CapabilityKeeper,
IBCKeeper: app.IBCKeeper,
CrisisKeeper: app.CrisisKeeper,
GovKeeper: &app.GovKeeper,
Codec: app.appCodec,
GetStoreKey: app.GetKey,
}
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
)

Expand All @@ -26,6 +27,7 @@ type AppKeepers struct {
CapabilityKeeper *capabilitykeeper.Keeper
IBCKeeper *ibckeeper.Keeper
CrisisKeeper *crisiskeeper.Keeper
GovKeeper *govkeeper.Keeper
}
type ModuleManager interface {
RunMigrations(ctx context.Context, cfg module.Configurator, fromVM module.VersionMap) (module.VersionMap, error)
Expand Down
28 changes: 24 additions & 4 deletions app/upgrades/v051/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
circuittypes "cosmossdk.io/x/circuit/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
Expand Down Expand Up @@ -58,19 +59,38 @@ func CreateUpgradeHandler(
}
}

logger.Info("==== Migrations summary end =====")

for moduleName, newVersion := range newVersionMap {
if _, ok := fromVM[moduleName]; !ok {
logger.Info(fmt.Sprintf("Module %s was added during the upgrade with version %d", moduleName, newVersion))
}
}

logger.Info("==== Migrations summary end =====")

// Set governance module parameters
logger.Info("==== Setting governance parameters =====")
govParams, err := ak.GovKeeper.Params.Get(sdkCtx)

if err != nil {
panic("Failed to get governance parameters")
}

// 5 times the deposit of regular proposals for expedited proposals
depositDenom, depositAmount := govParams.MinDeposit[0].Denom, govParams.MinDeposit[0].Amount.Mul(sdkmath.NewInt(5))
govParams.ExpeditedMinDeposit = sdk.NewCoins(sdk.NewInt64Coin(depositDenom, depositAmount.Int64()))
govParams.ProposalCancelRatio = sdkmath.LegacyZeroDec().String()

ok := ak.GovKeeper.Params.Set(ctx, govParams)

if ok != nil {
panic("Failed to set governance parameters")
}

// Check if we're good after the upgrade
logger.Info("Asserting invariants post-upgrade")
logger.Info(" === Asserting invariants post-upgrade === ")
ak.CrisisKeeper.AssertInvariants(sdkCtx)

logger.Info("Upgrade complete!")
logger.Info("Upgrade complete! 🎉")

return newVersionMap, err
}
Expand Down

0 comments on commit 7dd355c

Please sign in to comment.