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

fix: add empty address check before validator update and clear state before external call #507

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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
9 changes: 5 additions & 4 deletions contracts/BSCValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica

// step 1: distribute incoming
for (uint i; i < currentValidatorSet.length; ++i) {
if (currentValidatorSet[i].incoming != 0) {
IStakeHub(STAKE_HUB_ADDR).distributeReward{value : currentValidatorSet[i].incoming}(currentValidatorSet[i].consensusAddress);
uint256 incoming = currentValidatorSet[i].incoming;
if (incoming != 0) {
currentValidatorSet[i].incoming = 0;
IStakeHub(STAKE_HUB_ADDR).distributeReward{value : incoming}(currentValidatorSet[i].consensusAddress);
}
}

Expand Down Expand Up @@ -1162,7 +1163,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica

// count the number of felony validators
for (uint k; k<_validatorSet.length; ++k) {
if (_validatorSet[k].jailed) {
if (_validatorSet[k].jailed || _validatorSet[k].consensusAddress == address(0)) {
++numOfFelony;
}
}
Expand All @@ -1180,7 +1181,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
unjailedVoteAddrs = new bytes[](_validatorSet.length - numOfFelony);
i = 0;
for (uint index; index<_validatorSet.length; ++index) {
if (!_validatorSet[index].jailed) {
if (!_validatorSet[index].jailed && _validatorSet[index].consensusAddress != address(0)) {
unjailedValidatorSet[i] = _validatorSet[index];
unjailedVoteAddrs[i] = _voteAddrs[index];
++i;
Expand Down
Loading