From bd811165413fba03e1a0323ded9c76fbc8e2ecb1 Mon Sep 17 00:00:00 2001 From: trizzle Date: Fri, 16 Jan 2026 19:54:57 -0700 Subject: [PATCH 1/4] Minimum 5% Commission Added validation for minimum commission rate to ensure it is between 5% and 100%. --- x/customparams/types/params.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/x/customparams/types/params.go b/x/customparams/types/params.go index acdb51948..8d5f83c73 100644 --- a/x/customparams/types/params.go +++ b/x/customparams/types/params.go @@ -30,7 +30,10 @@ func (p *StakingParams) ParamSetPairs() paramtypes.ParamSetPairs { // ValidateBasic performs basic validation on staking parameters. func (p StakingParams) ValidateBasic() error { - return validateMinSelfDelegation(p.MinSelfDelegation) + if err := validateMinSelfDelegation(p.MinSelfDelegation); err != nil { + return err + } + return validateMinCommissionRate(p.MinCommissionRate) } func validateMinSelfDelegation(i interface{}) error { @@ -48,3 +51,28 @@ func validateMinSelfDelegation(i interface{}) error { return nil } + +// Add this new function to enforce the 5% floor +func validateMinCommissionRate(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return errors.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return errors.New("param min_commission_rate must be not nil") + } + + // Define the 5% floor (0.05) + minAllowed := sdk.NewDecWithPrec(5, 2) + + if v.LT(minAllowed) { + return errors.Errorf("param min_commission_rate cannot be lower than %s (5%%)", minAllowed) + } + + if v.GT(sdk.OneDec()) { + return errors.New("param min_commission_rate cannot be greater than 1 (100%)") + } + + return nil +} From b54ce25b269b85892e2e4147fd55d2006bd28ca8 Mon Sep 17 00:00:00 2001 From: trizzle Date: Fri, 16 Jan 2026 19:57:12 -0700 Subject: [PATCH 2/4] Add min_commission_rate to params.proto Added min_commission_rate field with custom options. --- proto/coreum/customparams/v1/params.proto | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proto/coreum/customparams/v1/params.proto b/proto/coreum/customparams/v1/params.proto index 1b2f24b60..266506d7e 100644 --- a/proto/coreum/customparams/v1/params.proto +++ b/proto/coreum/customparams/v1/params.proto @@ -13,4 +13,11 @@ message StakingParams { (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + // min_commission_rate is the minimum commission rate required for validators. + string min_commission_rate = 2 [ + (gogoproto.moretags) = "yaml:\"min_commission_rate\"", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } From 2f6ee6488f72e1697fff4ae68773659f666dad47 Mon Sep 17 00:00:00 2001 From: trizzle Date: Fri, 16 Jan 2026 19:59:05 -0700 Subject: [PATCH 3/4] Add MinCommissionRate parameter and update defaults --- x/customparams/types/params.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/x/customparams/types/params.go b/x/customparams/types/params.go index 8d5f83c73..ea4cada97 100644 --- a/x/customparams/types/params.go +++ b/x/customparams/types/params.go @@ -2,29 +2,35 @@ package types import ( sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" // <--- 1. ADD THIS IMPORT paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/pkg/errors" ) -// ParamStoreKeyMinSelfDelegation defines the param key for the min_self_delegation param. -var ParamStoreKeyMinSelfDelegation = []byte("minselfdelegation") +// 2. ADD THE NEW KEY HERE +var ( + ParamStoreKeyMinSelfDelegation = []byte("minselfdelegation") + ParamStoreKeyMinCommissionRate = []byte("mincommissionrate") +) // StakingParamKeyTable returns the parameter key table. func StakingParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&StakingParams{}) } -// DefaultStakingParams returns default staking parameters. +// 3. UPDATE DEFAULT PARAMS HERE func DefaultStakingParams() StakingParams { return StakingParams{ MinSelfDelegation: sdkmath.OneInt(), + MinCommissionRate: sdk.NewDecWithPrec(5, 2), // Sets default to 5% } } -// ParamSetPairs returns the parameter set pairs. +// 4. REGISTER THE NEW PARAMETER HERE func (p *StakingParams) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(ParamStoreKeyMinSelfDelegation, &p.MinSelfDelegation, validateMinSelfDelegation), + paramtypes.NewParamSetPair(ParamStoreKeyMinCommissionRate, &p.MinCommissionRate, validateMinCommissionRate), } } @@ -52,7 +58,7 @@ func validateMinSelfDelegation(i interface{}) error { return nil } -// Add this new function to enforce the 5% floor +// validateMinCommissionRate enforces the 5% floor func validateMinCommissionRate(i interface{}) error { v, ok := i.(sdk.Dec) if !ok { From 11a2269c36668544e1a7c750b16347ea5aeb20b8 Mon Sep 17 00:00:00 2001 From: trizzle Date: Sat, 17 Jan 2026 03:21:10 +0000 Subject: [PATCH 4/4] feat: add 5% min commission logic and proto definition --- proto/coreum/customparams/v1/params.proto | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/proto/coreum/customparams/v1/params.proto b/proto/coreum/customparams/v1/params.proto index 266506d7e..139597f9c 100644 --- a/proto/coreum/customparams/v1/params.proto +++ b/proto/coreum/customparams/v1/params.proto @@ -1,23 +1,2 @@ -syntax = "proto3"; -package coreum.customparams.v1; -import "gogoproto/gogo.proto"; -option go_package = "github.com/CoreumFoundation/coreum/v6/x/customparams/types"; - -// StakingParams defines the set of additional staking params for the staking module wrapper. -message StakingParams { - // min_self_delegation is the validators global self declared minimum for delegation. - string min_self_delegation = 1 [ - (gogoproto.moretags) = "yaml:\"min_self_delegation\"", - (gogoproto.customtype) = "cosmossdk.io/math.Int", - (gogoproto.nullable) = false - ]; - - // min_commission_rate is the minimum commission rate required for validators. - string min_commission_rate = 2 [ - (gogoproto.moretags) = "yaml:\"min_commission_rate\"", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; -}