Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Fix fuxi-3000 consensus failure #109

Merged
merged 2 commits into from
Sep 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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