crypto-com / crypto-com/chain-indexing

Problem: One-off validator minimum commission update on upgrade are not applied

Open
#824 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
34
Forks
32
PR merge metrics
No merged PRs in 30d

Description

Problem
On Crypto.org Chain v4 upgrade, there's a one-off minimum commission requirements applied to all the validators.
These updates do not emit any events, which complicates how we could capture them.

```
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// the minimal commission rate of 5% (0.05)
// (default is needed to be set because of SDK store migrations that set the param)
stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2)

stakingKeeper.IterateValidators(ctx, func(index int64, val stakingtypes.ValidatorI) (stop bool) {
if val.GetCommission().LT(stakingtypes.DefaultMinCommissionRate) {
validator, found := stakingKeeper.GetValidator(ctx, val.GetOperator())
if !found {
ctx.Logger().Error("validator not found", val)
return true
}
ctx.Logger().Info("update validator's commission rate to a minimal one", val)
validator.Commission.Rate = stakingtypes.DefaultMinCommissionRate
if validator.Commission.MaxRate.LT(stakingtypes.DefaultMinCommissionRate) {
validator.Commission.MaxRate = stakingtypes.DefaultMinCommissionRate
}
stakingKeeper.SetValidator(ctx, validator)
}
return false
})
```

Code ref: https://github.com/crypto-org-chain/chain-main/blob/v4.2.2/app/app.go#L702

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.