Skip to content

Commit fe4a8e2

Browse files
authored
Feat: Remove set withdrawal delay (#355)
* feat: remove setWithdrawalDelayBlocks() removing ability to modify withdrawalDelayBlocks, will only be initialized once * fix: fixed delegation.initialize() calls - Added `initializedWithdrawalDelayBlocks` to initialize params - Added regression test for initializing> MAX_WITHDRAWAL_DELAY_BLOCKS - DelegationUnit.t.sol, small fix for internal function `_registerOperatorWith1271DelegationApprover` * chore: emit WithdrawalDelayBlocksSet
1 parent 87f980e commit fe4a8e2

11 files changed

+66
-63
lines changed

script/middleware/DeployOpenEigenLayer.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ contract DeployOpenEigenLayer is Script, Test {
139139
eigenLayerProxyAdmin.upgradeAndCall(
140140
TransparentUpgradeableProxy(payable(address(delegation))),
141141
address(delegationImplementation),
142-
abi.encodeWithSelector(DelegationManager.initialize.selector, executorMultisig, eigenLayerPauserReg, 0)
142+
abi.encodeWithSelector(DelegationManager.initialize.selector, executorMultisig, eigenLayerPauserReg, 0, 0 /* withdrawalDelayBlocks */)
143143
);
144144
eigenLayerProxyAdmin.upgradeAndCall(
145145
TransparentUpgradeableProxy(payable(address(strategyManager))),

script/milestone/M2Deploy.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ contract M2Deploy is Script, Test {
326326
);
327327

328328
cheats.expectRevert(bytes("Initializable: contract is already initialized"));
329-
DelegationManager(address(delegation)).initialize(address(this), PauserRegistry(address(this)), 0);
329+
DelegationManager(address(delegation)).initialize(address(this), PauserRegistry(address(this)), 0, 0);
330330

331331
cheats.expectRevert(bytes("Initializable: contract is already initialized"));
332332
EigenPodManager(address(eigenPodManager)).initialize(

script/testing/M2_Deploy_From_Scratch.s.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ contract Deployer_M2 is Script, Test {
8282
uint256 STRATEGY_MANAGER_INIT_PAUSED_STATUS;
8383
uint256 SLASHER_INIT_PAUSED_STATUS;
8484
uint256 DELEGATION_INIT_PAUSED_STATUS;
85+
uint256 DELEGATION_WITHDRAWAL_DELAY_BLOCKS;
8586
uint256 EIGENPOD_MANAGER_INIT_PAUSED_STATUS;
8687
uint256 EIGENPOD_MANAGER_MAX_PODS;
8788
uint256 DELAYED_WITHDRAWAL_ROUTER_INIT_PAUSED_STATUS;
@@ -103,6 +104,7 @@ contract Deployer_M2 is Script, Test {
103104
STRATEGY_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".strategyManager.init_paused_status");
104105
SLASHER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".slasher.init_paused_status");
105106
DELEGATION_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".delegation.init_paused_status");
107+
DELEGATION_WITHDRAWAL_DELAY_BLOCKS = stdJson.readUint(config_data, ".delegation.init_withdrawal_delay_blocks");
106108
EIGENPOD_MANAGER_MAX_PODS = stdJson.readUint(config_data, ".eigenPodManager.max_pods");
107109
EIGENPOD_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".eigenPodManager.init_paused_status");
108110
DELAYED_WITHDRAWAL_ROUTER_INIT_PAUSED_STATUS = stdJson.readUint(
@@ -208,7 +210,8 @@ contract Deployer_M2 is Script, Test {
208210
DelegationManager.initialize.selector,
209211
executorMultisig,
210212
eigenLayerPauserReg,
211-
DELEGATION_INIT_PAUSED_STATUS
213+
DELEGATION_INIT_PAUSED_STATUS,
214+
DELEGATION_WITHDRAWAL_DELAY_BLOCKS
212215
)
213216
);
214217
eigenLayerProxyAdmin.upgradeAndCall(

script/testing/M2_deploy_from_scratch.mainnet.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
},
5454
"delegation":
5555
{
56-
"init_paused_status": 0
56+
"init_paused_status": 0,
57+
"init_withdrawal_delay_blocks": 50400
5758
},
5859
"ethPOSDepositAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
5960
}

src/contracts/core/DelegationManager.sol

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
6565

6666
/**
6767
* @dev Initializes the addresses of the initial owner, pauser registry, and paused status.
68+
* withdrawalDelayBlocks is set only once here
6869
*/
6970
function initialize(
7071
address initialOwner,
7172
IPauserRegistry _pauserRegistry,
72-
uint256 initialPausedStatus
73+
uint256 initialPausedStatus,
74+
uint256 _withdrawalDelayBlocks
7375
) external initializer {
7476
_initializePauser(_pauserRegistry, initialPausedStatus);
7577
_DOMAIN_SEPARATOR = _calculateDomainSeparator();
7678
_transferOwnership(initialOwner);
79+
_initializeWithdrawalDelayBlocks(_withdrawalDelayBlocks);
7780
}
7881

7982
/*******************************************************************************
@@ -218,19 +221,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
218221
_delegate(staker, operator, approverSignatureAndExpiry, approverSalt);
219222
}
220223

221-
/**
222-
* @notice Owner-only function for modifying the value of the `withdrawalDelayBlocks` variable.
223-
* @param newWithdrawalDelayBlocks new value of `withdrawalDelayBlocks`.
224-
*/
225-
function setWithdrawalDelayBlocks(uint256 newWithdrawalDelayBlocks) external onlyOwner {
226-
require(
227-
newWithdrawalDelayBlocks <= MAX_WITHDRAWAL_DELAY_BLOCKS,
228-
"DelegationManager.setWithdrawalDelayBlocks: newWithdrawalDelayBlocks too high"
229-
);
230-
emit WithdrawalDelayBlocksSet(withdrawalDelayBlocks, newWithdrawalDelayBlocks);
231-
withdrawalDelayBlocks = newWithdrawalDelayBlocks;
232-
}
233-
234224
/**
235225
* Allows the staker, the staker's operator, or that operator's delegationApprover to undelegate
236226
* a staker from their operator. Undelegation immediately removes ALL active shares/strategies from
@@ -771,6 +761,15 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
771761
}
772762
}
773763

764+
function _initializeWithdrawalDelayBlocks(uint256 _withdrawalDelayBlocks) internal {
765+
require(
766+
_withdrawalDelayBlocks <= MAX_WITHDRAWAL_DELAY_BLOCKS,
767+
"DelegationManager._initializeWithdrawalDelayBlocks: _withdrawalDelayBlocks cannot be > MAX_WITHDRAWAL_DELAY_BLOCKS"
768+
);
769+
emit WithdrawalDelayBlocksSet(withdrawalDelayBlocks, _withdrawalDelayBlocks);
770+
withdrawalDelayBlocks = _withdrawalDelayBlocks;
771+
}
772+
774773
/*******************************************************************************
775774
VIEW FUNCTIONS
776775
*******************************************************************************/

src/test/Delegation.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ contract DelegationTests is EigenLayerTestHelper {
333333
/// cannot be intitialized multiple times
334334
function testCannotInitMultipleTimesDelegation() public cannotReinit {
335335
//delegation has already been initialized in the Deployer test contract
336-
delegation.initialize(address(this), eigenLayerPauserReg, 0);
336+
delegation.initialize(address(this), eigenLayerPauserReg, 0, initializedWithdrawalDelayBlocks);
337337
}
338338

339339
/// @notice This function tests to ensure that a you can't register as a delegate multiple times
@@ -370,7 +370,7 @@ contract DelegationTests is EigenLayerTestHelper {
370370
//delegation has already been initialized in the Deployer test contract
371371
vm.prank(_attacker);
372372
cheats.expectRevert(bytes("Initializable: contract is already initialized"));
373-
delegation.initialize(_attacker, eigenLayerPauserReg, 0);
373+
delegation.initialize(_attacker, eigenLayerPauserReg, 0, initializedWithdrawalDelayBlocks);
374374
}
375375

376376
/// @notice This function tests that the earningsReceiver cannot be set to address(0)

src/test/DepositWithdraw.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ contract DepositWithdrawTests is EigenLayerTestHelper {
500500
DelegationManager.initialize.selector,
501501
eigenLayerReputedMultisig,
502502
eigenLayerPauserReg,
503-
0/*initialPausedStatus*/
503+
0 /*initialPausedStatus*/,
504+
initializedWithdrawalDelayBlocks
504505
)
505506
);
506507
eigenLayerProxyAdmin.upgradeAndCall(

src/test/EigenLayerDeployer.t.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ contract EigenLayerDeployer is Operators {
7373
uint256 public constant eigenTotalSupply = 1000e18;
7474
uint256 nonce = 69;
7575
uint256 public gasLimit = 750000;
76+
uint256 initializedWithdrawalDelayBlocks = 0;
7677
uint32 PARTIAL_WITHDRAWAL_FRAUD_PROOF_PERIOD_BLOCKS = 7 days / 12 seconds;
7778
uint256 REQUIRED_BALANCE_WEI = 32 ether;
7879
uint64 MAX_PARTIAL_WTIHDRAWAL_AMOUNT_GWEI = 1 ether / 1e9;
@@ -268,7 +269,8 @@ contract EigenLayerDeployer is Operators {
268269
DelegationManager.initialize.selector,
269270
eigenLayerReputedMultisig,
270271
eigenLayerPauserReg,
271-
0 /*initialPausedStatus*/
272+
0 /*initialPausedStatus*/,
273+
initializedWithdrawalDelayBlocks
272274
)
273275
);
274276
eigenLayerProxyAdmin.upgradeAndCall(

src/test/EigenPod.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
204204
DelegationManager.initialize.selector,
205205
initialOwner,
206206
pauserReg,
207-
0 /*initialPausedStatus*/
207+
0 /*initialPausedStatus*/,
208+
WITHDRAWAL_DELAY_BLOCKS
208209
)
209210
);
210211
eigenLayerProxyAdmin.upgradeAndCall(

src/test/integration/IntegrationDeployer.t.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
189189
DelayedWithdrawalRouter delayedWithdrawalRouterImplementation = new DelayedWithdrawalRouter(eigenPodManager);
190190

191191
// Third, upgrade the proxy contracts to point to the implementations
192+
uint256 withdrawalDelayBlocks = 7 days / 12 seconds;
192193
// DelegationManager
193194
eigenLayerProxyAdmin.upgradeAndCall(
194195
TransparentUpgradeableProxy(payable(address(delegationManager))),
@@ -197,7 +198,8 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
197198
DelegationManager.initialize.selector,
198199
eigenLayerReputedMultisig, // initialOwner
199200
pauserRegistry,
200-
0 // initialPausedStatus
201+
0 /* initialPausedStatus */,
202+
withdrawalDelayBlocks
201203
)
202204
);
203205
// StrategyManager
@@ -237,7 +239,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
237239
)
238240
);
239241
// Delayed Withdrawal Router
240-
uint256 withdrawalDelayBlocks = 7 days / 12 seconds;
241242
eigenLayerProxyAdmin.upgradeAndCall(
242243
TransparentUpgradeableProxy(payable(address(delayedWithdrawalRouter))),
243244
address(delayedWithdrawalRouterImplementation),

0 commit comments

Comments
 (0)