diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index 648f9eaf969c..0d9ea8dcc60d 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -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)) @@ -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) } diff --git a/x/stake/keeper/slash.go b/x/stake/keeper/slash.go index af3184b6a341..1aa3c4625b03 100644 --- a/x/stake/keeper/slash.go +++ b/x/stake/keeper/slash.go @@ -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(