Skip to content

Commit

Permalink
fix: remove stake registry method and event
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc committed Dec 6, 2023
1 parent bb24d61 commit ca2cf32
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 86 deletions.
12 changes: 0 additions & 12 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
EXTERNAL FUNCTIONS
*******************************************************************************/

/**
* @notice Sets the address of the stakeRegistry
* @param _stakeRegistry is the address of the StakeRegistry contract to call for stake updates when operator shares are changed
* @dev Only callable once
*/
function setStakeRegistry(IStakeRegistryStub _stakeRegistry) external onlyOwner {
require(address(stakeRegistry) == address(0), "DelegationManager.setStakeRegistry: stakeRegistry already set");
require(address(_stakeRegistry) != address(0), "DelegationManager.setStakeRegistry: stakeRegistry cannot be zero address");
stakeRegistry = _stakeRegistry;
emit StakeRegistrySet(_stakeRegistry);
}

/**
* @notice Registers the caller as an operator in EigenLayer.
* @param registeringOperatorDetails is the `OperatorDetails` for the operator.
Expand Down
5 changes: 1 addition & 4 deletions src/contracts/core/DelegationManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ abstract contract DelegationManagerStorage is IDelegationManager {
/// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
mapping(address => uint256) public cumulativeWithdrawalsQueued;

/// @notice the address of the StakeRegistry contract to call for stake updates when operator shares are changed
IStakeRegistryStub public stakeRegistry;

constructor(IStrategyManager _strategyManager, ISlasher _slasher, IEigenPodManager _eigenPodManager) {
strategyManager = _strategyManager;
eigenPodManager = _eigenPodManager;
Expand All @@ -103,5 +100,5 @@ abstract contract DelegationManagerStorage is IDelegationManager {
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[40] private __gap;
uint256[41] private __gap;
}
2 changes: 1 addition & 1 deletion src/contracts/core/Slasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
* Eventually, slashing design will be finalized and the Slasher will be finished
* and more fully incorporated into the core contracts. For now, you can ignore this
* file. If you really want to see what the deployed M1 version looks like, check
* out the `init-mainnet-deployment` branch under "releases."
* out the `init-mainnet-deployment` branch under "releases".
*
* This contract is a stub that maintains its original interface for use in testing
* and deploy scripts. Otherwise, it does nothing.
Expand Down
7 changes: 0 additions & 7 deletions src/contracts/interfaces/IDelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity >=0.5.0;

import "./IStrategy.sol";
import "./ISignatureUtils.sol";
import "./IStakeRegistryStub.sol";
import "./IStrategyManager.sol";

/**
Expand Down Expand Up @@ -70,9 +69,6 @@ interface IDelegationManager is ISignatureUtils {
uint256 expiry;
}

/// @notice Emitted when the StakeRegistry is set
event StakeRegistrySet(IStakeRegistryStub stakeRegistry);

/**
* Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
* In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal`, the data is resubmitted and the hash of the submitted
Expand Down Expand Up @@ -324,9 +320,6 @@ interface IDelegationManager is ISignatureUtils {
uint256 shares
) external;

/// @notice the address of the StakeRegistry contract to call for stake updates when operator shares are changed
function stakeRegistry() external view returns (IStakeRegistryStub);

/**
* @notice returns the address of the operator that `staker` is delegated to.
* @notice Mapping: staker => operator whom the staker is currently delegated to.
Expand Down
13 changes: 0 additions & 13 deletions src/contracts/interfaces/IStakeRegistryStub.sol

This file was deleted.

7 changes: 0 additions & 7 deletions src/test/Delegation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ contract DelegationTests is EigenLayerTestHelper {
uint32 serveUntil = 100;

address public registryCoordinator = address(uint160(uint256(keccak256("registryCoordinator"))));
StakeRegistryStub public stakeRegistry;
uint8 defaultQuorumNumber = 0;
bytes32 defaultOperatorId = bytes32(uint256(0));

Expand All @@ -24,12 +23,6 @@ contract DelegationTests is EigenLayerTestHelper {

function setUp() public virtual override {
EigenLayerDeployer.setUp();

initializeMiddlewares();
}

function initializeMiddlewares() public {
stakeRegistry = new StakeRegistryStub();
}

/// @notice testing if an operator can register to themselves.
Expand Down
2 changes: 0 additions & 2 deletions src/test/EigenLayerTestHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pragma solidity =0.8.12;
import "../test/EigenLayerDeployer.t.sol";
import "../contracts/interfaces/ISignatureUtils.sol";

import "./mocks/StakeRegistryStub.sol";

contract EigenLayerTestHelper is EigenLayerDeployer {
uint8 durationToInit = 2;
uint256 public SECP256K1N_MODULUS = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141;
Expand Down
11 changes: 0 additions & 11 deletions src/test/Withdrawals.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pragma solidity =0.8.12;

import "../test/EigenLayerTestHelper.t.sol";

import "./mocks/StakeRegistryStub.sol";

contract WithdrawalTests is EigenLayerTestHelper {
// packed info used to help handle stack-too-deep errors
struct DataForTestWithdrawal {
Expand All @@ -15,16 +13,9 @@ contract WithdrawalTests is EigenLayerTestHelper {
}

bytes32 defaultOperatorId = bytes32(uint256(0));
StakeRegistryStub public stakeRegistry;

function setUp() public virtual override {
EigenLayerDeployer.setUp();

initializeMiddlewares();
}

function initializeMiddlewares() public {
stakeRegistry = new StakeRegistryStub();
}

//This function helps with stack too deep issues with "testWithdrawal" test
Expand All @@ -41,8 +32,6 @@ contract WithdrawalTests is EigenLayerTestHelper {
cheats.assume(ethAmount >= 1 && ethAmount <= 1e18);
cheats.assume(eigenAmount >= 1 && eigenAmount <= 1e18);

initializeMiddlewares();

if (RANDAO) {
_testWithdrawalAndDeregistration(operator, depositor, withdrawer, ethAmount, eigenAmount, withdrawAsTokens);
} else {
Expand Down
4 changes: 0 additions & 4 deletions src/test/events/IDelegationManagerEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
pragma solidity =0.8.12;

import "src/contracts/interfaces/IDelegationManager.sol";
import "src/test/mocks/StakeRegistryStub.sol";

interface IDelegationManagerEvents {
/// @notice Emitted when the StakeRegistry is set
event StakeRegistrySet(IStakeRegistryStub stakeRegistry);

// @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails.
event OperatorRegistered(address indexed operator, IDelegationManager.OperatorDetails operatorDetails);

Expand Down
3 changes: 0 additions & 3 deletions src/test/mocks/DelegationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import "../../contracts/interfaces/IStrategyManager.sol";
contract DelegationManagerMock is IDelegationManager, Test {
mapping(address => bool) public isOperator;
mapping(address => mapping(IStrategy => uint256)) public operatorShares;
IStakeRegistryStub public stakeRegistry;

function setStakeRegistry(IStakeRegistryStub _stakeRegistry) external {}

function setIsOperator(address operator, bool _isOperatorReturnValue) external {
isOperator[operator] = _isOperatorReturnValue;
Expand Down
8 changes: 0 additions & 8 deletions src/test/mocks/StakeRegistryStub.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/unit/DelegationUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "src/contracts/core/DelegationManager.sol";
import "src/contracts/strategies/StrategyBase.sol";

import "src/test/events/IDelegationManagerEvents.sol";
import "src/test/mocks/StakeRegistryStub.sol";
import "src/test/utils/EigenLayerUnitTestSetup.sol";

/**
Expand All @@ -27,7 +26,6 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag
StrategyBase strategyMock;
IERC20 mockToken;
uint256 mockTokenInitialSupply = 10e50;
StakeRegistryStub stakeRegistryMock;

// Delegation signer
uint256 delegationSignerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80);
Expand Down Expand Up @@ -85,12 +83,6 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag
)
);

// Deploy mock stake registry and set
stakeRegistryMock = new StakeRegistryStub();
cheats.expectEmit(true, true, true, true, address(delegationManager));
emit StakeRegistrySet(stakeRegistryMock);
delegationManager.setStakeRegistry(stakeRegistryMock);

// Deploy mock token and strategy
mockToken = new ERC20PresetFixedSupply("Mock Token", "MOCK", mockTokenInitialSupply, address(this));
strategyImplementation = new StrategyBase(strategyManagerMock);
Expand Down Expand Up @@ -310,12 +302,6 @@ contract DelegationManagerUnitTests_Initialization_Setters is DelegationManagerU
delegationManager.initialize(address(this), pauserRegistry, 0, initializedWithdrawalDelayBlocks);
}

/// @notice Verifies that the stakeRegistry cannot be set after it has already been set
function test_setStakeRegistry_revert_alreadySet() public {
cheats.expectRevert("DelegationManager.setStakeRegistry: stakeRegistry already set");
delegationManager.setStakeRegistry(stakeRegistryMock);
}

function testFuzz_initialize_Revert_WhenWithdrawalDelayBlocksTooLarge(uint256 withdrawalDelayBlocks) public {
cheats.assume(withdrawalDelayBlocks > MAX_WITHDRAWAL_DELAY_BLOCKS);
// Deploy DelegationManager implmentation and proxy
Expand Down

0 comments on commit ca2cf32

Please sign in to comment.