-
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
startNextEpochProcess unit & integration test #11191
startNextEpochProcess unit & integration test #11191
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
packages/protocol/test-sol/integration/EpochManagerIntegration.sol
Outdated
Show resolved
Hide resolved
…ss-unit-and-integration-test
Fails when it hits a precompile in `EpochRewards.sol`
Still missing tests
|
||
interface IEpochManager is IBlocker { | ||
interface IEpochManager{ |
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.
- Add timestamp to initialize
- add startNextEpoch() and finishNextepcohProcess
- uncomment the rest or remove
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.
We are currently using getting block.timestamp
within the initializeSystem
function and assigning it to the L2 epoch start time.
were you thinking of also storing the timestamp of the last know block on L1 as well?
fix name conflict
…ss-unit-and-integration-test
…ss-unit-and-integration-test
packages/protocol/contracts-0.8/governance/test/MockElection.sol
Outdated
Show resolved
Hide resolved
@@ -930,6 +936,41 @@ contract Migration is Script, UsingRegistry, MigrationsConstants { | |||
); | |||
} | |||
|
|||
function migrateEpochManagerEnabler() public { |
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.
This should be added to the L2 scripts rather than this one, right?
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.
this contract should be deployed on L1, because it will have to store the epoch state in the contract so that it can initialize the epochManager
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.
wont do then
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.
not sure I understand what you mean.
…ss-unit-and-integration-test
carbonOffsettingPartner = actor("carbonOffsettingPartner"); | ||
communityRewardFund = actor("communityRewardFund"); | ||
|
||
deployCodeTo("Registry.sol", abi.encode(false), REGISTRY_ADDRESS); | ||
deployCodeTo("GoldToken.sol", abi.encode(false), celoTokenAddress); | ||
deployCodeTo("MockRegistry.sol", abi.encode(false), REGISTRY_ADDRESS); |
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.
Do we need MockRegistry? Wouldn't something like that's already on the PR?
function whenL2(Vm vm) public {
vm.etch(0x4200000000000000000000000000000000000018, abi.encodePacked(bytes1(0x01)));
}
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.
It's fine to use the above code for the L2 check because that gets deployed to the proxyAdmin address. For the case of the registry, we need the actual registry code for the tests to work. So deploying arbitrary code to the registry address will not work.
function mintStableToEpochManager( | ||
uint256 amount | ||
) external onlyL2 nonReentrant onlyRegisteredContract(EPOCH_MANAGER_REGISTRY_ID) { | ||
require(amount > 0, "mint amount is zero."); |
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.
I think it's dangerous to have this call here, transfers with zero value are valid, and if someone hits that edge case then this system will stall.
(which doesn't mean that we shouldn't try to avoid zero calls to this function to save gas)
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.
Could you elaborate more on the danger of this check?
Removed it, as a zero value wont negatively affect any code after the call.
* first compiling draft no working test. Co-authored-by: Martín Volpe <[email protected]> * Compiler fixes + finishNextEpochProcess * allocateValidatorsRewards compilable * First few tests * test fix * uisng registry instead * updated registry ID var names * typo * ++ mock contracts in 0.8 * ++ passing test using mock * Removal of using precompiles * ScoreManager refactor * Decouple epoch manager initializer from registry * isReadyToStartEpoch fix * startNextEpochProcess fixes * rename score manager to score reader * Rename transfer to release on CeloDistribution schedule * Celo distribution schedule renamed to CeloUnreleasedTreasure * conditions to getFirstBlockAtEpoch and getLastBlockAtEpoch * ScoreManager update * getFirstBlockOfEpoch in EpochManager initializer * extra checks * introduce new getValidatorsGroup * systemAlreadyInitialized update * Removal of IEpochManagerInterface * Made CI run on feature branch * merge fix * Added target for the CI * Fixed quote celo-monorepo.yml * Allow Validator registration in L2 without BLS key (#11181) * Allow validator registration in L2 without BLS key * Reallow ECDSA key change in L2 --------- Co-authored-by: Martín Volpe <[email protected]> * Fix CI * Fixed interfaces and imports * Build fix * lint * prettify * prettify 2 * Attempt to fix truffle build and migrations l2 epoch (#11190) * Added Blocking to LockedGold, Election (#11186) * add EpochManager to abis * force deploy abis * build fix * Move Validators.sol to 0.8 (#11192) * WIP * Validator test WIP, forge doesn't compile yet * buildable * most of the foundry tests working * Validator related tests fixed * truffle build working * cache bump * lint + prettify+ migrations * Enable optimization for Solidity 0.8 * prettify * Ci bump * CI bump 2 * Validators to 0.8 config * CI bump * foundry fix * Truffle migrations are partly fixed * Added import for ValidatorsMock08 in EpochManager.t.sol, I think it was removed by mistake * Added yarn.lock * Changes to mock with full implementation * Attempt to fix linking libraries not working with deployCodeTo foundry-rs/foundry#4049 * truffle migrations fixed * CI bump * lint * forge test fixes * artifacts test fix * lint * update of foundry version * add ProxyFactory import to tests * library linking fix * Foundry migrations fix * migration tests fix * CI bump * Little cleanup + retrigger CI * forgot to commit Validators.sol * Fixed the ABI encoded * lint * Fix contract versions * add Adapter to ignored contracts * revert of ReentrancyGuard change * lint fix * remove adapters from check * storage layout fix --------- Co-authored-by: pahor167 <[email protected]> * force release of canary abi * force new canary version * npm tag revert * Soloseng/update-l2-getepochnumber-logic (#11195) * disable getEpochSize on L2 * update registry * update relevant interfaces * update contracts with L2 `getEpochNumber()` logic * update tests with L2 `getEpochNumber()` logic * ++ TODO * moved constants to constants file * updated allocated supply function to handle L1 & L2 cases * made `epochManager.currenEpochNumber()` private, to avoid returning 0 when not initialized. * PR feedback * Passing validators test using mockEpochManager for L2 tests * clean up * fixed other failing tests * using mockEpochManager instead of interface. Fixed failing tests. * happy linter * revert npm tag ∆ * ++ TODO and comment * add score manager to abis * Split initEpochManager Function (#11199) * ++ contract function * ++ comment * startNextEpochProcess unit & integration test (#11191) * unit test with mocks * ++ integration tests * clean up * -- logging * removed duplicate interface * using `MockCeloToken` to get test to pass. Fails when it hits a precompile in `EpochRewards.sol` * removed endEpochTimestamp * moved IEpochManager to 0.5 folder * added L2 conditions for EpochRewards functions using precompiles Still missing tests * renamed EpochManagerInitializer due to name conflict * ++ more unit test * setup anvil migration fix name conflict * compiles * ++ require fund in unreleased treasury * Updated regex * ++ registry 0.8 for testing only * clean up * ++ unit test * initial integration test using L1 devchain * ++ comment * -- forge based integration test * ++ to const * happy linter * update contract name * ++ PR feedback * ++ checks * updated carbon address * proxy stableToken mint call via Validators contract * -- duplicate imports * removed registry08. replaced with vm call * PR feedback * -- coment * passing unit tests * clean up * ++ mintStable test * -- TODO; compiles test when filtering * PR feedback * updated migration script to add more validators * passing integration test * removed test for zero amount * yarn build fix * clean up comments && TODO * revert change as out of scope * E2E EpochManager test + Epoch truffle migrations & Anvil L2 migration build fix (#11198) * Soloseng/dynamically-fetch-epochmanagerenabler-address (#11207) * dynamically fetch epochManagerEnabler && carbonOffsettingPartner ++ to registry * PR feedback * removed onlyL1 modifier in setter functions * updated unit test to reflect changes * fixing tests * fix test * fixed migration data * fixed migration script error * removed unused modifier * removed duplicate or unused code * Implement sending of allocated validator payments (#11197) * EpochManager fixes (#11208) * truffle build fix * build fix * PR comments * prettify * rename of registerValidator overload * bug fix * extensing epochManager e2e test * yarn lint * Reset pending payment to 0 after sending (#11209) Reset pending payment to 0 when sending * Deleted duplicated import * Make captureEpochAndValidators work in constant time (#11210) * Use more general interface for token transfer (#11216) * Epoch manager enabler tests (#11213) * ++ basic test * -- celoToken balance check * cleanup comments * use celoToken instead of native token for `initializeSystem` balance check * ++ more test * removed additional epochs * Make sendValidatorPayment nonReentrant (#11217) * Martinvol/return account instead of signer (#11215) * EpochManager e2e tests add/remove validators between ecpochs (#11214) * Send validator payment on actions that would modify reward distribution (#11211) * Rename `CeloUnreleasedTreasure` to `CeloUnreleasedTreasury` (#11220) * updated `CeloUnrealeasedTreasure` to `CeloUnreleasedTreasury` * update `CeloUnreleasedTreasury` initial balance to use defined constant * renamed file * prevent CELO transfers to `CeloUnreleasedTreasury` * ++ comment * unused import * using internal accounting for released amount * updated integration test * PR feedback * PR feedback * reverted due to gas consideration * more revert --------- Co-authored-by: Martín Volpe <[email protected]> Co-authored-by: pahor167 <[email protected]> Co-authored-by: Martín Volpe <[email protected]> Co-authored-by: Martín Volpe <[email protected]> Co-authored-by: Martin <[email protected]> Co-authored-by: pahor167 <[email protected]>
Description
Implements unit and integration tests for epochManager contract
Other changes
Describe any minor or "drive-by" changes here.
Tested
An explanation of how the changes were tested or an explanation as to why they don't need to be.
Related issues
Backwards compatibility
Brief explanation of why these changes are/are not backwards compatible.
Documentation
The set of community facing docs that have been added/modified because of this change