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

[r4r] fix(BEP-171): fix bug that SLASH_CHANNELID cannot be suspended in order for consensus not to be affected #212

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion contracts/SlashIndicator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
event unKnownResponse(uint32 code);
event crashResponse();

event failedFelony(address indexed validator, uint256 slashCount, bytes failReason);

struct Indicator {
uint256 height;
uint256 count;
Expand Down Expand Up @@ -98,7 +100,9 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
if (indicator.count % felonyThreshold == 0) {
indicator.count = 0;
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(validator);
ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0);
try ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0) {} catch (bytes memory reason) {
emit failedFelony(validator, indicator.count, reason);
}
} else if (indicator.count % misdemeanorThreshold == 0) {
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).misdemeanor(validator);
}
Expand Down
6 changes: 5 additions & 1 deletion contracts/SlashIndicator.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
event unKnownResponse(uint32 code);
event crashResponse();

event failedFelony(address indexed validator, uint256 slashCount, bytes failReason);

struct Indicator {
uint256 height;
uint256 count;
Expand Down Expand Up @@ -103,7 +105,9 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
if (indicator.count % felonyThreshold == 0) {
indicator.count = 0;
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(validator);
ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0);
try ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).sendSynPackage(SLASH_CHANNELID, encodeSlashPackage(validator), 0) {} catch (bytes memory reason) {
emit failedFelony(validator, indicator.count, reason);
}
} else if (indicator.count % misdemeanorThreshold == 0) {
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).misdemeanor(validator);
}
Expand Down