Skip to content

Commit

Permalink
Merge branch 'masa/migrate-v15-validator-commission-rates' into saino…
Browse files Browse the repository at this point in the history
…e/v15-si-upgrade
  • Loading branch information
sainoe committed Jan 18, 2024
2 parents 9bb3ce7 + 2e9e16a commit 726f35c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ func CreateUpgradeHandler(
return vm, err
}

UpgradeCommissionRate(ctx, *keepers.StakingKeeper)
UpgradeMinCommissionRate(ctx, *keepers.StakingKeeper)
UpgradeSigningInfos(ctx, keepers.SlashingKeeper)

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

// UpgradeCommissionRate sets the minimum commission rate staking parameter to 5%
// UpgradeMinCommissionRate sets the minimum commission rate staking parameter to 5%
// and updates the commission rate for all validators that have a commission rate less than 5%
func UpgradeCommissionRate(ctx sdk.Context, sk stakingkeeper.Keeper) {
func UpgradeMinCommissionRate(ctx sdk.Context, sk stakingkeeper.Keeper) {
params := sk.GetParams(ctx)
params.MinCommissionRate = sdk.NewDecWithPrec(5, 2)
err := sk.SetParams(ctx, params)
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v15/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
v15 "github.com/cosmos/gaia/v15/app/upgrades/v15"
)

func TestUpgradeCommissionRate(t *testing.T) {
func TestUpgradeMinCommissionRate(t *testing.T) {
gaiaApp := helpers.Setup(t)
ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{})

Expand Down Expand Up @@ -54,7 +54,7 @@ func TestUpgradeCommissionRate(t *testing.T) {
require.Equal(t, stakingKeeper.GetParams(ctx).MinCommissionRate, sdk.ZeroDec(), "non-zero previous min commission rate")

// run the test and confirm the values have been updated
v15.UpgradeCommissionRate(ctx, *stakingKeeper)
v15.UpgradeMinCommissionRate(ctx, *stakingKeeper)

newStakingParams := stakingKeeper.GetParams(ctx)
require.NotEqual(t, newStakingParams.MinCommissionRate, sdk.ZeroDec(), "failed to update min commission rate")
Expand Down

0 comments on commit 726f35c

Please sign in to comment.