From f2d47f9e9187e99b5e87d78145848205593add0b Mon Sep 17 00:00:00 2001 From: rigelrozanski Date: Mon, 27 Aug 2018 14:46:38 -0400 Subject: [PATCH] slash contract, cwgoes comment --- x/stake/keeper/slash.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index b936e585d..c3c79714e 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -18,6 +18,8 @@ import ( // Infraction committed equal to or less than an unbonding period in the past, // so all unbonding delegations and redelegations from that height are stored // CONTRACT: +// Slash will not slash unbonded validators (for the above reason) +// CONTRACT: // Infraction committed at the current height or at a past height, // not at a height in the future func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, power int64, slashFactor sdk.Dec) { @@ -44,24 +46,15 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in return } - // do not slash if unbonded - unbonded := false + // slashing should not be slashing unbonded if validator.Status == sdk.Unbonded { - unbonded = true + panic(fmt.Sprintf("should not be slashing unbonded validator: %v", validator)) } else if validator.Status == sdk.Unbonding { ctxTime := ctx.BlockHeader().Time if ctxTime.After(validator.UnbondingMinTime) { - - // TODO should we also just update the - // validator status to unbonded here? - unbonded = true + panic(fmt.Sprintf("should not be slashing unbonded validator: %v", validator)) } } - if unbonded { - logger.Info(fmt.Sprintf( - "failed attempt to slash an unbonded validator")) - return - } operatorAddress := validator.GetOperator()