Skip to content

Commit 524d463

Browse files
0xrajathypatil12
authored andcommitted
fix: rewards v2 audit fixes (#987)
* fix: default operator split during first initialization * test: updated split tests feat: slashing release fix(slashing): upgrade script part 4 (#953) fix: patch (#956) feat: bindings (#960) fix: remove numtocomplete interface (#966) feat: add share helpers (#964) * feat: add share helpers * fix: add deposit scaling factor * fix: rebase fix: slashable window boundaries (#965) * fix: slashable window boundaries * test: regression for alm * test: update withdrawal delay not passed reversion * test: burning indices * refactor: switch conditionals * fix: added unit tests * test: assert slashable shares in queue * fix: typos --------- Co-authored-by: Yash Patil <[email protected]> refactor: small cleanup (#959) refactor small cleanup chore: `forge fmt` fix: `getQueuedWithdrawals` + test fix: add constructor back test: `totalQueued` > `withdrawal.strategies.length` test(wip): `completeQueuedWithdrawals` currently failing fix: effectBlock test(wip): @8sunyuan patch fix: one flaky test fix: second flaky test refactor: remove max strats list (#968) feat: slashing patch upgrade script (#967) * feat: initial deploy * feat: slashing patch fix non-present upgrade.json chore: bindings (#969) fix: try catch out of gas edge case (#971) chore: slashing consolidated script (#972) test: more slashing integration todos (#961) * test(wip): todos * fix: dealloc issue * fix: remaining * fix: forktest upgrade issue * test: add `check_Withdrawal_AsShares_State_AfterSlash` * refactor: cleanup * fix: ci * refactor: review changes docs: wip slashing docs (#925) * docs: add slashing docs * chore: bindings * docs: fixed commenting and updated queue withdrawal docs * docs: minor cleanup --------- Co-authored-by: Nadir Akhtar <[email protected]> refactor: scaled shares accounting (#975) * fix: correct expected share calc * chore: bindings * fix: rounding on failing unit test refactor: final slashing cleanup (#982) * chore: clean comments and naming in dm * refactor: simplify undelegate method * feat: removed 0 address check because 0 stakers cant be delegated * feat: condensed non-staker caller logic * refactor: remove unnecessary check * feat: use checks-effects-interactions when completing withdrawals * feat: remove implicit public method for queuedWithdrawals and impl dedicated getter * feat: deprecate withdrawer field * chore: make bindings and clean compile errors * refactor: redelegate reuses delegateTo and undelegate * fix: broken integration test * docs: update to reflect deprecated field * feat: add getter for stakers withdrawal roots chore: remove unused avsd events (#984) fix: integration test initialization params (#978) * fix: initialization params * fix: roll blocks usage fix: `SignatureUtils` construction (#990) * fix: integration test initialization params (#978) * fix: initialization params * fix: roll blocks usage * fix: `SignatureUtils` construction --------- Co-authored-by: Yash Patil <[email protected]> Co-authored-by: davidironblocks <[email protected]> fix: readd manual checks (#996) * fix: readd manual checks * chore: forge fmt feat: slashing 1.0.3 upgrade script (#995) * feat: add step 1 * feat: step 1 & 2 complete; pending step 3 sanity * test: add `_validateProxyDomainSeparators` * feat: add rc validation --------- Co-authored-by: clandestine.eth <[email protected]> fix: update alloc config delay bound (#985) * fix: update alloc delay bound * test: remove unnecessary roll chore: storage report (#1000) docs: shares accounting (#997) * docs: shares accounting * docs: fix gh markdown view * docs: try fix gh again * docs: cleanup * docs: edit share accounting * docs: wrap up share accounting doc * docs: edit edge cases --------- Co-authored-by: wadealexc <[email protected]> refactor: async burning (#1001) * refactor: burning * chore: fmt * chore: update storage report * chore: update readme * refactor: add burnableShares for epm storage * chore: update storage report test: `Snapshots` lib (#1002) docs: finish delegation manager docs (#1004) * docs: finish delegation manager docs * docs: update docs readme * docs: permission controller * fix: small typos * docs: address feedback * docs: nit --------- Co-authored-by: Michael Sun <[email protected]> docs: Strategy Manager slashing updates (#999) * docs: update StrategyManager docs with slashing delta * docs: remove references to thirdPartyTransfersForbidden * docs: update strategy docs to latest * also various edits to docs and natspec * chore: fmt and make bindings --------- Co-authored-by: wadealexc <[email protected]> docs: EigenPod Manager slashing updates (#1005) * docs: complete EigenPodManager for slashing * docs: add in _beaconChainSlashingFactor state variable note * docs: finish epm docs * chore: make bindings --------- Co-authored-by: wadealexc <[email protected]> fix: rebase fix: binding test: remove unneeded logic from integration test setup (#1023) fix: compile
1 parent 263f843 commit 524d463

File tree

5 files changed

+109
-207
lines changed

5 files changed

+109
-207
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
14831483
for (uint i = 0; i < strategies.length; i++) {
14841484
assertEq(prevShares[i], curShares[i], err);
14851485
}
1486-
<<<<<<< HEAD
14871486
}
14881487

14891488
/// @dev Check that the staker's withdrawable shares have increased by `addedShares`
@@ -1504,28 +1503,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
15041503
}
15051504

15061505
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
1507-
=======
1508-
}
1509-
1510-
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
1511-
function assert_Snap_Added_Staker_WithdrawableShares(
1512-
User staker,
1513-
IStrategy[] memory strategies,
1514-
uint[] memory addedShares,
1515-
string memory err
1516-
) internal {
1517-
uint[] memory curShares = _getStakerWithdrawableShares(staker, strategies);
1518-
// Use timewarp to get previous staker shares
1519-
uint[] memory prevShares = _getPrevStakerWithdrawableShares(staker, strategies);
1520-
1521-
// For each strategy, check (prev - removed == cur)
1522-
for (uint i = 0; i < strategies.length; i++) {
1523-
assertEq(prevShares[i] + addedShares[i], curShares[i], err);
1524-
}
1525-
}
1526-
1527-
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
1528-
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
15291506
function assert_Snap_Removed_Staker_WithdrawableShares(
15301507
User staker,
15311508
IStrategy[] memory strategies,
@@ -1542,7 +1519,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
15421519
}
15431520
}
15441521

1545-
<<<<<<< HEAD
15461522
/// @dev Check that all the staker's withdrawable shares have been removed
15471523
function assert_Snap_RemovedAll_Staker_WithdrawableShares(
15481524
User staker,
@@ -1568,19 +1544,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
15681544
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
15691545
/// FIX THIS WHEN WORKING ON ROUNDING ISSUES
15701546
function assert_Snap_Unchanged_Staker_WithdrawableShares_Delegation(
1571-
=======
1572-
function assert_Snap_Removed_Staker_WithdrawableShares(
1573-
User staker,
1574-
IStrategy strat,
1575-
uint removedShares,
1576-
string memory err
1577-
) internal {
1578-
assert_Snap_Removed_Staker_WithdrawableShares(staker, strat.toArray(), removedShares.toArrayU256(), err);
1579-
}
1580-
1581-
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
1582-
function assert_Snap_Unchanged_Staker_WithdrawableShares(
1583-
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
15841547
User staker,
15851548
string memory err
15861549
) internal {
@@ -1592,11 +1555,7 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
15921555

15931556
// For each strategy, check (prev - removed == cur)
15941557
for (uint i = 0; i < strategies.length; i++) {
1595-
<<<<<<< HEAD
15961558
assertApproxEqAbs(prevShares[i], curShares[i], 100000, err);
1597-
=======
1598-
assertEq(prevShares[i], curShares[i], err);
1599-
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
16001559
}
16011560
}
16021561

src/test/integration/IntegrationChecks.t.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ contract IntegrationCheckUtils is IntegrationBase {
249249
"check_Undelegate_State: staker should have increased nonce by withdrawals.length");
250250
assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares,
251251
"check_Undelegate_State: failed to remove operator shares");
252-
<<<<<<< HEAD
253252
assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares,
254253
"check_Undelegate_State: failed to remove staker shares");
255254
assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies,
@@ -283,11 +282,6 @@ contract IntegrationCheckUtils is IntegrationBase {
283282
assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares,
284283
"check_Redelegate_State: failed to remove staker shares");
285284
assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies,
286-
=======
287-
assert_Snap_Removed_Staker_DepositShares(staker, strategies, shares,
288-
"check_Undelegate_State: failed to remove staker shares");
289-
assert_Snap_Removed_Staker_WithdrawableShares(staker, strategies, shares,
290-
>>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036))
291285
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares");
292286
}
293287

@@ -993,4 +987,4 @@ contract IntegrationCheckUtils is IntegrationBase {
993987
}
994988
}
995989
}
996-
}
990+
}

src/test/integration/IntegrationDeployer.t.sol

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
4040
bool isUpgraded;
4141
uint mainnetForkBlock = 21_616_692; // Post Protocol Council upgrade
4242

43+
string version = "v9.9.9";
44+
4345
// Beacon chain genesis time when running locally
4446
// Multiple of 12 for sanity's sake
4547
uint64 constant GENESIS_TIME_LOCAL = 1 hours * 12;
@@ -160,10 +162,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
160162
}
161163

162164
/// Deploy EigenLayer locally
163-
function _setUpLocal() public virtual {
165+
function _setUpLocal() public noTracing virtual {
164166
console.log("Setting up `%s` integration tests:", "LOCAL".yellow().bold());
165-
// Bypass upgrade tests when running locally
166-
isUpgraded = true;
167167

168168
// Deploy ProxyAdmin
169169
eigenLayerProxyAdmin = new ProxyAdmin();
@@ -204,6 +204,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
204204
ethStrats.push(BEACONCHAIN_ETH_STRAT);
205205
allStrats.push(BEACONCHAIN_ETH_STRAT);
206206
allTokens.push(NATIVE_ETH);
207+
maxUniqueAssetsHeld = allStrats.length;
207208

208209
// Create time machine and beacon chain. Set block time to beacon chain genesis time
209210
BEACON_GENESIS_TIME = GENESIS_TIME_LOCAL;
@@ -213,7 +214,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
213214
}
214215

215216
/// Parse existing contracts from mainnet
216-
function _setUpMainnet() public virtual {
217+
function _setUpMainnet() public noTracing virtual {
217218
console.log("Setting up `%s` integration tests:", "MAINNET_FORK".green().bold());
218219
console.log("RPC:", cheats.rpcUrl("mainnet"));
219220
console.log("Block:", mainnetForkBlock);
@@ -239,13 +240,20 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
239240
allTokens.push(strategy.underlyingToken());
240241
}
241242

243+
maxUniqueAssetsHeld = allStrats.length;
244+
242245
// Create time machine and mock beacon chain
243246
BEACON_GENESIS_TIME = GENESIS_TIME_MAINNET;
244247
timeMachine = new TimeMachine();
245248
beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME);
249+
250+
// Since we haven't done the slashing upgrade on mainnet yet, upgrade mainnet contracts
251+
// prior to test. `isUpgraded` is true by default, but is set to false in `UpgradeTest.t.sol`
252+
if (isUpgraded) {
253+
_upgradeMainnetContracts();
254+
}
246255
}
247256

248-
/// Deploy current implementation contracts and upgrade existing proxies
249257
function _upgradeMainnetContracts() public virtual {
250258
cheats.startPrank(address(executorMultisig));
251259

@@ -277,6 +285,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
277285
ethStrats.push(BEACONCHAIN_ETH_STRAT);
278286
allStrats.push(BEACONCHAIN_ETH_STRAT);
279287
allTokens.push(NATIVE_ETH);
288+
maxUniqueAssetsHeld = allStrats.length;
280289
}
281290

282291
function _deployProxies() public {
@@ -310,10 +319,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
310319

311320
/// Deploy an implementation contract for each contract in the system
312321
function _deployImplementations() public {
313-
allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
314-
permissionControllerImplementation = new PermissionController();
315-
delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS);
316-
strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg);
322+
allocationManagerImplementation = new AllocationManager(
323+
delegationManager,
324+
eigenLayerPauserReg,
325+
permissionController,
326+
DEALLOCATION_DELAY,
327+
ALLOCATION_CONFIGURATION_DELAY,
328+
version
329+
);
330+
permissionControllerImplementation = new PermissionController(version);
331+
delegationManagerImplementation = new DelegationManager(
332+
strategyManager,
333+
eigenPodManager,
334+
allocationManager,
335+
eigenLayerPauserReg,
336+
permissionController,
337+
DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS,
338+
version
339+
);
340+
strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg, version);
317341
rewardsCoordinatorImplementation = new RewardsCoordinator(
318342
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({
319343
delegationManager: delegationManager,
@@ -337,17 +361,17 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
337361
eigenLayerPauserReg,
338362
"v9.9.9"
339363
);
340-
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg);
364+
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg, "v9.9.9");
341365

342366
// Beacon implementations
343-
eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME);
344-
baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg);
367+
eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME, "v9.9.9");
368+
baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg, "v9.9.9");
345369

346370
// Pre-longtail StrategyBaseTVLLimits implementation
347371
// TODO - need to update ExistingDeploymentParser
348372
}
349373

350-
function _upgradeProxies() public {
374+
function _upgradeProxies() public noTracing {
351375
// DelegationManager
352376
eigenLayerProxyAdmin.upgrade(
353377
ITransparentUpgradeableProxy(payable(address(delegationManager))),
@@ -412,7 +436,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
412436
}
413437
}
414438

415-
function _initializeProxies() public {
439+
function _initializeProxies() public noTracing {
416440
delegationManager.initialize({
417441
initialOwner: executorMultisig,
418442
initialPausedStatus: 0
@@ -486,7 +510,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
486510
allTokens.push(underlyingToken);
487511
}
488512

489-
function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private {
513+
function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private noTracing {
490514
// Using uint24 for the seed type so that if a test fails, it's easier
491515
// to manually use the seed to replay the same test.
492516
random = _hash(_randomSeed);
@@ -496,6 +520,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
496520
_configUserTypes(_userTypes);
497521
}
498522

523+
function _configAssetTypes(uint _assetTypes) internal {
524+
assetTypes = _bitmapToBytes(_assetTypes);
525+
assertTrue(assetTypes.length != 0, "_configRand: no asset types selected");
526+
}
527+
528+
function _configAssetAmounts(uint _maxUniqueAssetsHeld) internal {
529+
if (_maxUniqueAssetsHeld > allStrats.length) {
530+
_maxUniqueAssetsHeld = allStrats.length;
531+
}
532+
533+
maxUniqueAssetsHeld = _maxUniqueAssetsHeld;
534+
require(maxUniqueAssetsHeld != 0, "_configAssetAmounts: invalid 0");
535+
}
536+
537+
function _configUserTypes(uint _userTypes) internal {
538+
userTypes = _bitmapToBytes(_userTypes);
539+
assertTrue(userTypes.length != 0, "_configRand: no user types selected");
540+
}
541+
499542
/**
500543
* @dev Create a new User with a random config using the range defined in `_configRand`
501544
*
@@ -795,4 +838,4 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser {
795838
) internal pure returns (bytes32) {
796839
return keccak256(abi.encodePacked(x));
797840
}
798-
}
841+
}

0 commit comments

Comments
 (0)