From 601f8e24752e8617d33242912d7f85f111a47c01 Mon Sep 17 00:00:00 2001 From: Alex <18387287+wadealexc@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:29:54 -0500 Subject: [PATCH] refactor: remove deprecated methods (#903) * refactor: rename parameter to be more accurate * refactor: remove deprecated methods from dm * refactor: remove operator details usage * chore: nit word --- script/tasks/register_as_operator.s.sol | 9 +- src/contracts/core/DelegationManager.sol | 70 +++------- src/contracts/core/StrategyManager.sol | 14 +- .../interfaces/IDelegationManager.sol | 55 ++------ src/contracts/libraries/SlashingLib.sol | 18 +-- src/contracts/pods/EigenPodManager.sol | 12 +- src/test/DevnetLifecycle.t.sol | 7 +- src/test/integration/users/User.t.sol | 8 +- src/test/unit/DelegationUnit.t.sol | 127 ++++++------------ 9 files changed, 97 insertions(+), 223 deletions(-) diff --git a/script/tasks/register_as_operator.s.sol b/script/tasks/register_as_operator.s.sol index f9e20300e..57ee4f9bc 100644 --- a/script/tasks/register_as_operator.s.sol +++ b/script/tasks/register_as_operator.s.sol @@ -33,15 +33,8 @@ contract RegisterAsOperator is Script, Test { // Attach the delegationManager DelegationManager delegation = DelegationManager(delegationManager); - // Define OperatorDetails struct instance - IDelegationManagerTypes.OperatorDetails memory operatorDetails = IDelegationManagerTypes.OperatorDetails({ - __deprecated_earningsReceiver: address(0), - delegationApprover: operator, - __deprecated_stakerOptOutWindowBlocks: 0 - }); - // Register the sender as an Operator - delegation.registerAsOperator(operatorDetails, 0, metadataURI); + delegation.registerAsOperator(operator, 0, metadataURI); // STOP RECORDING TRANSACTIONS FOR DEPLOYMENT vm.stopBroadcast(); diff --git a/src/contracts/core/DelegationManager.sol b/src/contracts/core/DelegationManager.sol index 6aa710b6b..b2156041a 100644 --- a/src/contracts/core/DelegationManager.sol +++ b/src/contracts/core/DelegationManager.sol @@ -94,28 +94,28 @@ contract DelegationManager is /// @inheritdoc IDelegationManager function registerAsOperator( - OperatorDetails calldata registeringOperatorDetails, + address initDelegationApprover, uint32 allocationDelay, string calldata metadataURI ) external { require(!isDelegated(msg.sender), ActivelyDelegated()); allocationManager.setAllocationDelay(msg.sender, allocationDelay); - _setOperatorDetails(msg.sender, registeringOperatorDetails); + _setDelegationApprover(msg.sender, initDelegationApprover); // delegate from the operator to themselves _delegate(msg.sender, msg.sender); - emit OperatorRegistered(msg.sender, registeringOperatorDetails); + emit OperatorRegistered(msg.sender, initDelegationApprover); emit OperatorMetadataURIUpdated(msg.sender, metadataURI); } /// @inheritdoc IDelegationManager function modifyOperatorDetails( - OperatorDetails calldata newOperatorDetails + address newDelegationApprover ) external { require(isOperator(msg.sender), OperatorNotRegistered()); - _setOperatorDetails(msg.sender, newOperatorDetails); + _setDelegationApprover(msg.sender, newDelegationApprover); } /// @inheritdoc IDelegationManager @@ -289,7 +289,7 @@ contract DelegationManager is function increaseDelegatedShares( address staker, IStrategy strategy, - uint256 curDepositShares, + uint256 prevDepositShares, uint256 addedShares ) external onlyStrategyManagerOrEigenPodManager { address operator = delegatedTo[staker]; @@ -301,7 +301,7 @@ contract DelegationManager is operator: operator, staker: staker, strategy: strategy, - curDepositShares: curDepositShares, + prevDepositShares: prevDepositShares, addedShares: addedShares, slashingFactor: slashingFactor }); @@ -378,35 +378,6 @@ contract DelegationManager is } } - /** - * - * BACKWARDS COMPATIBLE LEGACY FUNCTIONS - * TO BE DEPRECATED IN FUTURE - * - */ - - /// @inheritdoc IDelegationManager - function completeQueuedWithdrawal( - Withdrawal calldata withdrawal, - IERC20[] calldata tokens, - uint256, // middlewareTimesIndex - bool receiveAsTokens - ) external onlyWhenNotPaused(PAUSED_EXIT_WITHDRAWAL_QUEUE) nonReentrant { - _completeQueuedWithdrawal(withdrawal, tokens, receiveAsTokens); - } - - /// @inheritdoc IDelegationManager - function completeQueuedWithdrawals( - Withdrawal[] calldata withdrawals, - IERC20[][] calldata tokens, - uint256[] calldata, // middlewareTimesIndexes - bool[] calldata receiveAsTokens - ) external onlyWhenNotPaused(PAUSED_EXIT_WITHDRAWAL_QUEUE) nonReentrant { - for (uint256 i = 0; i < withdrawals.length; ++i) { - _completeQueuedWithdrawal(withdrawals[i], tokens[i], receiveAsTokens[i]); - } - } - /** * * INTERNAL FUNCTIONS @@ -416,11 +387,11 @@ contract DelegationManager is /** * @notice Sets operator parameters in the `_operatorDetails` mapping. * @param operator The account registered as an operator updating their operatorDetails - * @param newOperatorDetails The new parameters for the operator + * @param newDelegationApprover The new parameters for the operator */ - function _setOperatorDetails(address operator, OperatorDetails calldata newOperatorDetails) internal { - _operatorDetails[operator] = newOperatorDetails; - emit OperatorDetailsModified(msg.sender, newOperatorDetails); + function _setDelegationApprover(address operator, address newDelegationApprover) internal { + _operatorDetails[operator].delegationApprover = newDelegationApprover; + emit DelegationApproverUpdated(msg.sender, newDelegationApprover); } /** @@ -450,7 +421,7 @@ contract DelegationManager is operator: operator, staker: staker, strategy: strategies[i], - curDepositShares: uint256(0), + prevDepositShares: uint256(0), addedShares: depositedShares[i], slashingFactor: slashingFactors[i] }); @@ -517,7 +488,7 @@ contract DelegationManager is }); } else { // Award shares back in StrategyManager/EigenPodManager. - (uint256 curDepositShares, uint256 addedShares) = shareManager.addShares({ + (uint256 prevDepositShares, uint256 addedShares) = shareManager.addShares({ staker: withdrawal.staker, strategy: withdrawal.strategies[i], token: tokens[i], @@ -529,7 +500,7 @@ contract DelegationManager is operator: newOperator, staker: withdrawal.staker, strategy: withdrawal.strategies[i], - curDepositShares: curDepositShares, + prevDepositShares: prevDepositShares, addedShares: addedShares, slashingFactor: newSlashingFactors[i] }); @@ -550,7 +521,7 @@ contract DelegationManager is * @param operator The operator to increase the delegated delegatedShares for * @param staker The staker to increase the depositScalingFactor for * @param strategy The strategy to increase the delegated delegatedShares and the depositScalingFactor for - * @param curDepositShares The number of deposit shares the staker already has in the strategy. + * @param prevDepositShares The number of delegated deposit shares the staker had in the strategy prior to the increase * @param addedShares The shares added to the staker in the StrategyManager/EigenPodManager * @param slashingFactor The current slashing factor for the staker/operator/strategy */ @@ -558,7 +529,7 @@ contract DelegationManager is address operator, address staker, IStrategy strategy, - uint256 curDepositShares, + uint256 prevDepositShares, uint256 addedShares, uint256 slashingFactor ) internal { @@ -569,7 +540,7 @@ contract DelegationManager is // Update the staker's depositScalingFactor. This only results in an update // if the slashing factor has changed for this strategy. DepositScalingFactor storage dsf = _depositScalingFactor[staker][strategy]; - dsf.update(curDepositShares, addedShares, slashingFactor); + dsf.update(prevDepositShares, addedShares, slashingFactor); emit DepositScalingFactorUpdated(staker, strategy, dsf.scalingFactor()); // If the staker is delegated to an operator, update the operator's shares @@ -820,13 +791,6 @@ contract DelegationManager is return operator != address(0) && delegatedTo[operator] == operator; } - /// @inheritdoc IDelegationManager - function operatorDetails( - address operator - ) external view returns (OperatorDetails memory) { - return _operatorDetails[operator]; - } - /// @inheritdoc IDelegationManager function delegationApprover( address operator diff --git a/src/contracts/core/StrategyManager.sol b/src/contracts/core/StrategyManager.sol index 21cb9acfb..eb8c545d6 100644 --- a/src/contracts/core/StrategyManager.sol +++ b/src/contracts/core/StrategyManager.sol @@ -203,19 +203,19 @@ contract StrategyManager is require(staker != address(0), StakerAddressZero()); require(shares != 0, SharesAmountZero()); - uint256 existingShares = stakerDepositShares[staker][strategy]; + uint256 prevDepositShares = stakerDepositShares[staker][strategy]; - // if they dont have existingShares of this strategy, add it to their strats - if (existingShares == 0) { + // if they dont have prevDepositShares of this strategy, add it to their strats + if (prevDepositShares == 0) { require(stakerStrategyList[staker].length < MAX_STAKER_STRATEGY_LIST_LENGTH, MaxStrategiesExceeded()); stakerStrategyList[staker].push(strategy); } // add the returned depositedShares to their existing shares for this strategy - stakerDepositShares[staker][strategy] = existingShares + shares; + stakerDepositShares[staker][strategy] = prevDepositShares + shares; emit Deposit(staker, token, strategy, shares); - return (existingShares, shares); + return (prevDepositShares, shares); } /** @@ -240,13 +240,13 @@ contract StrategyManager is shares = strategy.deposit(token, amount); // add the returned shares to the staker's existing shares for this strategy - (uint256 existingShares, uint256 addedShares) = _addShares(staker, token, strategy, shares); + (uint256 prevDepositShares, uint256 addedShares) = _addShares(staker, token, strategy, shares); // Increase shares delegated to operator delegation.increaseDelegatedShares({ staker: staker, strategy: strategy, - curDepositShares: existingShares, + prevDepositShares: prevDepositShares, addedShares: addedShares }); diff --git a/src/contracts/interfaces/IDelegationManager.sol b/src/contracts/interfaces/IDelegationManager.sol index 45d33b42a..382b14ab0 100644 --- a/src/contracts/interfaces/IDelegationManager.sol +++ b/src/contracts/interfaces/IDelegationManager.sol @@ -136,11 +136,11 @@ interface IDelegationManagerTypes { } interface IDelegationManagerEvents is IDelegationManagerTypes { - // @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails. - event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails); + // @notice Emitted when a new operator registers in EigenLayer and provides their delegation approver. + event OperatorRegistered(address indexed operator, address delegationApprover); - /// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails - event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails); + /// @notice Emitted when an operator updates their delegation approver + event DelegationApproverUpdated(address indexed operator, address newDelegationApprover); /** * @notice Emitted when @param operator indicates that they are updating their MetadataURI string @@ -199,7 +199,8 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele /** * @notice Registers the caller as an operator in EigenLayer. - * @param registeringOperatorDetails is the `OperatorDetails` for the operator. + * @param initDelegationApprover is an address that, if set, must provide a signature when stakers delegate + * to an operator. * @param allocationDelay The delay before allocations take effect. * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator. * @@ -208,19 +209,19 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event */ function registerAsOperator( - OperatorDetails calldata registeringOperatorDetails, + address initDelegationApprover, uint32 allocationDelay, string calldata metadataURI ) external; /** - * @notice Updates an operator's stored `OperatorDetails`. - * @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`. + * @notice Updates an operator's stored `delegationApprover`. + * @param newDelegationApprover is the new delegationApprover for the operator * * @dev The caller must have previously registered as an operator in EigenLayer. */ function modifyOperatorDetails( - OperatorDetails calldata newOperatorDetails + address newDelegationApprover ) external; /** @@ -332,7 +333,7 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele * the delegated delegatedShares. The staker's depositScalingFactor is updated here. * @param staker The address to increase the delegated shares for their operator. * @param strategy The strategy in which to increase the delegated shares. - * @param curDepositShares The number of deposit shares the staker already has in the strategy. This is the shares amount stored in the + * @param prevDepositShares The number of deposit shares the staker already had in the strategy. This is the shares amount stored in the * StrategyManager/EigenPodManager for the staker's shares. * @param addedShares The number of shares added to the staker's shares in the strategy * @@ -344,7 +345,7 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele function increaseDelegatedShares( address staker, IStrategy strategy, - uint256 curDepositShares, + uint256 prevDepositShares, uint256 addedShares ) external; @@ -383,31 +384,6 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele uint64 newMaxMagnitude ) external; - /** - * - * BACKWARDS COMPATIBLE LEGACY FUNCTIONS - * TO BE DEPRECATED IN FUTURE - * - */ - - /// @notice Overloaded version of `completeQueuedWithdrawal` that includes a `middlewareTimesIndex` parameter - /// for backwards compatibility with the M2 release. To be deprecated in a future release. - function completeQueuedWithdrawal( - Withdrawal calldata withdrawal, - IERC20[] calldata tokens, - uint256 middlewareTimesIndex, - bool receiveAsTokens - ) external; - - /// @notice Overloaded version of `completeQueuedWithdrawals` that includes a `middlewareTimesIndexes` parameter - /// for backwards compatibility with the M2 release. To be deprecated in a future release. - function completeQueuedWithdrawals( - Withdrawal[] calldata withdrawals, - IERC20[][] calldata tokens, - uint256[] calldata middlewareTimesIndexes, - bool[] calldata receiveAsTokens - ) external; - /** * * VIEW FUNCTIONS @@ -450,13 +426,6 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele address operator ) external view returns (bool); - /** - * @notice Returns the OperatorDetails struct associated with an `operator`. - */ - function operatorDetails( - address operator - ) external view returns (OperatorDetails memory); - /** * @notice Returns the delegationApprover account for an operator */ diff --git a/src/contracts/libraries/SlashingLib.sol b/src/contracts/libraries/SlashingLib.sol index 20b5b059d..7236a9604 100644 --- a/src/contracts/libraries/SlashingLib.sol +++ b/src/contracts/libraries/SlashingLib.sol @@ -100,13 +100,13 @@ library SlashingLib { function update( DepositScalingFactor storage dsf, - uint256 curDepositShares, + uint256 prevDepositShares, uint256 addedShares, uint256 slashingFactor ) internal { - // If this is the staker's first deposit for this operator, set the scaling factor to + // If this is the staker's first deposit, set the scaling factor to // the inverse of slashingFactor - if (curDepositShares == 0) { + if (prevDepositShares == 0) { dsf._scalingFactor = uint256(WAD).divWad(slashingFactor); return; } @@ -114,7 +114,7 @@ library SlashingLib { /** * Base Equations: * (1) newShares = currentShares + addedShares - * (2) newDepositShares = curDepositShares + addedShares + * (2) newDepositShares = prevDepositShares + addedShares * (3) newShares = newDepositShares * newDepositScalingFactor * slashingFactor * * Plugging (1) into (3): @@ -124,15 +124,15 @@ library SlashingLib { * (5) newDepositScalingFactor = (currentShares + addedShares) / (newDepositShares * slashingFactor) * * Plugging in (2) into (5): - * (7) newDepositScalingFactor = (currentShares + addedShares) / ((curDepositShares + addedShares) * slashingFactor) + * (7) newDepositScalingFactor = (currentShares + addedShares) / ((prevDepositShares + addedShares) * slashingFactor) * Note that magnitudes must be divided by WAD for precision. Thus, * - * (8) newDepositScalingFactor = WAD * (currentShares + addedShares) / ((curDepositShares + addedShares) * slashingFactor / WAD) - * (9) newDepositScalingFactor = (currentShares + addedShares) * WAD / (curDepositShares + addedShares) * WAD / slashingFactor + * (8) newDepositScalingFactor = WAD * (currentShares + addedShares) / ((prevDepositShares + addedShares) * slashingFactor / WAD) + * (9) newDepositScalingFactor = (currentShares + addedShares) * WAD / (prevDepositShares + addedShares) * WAD / slashingFactor */ // Step 1: Calculate Numerator - uint256 currentShares = dsf.calcWithdrawable(curDepositShares, slashingFactor); + uint256 currentShares = dsf.calcWithdrawable(prevDepositShares, slashingFactor); // Step 2: Compute currentShares + addedShares uint256 newShares = currentShares + addedShares; @@ -140,7 +140,7 @@ library SlashingLib { // Step 3: Calculate newDepositScalingFactor /// forgefmt: disable-next-item uint256 newDepositScalingFactor = newShares - .divWad(curDepositShares + addedShares) + .divWad(prevDepositShares + addedShares) .divWad(slashingFactor); dsf._scalingFactor = newDepositScalingFactor; diff --git a/src/contracts/pods/EigenPodManager.sol b/src/contracts/pods/EigenPodManager.sol index 88f14ffa1..418cdd003 100644 --- a/src/contracts/pods/EigenPodManager.sol +++ b/src/contracts/pods/EigenPodManager.sol @@ -105,13 +105,13 @@ contract EigenPodManager is // a negative balance delta, the pod owner's beacon chain slashing factor is decreased, devaluing // their shares. if (balanceDeltaWei >= 0) { - (uint256 curDepositShares, uint256 addedShares) = _addShares(podOwner, uint256(balanceDeltaWei)); + (uint256 prevDepositShares, uint256 addedShares) = _addShares(podOwner, uint256(balanceDeltaWei)); // Update operator shares delegationManager.increaseDelegatedShares({ staker: podOwner, strategy: beaconChainETHStrategy, - curDepositShares: curDepositShares, + prevDepositShares: prevDepositShares, addedShares: addedShares }); } else { @@ -244,15 +244,15 @@ contract EigenPodManager is /// @dev Adds the shares to the staker's balance, returning their current/added shares /// NOTE: if the staker ends with a non-positive balance, this returns (0, 0) - /// @return existingDepositShares the shares the staker had before any were added + /// @return prevDepositShares the shares the staker had before any were added /// @return addedShares the shares added to the staker's balance function _addShares(address staker, uint256 shares) internal returns (uint256, uint256) { require(staker != address(0), InputAddressZero()); require(int256(shares) >= 0, SharesNegative()); int256 sharesToAdd = int256(shares); - int256 currentDepositShares = podOwnerDepositShares[staker]; - int256 updatedDepositShares = currentDepositShares + sharesToAdd; + int256 prevDepositShares = podOwnerDepositShares[staker]; + int256 updatedDepositShares = prevDepositShares + sharesToAdd; podOwnerDepositShares[staker] = updatedDepositShares; emit PodSharesUpdated(staker, sharesToAdd); @@ -263,7 +263,7 @@ contract EigenPodManager is return (0, 0); } - return (currentDepositShares < 0 ? 0 : uint256(currentDepositShares), shares); + return (prevDepositShares < 0 ? 0 : uint256(prevDepositShares), shares); } /// @dev Calculates the proportion a pod owner's restaked balance has decreased, and diff --git a/src/test/DevnetLifecycle.t.sol b/src/test/DevnetLifecycle.t.sol index 546c94e13..552c67340 100644 --- a/src/test/DevnetLifecycle.t.sol +++ b/src/test/DevnetLifecycle.t.sol @@ -108,14 +108,9 @@ contract Devnet_Lifecycle_Test is Test { function _registerOperator() internal { // Register operator - IDelegationManagerTypes.OperatorDetails memory operatorDetails = IDelegationManagerTypes.OperatorDetails({ - __deprecated_earningsReceiver: msg.sender, - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }); string memory emptyStringForMetadataURI; cheats.prank(operator); - delegationManager.registerAsOperator(operatorDetails, 1, emptyStringForMetadataURI); + delegationManager.registerAsOperator(address(0), 1, emptyStringForMetadataURI); // Warp passed configuration delay cheats.roll(block.number + delegationManager.MIN_WITHDRAWAL_DELAY_BLOCKS()); diff --git a/src/test/integration/users/User.t.sol b/src/test/integration/users/User.t.sol index 2ce5afba5..a0732ad00 100644 --- a/src/test/integration/users/User.t.sol +++ b/src/test/integration/users/User.t.sol @@ -176,13 +176,7 @@ contract User is Logger, IDelegationManagerTypes, IAllocationManagerTypes { function registerAsOperator() public virtual createSnapshot { print.method("registerAsOperator"); - OperatorDetails memory details = OperatorDetails({ - __deprecated_earningsReceiver: address(this), - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }); - - delegationManager.registerAsOperator(details, withdrawalDelay, "metadata"); + delegationManager.registerAsOperator(address(0), withdrawalDelay, "metadata"); } /// @dev Delegate to the operator without a signature diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index 378d2af2f..c6dc318c0 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -260,21 +260,11 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag } function _registerOperatorWithBaseDetails(address operator) internal { - OperatorDetails memory operatorDetails = OperatorDetails({ - __deprecated_earningsReceiver: operator, - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }); - _registerOperator(operator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(operator, address(0), emptyStringForMetadataURI); } function _registerOperatorWithDelegationApprover(address operator) internal { - OperatorDetails memory operatorDetails = OperatorDetails({ - __deprecated_earningsReceiver: operator, - delegationApprover: defaultApprover, - __deprecated_stakerOptOutWindowBlocks: 0 - }); - _registerOperator(operator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(operator, defaultApprover, emptyStringForMetadataURI); } function _registerOperatorWith1271DelegationApprover(address operator) internal returns (ERC1271WalletMock) { @@ -284,24 +274,18 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag * so that we can create valid signatures from the `delegationSigner` for the contract to check when called */ ERC1271WalletMock wallet = new ERC1271WalletMock(delegationSigner); - - OperatorDetails memory operatorDetails = OperatorDetails({ - __deprecated_earningsReceiver: operator, - delegationApprover: address(wallet), - __deprecated_stakerOptOutWindowBlocks: 0 - }); - _registerOperator(operator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(operator, address(wallet), emptyStringForMetadataURI); return wallet; } function _registerOperator( address operator, - OperatorDetails memory operatorDetails, + address delegationApprover, string memory metadataURI ) internal filterFuzzedAddressInputs(operator) { cheats.prank(operator); - delegationManager.registerAsOperator(operatorDetails, 0, metadataURI); + delegationManager.registerAsOperator(delegationApprover, 0, metadataURI); } /** @@ -627,17 +611,17 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag struct RegisterAsOperatorEmitStruct { address operator; - IDelegationManagerTypes.OperatorDetails operatorDetails; + address delegationApprover; string metadataURI; } function _registerOperator_expectEmit(RegisterAsOperatorEmitStruct memory params) internal { cheats.expectEmit(true, true, true, true, address(delegationManager)); - emit OperatorDetailsModified(params.operator, params.operatorDetails); + emit DelegationApproverUpdated(params.operator, params.delegationApprover); cheats.expectEmit(true, true, true, true, address(delegationManager)); emit StakerDelegated(params.operator, params.operator); cheats.expectEmit(true, true, true, true, address(delegationManager)); - emit OperatorRegistered(params.operator, params.operatorDetails); + emit OperatorRegistered(params.operator, params.delegationApprover); cheats.expectEmit(true, true, true, true, address(delegationManager)); emit OperatorMetadataURIUpdated(params.operator, params.metadataURI); } @@ -901,57 +885,53 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU cheats.expectRevert(IPausable.CurrentlyPaused.selector); delegationManager.registerAsOperator( - OperatorDetails({ - __deprecated_earningsReceiver: defaultOperator, - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }), + address(0), 0, emptyStringForMetadataURI ); } - // @notice Verifies that someone cannot successfully call `DelegationManager.registerAsOperator(operatorDetails)` again after registering for the first time + // @notice Verifies that someone cannot successfully call `DelegationManager.registerAsOperator(delegationApprover)` again after registering for the first time function testFuzz_registerAsOperator_revert_cannotRegisterMultipleTimes( - OperatorDetails memory operatorDetails + address delegationApprover ) public { // Register once cheats.startPrank(defaultOperator); - delegationManager.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI); + delegationManager.registerAsOperator(delegationApprover, 0, emptyStringForMetadataURI); // Expect revert when register again cheats.expectRevert(ActivelyDelegated.selector); - delegationManager.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI); + delegationManager.registerAsOperator(delegationApprover, 0, emptyStringForMetadataURI); cheats.stopPrank(); } /** - * @notice `operator` registers via calling `DelegationManager.registerAsOperator(operatorDetails, metadataURI)` + * @notice `operator` registers via calling `DelegationManager.registerAsOperator(delegationApprover, metadataURI)` * Should be able to set any parameters, other than too high value for `stakerOptOutWindowBlocks` * The set parameters should match the desired parameters (correct storage update) * Operator becomes delegated to themselves - * Properly emits events – especially the `OperatorRegistered` event, but also `StakerDelegated` & `OperatorDetailsModified` events + * Properly emits events – especially the `OperatorRegistered` event, but also `StakerDelegated` & `DelegationApproverUpdated` events * Reverts appropriately if operator was already delegated to someone (including themselves, i.e. they were already an operator) - * @param operator and @param operatorDetails are fuzzed inputs + * @param operator and @param delegationApprover are fuzzed inputs */ function testFuzz_registerAsOperator( address operator, - OperatorDetails memory operatorDetails, + address delegationApprover, string memory metadataURI ) public filterFuzzedAddressInputs(operator) { _registerOperator_expectEmit( RegisterAsOperatorEmitStruct({ operator: operator, - operatorDetails: operatorDetails, + delegationApprover: delegationApprover, metadataURI: metadataURI }) ); cheats.prank(operator); - delegationManager.registerAsOperator(operatorDetails, 0, metadataURI); + delegationManager.registerAsOperator(delegationApprover, 0, metadataURI); // Storage checks assertEq( - operatorDetails.delegationApprover, + delegationApprover, delegationManager.delegationApprover(operator), "delegationApprover not set correctly" ); @@ -961,29 +941,29 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU /// @notice Register two separate operators shouldn't revert function testFuzz_registerAsOperator_TwoSeparateOperatorsRegister( address operator1, - IDelegationManagerTypes.OperatorDetails memory operatorDetails1, + address delegationApprover1, address operator2, - IDelegationManagerTypes.OperatorDetails memory operatorDetails2 + address delegationApprover2 ) public { cheats.assume(operator1 != operator2); // register operator1 with expected emits _registerOperator_expectEmit( RegisterAsOperatorEmitStruct({ operator: operator1, - operatorDetails: operatorDetails1, + delegationApprover: delegationApprover1, metadataURI: emptyStringForMetadataURI }) ); - _registerOperator(operator1, operatorDetails1, emptyStringForMetadataURI); + _registerOperator(operator1, delegationApprover1, emptyStringForMetadataURI); // register operator2 with expected emits _registerOperator_expectEmit( RegisterAsOperatorEmitStruct({ operator: operator2, - operatorDetails: operatorDetails2, + delegationApprover: delegationApprover2, metadataURI: emptyStringForMetadataURI }) ); - _registerOperator(operator2, operatorDetails2, emptyStringForMetadataURI); + _registerOperator(operator2, delegationApprover2, emptyStringForMetadataURI); assertTrue( delegationManager.isOperator(operator1), "operator1 not registered" @@ -998,7 +978,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU // @notice Verifies that a staker who is actively delegated to an operator cannot register as an operator (without first undelegating, at least) function testFuzz_Revert_registerAsOperator_cannotRegisterWhileDelegated( address staker, - OperatorDetails memory operatorDetails + address delegationApprover ) public filterFuzzedAddressInputs(staker) { cheats.assume(staker != defaultOperator); @@ -1012,7 +992,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU // expect revert if attempt to register as operator cheats.expectRevert(ActivelyDelegated.selector); - delegationManager.registerAsOperator(operatorDetails, 0, emptyStringForMetadataURI); + delegationManager.registerAsOperator(delegationApprover, 0, emptyStringForMetadataURI); cheats.stopPrank(); } @@ -1020,7 +1000,6 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU /// @notice Add test for registerAsOperator where the operator has existing deposits in strategies /// Assert: /// depositShares == operatorShares == withdrawableShares - /// check operatorDetails hash encode matches the operatorDetails hash stored (call view function) function testFuzz_registerAsOperator_withDeposits(Randomness r) public { uint256 shares = r.Uint256(1, MAX_STRATEGY_SHARES); // Set staker shares in StrategyManager @@ -1034,11 +1013,7 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU _registerOperator_expectEmit( RegisterAsOperatorEmitStruct({ operator: defaultOperator, - operatorDetails: IDelegationManagerTypes.OperatorDetails({ - __deprecated_earningsReceiver: defaultOperator, - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }), + delegationApprover: address(0), metadataURI: emptyStringForMetadataURI }) ); @@ -1064,32 +1039,32 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU * @notice Tests that an operator can modify their OperatorDetails by calling `DelegationManager.modifyOperatorDetails` * Should be able to set any parameters, other than setting their `earningsReceiver` to the zero address or too high value for `stakerOptOutWindowBlocks` * The set parameters should match the desired parameters (correct storage update) - * Properly emits an `OperatorDetailsModified` event + * Properly emits an `DelegationApproverUpdated` event * Reverts appropriately if the caller is not an operator * Reverts if operator tries to decrease their `stakerOptOutWindowBlocks` parameter - * @param initialOperatorDetails and @param modifiedOperatorDetails are fuzzed inputs + * @param delegationApprover1 and @param delegationApprover2 are fuzzed inputs */ function testFuzz_modifyOperatorParameters( - OperatorDetails memory initialOperatorDetails, - OperatorDetails memory modifiedOperatorDetails + address delegationApprover1, + address delegationApprover2 ) public { _registerOperator_expectEmit( RegisterAsOperatorEmitStruct({ operator: defaultOperator, - operatorDetails: initialOperatorDetails, + delegationApprover: delegationApprover1, metadataURI: emptyStringForMetadataURI }) ); - _registerOperator(defaultOperator, initialOperatorDetails, emptyStringForMetadataURI); + _registerOperator(defaultOperator, delegationApprover1, emptyStringForMetadataURI); cheats.startPrank(defaultOperator); cheats.expectEmit(true, true, true, true, address(delegationManager)); - emit OperatorDetailsModified(defaultOperator, modifiedOperatorDetails); - delegationManager.modifyOperatorDetails(modifiedOperatorDetails); + emit DelegationApproverUpdated(defaultOperator, delegationApprover2); + delegationManager.modifyOperatorDetails(delegationApprover2); assertEq( - modifiedOperatorDetails.delegationApprover, + delegationApprover2, delegationManager.delegationApprover(defaultOperator), "delegationApprover not set correctly" ); @@ -1114,10 +1089,10 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU * invariant that 'operators' are always delegated to themselves */ function testFuzz_Revert_updateOperatorMetadataUri_notOperator( - OperatorDetails memory operatorDetails + address delegationApprover ) public { cheats.expectRevert(OperatorNotRegistered.selector); - delegationManager.modifyOperatorDetails(operatorDetails); + delegationManager.modifyOperatorDetails(delegationApprover); } // @notice Tests that an operator who calls `updateOperatorMetadataURI` will correctly see an `OperatorMetadataURIUpdated` event emitted with their input @@ -1140,11 +1115,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { function test_Revert_WhenPaused() public { cheats.prank(defaultOperator); delegationManager.registerAsOperator( - OperatorDetails({ - __deprecated_earningsReceiver: defaultOperator, - delegationApprover: address(0), - __deprecated_stakerOptOutWindowBlocks: 0 - }), + address(0), 0, emptyStringForMetadataURI ); @@ -2365,13 +2336,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // deploy a ERC1271MaliciousMock contract that will return an incorrect value when called ERC1271MaliciousMock wallet = new ERC1271MaliciousMock(); - - IDelegationManagerTypes.OperatorDetails memory operatorDetails = IDelegationManagerTypes.OperatorDetails({ - __deprecated_earningsReceiver: defaultOperator, - delegationApprover: address(wallet), - __deprecated_stakerOptOutWindowBlocks: 0 - }); - _registerOperator(defaultOperator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(defaultOperator, address(wallet), emptyStringForMetadataURI); // create the signature struct ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry; @@ -2399,13 +2364,7 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // deploy a ERC1271WalletMock contract that will return an incorrect value when called // owner is the 0 address ERC1271WalletMock wallet = new ERC1271WalletMock(address(1)); - - IDelegationManagerTypes.OperatorDetails memory operatorDetails = IDelegationManagerTypes.OperatorDetails({ - __deprecated_earningsReceiver: defaultOperator, - delegationApprover: address(wallet), - __deprecated_stakerOptOutWindowBlocks: 0 - }); - _registerOperator(defaultOperator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(defaultOperator, address(wallet), emptyStringForMetadataURI); // calculate the delegationSigner's but this is not the correct signature from the wallet contract // since the wallet owner is address(1)