Skip to content

Commit

Permalink
fix impeach validator (#100)
Browse files Browse the repository at this point in the history
Co-authored-by: Keefe Liu <[email protected]>
  • Loading branch information
keefel and Keefe Liu authored Feb 8, 2023
1 parent cc4bbf6 commit 6166c69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
3 changes: 1 addition & 2 deletions x/slashing/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -80,7 +79,7 @@ func (k msgServer) Impeach(goCtx context.Context, msg *types.MsgImpeach) (*types
}

// Jail forever.
k.JailUntil(ctx, consAddr, time.Unix(253402300800, 0))
k.JailForever(ctx, consAddr)

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
Expand Down
23 changes: 23 additions & 0 deletions x/slashing/keeper/signing_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ func (k Keeper) JailUntil(ctx sdk.Context, consAddr sdk.ConsAddress, jailTime ti
k.SetValidatorSigningInfo(ctx, consAddr, signInfo)
}

// JailForever attempts to set the validator's JailedUntil attribute in its signing
// info to a very big value. When no signing info found, it will create a new signing
// info for the validator.
func (k Keeper) JailForever(ctx sdk.Context, consAddr sdk.ConsAddress) {
signingInfo, found := k.GetValidatorSigningInfo(ctx, consAddr)
if !found {
// Allow jail forever a no signing info validator.
signingInfo = types.NewValidatorSigningInfo(
consAddr,
ctx.BlockHeight(),
0,
time.Unix(0, 0),
false,
0,
)
}

// Jail to 10000-1-1 08:00:00.
signingInfo.JailedUntil = time.Unix(253402300800, 0)

k.SetValidatorSigningInfo(ctx, consAddr, signingInfo)
}

// Tombstone attempts to tombstone a validator. It will panic if signing info for
// the given validator does not exist.
func (k Keeper) Tombstone(ctx sdk.Context, consAddr sdk.ConsAddress) {
Expand Down

0 comments on commit 6166c69

Please sign in to comment.