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

Martinvol/state fix #11282

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 11 additions & 6 deletions packages/protocol/contracts-0.8/common/EpochManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ contract EpochManager is
*/
function startNextEpochProcess() external nonReentrant onlySystemAlreadyInitialized {
require(isTimeForNextEpoch(), "Epoch is not ready to start");
require(!isOnEpochProcess(), "Epoch process is already started");
require(!isEpochProcessingStarted(), "Epoch process is already started");
martinvol marked this conversation as resolved.
Show resolved Hide resolved

epochProcessing.status = EpochProcessStatus.Started;
epochs[currentEpochNumber].rewardsBlock = block.number;
Expand Down Expand Up @@ -273,10 +273,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];
Expand Down Expand Up @@ -452,7 +449,7 @@ contract EpochManager is
* @return Whether or not the blockable functions are blocked.
*/
function isBlocked() external view returns (bool) {
return isOnEpochProcess();
return isEpochProcessingStarted();
}

/**
Expand Down Expand Up @@ -599,6 +596,14 @@ contract EpochManager is
emit OracleAddressSet(newOracleAddress);
}

function isIndividualProcessing() public view returns (bool) {
martinvol marked this conversation as resolved.
Show resolved Hide resolved
return epochProcessing.status == EpochProcessStatus.IndivudualGroupsProcessing;
}

function isEpochProcessingStarted() public view returns (bool) {
martinvol marked this conversation as resolved.
Show resolved Hide resolved
return isOnEpochProcess() || isIndividualProcessing();
}

/**
* @return Whether or not the next epoch can be processed.
*/
Expand Down
13 changes: 13 additions & 0 deletions packages/protocol/test-sol/unit/common/EpochManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,19 @@ contract EpochManagerTest_setToProcessGroups is EpochManagerTest {
assertEq(EpochManager(address(epochManager)).toProcessGroups(), groups.length);
}

function test_blocksChilds() public {
martinvol marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down
Loading