Upgrade handler for Validator Commission rate#49
Conversation
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @TxCorpi0x)
app/upgrade/v6/validator_commission.go line 34 at r1 (raw file):
if validator.Commission.Rate.LT(minCommissionRate) { validatorsToUpdate = append(validatorsToUpdate, validator)
why do we need this intermediate slice ?
Can't we make all changes in a single for loop ?
testutil/simapp/simapp.go line 279 at r1 (raw file):
operator sdk.AccAddress, value sdk.Coin, commissionRate, maxRate *sdkmath.LegacyDec,
slightly better version IMO is to accept *stakingtypes.CommissionRates and use it or set default values (partially / fully)
integration-tests/upgrade/validator_commission.go line 17 at r1 (raw file):
type validatorCommission struct{} func (v *validatorCommission) Before(t *testing.T) {
do we have validators with < 5% commission generated in znet in current config ?
Would be nice to test this migration in integration test also, if we have this possibility
TxCorpi0x
left a comment
There was a problem hiding this comment.
Reviewable status: 2 of 10 files reviewed, 3 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)
app/upgrade/v6/validator_commission.go line 34 at r1 (raw file):
Previously, ysv (Yaroslav Savchuk) wrote…
why do we need this intermediate slice ?
Can't we make all changes in a single for loop ?
Done
integration-tests/upgrade/validator_commission.go line 17 at r1 (raw file):
Previously, ysv (Yaroslav Savchuk) wrote…
do we have validators with < 5% commission generated in znet in current config ?
Would be nice to test this migration in integration test also, if we have this possibility
They are created by 10% in the genesis, but also added a check for that in the Before step.
testutil/simapp/simapp.go line 279 at r1 (raw file):
Previously, ysv (Yaroslav Savchuk) wrote…
slightly better version IMO is to accept
*stakingtypes.CommissionRatesand use it or set default values (partially / fully)
Done
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 8 of 8 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh and @miladz68)
miladz68
left a comment
There was a problem hiding this comment.
@miladz68 reviewed 2 of 10 files at r1, 6 of 8 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @TxCorpi0x)
app/upgrade/v6/upgrade.go line 61 at r1 (raw file):
// Set minimum commission rate to 5% and update validators with lower rates minCommissionRate := sdkmath.LegacyNewDecWithPrec(5, 2) // 5 * 10^(-2) = 0.05 = 5% if err := SetMinCommissionRate(ctx, stakingKeeper, minCommissionRate); err != nil {
this action seems redundant.
TxCorpi0x
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)
app/upgrade/v6/upgrade.go line 61 at r1 (raw file):
Previously, miladz68 (milad) wrote…
this action seems redundant.
Is it planned to do it in separate proposal for governance with this?
I think It would be more straightforward to do it in upgrade handler in one shot.
TxCorpi0x
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @ysv)
app/upgrade/v6/upgrade.go line 61 at r1 (raw file):
Previously, TxCorpi0x wrote…
Is it planned to do it in separate proposal for governance with this?
I think It would be more straightforward to do it in upgrade handler in one shot.
@ysv What do you think?
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)
app/upgrade/v6/upgrade.go line 61 at r1 (raw file):
Previously, TxCorpi0x wrote…
@ysv What do you think?
this has already been executed as gov proposal on mainnet & testnet
So this action is redundant I agree
TxCorpi0x
left a comment
There was a problem hiding this comment.
Reviewable status: 7 of 10 files reviewed, 1 unresolved discussion (waiting on @masihyeganeh, @miladz68, and @ysv)
app/upgrade/v6/upgrade.go line 61 at r1 (raw file):
Previously, ysv (Yaroslav Savchuk) wrote…
this has already been executed as gov proposal on mainnet & testnet
So this action is redundant I agree
Done
ysv
left a comment
There was a problem hiding this comment.
@ysv reviewed 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @masihyeganeh and @miladz68)
miladz68
left a comment
There was a problem hiding this comment.
@miladz68 reviewed 3 of 3 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @masihyeganeh)
Description
This pull request introduces a migration to enforce a minimum validator commission rate of 5% in the staking module, updates all validators to comply with this new minimum, and adds comprehensive tests and integration checks for this change. It also updates helper functions and related tests to accommodate optional commission rates for validators.
Staking commission rate enforcement and migration:
RateandMaxRatefields as necessary. (app/upgrade/v6/upgrade.go,app/upgrade/v6/validator_commission.go)app/upgrade/v6/validator_commission_test.go)integration-tests/upgrade/validator_commission.go,integration-tests/upgrade/upgrade_test.go)Test and helper function improvements:
AddValidatorhelper function to accept optional commission rates, defaulting to 10% rate and 20% max rate if not provided, and updates all usages in tests to use the new signature. (testutil/simapp/simapp.go,x/dex/keeper/keeper_ft_test.go,x/pse/keeper/distribute_test.go,x/pse/keeper/grpc_query_test.go,x/pse/keeper/hooks_test.go)Dependency updates:
cosmossdk.io/mathpackage import to support decimal math operations for commission rates. (app/upgrade/v6/upgrade.go)Reviewers checklist:
Authors checklist
This change is