Skip to content

Commit

Permalink
feat: unified access management
Browse files Browse the repository at this point in the history
fix: test/compile
  • Loading branch information
ypatil12 committed Nov 11, 2024
1 parent bf0e200 commit f1eb96e
Show file tree
Hide file tree
Showing 37 changed files with 1,350 additions and 284 deletions.
11 changes: 1 addition & 10 deletions docs/release/slashing/AllocationManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ The AllocationManager contract manages the allocation and reallocation of operat

```solidity
/**
* @notice Called by the delagation manager to set delay when operators register.
* @notice Called by operators or the delegation manager to set their allocation delay.
* @param operator The operator to set the delay on behalf of.
* @param delay The allocation delay in seconds.
* @dev msg.sender is assumed to be the delegation manager.
*/
function setAllocationDelay(address operator, uint32 delay) external;
/**
* @notice Called by operators to set their allocation delay.
* @param delay the allocation delay in seconds
* @dev msg.sender is assumed to be the operator
*/
function setAllocationDelay(uint32 delay) external;
```

These functions allow operators to set their allocation delay. The first variant is called by the DelegationManager upon operator registration for all new operators created after the slashing release. The second variant is called by operators themselves to update their allocation delay or set it for the first time if they joined before the slashing release.
The allocation delay takes effect in `ALLOCATION_CONFIGURATION_DELAY` seconds.
Expand Down
20 changes: 18 additions & 2 deletions script/deploy/devnet/deploy_from_scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "../../../src/contracts/core/DelegationManager.sol";
import "../../../src/contracts/core/AVSDirectory.sol";
import "../../../src/contracts/core/RewardsCoordinator.sol";
import "../../../src/contracts/core/AllocationManager.sol";
import "../../../src/contracts/permissions/PermissionController.sol";

import "../../../src/contracts/strategies/StrategyBaseTVLLimits.sol";
import "../../../src/contracts/strategies/StrategyFactory.sol";
Expand Down Expand Up @@ -60,6 +61,8 @@ contract DeployFromScratch is Script, Test {
StrategyBase public baseStrategyImplementation;
AllocationManager public allocationManagerImplementation;
AllocationManager public allocationManager;
PermissionController public permissionController;
PermissionController public permissionControllerImplementation;

EmptyContract public emptyContract;

Expand Down Expand Up @@ -210,6 +213,9 @@ contract DeployFromScratch is Script, Test {
strategyFactory = StrategyFactory(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
permissionController = PermissionController(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// if on mainnet, use the ETH2 deposit contract address
if (chainId == 1) {
Expand All @@ -228,7 +234,7 @@ contract DeployFromScratch is Script, Test {

// Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs

delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, MIN_WITHDRAWAL_DELAY);
delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, MIN_WITHDRAWAL_DELAY);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg);
eigenPodManagerImplementation = new EigenPodManager(
Expand All @@ -242,13 +248,15 @@ contract DeployFromScratch is Script, Test {
delegation,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg);

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
Expand Down Expand Up @@ -310,6 +318,14 @@ contract DeployFromScratch is Script, Test {
)
);

eigenLayerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(permissionController))),
address(permissionControllerImplementation),
abi.encodeWithSelector(
PermissionController.initialize.selector
)
);

// Deploy strategyFactory & base
// Create base strategy implementation
baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg);
Expand Down
3 changes: 3 additions & 0 deletions script/deploy/holesky/Deploy_Test_RewardsCoordinator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ contract Deploy_Test_RewardsCoordinator is ExistingDeploymentParser {
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down Expand Up @@ -80,6 +81,7 @@ contract Deploy_Test_RewardsCoordinator is ExistingDeploymentParser {
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down Expand Up @@ -121,6 +123,7 @@ contract Deploy_Test_RewardsCoordinator is ExistingDeploymentParser {
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
13 changes: 11 additions & 2 deletions script/deploy/holesky/M2_Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {

eigenPodBeacon = new UpgradeableBeacon(address(eigenPodImplementation));
avsDirectoryImplementation = new AVSDirectory(delegationManager, eigenLayerPauserReg);
delegationManagerImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, MIN_WITHDRAWAL_DELAY);
delegationManagerImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, MIN_WITHDRAWAL_DELAY);
strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg);
eigenPodManagerImplementation = new EigenPodManager(
IETHPOSDeposit(ETHPOSDepositAddress),
Expand All @@ -86,7 +86,8 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {
delegationManager,
eigenLayerPauserReg
);
allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();

// Third, upgrade the proxy contracts to point to the implementations
IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0);
Expand Down Expand Up @@ -150,6 +151,14 @@ contract M2_Deploy_Holesky_From_Scratch is ExistingDeploymentParser {
ALLOCATION_MANAGER_INIT_PAUSED_STATUS
)
);
// PermissionController
eigenLayerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(permissionController))),
address(permissionControllerImplementation),
abi.encodeWithSelector(
PermissionController.initialize.selector
)
);

// Deploy Strategies
baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager, eigenLayerPauserReg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contract Upgrade_Testnet_RewardsCoordinator is Deploy_Test_RewardsCoordinator, T
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
20 changes: 18 additions & 2 deletions script/deploy/local/Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "../../../src/contracts/core/DelegationManager.sol";
import "../../../src/contracts/core/AVSDirectory.sol";
import "../../../src/contracts/core/RewardsCoordinator.sol";
import "../../../src/contracts/core/AllocationManager.sol";
import "../../../src/contracts/permissions/PermissionController.sol";

import "../../../src/contracts/strategies/StrategyBaseTVLLimits.sol";

Expand Down Expand Up @@ -63,6 +64,8 @@ contract DeployFromScratch is Script, Test {
StrategyBase public baseStrategyImplementation;
AllocationManager public allocationManagerImplementation;
AllocationManager public allocationManager;
PermissionController public permissionController;
PermissionController public permissionControllerImplementation;

EmptyContract public emptyContract;

Expand Down Expand Up @@ -216,6 +219,9 @@ contract DeployFromScratch is Script, Test {
allocationManager = AllocationManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
permissionController = PermissionController(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// if on mainnet, use the ETH2 deposit contract address
if (chainId == 1) {
Expand All @@ -234,7 +240,7 @@ contract DeployFromScratch is Script, Test {

// Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs

delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, MIN_WITHDRAWAL_DELAY);
delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, MIN_WITHDRAWAL_DELAY);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg);
eigenPodManagerImplementation = new EigenPodManager(
Expand All @@ -248,13 +254,15 @@ contract DeployFromScratch is Script, Test {
delegation,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
{
Expand Down Expand Up @@ -320,6 +328,14 @@ contract DeployFromScratch is Script, Test {
)
);

eigenLayerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(permissionController))),
address(permissionControllerImplementation),
abi.encodeWithSelector(
PermissionController.initialize.selector
)
);

// deploy StrategyBaseTVLLimits contract implementation
baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager, eigenLayerPauserReg);
// create upgradeable proxies that each point to the implementation and initialize them
Expand Down
18 changes: 16 additions & 2 deletions script/deploy/local/deploy_from_scratch.slashing.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "../../../src/contracts/core/DelegationManager.sol";
import "../../../src/contracts/core/AVSDirectory.sol";
import "../../../src/contracts/core/RewardsCoordinator.sol";
import "../../../src/contracts/core/AllocationManager.sol";
import "../../../src/contracts/permissions/PermissionController.sol";

import "../../../src/contracts/strategies/StrategyBaseTVLLimits.sol";

Expand Down Expand Up @@ -63,6 +64,8 @@ contract DeployFromScratch is Script, Test {
StrategyBase public baseStrategyImplementation;
AllocationManager public allocationManagerImplementation;
AllocationManager public allocationManager;
PermissionController public permissionControllerImplementation;
PermissionController public permissionController;

EmptyContract public emptyContract;

Expand Down Expand Up @@ -217,6 +220,9 @@ contract DeployFromScratch is Script, Test {
allocationManager = AllocationManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
permissionController = PermissionController(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// if on mainnet, use the ETH2 deposit contract address
if (chainId == 1) {
Expand All @@ -235,7 +241,7 @@ contract DeployFromScratch is Script, Test {

// Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs

delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, MIN_WITHDRAWAL_DELAY);
delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, MIN_WITHDRAWAL_DELAY);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg);
eigenPodManagerImplementation = new EigenPodManager(
Expand All @@ -249,13 +255,15 @@ contract DeployFromScratch is Script, Test {
delegation,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
{
Expand Down Expand Up @@ -321,6 +329,12 @@ contract DeployFromScratch is Script, Test {
)
);

eigenLayerProxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(permissionController))),
address(permissionControllerImplementation),
abi.encodeWithSelector(PermissionController.initialize.selector)
);

// deploy StrategyBaseTVLLimits contract implementation
baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager, eigenLayerPauserReg);
// create upgradeable proxies that each point to the implementation and initialize them
Expand Down
2 changes: 2 additions & 0 deletions script/deploy/mainnet/v0.3.0-mainnet-rewards.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ contract MainnetRewardsCoordinatorDeploy is ExistingDeploymentParser {
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down Expand Up @@ -86,6 +87,7 @@ contract MainnetRewardsCoordinatorDeploy is ExistingDeploymentParser {
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ contract Upgrade_Mainnet_RewardsCoordinator is ExistingDeploymentParser, Timeloc
delegationManager,
strategyManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
2 changes: 1 addition & 1 deletion script/tasks/allocate_operatorSet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract AllocateOperatorSet is Script, Test {
});

// Perform allocation
am.modifyAllocations(allocations);
am.modifyAllocations(msg.sender, allocations);

// STOP RECORDING TRANSACTIONS FOR DEPLOYMENT
vm.stopBroadcast();
Expand Down
8 changes: 4 additions & 4 deletions script/tasks/register_operator_to_operatorSet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ contract RegisterOperatorToOperatorSets is Script, Test {
operatorSetId: 1,
strategies: strategies
});
allocationManager.createOperatorSets(sets);
allocationManager.createOperatorSets(msg.sender, sets);

// Register the Operator to the AVS
avsDirectory.registerOperatorToAVS(
operator, ISignatureUtils.SignatureWithSaltAndExpiry(abi.encodePacked(r, s, v), bytes32(uint256(0) + 1), expiry)
);

// Deploy and set registrar
allocationManager.setAVSRegistrar(new AVSRegistrar());
// Deploy and set registrar.
allocationManager.setAVSRegistrar(msg.sender, new AVSRegistrar());

// Register OperatorSet(s)
IAllocationManagerTypes.RegisterParams memory register = IAllocationManagerTypes.RegisterParams({
avs: operator,
operatorSetIds: oids,
data: ""
});
allocationManager.registerForOperatorSets(register);
allocationManager.registerForOperatorSets(operator, register);

// STOP RECORDING TRANSACTIONS FOR DEPLOYMENT
vm.stopBroadcast();
Expand Down
2 changes: 1 addition & 1 deletion script/tasks/slash_operatorSet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract SlashOperatorSet is Script, Test {
});

// Perform slashing
am.slashOperator(slashing);
am.slashOperator(operator, slashing);

// STOP RECORDING TRANSACTIONS FOR DEPLOYMENT
vm.stopBroadcast();
Expand Down
3 changes: 3 additions & 0 deletions script/utils/ExistingDeploymentParser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../src/contracts/core/DelegationManager.sol";
import "../../src/contracts/core/AVSDirectory.sol";
import "../../src/contracts/core/RewardsCoordinator.sol";
import "../../src/contracts/core/AllocationManager.sol";
import "../../src/contracts/permissions/PermissionController.sol";

import "../../src/contracts/strategies/StrategyFactory.sol";
import "../../src/contracts/strategies/StrategyBase.sol";
Expand Down Expand Up @@ -64,6 +65,8 @@ contract ExistingDeploymentParser is Script, Test {
AllocationManager public allocationManagerImplementation;
UpgradeableBeacon public strategyBeacon;
StrategyBase public strategyFactoryBeaconImplementation;
PermissionController public permissionController;
PermissionController public permissionControllerImplementation;

// Token
ProxyAdmin public tokenProxyAdmin;
Expand Down
Loading

0 comments on commit f1eb96e

Please sign in to comment.