Skip to content

Commit

Permalink
add forced commission update to lupercalia (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-frey authored Feb 1, 2022
1 parent 0d27c2a commit 7ec1d74
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,31 @@ func (app *App) RegisterTendermintService(clientCtx client.Context) {
// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler("lupercalia", func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// force an update of validator min commission
// we already did this for moneta
// but validators could have snuck in changes in the
// interim
// and via state sync to post-moneta
validators := app.StakingKeeper.GetAllValidators(ctx)
// hard code this because we don't want
// a) a fork or
// b) immediate reaction with additional gov props
minCommissionRate := sdk.NewDecWithPrec(5, 2)
for _, v := range validators {
if v.Commission.Rate.LT(minCommissionRate) {
if v.Commission.MaxRate.LT(minCommissionRate) {
v.Commission.MaxRate = minCommissionRate
}

v.Commission.Rate = minCommissionRate
v.Commission.UpdateTime = ctx.BlockHeader().Time

// call the before-modification hook since we're about to update the commission
app.StakingKeeper.BeforeValidatorModified(ctx, v.GetOperator())

app.StakingKeeper.SetValidator(ctx, v)
}
}
return app.mm.RunMigrations(ctx, cfg, vm)
})
}
Expand Down

0 comments on commit 7ec1d74

Please sign in to comment.