Skip to content

Commit

Permalink
Update method epochOf & remove one-time-using function/event. (#81)
Browse files Browse the repository at this point in the history
Fix #51
  • Loading branch information
ducthotran2010 authored Nov 14, 2022
1 parent 60eb890 commit 7ac24c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
2 changes: 0 additions & 2 deletions contracts/interfaces/IRoninValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface IRoninValidatorSet is ICandidateManager {
event MaxValidatorNumberUpdated(uint256);
/// @dev Emitted when the number of reserved slots for prioritized validators is updated
event MaxPrioritizedValidatorNumberUpdated(uint256);
/// @dev Emitted when the number of blocks in epoch is updated
event NumberOfBlocksInEpochUpdated(uint256);
/// @dev Emitted when the validator set is updated
event ValidatorSetUpdated(uint256 indexed period, address[] consensusAddrs);
/// @dev Emitted when the bridge operator set is updated, to mirror the in-jail and maintaining status of the validator.
Expand Down
23 changes: 6 additions & 17 deletions contracts/ronin/validator/RoninValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract RoninValidatorSet is
_setMaxValidatorNumber(__maxValidatorNumber);
_setMaxValidatorCandidate(__maxValidatorCandidate);
_setMaxPrioritizedValidatorNumber(__maxPrioritizedValidatorNumber);
_setNumberOfBlocksInEpoch(__numberOfBlocksInEpoch);
_numberOfBlocksInEpoch = __numberOfBlocksInEpoch;
}

///////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -293,14 +293,14 @@ contract RoninValidatorSet is
uint256 epochLeft_
)
{
uint256 __jailedUntil = _jailedUntil[_addr];
if (__jailedUntil < _blockNum) {
uint256 _jailedBlock = _jailedUntil[_addr];
if (_jailedBlock < _blockNum) {
return (false, 0, 0);
}

isJailed_ = true;
blockLeft_ = __jailedUntil - _blockNum + 1;
epochLeft_ = epochOf(__jailedUntil) - epochOf(_blockNum) + 1;
blockLeft_ = _jailedBlock - _blockNum + 1;
epochLeft_ = epochOf(_jailedBlock) - epochOf(_blockNum) + 1;
}

/**
Expand Down Expand Up @@ -352,7 +352,7 @@ contract RoninValidatorSet is
* @inheritdoc IRoninValidatorSet
*/
function epochOf(uint256 _block) public view virtual override returns (uint256) {
return _block == 0 ? 0 : _block / _numberOfBlocksInEpoch + 1;
return _block / _numberOfBlocksInEpoch + 1;
}

/**
Expand Down Expand Up @@ -842,17 +842,6 @@ contract RoninValidatorSet is
emit MaxPrioritizedValidatorNumberUpdated(_number);
}

/**
* @dev Updates the number of blocks in epoch
*
* Emits the event `NumberOfBlocksInEpochUpdated`
*
*/
function _setNumberOfBlocksInEpoch(uint256 _number) internal {
_numberOfBlocksInEpoch = _number;
emit NumberOfBlocksInEpochUpdated(_number);
}

/**
* @dev See {IRoninValidatorSet-isPeriodEnding}
*/
Expand Down

0 comments on commit 7ac24c2

Please sign in to comment.