diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index 4a999b066f..1a7aa7ffeb 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -713,6 +713,7 @@ func TestUnjail(t *testing.T) { tests.WaitForHeight(4, port) require.Equal(t, true, signingInfo.IndexOffset > 0) require.Equal(t, time.Unix(0, 0).UTC(), signingInfo.JailedUntil) + require.Equal(t, true, signingInfo.MissedBlocksCounter == 0) } func TestProposalsQuery(t *testing.T) { diff --git a/docs/spec/slashing/begin-block.md b/docs/spec/slashing/begin-block.md index 375e191859..fb7d04e5dc 100644 --- a/docs/spec/slashing/begin-block.md +++ b/docs/spec/slashing/begin-block.md @@ -96,20 +96,20 @@ for val in block.Validators: previous = SigningBitArray.Get(val.Address, index) // update counter if array has changed - if previous and val in block.AbsentValidators: - SigningBitArray.Set(val.Address, index, false) - signInfo.SignedBlocksCounter-- - else if !previous and val not in block.AbsentValidators: + if !previous and val in block.AbsentValidators: SigningBitArray.Set(val.Address, index, true) - signInfo.SignedBlocksCounter++ + signInfo.MissedBlocksCounter++ + else if previous and val not in block.AbsentValidators: + SigningBitArray.Set(val.Address, index, false) + signInfo.MissedBlocksCounter-- // else previous == val not in block.AbsentValidators, no change // validator must be active for at least SIGNED_BLOCKS_WINDOW // before they can be automatically unbonded for failing to be // included in 50% of the recent LastCommits minHeight = signInfo.StartHeight + SIGNED_BLOCKS_WINDOW - minSigned = SIGNED_BLOCKS_WINDOW / 2 - if height > minHeight AND signInfo.SignedBlocksCounter < minSigned: + maxMissed = SIGNED_BLOCKS_WINDOW / 2 + if height > minHeight AND signInfo.MissedBlocksCounter > maxMissed: signInfo.JailedUntil = block.Time + DOWNTIME_UNBOND_DURATION slash & unbond the validator diff --git a/docs/spec/slashing/state.md b/docs/spec/slashing/state.md index ae426db7b3..fe6f39f5c6 100644 --- a/docs/spec/slashing/state.md +++ b/docs/spec/slashing/state.md @@ -40,7 +40,7 @@ type ValidatorSigningInfo struct { IndexOffset int64 // Offset into the signed block bit array JailedUntilHeight int64 // Block height until which the validator is jailed, // or sentinel value of 0 for not jailed - SignedBlocksCounter int64 // Running counter of signed blocks + MissedBlocksCounter int64 // Running counter of missed blocks } ``` @@ -49,7 +49,7 @@ Where: * `StartHeight` is set to the height that the candidate became an active validator (with non-zero voting power). * `IndexOffset` is incremented each time the candidate was a bonded validator in a block (and may have signed a precommit or not). * `JailedUntil` is set whenever the candidate is jailed due to downtime -* `SignedBlocksCounter` is a counter kept to avoid unnecessary array reads. `SignedBlocksBitArray.Sum() == SignedBlocksCounter` always. +* `MissedBlocksCounter` is a counter kept to avoid unnecessary array reads. `MissedBlocksBitArray.Sum() == MissedBlocksCounter` always. ## Slashing Period