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

Validator set contract excludes under balance validators in updating set #11

Merged
merged 2 commits into from
Sep 15, 2022

Conversation

nxqbao
Copy link
Contributor

@nxqbao nxqbao commented Sep 15, 2022

Description

  • Validator set contract excludes under balance validators in updating set
  • Staking contract weighs validators as 0 when they are under balance
  • Update test

Checklist

  • I have clearly commented on all the main functions followed the NatSpec Format
  • The box that allows repo maintainers to update this PR is checked
  • I tested locally to make sure this feature/fix works

Comment on lines 133 to 153
function getCandidateWeights() external view returns (address[] memory _candidates, uint256[] memory _weights) {
uint256 _length = validatorCandidates.length;
uint256 _newLength = _length;
_candidates = new address[](_length);
_weights = new uint256[](_length);

for (uint256 _i; _i < _length; _i++) {
ValidatorCandidate storage _candidate = validatorCandidates[_i];
if (_candidate.stakedAmount < _minValidatorBalance) {
_newLength--;
continue;
}
_candidates[_i] = _candidate.consensusAddr;
_weights[_i] = _candidate.delegatedAmount;
}

assembly {
mstore(_candidates, _newLength)
mstore(_weights, _newLength)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a temporary fix since we don't have a final decision for the slashing issue. Plz note sth here for future fixing

@nxqbao nxqbao merged commit 28e71aa into main Sep 15, 2022
@nxqbao nxqbao deleted the feat/validator-set-excludes-under-balance-validators branch September 15, 2022 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants