Skip to content

Commit

Permalink
Merge branch 'master' into soloseng/celo-minting-schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
soloseng committed May 22, 2024
2 parents e9c5b19 + f7047d3 commit 72da66a
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .github/actions/sync-workspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
runs:
using: "composite"
steps:
- uses: actions/cache/restore@v3
- uses: actions/cache/restore@v4
id: cache_node
env:
REBUILD_PACKAGE: ${{ inputs.rebuild-package }}
Expand All @@ -23,7 +23,7 @@ runs:
enableCrossOsArchive: true
fail-on-cache-miss: "!${{ fromJSON(env.REBUILD_PACKAGE) }}"
- name: Restore build artifacts cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
id: cache_build_artifacts
env:
REBUILD_PACKAGE: ${{ inputs.rebuild-package }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/celo-monorepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
with:
submodules: recursive
- name: Restore node cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache_node
with:
# We need to cache all the artifacts generated by yarn install+build
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
# We use cache to share the build artifacts between jobs (gh artifacts are too slow...)
# For more context check https://github.com/actions/upload-artifact/issues/199
- name: Restore build artifacts cache
uses: actions/cache@v3
uses: actions/cache@v4
id: cache_build_artifacts
with:
# We need to cache all the artifacts generated by yarn install+build
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:
rebuild-package: 'true'
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Execute matrix command for test
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 40
max_attempts: 3
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
with:
artifacts_to_cache: ${{ needs.install-dependencies.outputs.artifacts_to_cache }}
- name: Execute matrix command for test
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 30
max_attempts: 3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/protocol_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
fi
- name: Foundry cache
id: foundry-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-foundry-cache-${{ env.FOUNDRY_CACHE_KEY }}
- name: Foundry out
id: foundry-out
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ./out
key: ${{ runner.os }}-foundry-out-${{ env.FOUNDRY_CACHE_KEY }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../common/interfaces/ICeloVersionedContract.sol";
import "./SlasherUtil.sol";
import "../../contracts-0.8/common/IsL2Check.sol";

contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil, IsL2Check {
contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil {
using SafeMath for uint256;

// For each signer address, check if a block header has already been slashed
Expand Down
11 changes: 7 additions & 4 deletions packages/protocol/contracts/governance/DowntimeSlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ contract DowntimeSlasher is ICeloVersionedContract, SlasherUtil {
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (2, 0, 0, 1);
return (2, 0, 1, 0);
}

/**
* @notice Sets the slashable downtime.
* @param interval Slashable downtime in blocks.
*/
function setSlashableDowntime(uint256 interval) public onlyOwner {
function setSlashableDowntime(uint256 interval) public onlyOwner onlyL1 {
require(interval != 0, "slashable downtime cannot be zero");
slashableDowntime = interval;
emit SlashableDowntimeSet(interval);
Expand All @@ -84,7 +84,10 @@ contract DowntimeSlasher is ICeloVersionedContract, SlasherUtil {
* @return The signature bitmap for the specified interval.
* @dev startBlock and endBlock must be in the same epoch.
*/
function setBitmapForInterval(uint256 startBlock, uint256 endBlock) public returns (bytes32) {
function setBitmapForInterval(
uint256 startBlock,
uint256 endBlock
) public onlyL1 returns (bytes32) {
require(!isBitmapSetForInterval(startBlock, endBlock), "bitmap already set");

bytes32 bitmap = getBitmapForInterval(startBlock, endBlock);
Expand Down Expand Up @@ -124,7 +127,7 @@ contract DowntimeSlasher is ICeloVersionedContract, SlasherUtil {
address[] memory groupElectionLessers,
address[] memory groupElectionGreaters,
uint256[] memory groupElectionIndices
) public {
) public onlyL1 {
uint256 startBlock = startBlocks[0];
uint256 endBlock = endBlocks[endBlocks.length.sub(1)];
require(
Expand Down
25 changes: 15 additions & 10 deletions packages/protocol/contracts/governance/EpochRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../common/Initializable.sol";
import "../common/UsingRegistry.sol";
import "../common/UsingPrecompiles.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../../contracts-0.8/common/IsL2Check.sol";

/**
* @title Contract for calculating epoch rewards.
Expand All @@ -21,7 +22,8 @@ contract EpochRewards is
UsingPrecompiles,
UsingRegistry,
Freezable,
CalledByVm
CalledByVm,
IsL2Check
{
using FixidityLib for FixidityLib.Fraction;
using SafeMath for uint256;
Expand Down Expand Up @@ -143,7 +145,7 @@ contract EpochRewards is
* voting Gold fraction.
* @dev Only called directly by the protocol.
*/
function updateTargetVotingYield() external onlyVm onlyWhenNotFrozen {
function updateTargetVotingYield() external onlyVm onlyWhenNotFrozen onlyL1 {
_updateTargetVotingYield();
}

Expand Down Expand Up @@ -265,15 +267,15 @@ contract EpochRewards is
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 1);
return (1, 1, 2, 0);
}

/**
* @notice Sets the community reward percentage
* @param value The percentage of the total reward to be sent to the community funds.
* @return True upon success.
*/
function setCommunityRewardFraction(uint256 value) public onlyOwner returns (bool) {
function setCommunityRewardFraction(uint256 value) public onlyOwner onlyL1 returns (bool) {
require(
value != communityRewardFraction.unwrap() && value < FixidityLib.fixed1().unwrap(),
"Value must be different from existing community reward fraction and less than 1"
Expand All @@ -289,7 +291,10 @@ contract EpochRewards is
* @param value The percentage of the total reward to be sent to the carbon offsetting partner.
* @return True upon success.
*/
function setCarbonOffsettingFund(address partner, uint256 value) public onlyOwner returns (bool) {
function setCarbonOffsettingFund(
address partner,
uint256 value
) public onlyOwner onlyL1 returns (bool) {
require(
partner != carbonOffsettingPartner || value != carbonOffsettingFraction.unwrap(),
"Partner and value must be different from existing carbon offsetting fund"
Expand All @@ -306,7 +311,7 @@ contract EpochRewards is
* @param value The percentage of floating Gold voting to target.
* @return True upon success.
*/
function setTargetVotingGoldFraction(uint256 value) public onlyOwner returns (bool) {
function setTargetVotingGoldFraction(uint256 value) public onlyOwner onlyL1 returns (bool) {
require(value != targetVotingGoldFraction.unwrap(), "Target voting gold fraction unchanged");
require(
value < FixidityLib.fixed1().unwrap(),
Expand All @@ -322,7 +327,7 @@ contract EpochRewards is
* @param value The value in Celo Dollars.
* @return True upon success.
*/
function setTargetValidatorEpochPayment(uint256 value) public onlyOwner returns (bool) {
function setTargetValidatorEpochPayment(uint256 value) public onlyOwner onlyL1 returns (bool) {
require(value != targetValidatorEpochPayment, "Target validator epoch payment unchanged");
targetValidatorEpochPayment = value;
emit TargetValidatorEpochPaymentSet(value);
Expand All @@ -342,7 +347,7 @@ contract EpochRewards is
uint256 max,
uint256 underspendAdjustmentFactor,
uint256 overspendAdjustmentFactor
) public onlyOwner returns (bool) {
) public onlyOwner onlyL1 returns (bool) {
require(
max != rewardsMultiplierParams.max.unwrap() ||
overspendAdjustmentFactor != rewardsMultiplierParams.adjustmentFactors.overspend.unwrap() ||
Expand All @@ -369,7 +374,7 @@ contract EpochRewards is
function setTargetVotingYieldParameters(
uint256 max,
uint256 adjustmentFactor
) public onlyOwner returns (bool) {
) public onlyOwner onlyL1 returns (bool) {
require(
max != targetVotingYieldParams.max.unwrap() ||
adjustmentFactor != targetVotingYieldParams.adjustmentFactor.unwrap(),
Expand All @@ -391,7 +396,7 @@ contract EpochRewards is
* @param targetVotingYield The relative target block reward for voters.
* @return True upon success.
*/
function setTargetVotingYield(uint256 targetVotingYield) public onlyOwner returns (bool) {
function setTargetVotingYield(uint256 targetVotingYield) public onlyOwner onlyL1 returns (bool) {
FixidityLib.Fraction memory target = FixidityLib.wrap(targetVotingYield);
require(
target.lte(targetVotingYieldParams.max),
Expand Down
5 changes: 3 additions & 2 deletions packages/protocol/contracts/governance/SlasherUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import "../common/Initializable.sol";
import "../common/UsingRegistry.sol";
import "../common/UsingPrecompiles.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../../contracts-0.8/common/IsL2Check.sol";

contract SlasherUtil is Ownable, Initializable, UsingRegistry, UsingPrecompiles {
contract SlasherUtil is Ownable, Initializable, UsingRegistry, UsingPrecompiles, IsL2Check {
using SafeMath for uint256;

struct SlashingIncentives {
Expand All @@ -33,7 +34,7 @@ contract SlasherUtil is Ownable, Initializable, UsingRegistry, UsingPrecompiles
* @param penalty Penalty for the slashed signer.
* @param reward Reward that the observer gets.
*/
function setSlashingIncentives(uint256 penalty, uint256 reward) public onlyOwner {
function setSlashingIncentives(uint256 penalty, uint256 reward) public onlyL1 onlyOwner {
require(penalty > reward, "Penalty has to be larger than reward");
slashingIncentives.penalty = penalty;
slashingIncentives.reward = reward;
Expand Down
12 changes: 7 additions & 5 deletions packages/protocol/contracts/governance/test/MockElection.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pragma solidity ^0.5.13;

import "../../../contracts-0.8/common/IsL2Check.sol";

/**
* @title Holds a list of addresses of validators
*/
contract MockElection {
contract MockElection is IsL2Check {
mapping(address => bool) public isIneligible;
mapping(address => bool) public isEligible;
mapping(address => bool) public allowedToVoteOverMaxNumberOfGroups;
Expand All @@ -15,7 +17,7 @@ contract MockElection {
isIneligible[account] = true;
}

function markGroupEligible(address account, address, address) external {
function markGroupEligible(address account, address, address) external onlyL1 {
isEligible[account] = true;
}

Expand All @@ -31,11 +33,11 @@ contract MockElection {
electedValidators = _electedValidators;
}

function vote(address, uint256, address, address) external returns (bool) {
function vote(address, uint256, address, address) external onlyL1 returns (bool) {
return true;
}

function activate(address) external returns (bool) {
function activate(address) external onlyL1 returns (bool) {
return true;
}

Expand Down Expand Up @@ -78,7 +80,7 @@ contract MockElection {
return electedValidators;
}

function setAllowedToVoteOverMaxNumberOfGroups(address account, bool flag) public {
function setAllowedToVoteOverMaxNumberOfGroups(address account, bool flag) public onlyL1 {
allowedToVoteOverMaxNumberOfGroups[account] = flag;
}
}
Loading

0 comments on commit 72da66a

Please sign in to comment.