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

Make updateMembershipHistory in Validators.sol correct if epoch number is 0 #8060

Merged
merged 5 commits into from
Jun 11, 2021
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
14 changes: 10 additions & 4 deletions packages/protocol/contracts/governance/Validators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "solidity-bytes-utils/contracts/BytesLib.sol";
import "./interfaces/IValidators.sol";

import "../common/CalledByVm.sol";
import "../common/Initializable.sol";
import "../common/InitializableV2.sol";
import "../common/FixidityLib.sol";
import "../common/linkedlists/AddressLinkedList.sol";
import "../common/UsingRegistry.sol";
Expand All @@ -24,7 +24,7 @@ contract Validators is
ICeloVersionedContract,
Ownable,
ReentrancyGuard,
Initializable,
InitializableV2,
UsingRegistry,
UsingPrecompiles,
CalledByVm
Expand Down Expand Up @@ -163,7 +163,7 @@ contract Validators is
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 2, 0, 0);
return (1, 2, 0, 1);
}

/**
Expand Down Expand Up @@ -207,6 +207,12 @@ contract Validators is
setDowntimeGracePeriod(_downtimeGracePeriod);
}

/**
* @notice Sets initialized == true on implementation contracts
* @param test Set to true to skip implementation initialization
*/
constructor(bool test) public InitializableV2(test) {}

/**
* @notice Updates the block delay for a ValidatorGroup's commission udpdate
* @param delay Number of blocks to delay the update
Expand Down Expand Up @@ -1167,7 +1173,7 @@ contract Validators is
history.lastRemovedFromGroupTimestamp = now;
}

if (history.entries[head].epochNumber == epochNumber) {
if (history.numEntries > 0 && history.entries[head].epochNumber == epochNumber) {
// There have been no elections since the validator last changed membership, overwrite the
// previous entry.
history.entries[head] = MembershipHistoryEntry(epochNumber, group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../../common/FixidityLib.sol";
/**
* @title A wrapper around Validators that exposes onlyVm functions for testing.
*/
contract ValidatorsTest is Validators {
contract ValidatorsTest is Validators(true) {
function updateValidatorScoreFromSigner(address signer, uint256 uptime) external {
return _updateValidatorScoreFromSigner(signer, uptime);
}
Expand Down