Update spec
This commit is contained in:
parent
8c2c9dba8a
commit
6e4a8d9e16
|
@ -713,6 +713,7 @@ func TestUnjail(t *testing.T) {
|
||||||
tests.WaitForHeight(4, port)
|
tests.WaitForHeight(4, port)
|
||||||
require.Equal(t, true, signingInfo.IndexOffset > 0)
|
require.Equal(t, true, signingInfo.IndexOffset > 0)
|
||||||
require.Equal(t, time.Unix(0, 0).UTC(), signingInfo.JailedUntil)
|
require.Equal(t, time.Unix(0, 0).UTC(), signingInfo.JailedUntil)
|
||||||
|
require.Equal(t, true, signingInfo.MissedBlocksCounter == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProposalsQuery(t *testing.T) {
|
func TestProposalsQuery(t *testing.T) {
|
||||||
|
|
|
@ -96,20 +96,20 @@ for val in block.Validators:
|
||||||
previous = SigningBitArray.Get(val.Address, index)
|
previous = SigningBitArray.Get(val.Address, index)
|
||||||
|
|
||||||
// update counter if array has changed
|
// update counter if array has changed
|
||||||
if previous and val in block.AbsentValidators:
|
if !previous and val in block.AbsentValidators:
|
||||||
SigningBitArray.Set(val.Address, index, false)
|
|
||||||
signInfo.SignedBlocksCounter--
|
|
||||||
else if !previous and val not in block.AbsentValidators:
|
|
||||||
SigningBitArray.Set(val.Address, index, true)
|
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
|
// else previous == val not in block.AbsentValidators, no change
|
||||||
|
|
||||||
// validator must be active for at least SIGNED_BLOCKS_WINDOW
|
// validator must be active for at least SIGNED_BLOCKS_WINDOW
|
||||||
// before they can be automatically unbonded for failing to be
|
// before they can be automatically unbonded for failing to be
|
||||||
// included in 50% of the recent LastCommits
|
// included in 50% of the recent LastCommits
|
||||||
minHeight = signInfo.StartHeight + SIGNED_BLOCKS_WINDOW
|
minHeight = signInfo.StartHeight + SIGNED_BLOCKS_WINDOW
|
||||||
minSigned = SIGNED_BLOCKS_WINDOW / 2
|
maxMissed = SIGNED_BLOCKS_WINDOW / 2
|
||||||
if height > minHeight AND signInfo.SignedBlocksCounter < minSigned:
|
if height > minHeight AND signInfo.MissedBlocksCounter > maxMissed:
|
||||||
signInfo.JailedUntil = block.Time + DOWNTIME_UNBOND_DURATION
|
signInfo.JailedUntil = block.Time + DOWNTIME_UNBOND_DURATION
|
||||||
|
|
||||||
slash & unbond the validator
|
slash & unbond the validator
|
||||||
|
|
|
@ -40,7 +40,7 @@ type ValidatorSigningInfo struct {
|
||||||
IndexOffset int64 // Offset into the signed block bit array
|
IndexOffset int64 // Offset into the signed block bit array
|
||||||
JailedUntilHeight int64 // Block height until which the validator is jailed,
|
JailedUntilHeight int64 // Block height until which the validator is jailed,
|
||||||
// or sentinel value of 0 for not 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).
|
* `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).
|
* `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
|
* `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
|
## Slashing Period
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue