Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed min commission rate #11

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6766,7 +6766,6 @@ Params defines the parameters for the staking module.
| `max_entries` | [uint32](#uint32) | | max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). |
| `historical_entries` | [uint32](#uint32) | | historical_entries is the number of historical entries to persist. |
| `bond_denom` | [string](#string) | | bond_denom defines the bondable coin denomination. |
| `min_commission_rate` | [string](#string) | | min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators |
| `validator_bond_factor` | [string](#string) | | validator_bond_factor is required as a safety check for tokenizing shares and delegations from liquid staking providers |
| `global_liquid_staking_cap` | [string](#string) | | global_liquid_staking_cap represents a cap on the portion of stake that comes from liquid staking providers |
| `validator_liquid_staking_cap` | [string](#string) | | validator_liquid_staking_cap represents a cap on the portion of stake that comes from liquid staking providers for a specific validator |
Expand Down
12 changes: 3 additions & 9 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -308,29 +308,23 @@ message Params {
uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""];
// bond_denom defines the bondable coin denomination.
string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""];
// min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators
string min_commission_rate = 6 [
(gogoproto.moretags) = "yaml:\"min_commission_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// validator_bond_factor is required as a safety check for tokenizing shares and
// delegations from liquid staking providers
string validator_bond_factor = 7 [
string validator_bond_factor = 6 [
(gogoproto.moretags) = "yaml:\"validator_bond_factor\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// global_liquid_staking_cap represents a cap on the portion of stake that
// comes from liquid staking providers
string global_liquid_staking_cap = 8 [
string global_liquid_staking_cap = 7 [
(gogoproto.moretags) = "yaml:\"global_liquid_staking_cap\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// validator_liquid_staking_cap represents a cap on the portion of stake that
// comes from liquid staking providers for a specific validator
string validator_liquid_staking_cap = 9 [
string validator_liquid_staking_cap = 8 [
(gogoproto.moretags) = "yaml:\"validator_liquid_staking_cap\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down
3 changes: 1 addition & 2 deletions x/staking/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -895,15 +895,14 @@ global_liquid_staking_cap: "1.000000000000000000"
historical_entries: 10000
max_entries: 7
max_validators: 100
min_commission_rate: "0.000000000000000000"
unbonding_time: 1814400s
validator_bond_factor: "-1.000000000000000000"
validator_liquid_staking_cap: "1.000000000000000000"`,
},
{
"with json output",
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
`{"unbonding_time":"1814400s","max_validators":100,"max_entries":7,"historical_entries":10000,"bond_denom":"stake","min_commission_rate":"0.000000000000000000","validator_bond_factor":"-1.000000000000000000","global_liquid_staking_cap":"1.000000000000000000","validator_liquid_staking_cap":"1.000000000000000000"}`,
`{"unbonding_time":"1814400s","max_validators":100,"max_entries":7,"historical_entries":10000,"bond_denom":"stake","validator_bond_factor":"-1.000000000000000000","global_liquid_staking_cap":"1.000000000000000000","validator_liquid_staking_cap":"1.000000000000000000"}`,
},
}
for _, tc := range testCases {
Expand Down
5 changes: 0 additions & 5 deletions x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"errors"
"fmt"
"strconv"
"time"
Expand Down Expand Up @@ -41,10 +40,6 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa
return nil, err
}

if msg.Commission.Rate.LT(k.MinCommissionRate(ctx)) {
return nil, sdkerrors.Wrapf(errors.New("commission cannot be less than min rate"), "cannot set validator commission to less than minimum rate of %s", k.MinCommissionRate(ctx))
}

// check to see if the pubkey or sender has been registered before
if _, found := k.GetValidator(ctx, valAddr); found {
return nil, types.ErrValidatorOwnerExists
Expand Down
7 changes: 0 additions & 7 deletions x/staking/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ func (k Keeper) PowerReduction(ctx sdk.Context) sdk.Int {
return sdk.DefaultPowerReduction
}

// MinCommissionRate - Minimum validator commission rate
func (k Keeper) MinCommissionRate(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyMinCommissionRate, &res)
return
}

// Validator bond factor for all validators
func (k Keeper) ValidatorBondFactor(ctx sdk.Context) (res sdk.Dec) {
k.paramstore.Get(ctx, types.KeyValidatorBondFactor, &res)
Expand All @@ -79,7 +73,6 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params {
k.MaxEntries(ctx),
k.HistoricalEntries(ctx),
k.BondDenom(ctx),
k.MinCommissionRate(ctx),
k.ValidatorBondFactor(ctx),
k.GlobalLiquidStakingCap(ctx),
k.ValidatorLiquidStakingCap(ctx),
Expand Down
4 changes: 0 additions & 4 deletions x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ func (k Keeper) UpdateValidatorCommission(ctx sdk.Context,
return commission, err
}

if newRate.LT(k.MinCommissionRate(ctx)) {
return commission, fmt.Errorf("cannot set validator commission to less than minimum rate of %s", k.MinCommissionRate(ctx))
}

commission.Rate = newRate
commission.UpdateTime = blockTime

Expand Down
6 changes: 0 additions & 6 deletions x/staking/keeper/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,11 +1045,6 @@ func TestUpdateValidatorCommission(t *testing.T) {
app, ctx, _, addrVals := bootstrapValidatorTest(t, 1000, 20)
ctx = ctx.WithBlockHeader(tmproto.Header{Time: time.Now().UTC()})

// Set MinCommissionRate to 0.05
params := app.StakingKeeper.GetParams(ctx)
params.MinCommissionRate = sdk.NewDecWithPrec(5, 2)
app.StakingKeeper.SetParams(ctx, params)

commission1 := types.NewCommissionWithTime(
sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(3, 1),
sdk.NewDecWithPrec(1, 1), time.Now().UTC().Add(time.Duration(-1)*time.Hour),
Expand All @@ -1074,7 +1069,6 @@ func TestUpdateValidatorCommission(t *testing.T) {
{val2, sdk.NewDecWithPrec(-1, 1), true},
{val2, sdk.NewDecWithPrec(4, 1), true},
{val2, sdk.NewDecWithPrec(3, 1), true},
{val2, sdk.NewDecWithPrec(1, 2), true},
{val2, sdk.NewDecWithPrec(2, 1), false},
}

Expand Down
2 changes: 0 additions & 2 deletions x/staking/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func RandomizedGenState(simState *module.SimulationState) {
unbondTime time.Duration
maxVals uint32
histEntries uint32
minCommissionRate sdk.Dec
validatorBondFactor sdk.Dec
globalLiquidStakingCap sdk.Dec
validatorLiquidStakingCap sdk.Dec
Expand Down Expand Up @@ -73,7 +72,6 @@ func RandomizedGenState(simState *module.SimulationState) {
7,
histEntries,
sdk.DefaultBondDenom,
minCommissionRate,
validatorBondFactor,
globalLiquidStakingCap,
validatorLiquidStakingCap,
Expand Down
27 changes: 0 additions & 27 deletions x/staking/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const (
)

var (
// DefaultMinCommissionRate is set to 0%
DefaultMinCommissionRate = sdk.ZeroDec()
// DefaultValidatorBondFactor is set to -1 (disabled)
DefaultValidatorBondFactor = sdk.NewDecFromInt(sdk.NewInt(-1))
// DefaultGlobalLiquidStakingCap is set to 100%
Expand All @@ -50,7 +48,6 @@ var (
KeyBondDenom = []byte("BondDenom")
KeyHistoricalEntries = []byte("HistoricalEntries")
KeyPowerReduction = []byte("PowerReduction")
KeyMinCommissionRate = []byte("MinCommissionRate")
KeyValidatorBondFactor = []byte("ValidatorBondFactor")
KeyGlobalLiquidStakingCap = []byte("GlobalLiquidStakingCap")
KeyValidatorLiquidStakingCap = []byte("ValidatorLiquidStakingCap")
Expand All @@ -70,7 +67,6 @@ func NewParams(
maxEntries uint32,
historicalEntries uint32,
bondDenom string,
minCommissionRate sdk.Dec,
validatorBondFactor sdk.Dec,
globalLiquidStakingCap sdk.Dec,
validatorLiquidStakingCap sdk.Dec,
Expand All @@ -81,7 +77,6 @@ func NewParams(
MaxEntries: maxEntries,
HistoricalEntries: historicalEntries,
BondDenom: bondDenom,
MinCommissionRate: minCommissionRate,
ValidatorBondFactor: validatorBondFactor,
GlobalLiquidStakingCap: globalLiquidStakingCap,
ValidatorLiquidStakingCap: validatorLiquidStakingCap,
Expand All @@ -96,7 +91,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyMaxEntries, &p.MaxEntries, validateMaxEntries),
paramtypes.NewParamSetPair(KeyHistoricalEntries, &p.HistoricalEntries, validateHistoricalEntries),
paramtypes.NewParamSetPair(KeyBondDenom, &p.BondDenom, validateBondDenom),
paramtypes.NewParamSetPair(KeyMinCommissionRate, &p.MinCommissionRate, validateMinCommissionRate),
paramtypes.NewParamSetPair(KeyValidatorBondFactor, &p.ValidatorBondFactor, validateValidatorBondFactor),
paramtypes.NewParamSetPair(KeyGlobalLiquidStakingCap, &p.GlobalLiquidStakingCap, validateGlobalLiquidStakingCap),
paramtypes.NewParamSetPair(KeyValidatorLiquidStakingCap, &p.ValidatorLiquidStakingCap, validateValidatorLiquidStakingCap),
Expand All @@ -111,7 +105,6 @@ func DefaultParams() Params {
DefaultMaxEntries,
DefaultHistoricalEntries,
sdk.DefaultBondDenom,
DefaultMinCommissionRate,
DefaultValidatorBondFactor,
DefaultGlobalLiquidStakingCap,
DefaultValidatorLiquidStakingCap,
Expand Down Expand Up @@ -162,10 +155,6 @@ func (p Params) Validate() error {
return err
}

if err := validateMinCommissionRate(p.MinCommissionRate); err != nil {
return err
}

if err := validateValidatorBondFactor(p.ValidatorBondFactor); err != nil {
return err
}
Expand Down Expand Up @@ -259,22 +248,6 @@ func ValidatePowerReduction(i interface{}) error {
return nil
}

func validateMinCommissionRate(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v.IsNegative() {
return fmt.Errorf("minimum commission rate cannot be negative: %s", v)
}
if v.GT(sdk.OneDec()) {
return fmt.Errorf("minimum commission rate cannot be greater than 100%%: %s", v)
}

return nil
}

func validateValidatorBondFactor(i interface{}) error {
v, ok := i.(sdk.Dec)
if !ok {
Expand Down
8 changes: 0 additions & 8 deletions x/staking/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/stretchr/testify/require"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -28,11 +27,4 @@ func Test_validateParams(t *testing.T) {

// default params have no error
require.NoError(t, params.Validate())

// validate mincommision
params.MinCommissionRate = sdk.NewDec(-1)
require.Error(t, params.Validate())

params.MinCommissionRate = sdk.NewDec(2)
require.Error(t, params.Validate())
}
Loading