Skip to content

Commit

Permalink
fix: validator contract allows receiving core
Browse files Browse the repository at this point in the history
  • Loading branch information
zfliex924 committed Jun 5, 2023
1 parent 33e8906 commit fb1689f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/ValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contract ValidatorSet is IValidatorSet, System, IParamSubscriber {
event validatorMisdemeanor(address indexed validator, uint256 amount);
event validatorFelony(address indexed validator, uint256 amount);
event paramChange(string key, bytes value);
event received(address indexed from, uint256 amount);

/*********************** init **************************/
function init() external onlyNotInit {
Expand All @@ -86,6 +87,12 @@ contract ValidatorSet is IValidatorSet, System, IParamSubscriber {
return currentValidatorSetMap[addr] != 0;
}

receive() external payable {
if (msg.value != 0) {
emit received(msg.sender, msg.value);
}
}

/// Add block reward on a validator
/// @dev This method is called by the golang consensus engine every block
/// @param valAddr The validator address
Expand Down
7 changes: 7 additions & 0 deletions contracts/ValidatorSet.template
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contract ValidatorSet is IValidatorSet, System, IParamSubscriber {
event validatorMisdemeanor(address indexed validator, uint256 amount);
event validatorFelony(address indexed validator, uint256 amount);
event paramChange(string key, bytes value);
event received(address indexed from, uint256 amount);

/*********************** init **************************/
function init() external onlyNotInit {
Expand All @@ -86,6 +87,12 @@ contract ValidatorSet is IValidatorSet, System, IParamSubscriber {
return currentValidatorSetMap[addr] != 0;
}

receive() external payable {
if (msg.value != 0) {
emit received(msg.sender, msg.value);
}
}

/// Add block reward on a validator
/// @dev This method is called by the golang consensus engine every block
/// @param valAddr The validator address
Expand Down

0 comments on commit fb1689f

Please sign in to comment.