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

test: slashing release #374

Merged
merged 17 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
49 changes: 49 additions & 0 deletions .github/workflows/forge-test-intense.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Forge Test (Intense)

on:
workflow_dispatch:
push:
branches:
- mainnet
- testnet-holesky
- dev

env:
FOUNDRY_PROFILE: ci
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
CHAIN_ID: ${{ secrets.CHAIN_ID }}

jobs:
# -----------------------------------------------------------------------
# Forge Test (Intense)
# -----------------------------------------------------------------------

forge-test-intense:
name: Test (Intense)
runs-on: ubuntu-latest
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Build the project and display contract sizes.
- name: Forge Build
run: |
forge --version
forge build --sizes
id: build

# Run Forge Test (Intense)
- name: Forge Test (Intense)
run: |
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
FOUNDRY_PROFILE=intense forge test -vvv
68 changes: 10 additions & 58 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
workflow_dispatch:
push:
branches:
- master
- mainnet
- testnet-goerli
- testnet-holesky
- dev
pull_request:

Expand All @@ -24,101 +23,54 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Run Forge's formatting checker to ensure consistent code style.
- name: "Forge Fmt"
- name: Forge Fmt
run: |
forge fmt --check
id: fmt

# Build the project and display contract sizes.
- name: "Forge Build"
- name: Forge Build
run: |
forge --version
forge build --sizes
id: build

# Run local tests (unit and integration).
- name: "Forge Test (Local)"
- name: Forge Test (Local)
run: forge test -vvv

# Run integration tests using a mainnet fork.
- name: "Forge Test Integration (Fork)"
- name: Forge Test Integration (Fork)
run: FOUNDRY_PROFILE=forktest forge test --match-contract Integration -vvv

# -----------------------------------------------------------------------
# Forge Test (Intense)
# -----------------------------------------------------------------------

continuous-fuzzing:
name: Test (Intense)
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable

# Build the project and display contract sizes.
- name: "Forge Build"
run: |
forge --version
forge build --sizes
id: build

# Run Forge Test (Intense)
- name: Forge Test (Intense)
run: |
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
FOUNDRY_PROFILE=intense forge test -vvv

# -----------------------------------------------------------------------
# Forge Coverage
# -----------------------------------------------------------------------

run-coverage:
name: Coverage
runs-on: ubuntu-latest
# Only run coverage checks on dev, testnet-holesky, and mainnet branches, or PRs targeting these branches
if: |
github.ref == 'refs/heads/dev' ||
github.ref == 'refs/heads/testnet-holesky' ||
github.ref == 'refs/heads/mainnet' ||
github.base_ref == 'dev' ||
github.base_ref == 'testnet-holesky' ||
github.base_ref == 'mainnet'
strategy:
fail-fast: true
steps:
# Check out repository with all submodules for complete codebase access.
- uses: actions/checkout@v4
with:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
Expand All @@ -130,7 +82,7 @@ jobs:
id: lcov

# Build the project and display contract sizes.
- name: "Forge Build"
- name: Forge Build
run: |
forge --version
forge build --sizes
Expand All @@ -150,7 +102,7 @@ jobs:
path: report/*

# Check coverage threshold after uploading report
- name: Check Coverage Threshold
- name: Check Coverage Threshold for >=90%
run: |
LINES_PCT=$(lcov --summary lcov.info | grep "lines" | cut -d ':' -f 2 | cut -d '%' -f 1 | tr -d '[:space:]')
FUNCTIONS_PCT=$(lcov --summary lcov.info | grep "functions" | cut -d ':' -f 2 | cut -d '%' -f 1 | tr -d '[:space:]')
Expand Down Expand Up @@ -188,7 +140,7 @@ jobs:
submodules: recursive

# Install the Foundry toolchain.
- name: "Install Foundry"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
Expand Down
8 changes: 5 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

# Defines paths for Solidity imports.
remappings = [
"@openzeppelin/=lib/openzeppelin-contracts-v4.9.0/",
"@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable-v4.9.0/",
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/ds-test/src/",
"forge-std/=lib/forge-std/src/"
"@openzeppelin/=lib/openzeppelin-contracts/",
"@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/",
"eigenlayer-contracts/=lib/eigenlayer-contracts/",

]
# Specifies the exact version of Solidity to use, overriding auto-detection.
solc_version = '0.8.27'
Expand Down
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
5 changes: 0 additions & 5 deletions remappings.txt

This file was deleted.

4 changes: 1 addition & 3 deletions src/BLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
quorumApkUpdatesLength == 0
|| blockNumber < apkHistory[quorumNumber][0].updateBlockNumber
) {
revert(
"BLSApkRegistry.getApkIndicesAtBlockNumber: blockNumber is before the first update"
);
revert BlockNumberBeforeFirstUpdate();
}

// Loop backward through apkHistory until we find an entry that preceeds `blockNumber`
Expand Down
7 changes: 6 additions & 1 deletion src/BLSSignatureChecker.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {BitmapUtils} from "./libraries/BitmapUtils.sol";
import {BN254} from "./libraries/BN254.sol";

Expand All @@ -18,7 +20,10 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage {
/// MODIFIERS

modifier onlyCoordinatorOwner() {
require(msg.sender == registryCoordinator.owner(), OnlyRegistryCoordinatorOwner());
require(
msg.sender == Ownable(address(registryCoordinator)).owner(),
OnlyRegistryCoordinatorOwner()
);
_;
}

Expand Down
18 changes: 8 additions & 10 deletions src/EjectionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl
import {
EjectionManagerStorage,
IEjectionManager,
IRegistryCoordinator,
ISlashingRegistryCoordinator,
IStakeRegistry
} from "./EjectionManagerStorage.sol";

// TODO: double check order of inheritance since we separated storage from logic...

/**
* @title Used for automated ejection of operators from the RegistryCoordinator under a ratelimit
* @title Used for automated ejection of operators from the SlashingRegistryCoordinator under a ratelimit
* @author Layr Labs, Inc.
*/
contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
constructor(
IRegistryCoordinator _registryCoordinator,
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
IStakeRegistry _stakeRegistry
) EjectionManagerStorage(_registryCoordinator, _stakeRegistry) {
) EjectionManagerStorage(_slashingRegistryCoordinator, _stakeRegistry) {
_disableInitializers();
}

Expand Down Expand Up @@ -67,8 +65,8 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
stakeForEjection += operatorStake;
++ejectedOperators;

registryCoordinator.ejectOperator(
registryCoordinator.getOperatorFromId(operatorIds[i][j]),
slashingRegistryCoordinator.ejectOperator(
slashingRegistryCoordinator.getOperatorFromId(operatorIds[i][j]),
abi.encodePacked(quorumNumber)
);

Expand All @@ -80,8 +78,8 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
stakeForEjection += operatorStake;
++ejectedOperators;

registryCoordinator.ejectOperator(
registryCoordinator.getOperatorFromId(operatorIds[i][j]),
slashingRegistryCoordinator.ejectOperator(
slashingRegistryCoordinator.getOperatorFromId(operatorIds[i][j]),
abi.encodePacked(quorumNumber)
);

Expand Down
11 changes: 7 additions & 4 deletions src/EjectionManagerStorage.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
import {IEjectionManager} from "./interfaces/IEjectionManager.sol";

Expand All @@ -12,7 +12,7 @@ abstract contract EjectionManagerStorage is IEjectionManager {
uint8 internal constant MAX_QUORUM_COUNT = 192;

/// @inheritdoc IEjectionManager
IRegistryCoordinator public immutable registryCoordinator;
ISlashingRegistryCoordinator public immutable slashingRegistryCoordinator;
/// @inheritdoc IEjectionManager
IStakeRegistry public immutable stakeRegistry;

Expand All @@ -23,8 +23,11 @@ abstract contract EjectionManagerStorage is IEjectionManager {
/// @inheritdoc IEjectionManager
mapping(uint8 => QuorumEjectionParams) public quorumEjectionParams;

constructor(IRegistryCoordinator _registryCoordinator, IStakeRegistry _stakeRegistry) {
registryCoordinator = _registryCoordinator;
constructor(
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
IStakeRegistry _stakeRegistry
) {
slashingRegistryCoordinator = _slashingRegistryCoordinator;
stakeRegistry = _stakeRegistry;
}

Expand Down
Loading
Loading