Skip to content

Commit 9a0c717

Browse files
daring5920stevennevins0x0aa0Gajesh2007samlaf
authored
Dev (#9)
* perf: refactor to modifers to use internal functions (Layr-Labs#272) * perf: refactor index registry to use internal functions for modifier (Layr-Labs#269) * fix: deprecated struct field for earning receiver * perf: move modifier logic to internal function * perf: refactor apk modifiers to use internal functions (Layr-Labs#268) * fix: deprecated struct field for earning receiver * perf: move modifier logic to internal function * perf: refactor modifiers to use internal functions for stake registry (Layr-Labs#266) * fix: deprecated struct field for earning receiver * refactor: require statements to internal functions * test: update revert reason strings * fix: storage layout (Layr-Labs#275) updated inheritance to allow the EigenDAServiceManager to maintain its current storage layout * feat: reward initiator for ECDSAServiceManagerBase (Layr-Labs#274) * feat: reward initiator for ECDSAServiceManagerBase * fix: update gap * feat: changes to onlyRewardsInitiator modifier * fix: error code * fix: comment typos in IServiceManagerUI (Layr-Labs#278) * fix: correct index get operator restakable strategies (Layr-Labs#280) * fix: add unit tests for ECDSAServiceManager and fix index in getOperatorRestakableStrategies * chore: formatter * chore: formatter * chore: update dev to eigenlayer contracts dev (Layr-Labs#282) * chore: update to latest eigenlayer-contracts dev * fix: update mocks * fix: increase gas limit * fix: overflow (Layr-Labs#290) * feat: mainnet rewards release tag (Layr-Labs#297) * build: update core submodule to new release (Layr-Labs#298) * build: update core submodule to new release * fix: flakey tests from pepe upgrade * add overrides (Layr-Labs#302) Co-authored-by: steven <[email protected]> * onchain socket (Layr-Labs#307) * feat: onchain socket moves sockets onchain to SM * feat: socket registry - move storage to new registry - leave event in RegCoord - trim bytecode from error strings * fix: internal function internal function to update socket * chore: bump dependency with core to v0.4.3-mainnet-rewards-programmatic-incentives (Layr-Labs#314) * chore: bump core dep * fix: intefface changes from dependency bump * test: vm.skip stale stake case * feat: ejection policy change (Layr-Labs#313) * feat: ejection stake capping * fix: behavior * feat: Rewards v2 (Layr-Labs#315) * chore: bump up eigenlayer contracts dependency * feat: createAVSPerformanceRewardsSubmission in AVSServiceManager * feat: setClaimerFor * feat: updated IServiceManager * fix: onlyOwner for setClaimerFor * refactor: commission to split terminology * test: not owner * test: erc20 not approved * test: single submission * test: multiple submissions * test: setClaimer * chore: updated events * chore: updated submodules * ejector fix (Layr-Labs#322) * fix: ejector * fix: ejector * fix: nit * fix: for real this time * test: fix * fix: ejector owner (Layr-Labs#326) * test: socket registry (Layr-Labs#327) * docs: fix typos and add note that large array may cause revert (Layr-Labs#323) --------- Co-authored-by: steven <[email protected]> Co-authored-by: quaq <[email protected]> Co-authored-by: Gajesh Naik <[email protected]> Co-authored-by: Samuel Laferriere <[email protected]> Co-authored-by: Madhur Shrimal <[email protected]> Co-authored-by: Michael Sun <[email protected]> Co-authored-by: Gautham Anant <[email protected]> Co-authored-by: Rajath Alex <[email protected]> Co-authored-by: Nadir Akhtar <[email protected]>
1 parent 88c320f commit 9a0c717

40 files changed

+2858
-951
lines changed

foundry.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ src = "src"
33
out = "out"
44
libs = ["lib"]
55
fs_permissions = [{ access = "read-write", path = "./" }]
6+
gas_limit = 5000000000
67

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

lib/eigenlayer-contracts

src/BLSApkRegistry.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
1212

1313
/// @notice when applied to a function, only allows the RegistryCoordinator to call it
1414
modifier onlyRegistryCoordinator() {
15-
require(
16-
msg.sender == address(registryCoordinator),
17-
"BLSApkRegistry.onlyRegistryCoordinator: caller is not the registry coordinator"
18-
);
15+
_checkRegistryCoordinator();
1916
_;
2017
}
2118

@@ -281,4 +278,11 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
281278
function getOperatorId(address operator) public view returns (bytes32) {
282279
return operatorToPubkeyHash[operator];
283280
}
281+
282+
function _checkRegistryCoordinator() internal view {
283+
require(
284+
msg.sender == address(registryCoordinator),
285+
"BLSApkRegistry.onlyRegistryCoordinator: caller is not the registry coordinator"
286+
);
287+
}
284288
}

src/EjectionManager.sol

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,45 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable{
7474
uint32 ejectedOperators;
7575

7676
bool ratelimitHit;
77-
for(uint8 j = 0; j < _operatorIds[i].length; ++j) {
78-
uint256 operatorStake = stakeRegistry.getCurrentStake(_operatorIds[i][j], quorumNumber);
79-
80-
//if caller is ejector enforce ratelimit
81-
if(
82-
isEjector[msg.sender] &&
83-
quorumEjectionParams[quorumNumber].rateLimitWindow > 0 &&
84-
stakeForEjection + operatorStake > amountEjectable
85-
){
86-
stakeEjectedForQuorum[quorumNumber].push(StakeEjection({
87-
timestamp: block.timestamp,
88-
stakeEjected: stakeForEjection
89-
}));
90-
ratelimitHit = true;
91-
break;
77+
if(amountEjectable > 0 || msg.sender == owner()){
78+
for(uint8 j = 0; j < _operatorIds[i].length; ++j) {
79+
uint256 operatorStake = stakeRegistry.getCurrentStake(_operatorIds[i][j], quorumNumber);
80+
81+
//if caller is ejector enforce ratelimit
82+
if(
83+
isEjector[msg.sender] &&
84+
quorumEjectionParams[quorumNumber].rateLimitWindow > 0 &&
85+
stakeForEjection + operatorStake > amountEjectable
86+
){
87+
ratelimitHit = true;
88+
89+
stakeForEjection += operatorStake;
90+
++ejectedOperators;
91+
92+
registryCoordinator.ejectOperator(
93+
registryCoordinator.getOperatorFromId(_operatorIds[i][j]),
94+
abi.encodePacked(quorumNumber)
95+
);
96+
97+
emit OperatorEjected(_operatorIds[i][j], quorumNumber);
98+
99+
break;
100+
}
101+
102+
stakeForEjection += operatorStake;
103+
++ejectedOperators;
104+
105+
registryCoordinator.ejectOperator(
106+
registryCoordinator.getOperatorFromId(_operatorIds[i][j]),
107+
abi.encodePacked(quorumNumber)
108+
);
109+
110+
emit OperatorEjected(_operatorIds[i][j], quorumNumber);
92111
}
93-
94-
stakeForEjection += operatorStake;
95-
++ejectedOperators;
96-
97-
registryCoordinator.ejectOperator(
98-
registryCoordinator.getOperatorFromId(_operatorIds[i][j]),
99-
abi.encodePacked(quorumNumber)
100-
);
101-
102-
emit OperatorEjected(_operatorIds[i][j], quorumNumber);
103112
}
104113

105114
//record the stake ejected if ejector and ratelimit enforced
106-
if(!ratelimitHit && isEjector[msg.sender]){
115+
if(isEjector[msg.sender] && stakeForEjection > 0){
107116
stakeEjectedForQuorum[quorumNumber].push(StakeEjection({
108117
timestamp: block.timestamp,
109118
stakeEjected: stakeForEjection
@@ -150,7 +159,7 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable{
150159
*/
151160
function amountEjectableForQuorum(uint8 _quorumNumber) public view returns (uint256) {
152161
uint256 cutoffTime = block.timestamp - quorumEjectionParams[_quorumNumber].rateLimitWindow;
153-
uint256 totalEjectable = quorumEjectionParams[_quorumNumber].ejectableStakePercent * stakeRegistry.getCurrentTotalStake(_quorumNumber) / BIPS_DENOMINATOR;
162+
uint256 totalEjectable = uint256(quorumEjectionParams[_quorumNumber].ejectableStakePercent) * uint256(stakeRegistry.getCurrentTotalStake(_quorumNumber)) / uint256(BIPS_DENOMINATOR);
154163
uint256 totalEjected;
155164
uint256 i;
156165
if (stakeEjectedForQuorum[_quorumNumber].length == 0) {
@@ -172,4 +181,4 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable{
172181
}
173182
return totalEjectable - totalEjected;
174183
}
175-
}
184+
}

src/IndexRegistry.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ contract IndexRegistry is IndexRegistryStorage {
1212

1313
/// @notice when applied to a function, only allows the RegistryCoordinator to call it
1414
modifier onlyRegistryCoordinator() {
15-
require(msg.sender == address(registryCoordinator), "IndexRegistry.onlyRegistryCoordinator: caller is not the registry coordinator");
15+
_checkRegistryCoordinator();
1616
_;
1717
}
1818

@@ -340,4 +340,8 @@ contract IndexRegistry is IndexRegistryStorage {
340340
function totalOperatorsForQuorum(uint8 quorumNumber) external view returns (uint32){
341341
return _latestQuorumUpdate(quorumNumber).numOperators;
342342
}
343+
344+
function _checkRegistryCoordinator() internal view {
345+
require(msg.sender == address(registryCoordinator), "IndexRegistry.onlyRegistryCoordinator: caller is not the registry coordinator");
346+
}
343347
}

0 commit comments

Comments
 (0)