Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a safeguard to avoid jailing down to too few nodes #151

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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