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

[Validator] Fix epoch index & order of deleting #21

Merged
merged 1 commit into from
Sep 28, 2022
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
6 changes: 3 additions & 3 deletions contracts/validator/RoninValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ contract RoninValidatorSet is
* @inheritdoc IRoninValidatorSet
*/
function epochOf(uint256 _block) public view virtual override returns (uint256) {
return _block / _numberOfBlocksInEpoch + 1;
return _block == 0 ? 0 : _block / _numberOfBlocksInEpoch + 1;
}

/**
* @inheritdoc IRoninValidatorSet
*/
function periodOf(uint256 _block) public view virtual override returns (uint256) {
return _block / (_numberOfBlocksInEpoch * _numberOfEpochsInPeriod) + 1;
return _block == 0 ? 0 : _block / (_numberOfBlocksInEpoch * _numberOfEpochsInPeriod) + 1;
}

/**
Expand Down Expand Up @@ -418,8 +418,8 @@ contract RoninValidatorSet is
}

for (uint256 _i = _newValidatorCount; _i < validatorCount; _i++) {
delete _validator[_i];
delete _validatorMap[_validator[_i]];
delete _validator[_i];
}

uint256 _count;
Expand Down