From 967ce32b931b7c401b8de4c4dd0df33f1efcf793 Mon Sep 17 00:00:00 2001 From: Giuseppe Natale <12249307+giunatale@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:30:34 +0100 Subject: [PATCH 1/4] add commission rate migration --- CHANGELOG.md | 1 + app/upgrades/v4/upgrades.go | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a75f6041..8fce2335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Migrate `x/gov` fork from Atom One to Atom One SDK [#248](https://github.com/atomone-hub/atomone/pull/248) - Add governors to `x/gov` module [#258](https://github.com/atomone-hub/atomone/pull/258) - Prevent Oversight DAO from vetoing proposals that include a change to the Oversight DAO address [#275](https://github.com/atomone-hub/atomone/pull/275) +- Set chain-wide `MaxCommissionRate` and `MinCommissionRate` to 5% and update validator commission rates accordingly [#300](https://github.com/atomone-hub/atomone/pull/300) ### STATE BREAKING diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 4565d3c9..27f2d439 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -18,6 +18,7 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" sdkgov "github.com/cosmos/cosmos-sdk/x/gov/types" sdkgovv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/atomone-hub/atomone/app/keepers" v1 "github.com/atomone-hub/atomone/x/gov/types/v1" @@ -43,6 +44,10 @@ func CreateUpgradeHandler( return vm, err } + if err := migrateValidatorsCommission(ctx, cdc, keepers.StakingKeeper); err != nil { + return vm, err + } + return vm, nil } } @@ -573,3 +578,38 @@ func governorValSharesValueCodec(cdc codec.Codec) collcodec.ValueCodec[sdkgovv1. return *v1.ConvertAtomOneGovernorValSharesToSDK(c), nil }) } + +// migrateValidatorsCommission sets the chain-wide commission to the constitutionally-mandated 5% and updates all existing validator's commission accordingly. +func migrateValidatorsCommission(ctx context.Context, cdc codec.Codec, stakingKeeper *stakingkeeper.Keeper) error { + // Set chain-wide commission to 5% + params, err := stakingKeeper.GetParams(ctx) + if err != nil { + return err + } + + fivePercent := math.LegacyMustNewDecFromStr("0.05") + + params.MaxCommissionRate = fivePercent + params.MinCommissionRate = fivePercent + if err := stakingKeeper.SetParams(ctx, params); err != nil { + return err + } + + // Update all existing validators' commission to 5% + validators, err := stakingKeeper.GetAllValidators(ctx) + if err != nil { + return err + } + for _, validator := range validators { + // leaving MaxRate and MaxChangeRate unchanged as validator-defined values. + // In any case, the chain-wide MaxCommissionRate = MinCommissionRate = 5% would still prevent validators from changing their + // commission rate to anything other than 5%. + validator.Commission.Rate = fivePercent + + if err := stakingKeeper.SetValidator(ctx, validator); err != nil { + return err + } + } + + return nil +} From 15933fc03b7b9ad6cf9887ff89ad3cf44505ecc5 Mon Sep 17 00:00:00 2001 From: Giuseppe Natale <12249307+giunatale@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:42:46 +0100 Subject: [PATCH 2/4] lint fix --- app/upgrades/v4/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 27f2d439..53132364 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -580,7 +580,7 @@ func governorValSharesValueCodec(cdc codec.Codec) collcodec.ValueCodec[sdkgovv1. } // migrateValidatorsCommission sets the chain-wide commission to the constitutionally-mandated 5% and updates all existing validator's commission accordingly. -func migrateValidatorsCommission(ctx context.Context, cdc codec.Codec, stakingKeeper *stakingkeeper.Keeper) error { +func migrateValidatorsCommission(ctx context.Context, stakingKeeper *stakingkeeper.Keeper) error { // Set chain-wide commission to 5% params, err := stakingKeeper.GetParams(ctx) if err != nil { From e0a8bca87847c2943f4d1339e52349fdae19cb3d Mon Sep 17 00:00:00 2001 From: Giuseppe Natale <12249307+giunatale@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:11:18 +0100 Subject: [PATCH 3/4] fix --- app/upgrades/v4/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 53132364..7d34bd5a 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -44,7 +44,7 @@ func CreateUpgradeHandler( return vm, err } - if err := migrateValidatorsCommission(ctx, cdc, keepers.StakingKeeper); err != nil { + if err := migrateValidatorsCommission(ctx, keepers.StakingKeeper); err != nil { return vm, err } From 6f9ec668e8b0dd38179cd15fb8585384563a5f35 Mon Sep 17 00:00:00 2001 From: Giuseppe Natale <12249307+giunatale@users.noreply.github.com> Date: Wed, 18 Mar 2026 09:39:54 +0100 Subject: [PATCH 4/4] update maxrate when below five percent --- app/upgrades/v4/upgrades.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/upgrades/v4/upgrades.go b/app/upgrades/v4/upgrades.go index 7d34bd5a..dd7f8d08 100644 --- a/app/upgrades/v4/upgrades.go +++ b/app/upgrades/v4/upgrades.go @@ -604,7 +604,11 @@ func migrateValidatorsCommission(ctx context.Context, stakingKeeper *stakingkeep // leaving MaxRate and MaxChangeRate unchanged as validator-defined values. // In any case, the chain-wide MaxCommissionRate = MinCommissionRate = 5% would still prevent validators from changing their // commission rate to anything other than 5%. + // The only exception is if MaxRate < 5%, in which case we set it also to 5%. validator.Commission.Rate = fivePercent + if validator.Commission.MaxRate.LT(fivePercent) { + validator.Commission.MaxRate = fivePercent + } if err := stakingKeeper.SetValidator(ctx, validator); err != nil { return err