Skip to content

Commit

Permalink
revert: min commission rate check on create validator (#11)
Browse files Browse the repository at this point in the history
This reverts commit c3212d3.
  • Loading branch information
RiccardoM committed Apr 26, 2022
1 parent 57fef49 commit fab21ca
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 65 deletions.
5 changes: 0 additions & 5 deletions x/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa
if err != nil {
return nil, err
}

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

commission := types.NewCommissionWithTime(
msg.Commission.Rate, msg.Commission.MaxRate,
msg.Commission.MaxChangeRate, ctx.BlockHeader().Time,
Expand Down
42 changes: 0 additions & 42 deletions x/staking/keeper/msg_server_test.go

This file was deleted.

17 changes: 0 additions & 17 deletions x/staking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,6 @@ func (k Keeper) UpdateValidatorCommission(ctx sdk.Context,
return commission, nil
}

// MustUpdateValidatorCommission updates a validator's commission rate,
// ignoring the max change rate.
func (k Keeper) MustUpdateValidatorCommission(ctx sdk.Context,
validator types.Validator, newRate sdk.Dec) (types.Commission, error) {
commission := validator.Commission
blockTime := ctx.BlockHeader().Time

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

return commission, nil
}

// remove the validator record and associated indexes
// except for the bonded validator index which is only handled in ApplyAndReturnTendermintUpdates
// TODO, this function panics, and it's not good.
Expand Down
1 change: 0 additions & 1 deletion x/staking/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ var (
ErrInvalidHistoricalInfo = sdkerrors.Register(ModuleName, 37, "invalid historical info")
ErrNoHistoricalInfo = sdkerrors.Register(ModuleName, 38, "no historical info found")
ErrEmptyValidatorPubKey = sdkerrors.Register(ModuleName, 39, "empty validator public key")
ErrCommissionLTMinRate = sdkerrors.Register(ModuleName, 40, "commission cannot be less than min rate")
)

0 comments on commit fab21ca

Please sign in to comment.