Skip to content

Commit

Permalink
Merge pull request #110 from irisnet/irisnet/hotfix-v0.23.0-iris4
Browse files Browse the repository at this point in the history
Irisnet/hotfix v0.23.0 iris4
  • Loading branch information
wukongcheng authored Sep 22, 2018
2 parents 94a1fa7 + 1ff2982 commit 66cf80e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions x/slashing/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, pubkey crypto.PubKey, infracti
logger.Info(fmt.Sprintf("Ignored double sign from %s at height %d, age of %d past max age of %d", pubkey.Address(), infractionHeight, age, MaxEvidenceAge))
return
}
signInfo, found := k.getValidatorSigningInfo(ctx, address)
if !found {
logger.Info(fmt.Sprintf("There is no signing info for validator %s. It can't be slashed here", address))
return
}

// Double sign confirmed
logger.Info(fmt.Sprintf("Confirmed double sign from %s at height %d, age of %d less than max age of %d", pubkey.Address(), infractionHeight, age, MaxEvidenceAge))
Expand All @@ -52,10 +57,6 @@ func (k Keeper) handleDoubleSign(ctx sdk.Context, pubkey crypto.PubKey, infracti
k.validatorSet.Revoke(ctx, pubkey)

// Jail validator
signInfo, found := k.getValidatorSigningInfo(ctx, address)
if !found {
panic(fmt.Sprintf("Expected signing info for validator %s but not found", address))
}
signInfo.JailedUntil = time + DoubleSignUnbondDuration
k.setValidatorSigningInfo(ctx, address, signInfo)
}
Expand Down
4 changes: 2 additions & 2 deletions x/stake/keeper/slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ func (k Keeper) Slash(ctx sdk.Context, pubkey crypto.PubKey, infractionHeight in
remainingSlashAmount := slashAmount

switch {
case infractionHeight > ctx.BlockHeight():
case infractionHeight > ctx.BlockHeight() + 1:

// Can't slash infractions in the future
panic(fmt.Sprintf(
"impossible attempt to slash future infraction at height %d but we are at height %d",
infractionHeight, ctx.BlockHeight()))

case infractionHeight == ctx.BlockHeight():
case infractionHeight == ctx.BlockHeight() || infractionHeight == ctx.BlockHeight() + 1:

// Special-case slash at current height for efficiency - we don't need to look through unbonding delegations or redelegations
logger.Info(fmt.Sprintf(
Expand Down

0 comments on commit 66cf80e

Please sign in to comment.