diff --git a/packages/protocol/contracts-0.8/common/EpochManager.sol b/packages/protocol/contracts-0.8/common/EpochManager.sol index e467588a033..649b5b76cf4 100644 --- a/packages/protocol/contracts-0.8/common/EpochManager.sol +++ b/packages/protocol/contracts-0.8/common/EpochManager.sol @@ -191,7 +191,11 @@ contract EpochManager is */ function startNextEpochProcess() external nonReentrant onlySystemAlreadyInitialized { require(isTimeForNextEpoch(), "Epoch is not ready to start"); - require(!isOnEpochProcess(), "Epoch process is already started"); + require( + epochProcessing.status != EpochProcessStatus.Started, + "Epoch process is already started" + ); + require(!isEpochProcessingStarted(), "Epoch process is already started"); epochProcessing.status = EpochProcessStatus.Started; epochs[currentEpochNumber].rewardsBlock = block.number; @@ -273,10 +277,7 @@ contract EpochManager is */ function processGroup(address group, address lesser, address greater) public { EpochProcessState storage _epochProcessing = epochProcessing; - require( - _epochProcessing.status == EpochProcessStatus.IndivudualGroupsProcessing, - "Indivudual epoch process is not started" - ); + require(isIndividualProcessing(), "Indivudual epoch process is not started"); require(toProcessGroups > 0, "no more groups to process"); uint256 epochRewards = processedGroups[group]; @@ -452,7 +453,7 @@ contract EpochManager is * @return Whether or not the blockable functions are blocked. */ function isBlocked() external view returns (bool) { - return isOnEpochProcess(); + return isEpochProcessingStarted(); } /** @@ -599,6 +600,14 @@ contract EpochManager is emit OracleAddressSet(newOracleAddress); } + function isIndividualProcessing() public view returns (bool) { + return epochProcessing.status == EpochProcessStatus.IndivudualGroupsProcessing; + } + + function isEpochProcessingStarted() public view returns (bool) { + return isOnEpochProcess() || isIndividualProcessing(); + } + /** * @return Whether or not the next epoch can be processed. */ diff --git a/packages/protocol/migrations_sol/MigrationL2.s.sol b/packages/protocol/migrations_sol/MigrationL2.s.sol index decd5ebc374..72c80815eb1 100644 --- a/packages/protocol/migrations_sol/MigrationL2.s.sol +++ b/packages/protocol/migrations_sol/MigrationL2.s.sol @@ -8,7 +8,7 @@ import "forge-std/console.sol"; import "@celo-contracts/common/FixidityLib.sol"; import "@celo-contracts-8/common/UsingRegistry.sol"; -import "../../contracts/common/interfaces/IEpochManagerEnabler.sol"; +import "@celo-contracts/common/interfaces/IEpochManagerEnabler.sol"; contract MigrationL2 is Script, MigrationsConstants, UsingRegistry { using FixidityLib for FixidityLib.Fraction; diff --git a/packages/protocol/test-sol/unit/common/EpochManager.t.sol b/packages/protocol/test-sol/unit/common/EpochManager.t.sol index bebd3999b10..5b284113e5d 100644 --- a/packages/protocol/test-sol/unit/common/EpochManager.t.sol +++ b/packages/protocol/test-sol/unit/common/EpochManager.t.sol @@ -698,6 +698,19 @@ contract EpochManagerTest_setToProcessGroups is EpochManagerTest { assertEq(EpochManager(address(epochManager)).toProcessGroups(), groups.length); } + function test_blocksChilds() public { + epochManager.startNextEpochProcess(); + epochManager.setToProcessGroups(); + assertTrue(epochManager.isBlocked()); + } + + function test_Reverts_startEpochAgain() public { + epochManager.startNextEpochProcess(); + epochManager.setToProcessGroups(); + vm.expectRevert("Epoch process is already started"); + epochManager.startNextEpochProcess(); + } + function test_setsGroupRewards() public { (address[] memory groups, , ) = getGroupsWithLessersAndGreaters(); epochManager.startNextEpochProcess();