slash contract, cwgoes comment
This commit is contained in:
parent
527320c9fc
commit
f2d47f9e91
|
@ -18,6 +18,8 @@ import (
|
||||||
// Infraction committed equal to or less than an unbonding period in the past,
|
// Infraction committed equal to or less than an unbonding period in the past,
|
||||||
// so all unbonding delegations and redelegations from that height are stored
|
// so all unbonding delegations and redelegations from that height are stored
|
||||||
// CONTRACT:
|
// CONTRACT:
|
||||||
|
// Slash will not slash unbonded validators (for the above reason)
|
||||||
|
// CONTRACT:
|
||||||
// Infraction committed at the current height or at a past height,
|
// Infraction committed at the current height or at a past height,
|
||||||
// not at a height in the future
|
// not at a height in the future
|
||||||
func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight int64, power int64, slashFactor sdk.Dec) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not slash if unbonded
|
// slashing should not be slashing unbonded
|
||||||
unbonded := false
|
|
||||||
if validator.Status == sdk.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 {
|
} else if validator.Status == sdk.Unbonding {
|
||||||
ctxTime := ctx.BlockHeader().Time
|
ctxTime := ctx.BlockHeader().Time
|
||||||
if ctxTime.After(validator.UnbondingMinTime) {
|
if ctxTime.After(validator.UnbondingMinTime) {
|
||||||
|
panic(fmt.Sprintf("should not be slashing unbonded validator: %v", validator))
|
||||||
// TODO should we also just update the
|
|
||||||
// validator status to unbonded here?
|
|
||||||
unbonded = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if unbonded {
|
|
||||||
logger.Info(fmt.Sprintf(
|
|
||||||
"failed attempt to slash an unbonded validator"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
operatorAddress := validator.GetOperator()
|
operatorAddress := validator.GetOperator()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue