Fixes after rebase, jail in x/slashing
This commit is contained in:
parent
e4b0d0a618
commit
d03577a2fc
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestContextWithSigners(t *testing.T) {
|
||||
ms, _ := setupMultiStore()
|
||||
ms, _, _ := setupMultiStore()
|
||||
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, nil, log.NewNopLogger(), nil)
|
||||
|
||||
_, _, addr1 := keyPubAddr()
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
|||
cdc := wire.NewCodec()
|
||||
|
||||
// make context and keeper
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
|
||||
fck := NewFeeCollectionKeeper(cdc, capKey2)
|
||||
|
||||
// no coins initially
|
||||
|
@ -42,7 +42,7 @@ func TestFeeCollectionKeeperAdd(t *testing.T) {
|
|||
cdc := wire.NewCodec()
|
||||
|
||||
// make context and keeper
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
|
||||
fck := NewFeeCollectionKeeper(cdc, capKey2)
|
||||
|
||||
// no coins initially
|
||||
|
@ -62,7 +62,7 @@ func TestFeeCollectionKeeperClear(t *testing.T) {
|
|||
cdc := wire.NewCodec()
|
||||
|
||||
// make context and keeper
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger())
|
||||
ctx := sdk.NewContext(ms, abci.Header{}, false, nil, log.NewNopLogger(), nil)
|
||||
fck := NewFeeCollectionKeeper(cdc, capKey2)
|
||||
|
||||
// set coins initially
|
||||
|
|
|
@ -22,12 +22,14 @@ func handleMsgUnrevoke(ctx sdk.Context, msg MsgUnrevoke, k Keeper) sdk.Result {
|
|||
return ErrNoValidatorForAddress(k.codespace).Result()
|
||||
}
|
||||
|
||||
// TODO
|
||||
/*
|
||||
if ctx.BlockHeader().Time < validator.RevokedUntilTime {
|
||||
return ErrValidatorJailed(k.codespace).Result()
|
||||
}
|
||||
*/
|
||||
info, found := k.getValidatorSigningInfo(ctx, validator.GetPubKey().Address())
|
||||
if !found {
|
||||
return ErrNoValidatorForAddress(k.codespace).Result()
|
||||
}
|
||||
|
||||
if ctx.BlockHeader().Time < info.JailedUntil {
|
||||
return ErrValidatorJailed(k.codespace).Result()
|
||||
}
|
||||
|
||||
if ctx.IsCheckTx() {
|
||||
return sdk.Result{}
|
||||
|
|
|
@ -99,7 +99,9 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey,
|
|||
if height > minHeight && signInfo.SignedBlocksCounter < MinSignedPerWindow {
|
||||
logger.Info(fmt.Sprintf("Validator %s past min height of %d and below signed blocks threshold of %d", pubkey.Address(), minHeight, MinSignedPerWindow))
|
||||
k.stakeKeeper.Slash(ctx, pubkey, height, SlashFractionDowntime)
|
||||
k.stakeKeeper.Revoke(ctx, pubkey) // , DowntimeUnbondDuration) // TODO
|
||||
k.stakeKeeper.Revoke(ctx, pubkey)
|
||||
signInfo.JailedUntil = ctx.BlockHeader().Time + DowntimeUnbondDuration
|
||||
k.setValidatorSigningInfo(ctx, address, signInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,6 +144,7 @@ func (k Keeper) setValidatorSigningBitArray(ctx sdk.Context, address sdk.Address
|
|||
type validatorSigningInfo struct {
|
||||
StartHeight int64 `json:"start_height"`
|
||||
IndexOffset int64 `json:"index_offset"`
|
||||
JailedUntil int64 `json:"jailed_until"`
|
||||
SignedBlocksCounter int64 `json:"signed_blocks_counter"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue