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: ensure validator incoming will be clear after distribution #447

Merged
merged 1 commit into from
Dec 15, 2023
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
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
Loading