Skip to content

Commit

Permalink
chore: remove maxPods (#463)
Browse files Browse the repository at this point in the history
* chore: remove maxPods

* docs: update docs

* refactor: set to private
  • Loading branch information
8sunyuan authored Mar 13, 2024
1 parent 9ac0ef8 commit 3ba2b34
Show file tree
Hide file tree
Showing 16 changed files with 7 additions and 195 deletions.
1 change: 0 additions & 1 deletion certora/specs/pods/EigenPodManager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ methods {
function slasher() external returns (address) envfree;
function hasPod(address podOwner) external returns (bool) envfree;
function numPods() external returns (uint256) envfree;
function maxPods() external returns (uint256) envfree;
function podOwnerShares(address podOwner) external returns (int256) envfree;
function beaconChainETHStrategy() external returns (address) envfree;

Expand Down
15 changes: 0 additions & 15 deletions docs/core/EigenPodManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,24 +527,9 @@ This method loops over up to `maxNumberOfDelayedWithdrawalsToClaim` withdrawals,

### System Configuration

* [`EigenPodManager.setMaxPods`](#eigenpodmanagersetmaxpods)
* [`EigenPodManager.updateBeaconChainOracle`](#eigenpodmanagerupdatebeaconchainoracle)
* [`DelayedWithdrawalRouter.setWithdrawalDelayBlocks`](#delayedwithdrawalroutersetwithdrawaldelayblocks)

#### `EigenPodManager.setMaxPods`

```solidity
function setMaxPods(uint256 newMaxPods) external onlyUnpauser
```

Allows the unpauser to update the maximum number of `EigenPods` that the `EigenPodManager` can create.

*Effects*:
* Updates `EigenPodManager.maxPods`

*Requirements*:
* Caller MUST be the unpauser

#### `EigenPodManager.updateBeaconChainOracle`

```solidity
Expand Down
6 changes: 1 addition & 5 deletions script/deploy/mainnet/M2Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ contract M2Deploy is Script, Test {
uint256 public withdrawalDelayBlocks;
bytes32 public delegationManagerDomainSeparator;
uint256 public numPods;
uint256 public maxPods;

// Pointers to pre-upgrade values for lstDepositor
address public lstDepositor;
Expand Down Expand Up @@ -122,7 +121,6 @@ contract M2Deploy is Script, Test {
withdrawalDelayBlocks = m1StrategyManager(address(strategyManager)).withdrawalDelayBlocks();
delegationManagerDomainSeparator = IDelegationManagerV0(address(delegation)).DOMAIN_SEPARATOR();
numPods = eigenPodManager.numPods();
maxPods = eigenPodManager.maxPods();
delayedWithdrawalRouter = EigenPod(payable(eigenPodBeacon.implementation())).delayedWithdrawalRouter();

// Set chain-specific values
Expand Down Expand Up @@ -277,7 +275,7 @@ contract M2Deploy is Script, Test {
// Call contracts to ensure that all simple view functions return the same values (e.g. the return value of `StrategyManager.delegation()` hasn’t changed)
// StrategyManager: delegation, eigenPodManager, slasher, strategyWhitelister, withdrawalDelayBlocks all unchanged
// DelegationManager: DOMAIN_SEPARATOR, strategyManager, slasher, eigenPodManager all unchanged
// EigenPodManager: ethPOS, eigenPodBeacon, strategyManager, slasher, beaconChainOracle, numPods, maxPods all unchanged
// EigenPodManager: ethPOS, eigenPodBeacon, strategyManager, slasher, beaconChainOracle, numPods all unchanged
// delegationManager is now correct (added immutable)
// Call contracts to make sure they are still “initialized” (ensure that trying to call initializer reverts)
function _verifyStorageSlots() internal view {
Expand Down Expand Up @@ -311,7 +309,6 @@ contract M2Deploy is Script, Test {
"eigenPodManager.beaconChainOracle incorrect"
);
require(eigenPodManager.numPods() == numPods, "eigenPodManager.numPods incorrect");
require(eigenPodManager.maxPods() == maxPods, "eigenPodManager.maxPods incorrect");
require(EigenPodManagerStorage(address(eigenPodManager)).delegationManager() == delegation, "eigenPodManager.delegationManager incorrect");
}

Expand Down Expand Up @@ -339,7 +336,6 @@ contract M2Deploy is Script, Test {

cheats.expectRevert(bytes("Initializable: contract is already initialized"));
EigenPodManager(address(eigenPodManager)).initialize(
0,
IBeaconChainOracle(address(this)),
address(this),
PauserRegistry(address(this)),
Expand Down
4 changes: 2 additions & 2 deletions script/utils/validateStorage/validateUpgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ echo "Comparing storage layouts..."
# Add -k operator if present
if [ ! -k "$1" ]; then
echo "Keeping old storage layout files"
eval "npx ts-node script/upgrade/validateStorage.ts --old onChainLayout.csv --new localLayout.csv --keep"
eval "npx ts-node script/utils/validateStorage/validateStorage.ts --old onChainLayout.csv --new localLayout.csv --keep"
else
eval "npx ts-node script/upgrade/validateStorage.ts --old onChainLayout.csv --new localLayout.csv"
eval "npx ts-node script/utils/validateStorage/validateStorage.ts --old onChainLayout.csv --new localLayout.csv"
fi
6 changes: 0 additions & 6 deletions src/contracts/interfaces/IEigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ interface IEigenPodManager is IPausable {
/// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager
event BeaconChainETHDeposited(address indexed podOwner, uint256 amount);

/// @notice Emitted when `maxPods` value is updated from `previousValue` to `newValue`
event MaxPodsUpdated(uint256 previousValue, uint256 newValue);

/// @notice Emitted when the balance of an EigenPod is updated
event PodSharesUpdated(address indexed podOwner, int256 sharesDelta);

Expand Down Expand Up @@ -107,9 +104,6 @@ interface IEigenPodManager is IPausable {
/// @notice Returns the number of EigenPods that have been created
function numPods() external view returns (uint256);

/// @notice Returns the maximum number of EigenPods that can be created
function maxPods() external view returns (uint256);

/**
* @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy.
* @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can
Expand Down
19 changes: 0 additions & 19 deletions src/contracts/pods/EigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ contract EigenPodManager is
}

function initialize(
uint256 _maxPods,
IBeaconChainOracle _beaconChainOracle,
address initialOwner,
IPauserRegistry _pauserRegistry,
uint256 _initPausedStatus
) external initializer {
_setMaxPods(_maxPods);
_updateBeaconChainOracle(_beaconChainOracle);
_transferOwnership(initialOwner);
_initializePauser(_pauserRegistry, _initPausedStatus);
Expand Down Expand Up @@ -223,15 +221,6 @@ contract EigenPodManager is
ownerToPod[podOwner].withdrawRestakedBeaconChainETH(destination, shares);
}

/**
* Sets the maximum number of pods that can be deployed
* @param newMaxPods The new maximum number of pods that can be deployed
* @dev Callable by the unpauser of this contract
*/
function setMaxPods(uint256 newMaxPods) external onlyUnpauser {
_setMaxPods(newMaxPods);
}

/**
* @notice Updates the oracle contract that provides the beacon chain state root
* @param newBeaconChainOracle is the new oracle contract being pointed to
Expand All @@ -256,8 +245,6 @@ contract EigenPodManager is
// INTERNAL FUNCTIONS

function _deployPod() internal returns (IEigenPod) {
// check that the limit of EigenPods has not been hit, and increment the EigenPod count
require(numPods + 1 <= maxPods, "EigenPodManager._deployPod: pod limit reached");
++numPods;
// create the pod
IEigenPod pod = IEigenPod(
Expand All @@ -281,12 +268,6 @@ contract EigenPodManager is
emit BeaconOracleUpdated(address(newBeaconChainOracle));
}

/// @notice Internal setter for `maxPods` that also emits an event
function _setMaxPods(uint256 _maxPods) internal {
emit MaxPodsUpdated(maxPods, _maxPods);
maxPods = _maxPods;
}

/**
* @notice Calculates the change in a pod owner's delegateable shares as a result of their beacon chain ETH shares changing
* from `sharesBefore` to `sharesAfter`. The key concept here is that negative/"deficit" shares are not delegateable.
Expand Down
5 changes: 3 additions & 2 deletions src/contracts/pods/EigenPodManagerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ abstract contract EigenPodManagerStorage is IEigenPodManager {
/// @notice The number of EigenPods that have been deployed
uint256 public numPods;

/// @notice The maximum number of EigenPods that can be deployed
uint256 public maxPods;
/// @notice Deprecated from old mainnet release. Was initially used to limit growth early on but there is no longer
/// a maximum number of EigenPods that can be deployed.
uint256 private __deprecated_maxPods;

// BEGIN STORAGE VARIABLES ADDED AFTER MAINNET DEPLOYMENT -- DO NOT SUGGEST REORDERING TO CONVENTIONAL ORDER
/**
Expand Down
1 change: 0 additions & 1 deletion src/test/DepositWithdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ contract DepositWithdrawTests is EigenLayerTestHelper {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
type(uint256).max,
beaconChainOracleAddress,
eigenLayerReputedMultisig,
eigenLayerPauserReg,
Expand Down
1 change: 0 additions & 1 deletion src/test/EigenLayerDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ contract EigenLayerDeployer is Operators {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
type(uint256).max, // maxPods
beaconChainOracleAddress,
eigenLayerReputedMultisig,
eigenLayerPauserReg,
Expand Down
82 changes: 0 additions & 82 deletions src/test/EigenPod.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
/// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager
event BeaconChainETHDeposited(address indexed podOwner, uint256 amount);

/// @notice Emitted when `maxPods` value is updated from `previousValue` to `newValue`
event MaxPodsUpdated(uint256 previousValue, uint256 newValue);

// EIGENPOD EVENTS
/// @notice Emitted when an ETH validator stakes via this eigenPod
event EigenPodStaked(bytes pubkey);
Expand Down Expand Up @@ -238,7 +235,6 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
type(uint256).max, // maxPods
beaconChainOracle,
initialOwner,
pauserReg,
Expand Down Expand Up @@ -1334,37 +1330,6 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
require(numPodsAfter == numPodsBefore + 1, "numPods did not increment correctly");
}

// verifies that the `maxPods` variable is enforced on the `EigenPod.stake` function
function test_maxPodsEnforcementOnStake(
bytes calldata _pubkey,
bytes calldata _signature,
bytes32 _depositDataRoot
) public {
// set pod limit to current number of pods
cheats.startPrank(unpauser);
EigenPodManager(address(eigenPodManager)).setMaxPods(EigenPodManager(address(eigenPodManager)).numPods());
cheats.stopPrank();

cheats.startPrank(podOwner);
cheats.expectRevert("EigenPodManager._deployPod: pod limit reached");
eigenPodManager.stake{value: 32 ether}(_pubkey, _signature, _depositDataRoot);
cheats.stopPrank();

// set pod limit to *one more than* current number of pods
cheats.startPrank(unpauser);
EigenPodManager(address(eigenPodManager)).setMaxPods(EigenPodManager(address(eigenPodManager)).numPods() + 1);
cheats.stopPrank();

IEigenPod newPod = eigenPodManager.getPod(podOwner);

cheats.startPrank(podOwner);
// successful call
cheats.expectEmit(true, true, true, true, address(newPod));
emit EigenPodStaked(_pubkey);
eigenPodManager.stake{value: 32 ether}(_pubkey, _signature, _depositDataRoot);
cheats.stopPrank();
}

// verifies that the `numPod` variable increments correctly on a succesful call to the `EigenPod.createPod` function
function test_incrementNumPodsOnCreatePod() public {
uint256 numPodsBefore = EigenPodManager(address(eigenPodManager)).numPods();
Expand All @@ -1379,53 +1344,6 @@ contract EigenPodTests is ProofParsing, EigenPodPausingConstants {
eigenPodManager.createPod();
}

// verifies that the `maxPods` variable is enforced on the `EigenPod.createPod` function
function test_maxPodsEnforcementOnCreatePod() public {
// set pod limit to current number of pods
cheats.startPrank(unpauser);
uint256 previousValue = EigenPodManager(address(eigenPodManager)).maxPods();
uint256 newValue = EigenPodManager(address(eigenPodManager)).numPods();
cheats.expectEmit(true, true, true, true, address(eigenPodManager));
emit MaxPodsUpdated(previousValue, newValue);
EigenPodManager(address(eigenPodManager)).setMaxPods(newValue);
cheats.stopPrank();

cheats.expectRevert("EigenPodManager._deployPod: pod limit reached");
eigenPodManager.createPod();

// set pod limit to *one more than* current number of pods
cheats.startPrank(unpauser);
previousValue = EigenPodManager(address(eigenPodManager)).maxPods();
newValue = EigenPodManager(address(eigenPodManager)).numPods() + 1;
cheats.expectEmit(true, true, true, true, address(eigenPodManager));
emit MaxPodsUpdated(previousValue, newValue);
EigenPodManager(address(eigenPodManager)).setMaxPods(newValue);
cheats.stopPrank();

// successful call
eigenPodManager.createPod();
}

function test_setMaxPods(uint256 newValue) public {
cheats.startPrank(unpauser);
uint256 previousValue = EigenPodManager(address(eigenPodManager)).maxPods();
cheats.expectEmit(true, true, true, true, address(eigenPodManager));
emit MaxPodsUpdated(previousValue, newValue);
EigenPodManager(address(eigenPodManager)).setMaxPods(newValue);
cheats.stopPrank();

require(EigenPodManager(address(eigenPodManager)).maxPods() == newValue, "maxPods value not set correctly");
}

function test_setMaxPods_RevertsWhenNotCalledByUnpauser(address notUnpauser) public fuzzedAddress(notUnpauser) {
cheats.assume(notUnpauser != unpauser);
uint256 newValue = 0;
cheats.startPrank(notUnpauser);
cheats.expectRevert("msg.sender is not permissioned as unpauser");
EigenPodManager(address(eigenPodManager)).setMaxPods(newValue);
cheats.stopPrank();
}

function test_validatorPubkeyToInfo() external {
bytes memory _pubkey = hex"93a0dd04ccddf3f1b419fdebf99481a2182c17d67cf14d32d6e50fc4bf8effc8db4a04b7c2f3a5975c1b9b74e2841888";

Expand Down
4 changes: 0 additions & 4 deletions src/test/events/IEigenPodManagerEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ interface IEigenPodManagerEvents {
/// @notice Emitted to notify that the denebForkTimestamp has been set
event DenebForkTimestampUpdated(uint64 denebForkTimestamp);


/// @notice Emitted to notify the deployment of an EigenPod
event PodDeployed(address indexed eigenPod, address indexed podOwner);

/// @notice Emitted when `maxPods` value is updated from `previousValue` to `newValue`
event MaxPodsUpdated(uint256 previousValue, uint256 newValue);

/// @notice Emitted when the balance of an EigenPod is updated
event PodSharesUpdated(address indexed podOwner, int256 sharesDelta);
}
1 change: 0 additions & 1 deletion src/test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
type(uint).max, // maxPods
address(beaconChainOracle),
eigenLayerReputedMultisig, // initialOwner
pauserRegistry,
Expand Down
3 changes: 0 additions & 3 deletions src/test/mocks/EigenPodManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ contract EigenPodManagerMock is IEigenPodManager, Test {

function numPods() external view returns (uint256) {}

function maxPods() external view returns (uint256) {}


function denebForkTimestamp() external pure returns (uint64) {
return type(uint64).max;
}
Expand Down
7 changes: 0 additions & 7 deletions src/test/tree/EigenPodManagerUnit.tree
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,13 @@
├── when createPod called
│ ├── given the user has already created a pod
│ │ └── it should revert
│ ├── given that the max number of pods has been deployed
│ │ └── it should revert
│ └── given the user has not created a pod
│ └── it should deploy a pod
├── when stake is called
│ ├── given the user has not created a pod
│ │ └── it should deploy a pod
│ └── given the user has already created a pod
│ └── it should call stake on the eigenPod
├── when setMaxPods is called
│ ├── given the user is not the pauser
│ │ └── it should revert
│ └── given the user is the pauser
│ └── it should set the max pods
├── when updateBeaconChainOracle is called
│ ├── given the user is not the owner
│ │ └── it should revert
Expand Down
3 changes: 0 additions & 3 deletions src/test/unit/EigenPod-PodManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ contract EigenPod_PodManager_UnitTests is EigenLayerUnitTestSetup {
address(eigenPodManagerWrapper),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
type(uint256).max /*maxPods*/,
beaconChainOracle,
initialOwner,
pauserRegistry,
Expand Down Expand Up @@ -228,9 +227,7 @@ contract EigenPod_PodManager_UnitTests_EigenPod is EigenPod_PodManager_UnitTests
function test_stake_podAlreadyDeployed(bytes memory signature, bytes32 depositDataRoot) public {
uint256 stakeAmount = 32e18;

uint256 maxPods = eigenPodManager.maxPods();
uint256 numPods = eigenPodManager.numPods();
emit log_named_uint("maxPods", maxPods);
emit log_named_uint("numPods", numPods);

cheats.startPrank(podOwner);
Expand Down
Loading

0 comments on commit 3ba2b34

Please sign in to comment.