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

[DO NOT MERGE] Slashing Release Branch Internal Security Review #331

Draft
wants to merge 65 commits into
base: mainnet
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c29cf07
feat: automated ejector (#146)
0x0aa0 Apr 11, 2024
f224cf9
chore: bump forge-std and remove ds-test dependency (#227)
stevennevins Apr 13, 2024
6454c05
feat: allowlist mapping (#226)
0x0aa0 Apr 15, 2024
0328639
feat: return ops ejected (#228)
0x0aa0 Apr 16, 2024
59ebd32
Use uint32 for number of ejected operators (#232)
jianoaix Apr 17, 2024
e18c19e
feat: service manager payments (#242)
8sunyuan Apr 23, 2024
2b65511
fix: spacing (#244)
8sunyuan Apr 24, 2024
deebd4b
chore: rename audit report for clarity and consistency with core (#245)
wadealexc Apr 25, 2024
1feb6ae
feat: batch operator id conversions (#248)
0x0aa0 Apr 29, 2024
1703d25
fix: vm assume too many rejections (#247)
stevennevins Apr 29, 2024
74c86d2
feat: reregistration delay (#246)
0x0aa0 Apr 30, 2024
9968b1d
feat: ecdsa service manager (#234)
stevennevins May 1, 2024
8ed82a4
fix: add init function for staleStakesForbidden in BLSSignatureChecke…
stevennevins May 6, 2024
4ad5c85
feat: update core contracts submodule (#254)
8sunyuan May 7, 2024
c5b419a
fix: multiple rangepayments with same token (#257)
8sunyuan May 8, 2024
a23de11
test: fix flaky fuzz tests hitting the default operator who is alread…
stevennevins May 14, 2024
0351419
chore: update license (#259)
ChaoticWalrus May 21, 2024
afbcba8
feat: ecdsa key rotation (#252)
stevennevins May 23, 2024
1142437
fix: storage gap (#261)
stevennevins May 24, 2024
a7b1851
feat: `paymentInitiator` role in `ServiceManagerBase` (#260)
diyahir May 28, 2024
51e36f1
chore: refactor with RewardsCoordinator (#262)
8sunyuan May 30, 2024
c75eb8e
chore: rewards release submodule (#264)
8sunyuan Jun 5, 2024
b45dced
fix: deprecated struct field for earning receiver (#265)
stevennevins Jun 6, 2024
da5cf42
perf: refactor to modifers to use internal functions (#272)
stevennevins Jun 14, 2024
9f92f72
perf: refactor index registry to use internal functions for modifier …
stevennevins Jun 14, 2024
b1f706b
perf: refactor apk modifiers to use internal functions (#268)
stevennevins Jun 14, 2024
89cbd3c
perf: refactor modifiers to use internal functions for stake registry…
stevennevins Jun 14, 2024
dc5385e
fix: storage layout (#275)
0x0aa0 Jun 20, 2024
b816138
feat: reward initiator for ECDSAServiceManagerBase (#274)
Gajesh2007 Jun 22, 2024
d643f3b
fix: comment typos in IServiceManagerUI (#278)
samlaf Jun 25, 2024
c00aad7
fix: correct index get operator restakable strategies (#280)
stevennevins Jul 1, 2024
3b96caf
chore: update dev to eigenlayer contracts dev (#282)
shrimalmadhur Jul 10, 2024
163f4c3
chore: upgrade core to target operator set release
stevennevins Jul 25, 2024
17b1f44
fix: overflow (#290)
0x0aa0 Jul 26, 2024
ad64a45
Merge branch 'dev' into feat/operate-set-release-branch
stevennevins Aug 2, 2024
b7f4903
chore: update mock contracts with latest interfaces (#293)
shrimalmadhur Aug 5, 2024
d991827
chore: bump to latest operator set release commits
stevennevins Aug 8, 2024
4966813
chore: fixes for depedency bump
stevennevins Aug 8, 2024
4fabf80
feat: operator set migration-1-migration (#286)
stevennevins Aug 12, 2024
fe93ac6
feat: operator set migration-2-create quorum (#287)
stevennevins Aug 12, 2024
a9c1aa7
feat: mainnet rewards release tag (#297)
8sunyuan Aug 13, 2024
e5b2688
chore: bump operator set release dependency in core
stevennevins Aug 15, 2024
ec2fdf3
chore: updates from dependency bump
stevennevins Aug 15, 2024
12eda5d
feat: add natspec
stevennevins Aug 15, 2024
788cd09
docs: add natspec
stevennevins Aug 15, 2024
d64f4af
feat: add checks operator was registered for quorums when migrating
stevennevins Aug 15, 2024
a92d51a
fix: resolve code size issue in RegistryCoordinator
stevennevins Aug 15, 2024
74438b7
build: update core submodule to new release (#298)
8sunyuan Aug 15, 2024
32148de
chore: update to latest core (#299)
shrimalmadhur Aug 15, 2024
cb2b334
add overrides (#302)
gpsanant Aug 20, 2024
86f0928
feat(op sets): update stakes when forceUnregister (#300)
stevennevins Aug 21, 2024
3e4cb2b
merge dev
stevennevins Aug 21, 2024
f6ad20e
feat(op sets): register and deregister (#301)
stevennevins Aug 22, 2024
e0a79f1
feat(op sets): upgrade and migrate script (#303)
stevennevins Aug 22, 2024
eb0d6ad
chore: bump slashing core dependency (#312)
stevennevins Oct 17, 2024
cb4df12
feat: slasher templates / examples (#310)
stevennevins Nov 1, 2024
145bdaf
chore: remove unused test util contracts (#319)
stevennevins Nov 18, 2024
9a975df
feat: remove both option
stevennevins Nov 8, 2024
fa04f06
fix: storage gap remove one slot (#320)
stevennevins Nov 20, 2024
388e9f9
feat: track total slashable stake and total delegated stake per quoru…
stevennevins Nov 20, 2024
158a890
fix: use libraries with only internal vis (#324)
stevennevins Dec 4, 2024
817ad42
feat: avs registrar registration flow changes (#318)
stevennevins Dec 5, 2024
dbd59dd
feat: registration changes part 2
stevennevins Dec 9, 2024
6fd466e
chore: bump dependency for slashing mags updates (#329)
stevennevins Dec 10, 2024
f9ce2fc
Merge branch 'mainnet' into feat/slashing-release-branch
nadir-akhtar Dec 11, 2024
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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
path = lib/eigenlayer-contracts
url = https://github.com/Layr-labs/eigenlayer-contracts
branch = dev
[submodule "lib/ds-test"]
path = lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ EigenLayer AVSs ("actively validated services") are protocols that make use of E
**Currently, each AVS needs to implement one thing on-chain:** registration/deregistration conditions that define how an Operator registers for/deregisters from the AVS. This repo provides building blocks to support these functions.

*Eventually,* the core contracts and this repo will be extended to cover other conditions, including:
* payment conditions that define how an Operator is paid for the services it provides
* reward conditions that define how an Operator is rewarded for the services it provides
* slashing conditions that define "malicious behavior" in the context of the AVS, and the punishments for this behavior

*... however, the design for these conditions is still in progress.*
Expand Down Expand Up @@ -102,7 +102,7 @@ The main thing that links an AVS to the EigenLayer core contracts is that when E

These methods ensure that the Operator registering with the AVS is also registered as an Operator in EigenLayer core. In this repo, these methods are called by the `ServiceManagerBase`.

Eventually, Operator slashing and payment for services will be part of the middleware/core relationship, but these features aren't implemented yet and their design is a work in progress.
Eventually, Operator slashing and rewards for services will be part of the middleware/core relationship, but these features aren't implemented yet and their design is a work in progress.

### System Components

Expand Down
2 changes: 1 addition & 1 deletion docs/ServiceManagerBase.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
The `ServiceManagerBase` represents the AVS's address relative to EigenLayer core. When registering or deregistering an operator from an AVS, the AVS's `ServiceManagerBase` communicates this change to the core contracts, allowing the core contracts to maintain an up-to-date view on operator registration status with various AVSs.

*As of M2*:
* Currently, this contract is used by the `AVSDirectory` to keep track of operator registration and deregistration. Eventually, this relationship will be expanded to allow operators to opt in to slashing and payments for services.
* Currently, this contract is used by the `AVSDirectory` to keep track of operator registration and deregistration. Eventually, this relationship will be expanded to allow operators to opt in to slashing and rewards for services.

---

Expand Down
2 changes: 1 addition & 1 deletion docs/experimental/AVS-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document aims to describe and summarize how actively validated services (AV
- enabling operators to continuously update their commitments to middlewares, and
- enabling AVS to freeze operators for the purpose of slashing (the corresponding unfreeze actions are determined by the veto committee).

We are currently in the process of implementing the API for payment flow from AVSs to operators in EigenLayer. Details of this API will be added to this document in the near future.
We are currently in the process of implementing the API for rewards flow from AVSs to operators in EigenLayer. Details of this API will be added to this document in the near future.

The following figure summarizes scope of this document:
![Doc Outline](../images/middleware_outline_doc.png)
Expand Down
11 changes: 7 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read-write", path = "./" }]
gas_limit = 5000000000

ffi = true
no-match-contract = "FFI"

# Enables or disables the optimizer
optimizer = true
# The number of optimizer runs
optimizer_runs = 200
optimizer = false
# Whether or not to use the Yul intermediate representation compilation pipeline
via_ir = false
# Override the Solidity version (this overrides `auto_detect_solc`)
solc_version = '0.8.12'
solc_version = '0.8.27'

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
holesky = { key = "${ETHERSCAN_API_KEY}" }

[fmt]
bracket_spacing = false
Expand Down
1 change: 0 additions & 1 deletion lib/ds-test
Submodule ds-test deleted from e28215
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
40 changes: 40 additions & 0 deletions script/utils/UpgradeLib.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Deploy L2AVS proxy

import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

import {Vm} from "forge-std/Vm.sol";
import {stdJson} from "forge-std/StdJson.sol";

library OperatorSetUpgradeLib {
using stdJson for string;
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
bytes32 internal constant IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;


function upgrade(address proxy, address implementation, bytes memory data) internal {
ProxyAdmin admin = ProxyAdmin(getAdmin(proxy));
admin.upgradeAndCall(TransparentUpgradeableProxy(payable(proxy)), implementation, data);
}

function upgrade(address proxy, address implementation) internal {
ProxyAdmin admin = ProxyAdmin(getAdmin(proxy));
admin.upgrade(TransparentUpgradeableProxy(payable(proxy)), implementation);
}

function getAdmin(address proxy) internal view returns (address){
bytes32 value = vm.load(proxy, ADMIN_SLOT);
return address(uint160(uint256(value)));
}

function getImplementation(address proxy) internal view returns (address) {
bytes32 value = vm.load(proxy, IMPLEMENTATION_SLOT);
return address(uint160(uint256(value)));
}
}
23 changes: 23 additions & 0 deletions script/utils/testdata/17000/core_testdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"addresses":{
"avsDirectory": "0x141d6995556135D4997b2ff72EB443Be300353bC",
"avsDirectoryImplementation": "0x357978adC03375BD6a3605DE055fABb84695d79A",
"baseStrategyImplementation": "0x62450517EfA1CE60d79801daf8f95973865e8D40",
"beaconOracle": "0x4C116BB629bff7A8373c2378bBd919f8349B8f25",
"delayedWithdrawalRouter": "0xC4BC46a87A67a531eCF7f74338E1FA79533334Fa",
"delayedWithdrawalRouterImplementation": "0x0011FA2c512063C495f77296Af8d195F33A8Dd38",
"delegationManager": "0x75dfE5B44C2E530568001400D3f704bC8AE350CC",
"delegationManagerImplementation": "0x56E88cb4f0136fC27D95499dE4BE2acf47946Fa1",
"eigenLayerPauserReg": "0x9Ab2FEAf0465f0eD51Fc2b663eF228B418c9Dad1",
"eigenLayerProxyAdmin": "0x1BEF05C7303d44e0E2FCD2A19d993eDEd4c51b5B",
"eigenPodBeacon": "0x92Cc4a800A1513E85C481dDDf3A06C6921211eaC",
"eigenPodImplementation": "0x2D6c7f9862BD80Cf0d9d93FC6b513D69E7Db7869",
"eigenPodManager": "0xB8d8952f572e67B11e43bC21250967772fa883Ff",
"eigenPodManagerImplementation": "0xc5B857A92245f64e9D90cCc5b096Db82eB77eB5c",
"emptyContract": "0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2",
"rewardsCoordinator": "0xb22Ef643e1E067c994019A4C19e403253C05c2B0",
"rewardsCoordinatorImplementation": "0x76d4D84c90a2AFf213F7D859d2a288685A1a2Ede",
"slasher": "0x12699471dF8dca329C76D72823B1b79d55709384",
"slasherImplementation": "0x9460fCe11E1e0365419fa860599903B4E5097cf0"
}
}
18 changes: 18 additions & 0 deletions script/utils/testdata/17000/middlware_testdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"addresses":{
"blsApkRegistry": "0xAd7f9e558170a149Ca8E90f41Ab2444A5d3bd6aD",
"blsApkRegistryImplementation": "0x482a96D5879e32347d8df125f038D7eC8Ab358dd",
"eigenDAProxyAdmin": "0x9Fd7E279f5bD692Dc04792151E14Ad814FC60eC1",
"eigenDAServiceManager": "0x54A03db2784E3D0aCC08344D05385d0b62d4F432",
"eigenDAServiceManagerImplementation": "0xEB11a0f320E39d3371Fec4Bf5C76944DfBA8ee10",
"indexRegistry": "0x8cE5F2a53cBd29710eb94A04e40C07A4DdF15d10",
"indexRegistryImplementation": "0x1D4d6054BD11A5711ad7c5d3E376C987a603e17C",
"mockRollup": "0x0433646AdCeE95fbF89b3BFDb8157e75c19b6C2e",
"operatorStateRetriever": "0x17cA8C41a59466710443143b2ECF08CaA35d80ad",
"registryCoordinator": "0x2c61EA360D6500b58E7f481541A36B443Bc858c6",
"registryCoordinatorImplementation": "0x6f21A84E7f185cCBA248B436e3b583E609d1dE1D",
"serviceManagerRouter": "0xDb028E067fe81e9f406C2DE382Ba82e9cD7cBD03",
"stakeRegistry": "0x53668EBf2e28180e38B122c641BC51Ca81088871",
"stakeRegistryImplementation": "0x854dc9e5d011B060bf77B1a492302C349f2f00b5"
}
}
21 changes: 21 additions & 0 deletions src/AVSRegistrar.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;

import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol";

abstract contract AVSRegistrar is IAVSRegistrar {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we instantiate this abstract contract even though it adds no new functions and implements none either

function registerOperator(
address operator,
uint32[] calldata operatorSetIds,
bytes calldata data
) external virtual;

function deregisterOperator(
address operator,
uint32[] calldata operatorSetIds
) external virtual;
}
12 changes: 8 additions & 4 deletions src/BLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {

/// @notice when applied to a function, only allows the RegistryCoordinator to call it
modifier onlyRegistryCoordinator() {
require(
msg.sender == address(registryCoordinator),
"BLSApkRegistry.onlyRegistryCoordinator: caller is not the registry coordinator"
);
_checkRegistryCoordinator();
_;
}

Expand Down Expand Up @@ -281,4 +278,11 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
function getOperatorId(address operator) public view returns (bytes32) {
return operatorToPubkeyHash[operator];
}

function _checkRegistryCoordinator() internal view {
require(
msg.sender == address(registryCoordinator),
"BLSApkRegistry.onlyRegistryCoordinator: caller is not the registry coordinator"
);
}
}
Loading
Loading