Skip to content

Commit

Permalink
fix: ensure validator incoming will be clear after distribution (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 authored Dec 15, 2023
1 parent a913595 commit e077181
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contracts/BSCValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
for (uint i; i < currentValidatorSet.length; ++i) {
if (currentValidatorSet[i].incoming != 0) {
IStakeHub(STAKE_HUB_ADDR).distributeReward{value : currentValidatorSet[i].incoming}(currentValidatorSet[i].consensusAddress);
currentValidatorSet[i].incoming = 0;
}
}

Expand Down Expand Up @@ -527,6 +528,12 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
}
}

for (uint i; i < currentValidatorSet.length; ++i) {
if (currentValidatorSet[i].incoming != 0) {
currentValidatorSet[i].incoming = 0;
}
}

// step 4: do dusk transfer
if (address(this).balance>0) {
emit systemTransfer(address(this).balance);
Expand Down Expand Up @@ -918,11 +925,10 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
validatorExtraSet[i].isMaintaining = false;
validatorExtraSet[i].enterMaintenanceHeight = 0;
} else {
// if the validator is the same, update the vote address if it is different
// update the vote address if it is different
if (!BytesLib.equal(newVoteAddrs[i], validatorExtraSet[i].voteAddress)) {
validatorExtraSet[i].voteAddress = newVoteAddrs[i];
}
currentValidatorSet[i].incoming = 0;
currentValidatorSet[i].jailed = newValidatorSet[i].jailed;
}
}
Expand Down

0 comments on commit e077181

Please sign in to comment.