@@ -5,41 +5,23 @@ import "src/test/integration/IntegrationChecks.t.sol";
55import "src/test/integration/users/User.t.sol " ;
66import {console} from "forge-std/console.sol " ;
77
8- contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is IntegrationCheckUtils {
8+ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is IntegrationCheckUtils , IDelegationManagerTypes {
99
10- AVS avs;
11- OperatorSet operatorSet;
12-
13- User operator;
14- AllocateParams allocateParams;
15-
16- User staker;
17- IStrategy[] strategies;
18- uint [] initTokenBalances;
19- uint [] initDepositShares;
20-
21- uint [] numTokensRemaining;
22-
23- function _init () internal override {
24- // TODO: Partial deposits don't work when beacon chain eth balance is initialized to < 64 ETH, need to write _newRandomStaker variant that ensures beacon chain ETH balance
25- // greater than or equal to 64
26- _configAssetTypes (HOLDS_LST);
27- _configUserTypes (DEFAULT);
28-
29- (staker, strategies, initTokenBalances) = _newRandomStaker ();
30- (operator,,) = _newRandomOperator ();
31- (avs,) = _newRandomAVS ();
32-
33- uint256 [] memory tokensToDeposit = new uint256 [](initTokenBalances.length );
34- numTokensRemaining = new uint256 [](initTokenBalances.length );
35- for (uint256 i = 0 ; i < initTokenBalances.length ; i++ ) {
36- if (strategies[i] == BEACONCHAIN_ETH_STRAT) {
37- tokensToDeposit[i] = initTokenBalances[i];
38- continue ;
39- }
40-
41- tokensToDeposit[i] = initTokenBalances[i]/ 2 ;
42- numTokensRemaining[i] = initTokenBalances[i] - tokensToDeposit[i];
10+ function testFuzz_deposit_delegate_allocate_fullSlash_queue_complete_redeposit (
11+ uint24 _random
12+ ) public {
13+ _configRand ({_randomSeed: _random, _assetTypes: HOLDS_LST, _userTypes: DEFAULT});
14+ _upgradeEigenLayerContracts ();
15+
16+ (User staker , IStrategy[] memory strategies , uint256 [] memory tokenBalances ) = _newRandomStaker ();
17+ (User operator ,,) = _newRandomOperator ();
18+ (AVS avs ,) = _newRandomAVS ();
19+
20+ uint256 [] memory tokensToDeposit = new uint256 [](tokenBalances.length );
21+ uint256 [] memory numTokensRemaining = new uint256 [](tokenBalances.length );
22+ for (uint256 i = 0 ; i < tokenBalances.length ; i++ ) {
23+ tokensToDeposit[i] = tokenBalances[i]/ 2 ;
24+ numTokensRemaining[i] = tokenBalances[i] - tokensToDeposit[i];
4325 }
4426
4527 uint256 [] memory shares = _calculateExpectedShares (strategies, tokensToDeposit);
@@ -53,127 +35,63 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat
5335 check_Delegation_State (staker, operator, strategies, shares);
5436
5537 // Create operator set and register operator
56- operatorSet = avs.createOperatorSet (strategies);
38+ OperatorSet memory operatorSet = avs.createOperatorSet (strategies);
5739 operator.registerForOperatorSet (operatorSet);
58- check_Registration_State_NoAllocation (operator, operatorSet, allStrats);
5940
6041 // 3. Allocate to operator set
61- allocateParams = _genAllocation_AllAvailable (operator, operatorSet);
62- operator.modifyAllocations (allocateParams);
63- check_IncrAlloc_State_Slashable (operator, allocateParams);
42+ IAllocationManagerTypes.AllocateParams memory allocateParams =
43+ operator.modifyAllocations (operatorSet, _maxMagnitudes (operatorSet, operator));
44+
45+ assert_Snap_Allocations_Modified (
46+ operator,
47+ allocateParams,
48+ false ,
49+ "operator allocations should be updated before delay "
50+ );
6451
6552 _rollBlocksForCompleteAllocation (operator, operatorSet, strategies);
66- }
67-
68- function testFuzz_fullSlash_queue_complete_redeposit (
69- uint24 _random
70- ) public rand (_random) {
53+
54+ assert_Snap_Allocations_Modified (
55+ operator,
56+ allocateParams,
57+ true ,
58+ "operator allocations should be updated after delay "
59+ );
60+
7161 // 4. Fully slash operator
72- SlashingParams memory slashingParams;
62+ IAllocationManagerTypes. SlashingParams memory slashingParams;
7363 {
7464 (IStrategy[] memory strategiesToSlash , uint256 [] memory wadsToSlash ) =
7565 _strategiesAndWadsForFullSlash (operatorSet);
7666
7767 slashingParams = avs.slashOperator (operator, operatorSet.id, strategiesToSlash, wadsToSlash);
7868 assert_Snap_Allocations_Slashed (slashingParams, operatorSet, true , "operator allocations should be slashed " );
79- assert_Snap_Unchanged_Staker_DepositShares (staker, "staker deposit shares should be unchanged after slashing " );
69+ assert_Snap_Unchanged_StakerDepositShares (staker, "staker deposit shares should be unchanged after slashing " );
8070 assert_Snap_StakerWithdrawableShares_AfterSlash (staker, allocateParams, slashingParams, "staker deposit shares should be slashed " );
8171 }
8272
8373 // 5. Undelegate from an operator
84- Withdrawal[] memory withdrawals = staker.undelegate ();
85- bytes32 [] memory withdrawalRoots = _getWithdrawalHashes (withdrawals);
86-
87- // 6. Complete withdrawal
88- _rollBlocksForCompleteWithdrawals (withdrawals);
89- for (uint256 i = 0 ; i < withdrawals.length ; ++ i) {
90- uint256 [] memory expectedTokens =
91- _calculateExpectedTokens (withdrawals[i].strategies, withdrawals[i].scaledShares);
92- staker.completeWithdrawalAsTokens (withdrawals[i]);
93- check_Withdrawal_AsTokens_State_AfterSlash (staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens);
94- }
95-
96- // 7. Redeposit
97- uint [] memory shares = _calculateExpectedShares (strategies, numTokensRemaining);
98- staker.depositIntoEigenlayer (strategies, numTokensRemaining);
99- check_Deposit_State (staker, strategies, shares);
100-
101- // Final state checks
102- assert_HasExpectedShares (staker, strategies, shares, "staker should have expected shares after redeposit " );
103- assert_NoWithdrawalsPending (withdrawalRoots, "all withdrawals should be removed from pending " );
104- }
105-
106- function testFuzz_undelegate_fullSlash_complete_redeposit (
107- uint24 _random
108- ) public rand (_random) {
109- // 4. Undelegate from an operator
110- Withdrawal[] memory withdrawals = staker.undelegate ();
74+ IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate ();
11175 bytes32 [] memory withdrawalRoots = _getWithdrawalHashes (withdrawals);
11276
113- // 5. Fully slash operator
114- SlashingParams memory slashingParams;
115- {
116- (IStrategy[] memory strategiesToSlash , uint256 [] memory wadsToSlash ) =
117- _strategiesAndWadsForFullSlash (operatorSet);
118-
119- slashingParams = avs.slashOperator (operator, operatorSet.id, strategiesToSlash, wadsToSlash);
120- assert_Snap_Allocations_Slashed (slashingParams, operatorSet, true , "operator allocations should be slashed " );
121- assert_Snap_Unchanged_Staker_DepositShares (staker, "staker deposit shares should be unchanged after slashing " );
122- assert_Snap_StakerWithdrawableShares_AfterSlash (staker, allocateParams, slashingParams, "staker deposit shares should be slashed " );
123- }
124-
12577 // 6. Complete withdrawal
12678 _rollBlocksForCompleteWithdrawals (withdrawals);
12779 for (uint256 i = 0 ; i < withdrawals.length ; ++ i) {
12880 uint256 [] memory expectedTokens =
12981 _calculateExpectedTokens (withdrawals[i].strategies, withdrawals[i].scaledShares);
82+ for (uint256 i = 0 ; i < expectedTokens.length ; i++ ) {
83+ }
13084 staker.completeWithdrawalAsTokens (withdrawals[i]);
13185 check_Withdrawal_AsTokens_State_AfterSlash (staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens);
13286 }
13387
13488 // 7. Redeposit
135- uint [] memory shares = _calculateExpectedShares (strategies, numTokensRemaining);
89+ shares = _calculateExpectedShares (strategies, numTokensRemaining);
13690 staker.depositIntoEigenlayer (strategies, numTokensRemaining);
13791 check_Deposit_State (staker, strategies, shares);
13892
13993 // Final state checks
14094 assert_HasExpectedShares (staker, strategies, shares, "staker should have expected shares after redeposit " );
14195 assert_NoWithdrawalsPending (withdrawalRoots, "all withdrawals should be removed from pending " );
14296 }
143-
144- function testFuzz_depositFull_fullSlash_undelegate_completeAsShares (
145- uint24 _random
146- ) public rand (_random) {
147- uint [] memory shares = _calculateExpectedShares (strategies, numTokensRemaining);
148- staker.depositIntoEigenlayer (strategies, numTokensRemaining);
149- check_Deposit_State (staker, strategies, shares);
150-
151- // 4. Fully slash random proper subset of operators strategies
152- SlashingParams memory slashingParams;
153- {
154- (IStrategy[] memory strategiesToSlash , uint256 [] memory wadsToSlash ) =
155- _strategiesAndWadsForRandFullSlash (operatorSet);
156- slashingParams = avs.slashOperator (operator, operatorSet.id, strategiesToSlash, wadsToSlash);
157- assert_Snap_Allocations_Slashed (slashingParams, operatorSet, true , "operator allocations should be slashed " );
158- assert_Snap_Unchanged_Staker_DepositShares (staker, "staker deposit shares should be unchanged after slashing " );
159- assert_Snap_StakerWithdrawableShares_AfterSlash (staker, allocateParams, slashingParams, "staker deposit shares should be slashed " );
160- }
161-
162- // 5. Undelegate from an operator
163- Withdrawal[] memory withdrawals = staker.undelegate ();
164- bytes32 [] memory withdrawalRoots = _getWithdrawalHashes (withdrawals);
165-
166- // 6. Complete withdrawal as shares
167- // Fast forward to when we can complete the withdrawal
168- _rollBlocksForCompleteWithdrawals (withdrawals);
169-
170- for (uint256 i = 0 ; i < withdrawals.length ; ++ i) {
171- staker.completeWithdrawalAsShares (withdrawals[i]);
172- check_Withdrawal_AsShares_State_AfterSlash (staker, operator, withdrawals[i], allocateParams, slashingParams);
173- }
174-
175- // Check final state:
176- assert_HasNoUnderlyingTokenBalance (staker, slashingParams.strategies, "staker not have any underlying tokens " );
177- assert_NoWithdrawalsPending (withdrawalRoots, "all withdrawals should be removed from pending " );
178- }
17997}
0 commit comments