Skip to content

Commit

Permalink
Add a safeguard to avoid jailing down to too few nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Pohl committed Nov 7, 2023
1 parent 28762bd commit f85a8c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contracts/ConsensusUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ contract ConsensusUtils is EternalStorage, ValidatorSet {
uint256 expectedNumberOfBlocks = getCycleDurationBlocks().mul(VALIDATOR_PRODUCTIVITY_BP).div(_validatorSet.length).div(10000);
for (uint i = 0; i < _validatorSet.length; i++) {
if(blockCounter(_validatorSet[i]) < expectedNumberOfBlocks) {
// Validator hasn't met the desired uptime jail them and remove them from the next cycle
_jailValidator(_validatorSet[i]);
// Don't jail below 4 validators
if (pendingValidatorsLength() > 4) {
// Validator hasn't met the desired uptime jail them and remove them from the next cycle
_jailValidator(_validatorSet[i]);
}
} else if (getStrikes(_validatorSet[i]) != 0) {
// Validator has met desired uptime and has strikes, inc the strike reset
_incStrikeReset(_validatorSet[i]);
Expand Down

0 comments on commit f85a8c0

Please sign in to comment.