Skip to content

Commit

Permalink
chore!: add min commission rates migration (prop 826)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Dec 13, 2023
1 parent c9b7817 commit 16a9c97
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/cosmos/gaia/v15/app/keepers"
)

// adhere to prop 826 which sets the minimum commission rate to 5% for all validators
// https://www.mintscan.io/cosmos/proposals/826
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand All @@ -21,7 +23,21 @@ func CreateUpgradeHandler(
return vm, err
}

ctx.Logger().Info("Upgrade complete")
params := keepers.StakingKeeper.GetParams(ctx)
params.MinCommissionRate = sdk.NewDecWithPrec(5, 2)
keepers.StakingKeeper.SetParams(ctx, params)

Check failure on line 28 in app/upgrades/v15/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `keepers.StakingKeeper.SetParams` is not checked (errcheck)

Check failure on line 28 in app/upgrades/v15/upgrades.go

View workflow job for this annotation

GitHub Actions / Analyze

Error return value of `keepers.StakingKeeper.SetParams` is not checked (errcheck)

for _, val := range keepers.StakingKeeper.GetAllValidators(ctx) {
val := val
// update validator commission rate if it is less than 5%
if val.Commission.CommissionRates.Rate.LT(sdk.NewDecWithPrec(5, 2)) {
val.Commission.UpdateTime = ctx.BlockHeader().Time
val.Commission.CommissionRates.Rate = sdk.NewDecWithPrec(5, 2)
keepers.StakingKeeper.SetValidator(ctx, val)
}
}

ctx.Logger().Info("Upgrade v15 complete")
return vm, err
}
}

0 comments on commit 16a9c97

Please sign in to comment.