diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index 89faf64ed..c7cf06369 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -55,7 +55,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, pubkey crypto.PubKey, address := pubkey.Address() // Local index, so counts blocks validator *should* have signed - // Will use the 0-value default signing info if not present + // Will use the 0-value default signing info if not present, except for start height signInfo, found := k.getValidatorSigningInfo(ctx, address) if !found { // If this validator has never been seen before, set the start height diff --git a/x/slashing/keeper_test.go b/x/slashing/keeper_test.go index 3d49b65c4..3e78d939d 100644 --- a/x/slashing/keeper_test.go +++ b/x/slashing/keeper_test.go @@ -144,12 +144,15 @@ func TestHandleNewValidator(t *testing.T) { // 1000 first blocks not a validator ctx = ctx.WithBlockHeight(1001) - // Now a validator + // Now a validator, for two blocks keeper.handleValidatorSignature(ctx, val, true) + ctx = ctx.WithBlockHeight(1002) + keeper.handleValidatorSignature(ctx, val, false) + info, found := keeper.getValidatorSigningInfo(ctx, val.Address()) require.True(t, found) require.Equal(t, int64(1001), info.StartHeight) - require.Equal(t, int64(1), info.IndexOffset) + require.Equal(t, int64(2), info.IndexOffset) require.Equal(t, int64(1), info.SignedBlocksCounter) require.Equal(t, int64(0), info.JailedUntil)