Add height offsets
This commit is contained in:
parent
5316be75b5
commit
549eba0d54
|
@ -62,8 +62,11 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, addr crypto.Address, infractio
|
|||
revisedFraction := k.capBySlashingPeriod(ctx, address, fraction, infractionHeight)
|
||||
logger.Info(fmt.Sprintf("Fraction slashed capped by slashing period from %v to %v", fraction, revisedFraction))
|
||||
|
||||
// We need to retrieve the stake distribution which signed the block, so we subtract ValidatorUpdateDelay from the evidence height.
|
||||
distributionHeight := infractionHeight - ValidatorUpdateDelay
|
||||
|
||||
// Slash validator
|
||||
k.validatorSet.Slash(ctx, pubkey, infractionHeight, power, revisedFraction)
|
||||
k.validatorSet.Slash(ctx, pubkey, distributionHeight, power, revisedFraction)
|
||||
|
||||
// Jail validator
|
||||
k.validatorSet.Jail(ctx, pubkey)
|
||||
|
@ -123,7 +126,10 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
|
|||
// Downtime confirmed: slash and jail the validator
|
||||
logger.Info(fmt.Sprintf("Validator %s past min height of %d and below signed blocks threshold of %d",
|
||||
pubkey.Address(), minHeight, k.MinSignedPerWindow(ctx)))
|
||||
k.validatorSet.Slash(ctx, pubkey, height, power, k.SlashFractionDowntime(ctx))
|
||||
// We need to retrieve the stake distribution which signed the block, so we subtract ValidatorUpdateDelay from the evidence height,
|
||||
// and subtract an additional 1 since this is the LastCommit.
|
||||
distributionHeight := height - ValidatorUpdateDelay - 1
|
||||
k.validatorSet.Slash(ctx, pubkey, distributionHeight, power, k.SlashFractionDowntime(ctx))
|
||||
k.validatorSet.Jail(ctx, pubkey)
|
||||
signInfo.JailedUntil = ctx.BlockHeader().Time.Add(k.DowntimeUnbondDuration(ctx))
|
||||
} else {
|
||||
|
|
|
@ -15,6 +15,12 @@ const (
|
|||
DowntimeUnbondDurationKey = "slashing/DowntimeUnbondDuration"
|
||||
SlashFractionDoubleSignKey = "slashing/SlashFractionDoubleSign"
|
||||
SlashFractionDowntimeKey = "slashing/SlashFractionDowntime"
|
||||
|
||||
// Delay, in blocks, between when validator updates are returned to Tendermint and when they are applied
|
||||
// For example, if this is 0, the validator set at the end of a block will sign the next block, or
|
||||
// if this is 1, the validator set at the end of a block will sign the block after the next.
|
||||
// Constant as this should not change without a hard fork.
|
||||
ValidatorUpdateDelay int64 = 1
|
||||
)
|
||||
|
||||
// MaxEvidenceAge - Max age for evidence - 21 days (3 weeks)
|
||||
|
|
Loading…
Reference in New Issue