Skip to content

Commit

Permalink
fix: modify vote slash code to avoid reentry
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink committed Sep 5, 2024
1 parent 0b0e394 commit 348fe40
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions contracts/SlashIndicator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,19 @@ contract SlashIndicator is ISlashIndicator, System, IParamSubscriber, IApplicati
"verify signature failed"
);

IStakeHub(STAKE_HUB_ADDR).maliciousVoteSlash(_evidence.voteAddr);

// reward sender and felony validator if validator found
// TODO: after BC-fusion, we don't need to check if validator is living
(address[] memory vals, bytes[] memory voteAddrs) =
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).getLivingValidators();
for (uint256 i; i < voteAddrs.length; ++i) {
if (BytesLib.equal(voteAddrs[i], _evidence.voteAddr)) {
uint256 amount = (address(SYSTEM_REWARD_ADDR).balance * felonySlashRewardRatio) / 100;
ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(msg.sender, amount);
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(vals[i]);
ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(msg.sender, amount);
break;
}
}

IStakeHub(STAKE_HUB_ADDR).maliciousVoteSlash(_evidence.voteAddr);
}

function submitDoubleSignEvidence(bytes memory header1, bytes memory header2) public onlyInit {
Expand Down

0 comments on commit 348fe40

Please sign in to comment.