Skip to content

Commit 848032a

Browse files
0xClandestineneutiyooypatil12stevennevinsafkbyte
authored
test: slashing release (#374)
Co-authored-by: Noel <[email protected]> Co-authored-by: Yash Patil <[email protected]> Co-authored-by: steven <[email protected]> Co-authored-by: afk <[email protected]> Co-authored-by: Gautham Anant <[email protected]> Co-authored-by: Michael Sun <[email protected]> Co-authored-by: Michael Sun <[email protected]> Co-authored-by: Nadir Akhtar <[email protected]> Co-authored-by: gpsanant <[email protected]> Co-authored-by: steven <[email protected]>
1 parent 4ee1c6f commit 848032a

File tree

64 files changed

+4540
-1483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4540
-1483
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Forge Test (Intense)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- mainnet
8+
- testnet-holesky
9+
- dev
10+
11+
env:
12+
FOUNDRY_PROFILE: ci
13+
RPC_MAINNET: ${{ secrets.RPC_MAINNET }}
14+
RPC_HOLESKY: ${{ secrets.RPC_HOLESKY }}
15+
CHAIN_ID: ${{ secrets.CHAIN_ID }}
16+
17+
jobs:
18+
# -----------------------------------------------------------------------
19+
# Forge Test (Intense)
20+
# -----------------------------------------------------------------------
21+
22+
forge-test-intense:
23+
name: Test (Intense)
24+
runs-on: ubuntu-latest
25+
steps:
26+
# Check out repository with all submodules for complete codebase access.
27+
- uses: actions/checkout@v4
28+
with:
29+
submodules: recursive
30+
31+
# Install the Foundry toolchain.
32+
- name: Install Foundry
33+
uses: foundry-rs/foundry-toolchain@v1
34+
with:
35+
version: stable
36+
37+
# Build the project and display contract sizes.
38+
- name: Forge Build
39+
run: |
40+
forge --version
41+
forge build --sizes
42+
id: build
43+
44+
# Run Forge Test (Intense)
45+
- name: Forge Test (Intense)
46+
run: |
47+
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
48+
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
49+
FOUNDRY_PROFILE=intense forge test -vvv

.github/workflows/foundry.yml

+10-58
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ on:
44
workflow_dispatch:
55
push:
66
branches:
7-
- master
87
- mainnet
9-
- testnet-goerli
8+
- testnet-holesky
109
- dev
1110
pull_request:
1211

@@ -24,101 +23,54 @@ jobs:
2423
test:
2524
name: Test
2625
runs-on: ubuntu-latest
27-
strategy:
28-
fail-fast: true
2926
steps:
3027
# Check out repository with all submodules for complete codebase access.
3128
- uses: actions/checkout@v4
3229
with:
3330
submodules: recursive
3431

3532
# Install the Foundry toolchain.
36-
- name: "Install Foundry"
33+
- name: Install Foundry
3734
uses: foundry-rs/foundry-toolchain@v1
3835
with:
3936
version: stable
4037

4138
# Run Forge's formatting checker to ensure consistent code style.
42-
- name: "Forge Fmt"
39+
- name: Forge Fmt
4340
run: |
4441
forge fmt --check
4542
id: fmt
4643

4744
# Build the project and display contract sizes.
48-
- name: "Forge Build"
45+
- name: Forge Build
4946
run: |
5047
forge --version
5148
forge build --sizes
5249
id: build
5350

5451
# Run local tests (unit and integration).
55-
- name: "Forge Test (Local)"
52+
- name: Forge Test (Local)
5653
run: forge test -vvv
5754

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

62-
# -----------------------------------------------------------------------
63-
# Forge Test (Intense)
64-
# -----------------------------------------------------------------------
65-
66-
continuous-fuzzing:
67-
name: Test (Intense)
68-
runs-on: ubuntu-latest
69-
strategy:
70-
fail-fast: true
71-
steps:
72-
# Check out repository with all submodules for complete codebase access.
73-
- uses: actions/checkout@v4
74-
with:
75-
submodules: recursive
76-
77-
# Install the Foundry toolchain.
78-
- name: "Install Foundry"
79-
uses: foundry-rs/foundry-toolchain@v1
80-
with:
81-
version: stable
82-
83-
# Build the project and display contract sizes.
84-
- name: "Forge Build"
85-
run: |
86-
forge --version
87-
forge build --sizes
88-
id: build
89-
90-
# Run Forge Test (Intense)
91-
- name: Forge Test (Intense)
92-
run: |
93-
echo -e "\033[1;33mWarning: This workflow may take several hours to complete.\033[0m"
94-
echo -e "\033[1;33mThis intense fuzzing workflow is optional but helps catch edge cases through extended testing.\033[0m"
95-
FOUNDRY_PROFILE=intense forge test -vvv
96-
9759
# -----------------------------------------------------------------------
9860
# Forge Coverage
9961
# -----------------------------------------------------------------------
10062

10163
run-coverage:
10264
name: Coverage
10365
runs-on: ubuntu-latest
104-
# Only run coverage checks on dev, testnet-holesky, and mainnet branches, or PRs targeting these branches
105-
if: |
106-
github.ref == 'refs/heads/dev' ||
107-
github.ref == 'refs/heads/testnet-holesky' ||
108-
github.ref == 'refs/heads/mainnet' ||
109-
github.base_ref == 'dev' ||
110-
github.base_ref == 'testnet-holesky' ||
111-
github.base_ref == 'mainnet'
112-
strategy:
113-
fail-fast: true
11466
steps:
11567
# Check out repository with all submodules for complete codebase access.
11668
- uses: actions/checkout@v4
11769
with:
11870
submodules: recursive
11971

12072
# Install the Foundry toolchain.
121-
- name: "Install Foundry"
73+
- name: Install Foundry
12274
uses: foundry-rs/foundry-toolchain@v1
12375
with:
12476
version: stable
@@ -130,7 +82,7 @@ jobs:
13082
id: lcov
13183

13284
# Build the project and display contract sizes.
133-
- name: "Forge Build"
85+
- name: Forge Build
13486
run: |
13587
forge --version
13688
forge build --sizes
@@ -150,7 +102,7 @@ jobs:
150102
path: report/*
151103

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

190142
# Install the Foundry toolchain.
191-
- name: "Install Foundry"
143+
- name: Install Foundry
192144
uses: foundry-rs/foundry-toolchain@v1
193145
with:
194146
version: stable

foundry.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616

1717
# Defines paths for Solidity imports.
1818
remappings = [
19-
"@openzeppelin/=lib/openzeppelin-contracts-v4.9.0/",
20-
"@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable-v4.9.0/",
19+
"forge-std/=lib/forge-std/src/",
2120
"ds-test/=lib/ds-test/src/",
22-
"forge-std/=lib/forge-std/src/"
21+
"@openzeppelin/=lib/openzeppelin-contracts/",
22+
"@openzeppelin-upgrades/=lib/openzeppelin-contracts-upgradeable/",
23+
"eigenlayer-contracts/=lib/eigenlayer-contracts/",
24+
2325
]
2426
# Specifies the exact version of Solidity to use, overriding auto-detection.
2527
solc_version = '0.8.27'

lib/eigenlayer-contracts

remappings.txt

-5
This file was deleted.

src/BLSApkRegistry.sol

+1-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
189189
quorumApkUpdatesLength == 0
190190
|| blockNumber < apkHistory[quorumNumber][0].updateBlockNumber
191191
) {
192-
revert(
193-
"BLSApkRegistry.getApkIndicesAtBlockNumber: blockNumber is before the first update"
194-
);
192+
revert BlockNumberBeforeFirstUpdate();
195193
}
196194

197195
// Loop backward through apkHistory until we find an entry that preceeds `blockNumber`

src/BLSSignatureChecker.sol

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.27;
33

4+
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
5+
46
import {BitmapUtils} from "./libraries/BitmapUtils.sol";
57
import {BN254} from "./libraries/BN254.sol";
68

@@ -18,7 +20,10 @@ contract BLSSignatureChecker is BLSSignatureCheckerStorage {
1820
/// MODIFIERS
1921

2022
modifier onlyCoordinatorOwner() {
21-
require(msg.sender == registryCoordinator.owner(), OnlyRegistryCoordinatorOwner());
23+
require(
24+
msg.sender == Ownable(address(registryCoordinator)).owner(),
25+
OnlyRegistryCoordinatorOwner()
26+
);
2227
_;
2328
}
2429

src/EjectionManager.sol

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl
55
import {
66
EjectionManagerStorage,
77
IEjectionManager,
8-
IRegistryCoordinator,
8+
ISlashingRegistryCoordinator,
99
IStakeRegistry
1010
} from "./EjectionManagerStorage.sol";
1111

12-
// TODO: double check order of inheritance since we separated storage from logic...
13-
1412
/**
15-
* @title Used for automated ejection of operators from the RegistryCoordinator under a ratelimit
13+
* @title Used for automated ejection of operators from the SlashingRegistryCoordinator under a ratelimit
1614
* @author Layr Labs, Inc.
1715
*/
1816
contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
1917
constructor(
20-
IRegistryCoordinator _registryCoordinator,
18+
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
2119
IStakeRegistry _stakeRegistry
22-
) EjectionManagerStorage(_registryCoordinator, _stakeRegistry) {
20+
) EjectionManagerStorage(_slashingRegistryCoordinator, _stakeRegistry) {
2321
_disableInitializers();
2422
}
2523

@@ -67,8 +65,8 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
6765
stakeForEjection += operatorStake;
6866
++ejectedOperators;
6967

70-
registryCoordinator.ejectOperator(
71-
registryCoordinator.getOperatorFromId(operatorIds[i][j]),
68+
slashingRegistryCoordinator.ejectOperator(
69+
slashingRegistryCoordinator.getOperatorFromId(operatorIds[i][j]),
7270
abi.encodePacked(quorumNumber)
7371
);
7472

@@ -80,8 +78,8 @@ contract EjectionManager is OwnableUpgradeable, EjectionManagerStorage {
8078
stakeForEjection += operatorStake;
8179
++ejectedOperators;
8280

83-
registryCoordinator.ejectOperator(
84-
registryCoordinator.getOperatorFromId(operatorIds[i][j]),
81+
slashingRegistryCoordinator.ejectOperator(
82+
slashingRegistryCoordinator.getOperatorFromId(operatorIds[i][j]),
8583
abi.encodePacked(quorumNumber)
8684
);
8785

src/EjectionManagerStorage.sol

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.27;
33

4-
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
4+
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
55
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
66
import {IEjectionManager} from "./interfaces/IEjectionManager.sol";
77

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

1414
/// @inheritdoc IEjectionManager
15-
IRegistryCoordinator public immutable registryCoordinator;
15+
ISlashingRegistryCoordinator public immutable slashingRegistryCoordinator;
1616
/// @inheritdoc IEjectionManager
1717
IStakeRegistry public immutable stakeRegistry;
1818

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

26-
constructor(IRegistryCoordinator _registryCoordinator, IStakeRegistry _stakeRegistry) {
27-
registryCoordinator = _registryCoordinator;
26+
constructor(
27+
ISlashingRegistryCoordinator _slashingRegistryCoordinator,
28+
IStakeRegistry _stakeRegistry
29+
) {
30+
slashingRegistryCoordinator = _slashingRegistryCoordinator;
2831
stakeRegistry = _stakeRegistry;
2932
}
3033

0 commit comments

Comments
 (0)