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

EpochManager fixes #11208

Merged
merged 9 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion packages/protocol/contracts-0.8/common/EpochManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ contract EpochManager is
epochProcessing.toProcessGroups++;
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(
uint256 epochRewards = getElection().getGroupEpochRewardsScore(
group,
epochProcessing.totalRewardsVoter,
groupScore
Expand Down Expand Up @@ -331,6 +331,10 @@ contract EpochManager is
validatorPendingPayments[elected[i]] += validatorReward;
totalRewards += validatorReward;
}
if (totalRewards == 0) {
return;
}

// Mint all cUSD required for payment and the corresponding CELO
validators.mintStableToEpochManager(totalRewards);
// this should have a setter for the oracle.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/governance/Election.sol
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ contract Election is
* @return The amount of rewards that voters for `group` are due at the end of an epoch.
* @dev Eligible groups that have received their maximum number of votes cannot receive more.
*/
function getGroupEpochRewards(
function getGroupEpochRewardsScore(
pahor167 marked this conversation as resolved.
Show resolved Hide resolved
address group,
uint256 totalEpochRewards,
uint256 groupScore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface IElection {
uint256,
uint256[] calldata
) external view returns (uint256);
function getGroupEpochRewards(
function getGroupEpochRewardsScore(
address group,
uint256 totalEpochRewards,
uint256 groupScore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ CELO_DISTRIBUTION_SCHEDULE_ADDRESS=$(
# implement the receive function nor does it allow ERC20 transfers. This is the only way I
# managed to give the CeloUnreleasedTreasure a balance.
echo "Setting CeloUnreleasedTreasure balance..."
HEX_CELO_DISTRIBUTION_SCHEDULE_INITIAL_BALANCE=$(cast to-hex $CELO_DISTRIBUTION_SCHEDULE_INITIAL_BALANCE"000000000000000000")
pahor167 marked this conversation as resolved.
Show resolved Hide resolved
cast rpc \
anvil_setBalance \
$CELO_DISTRIBUTION_SCHEDULE_ADDRESS $CELO_DISTRIBUTION_SCHEDULE_INITIAL_BALANCE \
$CELO_DISTRIBUTION_SCHEDULE_ADDRESS $HEX_CELO_DISTRIBUTION_SCHEDULE_INITIAL_BALANCE \
--rpc-url $ANVIL_RPC_URL

# Run L2 migrations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ contract E2E_EpochManager_FinishNextEpochProcess is E2E_EpochManager {
groupWithVotes[i] = GroupWithVotes(
groupsEligible[i],
values[i] +
election.getGroupEpochRewards(groupsEligible[i], totalRewardsVote, groupScore[i])
election.getGroupEpochRewardsScore(groupsEligible[i], totalRewardsVote, groupScore[i])
);
}

Expand Down
Loading