-
Notifications
You must be signed in to change notification settings - Fork 369
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
E2E EpochManager test + Epoch truffle migrations & Anvil L2 migration build fix #11198
Merged
Merged
Changes from 65 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
f9979ce
unit test with mocks
soloseng 75bf938
++ integration tests
soloseng cb47ec9
clean up
soloseng fbdc5fd
Merge branch 'feat/l2-epoch-system' into soloseng/startNextEpochProce…
soloseng b8f5584
-- logging
soloseng 282ef91
removed duplicate interface
soloseng 40711cb
using `MockCeloToken` to get test to pass.
soloseng 654b279
removed endEpochTimestamp
soloseng 2072107
moved IEpochManager to 0.5 folder
soloseng 9a6c01f
added L2 conditions for EpochRewards functions using precompiles
soloseng c48b8e5
renamed EpochManagerInitializer due to name conflict
soloseng 47f93af
++ more unit test
soloseng d3b1db4
setup anvil migration
soloseng a6e2844
Merge branch 'feat/l2-epoch-system' into soloseng/startNextEpochProce…
soloseng 2ba9360
compiles
soloseng 35b637a
++ require fund in unreleased treasury
soloseng c02c0a4
Updated regex
soloseng 92ac7cf
++ registry 0.8 for testing only
soloseng f50ac8b
clean up
soloseng 3aa816c
++ unit test
soloseng 180162b
initial integration test using L1 devchain
soloseng 22946ff
++ comment
soloseng 0ed7e93
-- forge based integration test
soloseng 7fcc9a8
Merge branch 'feat/l2-epoch-system' into soloseng/startNextEpochProce…
soloseng 8f0ea64
++ to const
soloseng cfa7cdb
happy linter
soloseng cdf7aea
update contract name
soloseng 4b709d3
Adding truffle migrations
pahor167 969f9d3
Fix of L2 Anvil migrations
pahor167 8838c5c
Improved anvil devchain compilation
pahor167 93274c8
Release init params
pahor167 b49f929
++ PR feedback
soloseng 1b616ca
++ checks
soloseng b47dba3
updated carbon address
soloseng f34e7e0
E2E test
pahor167 a050d27
lint
pahor167 0e8da38
Merge branch 'soloseng/startNextEpochProcess-unit-and-integration-tes…
pahor167 48db871
proxy stableToken mint call via Validators contract
soloseng 8a8f4d9
Merge branch 'feat/l2-epoch-system' into soloseng/startNextEpochProce…
soloseng bbb239f
-- duplicate imports
soloseng 2ffeed2
removed registry08. replaced with vm call
soloseng b195ebb
PR feedback
soloseng e84a5b5
generate Ecdsa Pub Key dynamically in migration.s.sol
pahor167 3c2ebfc
-- coment
soloseng 83bd5aa
passing unit tests
soloseng 1d4eaa4
clean up
soloseng 43ae993
++ mintStable test
soloseng de06b4e
-- TODO; compiles test when filtering
soloseng 15a5290
E2E test with 3 groups with 2 validators each
pahor167 84f4349
fix for rewards computation
pahor167 17c5884
lint
pahor167 bc53164
merge
pahor167 9ddb522
anvil migration rename
pahor167 48cf98c
remove setEpochMangerEnabler
pahor167 28bf1ff
truffle build fix
pahor167 e5ffbf1
initializeEpochManagerSystem
pahor167 96363fc
migration test fix
pahor167 812604d
prettify
pahor167 abdbae4
removal of logging
pahor167 55bd69b
removal of logging2
pahor167 fe91831
EpochManagerEnabler version
pahor167 2c5a95f
Enable epoch manager in devchain
pahor167 13510fd
lint
pahor167 eb5691b
Merge branch 'feat/l2-epoch-system' into pahor/truffleMigrations
martinvol 6011483
Rolled back contracts/identity/FederatedAttestations.sol added by mis…
martinvol 776f864
removed duplicated function
martinvol a152a09
Fix tests
martinvol f5a2cb8
lint
martinvol 95a6b65
Fixed tests and moved ValidatorsMock08 to solidity test folder
martinvol 69b3bd8
Added release data
martinvol f477f74
Deleted prints in release script
martinvol 4093393
Removed unnecesary mocking
martinvol fc278cb
Force compilation of validator
martinvol 5bf0d85
moved mocks to right path
martinvol df7a9e8
Fixed tests
martinvol 1d62d5f
Added ScoreManager to releaseData/initializationData/release12.json
martinvol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,9 +50,14 @@ contract EpochManager is | |
uint256 private currentEpochNumber; | ||
address[] public elected; | ||
|
||
struct ProcessedGroup { | ||
bool processed; | ||
uint256 epochRewards; | ||
} | ||
|
||
// TODO this should be able to get deleted easily | ||
// maybe even having it in a stadalone contract | ||
mapping(address => bool) public processedGroups; | ||
mapping(address => ProcessedGroup) public processedGroups; | ||
|
||
EpochProcessState public epochProcessing; | ||
mapping(uint256 => Epoch) private epochs; | ||
|
@@ -181,6 +186,7 @@ contract EpochManager is | |
// TODO complete this function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these TODO still required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be removed |
||
require(isOnEpochProcess(), "Epoch process is not started"); | ||
// finalize epoch | ||
// TODO last block should be the block before and timestamp from previous block | ||
epochs[currentEpochNumber].lastBlock = block.number - 1; | ||
// start new epoch | ||
currentEpochNumber++; | ||
|
@@ -189,27 +195,36 @@ contract EpochManager is | |
|
||
for (uint i = 0; i < elected.length; i++) { | ||
address group = getValidators().getValidatorsGroup(elected[i]); | ||
if (!processedGroups[group]) { | ||
if (!processedGroups[group].processed) { | ||
epochProcessing.toProcessGroups++; | ||
processedGroups[group] = true; | ||
uint256 groupScore = getScoreReader().getGroupScore(group); | ||
// We need to precompute epoch rewards for each group since computation depends on total active votes for all groups. | ||
uint256 epochRewards = getElection().getGroupEpochRewards( | ||
group, | ||
epochProcessing.totalRewardsVoter, | ||
groupScore | ||
); | ||
processedGroups[group] = ProcessedGroup(true, epochRewards); | ||
} | ||
} | ||
|
||
require(epochProcessing.toProcessGroups == groups.length, "number of groups does not match"); | ||
|
||
for (uint i = 0; i < groups.length; i++) { | ||
// since we are adding values it makes sense to start from the end | ||
martinvol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (uint ii = groups.length; ii > 0; ii--) { | ||
uint256 i = ii - 1; | ||
ProcessedGroup storage processedGroup = processedGroups[groups[i]]; | ||
// checks that group is actually from elected group | ||
require(processedGroups[groups[i]], "group not processed"); | ||
// by doing this, we avoid processing a group twice | ||
delete processedGroups[groups[i]]; | ||
// TODO what happens to uptime? | ||
uint256 groupScore = getScoreReader().getGroupScore(groups[i]); | ||
uint256 epochRewards = getElection().getGroupEpochRewards( | ||
require(processedGroup.processed, "group not processed"); | ||
getElection().distributeEpochRewards( | ||
groups[i], | ||
epochProcessing.totalRewardsVoter, | ||
groupScore | ||
processedGroup.epochRewards, | ||
lessers[i], | ||
greaters[i] | ||
); | ||
getElection().distributeEpochRewards(groups[i], epochRewards, lessers[i], greaters[i]); | ||
|
||
// by doing this, we avoid processing a group twice | ||
delete processedGroups[groups[i]]; | ||
} | ||
getCeloUnreleasedTreasure().release( | ||
registry.getAddressForOrDie(GOVERNANCE_REGISTRY_ID), | ||
|
@@ -220,7 +235,7 @@ contract EpochManager is | |
epochProcessing.totalRewardsCarbonFund | ||
); | ||
// run elections | ||
elected = getElection().electNValidatorSigners(10, 20); | ||
elected = getElection().electValidatorSigners(); | ||
// TODO check how to nullify stuct | ||
epochProcessing.status = EpochProcessStatus.NotStarted; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/protocol/contracts-0.8/common/interfaces/IScoreManager.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.5.13 <0.9.0; | ||
|
||
interface IScoreManager { | ||
function setGroupScore(address group, uint256 score) external; | ||
function setValidatorScore(address validator, uint256 score) external; | ||
function getValidatorScore(address validator) external view returns (uint256); | ||
function getGroupScore(address validator) external view returns (uint256); | ||
function owner() external view returns (address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts/common/proxies/EpochManagerEnablerProxy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
import "../Proxy.sol"; | ||
|
||
/* solhint-disable-next-line no-empty-blocks */ | ||
contract EpochManagerEnablerProxy is Proxy {} |
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts/common/proxies/EpochManagerProxy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
import "../Proxy.sol"; | ||
|
||
/* solhint-disable-next-line no-empty-blocks */ | ||
contract EpochManagerProxy is Proxy {} |
6 changes: 6 additions & 0 deletions
6
packages/protocol/contracts/common/proxies/ScoreManagerProxy.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pragma solidity ^0.5.13; | ||
|
||
import "../Proxy.sol"; | ||
|
||
/* solhint-disable-next-line no-empty-blocks */ | ||
contract ScoreManagerProxy is Proxy {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this TODO still required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed