Skip to content

Commit f85a8c0

Browse files
committed
Add a safeguard to avoid jailing down to too few nodes
1 parent 28762bd commit f85a8c0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

contracts/ConsensusUtils.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,11 @@ contract ConsensusUtils is EternalStorage, ValidatorSet {
225225
uint256 expectedNumberOfBlocks = getCycleDurationBlocks().mul(VALIDATOR_PRODUCTIVITY_BP).div(_validatorSet.length).div(10000);
226226
for (uint i = 0; i < _validatorSet.length; i++) {
227227
if(blockCounter(_validatorSet[i]) < expectedNumberOfBlocks) {
228-
// Validator hasn't met the desired uptime jail them and remove them from the next cycle
229-
_jailValidator(_validatorSet[i]);
228+
// Don't jail below 4 validators
229+
if (pendingValidatorsLength() > 4) {
230+
// Validator hasn't met the desired uptime jail them and remove them from the next cycle
231+
_jailValidator(_validatorSet[i]);
232+
}
230233
} else if (getStrikes(_validatorSet[i]) != 0) {
231234
// Validator has met desired uptime and has strikes, inc the strike reset
232235
_incStrikeReset(_validatorSet[i]);

0 commit comments

Comments
 (0)