Skip to content

Commit

Permalink
fix: compilation & tests
Browse files Browse the repository at this point in the history
feat: add multiple admins

fix: dm & alm funcs

feat: update RC interface

chore: format

chore: comment update

fix: avs param

fix: staker bricking

fix: compile

chore: format
  • Loading branch information
ypatil12 committed Nov 11, 2024
1 parent c78c0e1 commit 6216df3
Show file tree
Hide file tree
Showing 20 changed files with 241 additions and 249 deletions.
2 changes: 1 addition & 1 deletion script/deploy/devnet/deploy_from_scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ contract DeployFromScratch is Script, Test {
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();
strategyFactoryImplementation = new StrategyFactory(strategyManager);
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg);

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
{
Expand Down
6 changes: 0 additions & 6 deletions script/deploy/holesky/Deploy_Test_RewardsCoordinator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ contract Deploy_Test_RewardsCoordinator is ExistingDeploymentParser {
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegationManager,
strategyManager,
<<<<<<< HEAD
eigenLayerPauserReg,
=======
permissionController,
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down Expand Up @@ -83,11 +80,8 @@ contract Deploy_Test_RewardsCoordinator is ExistingDeploymentParser {
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegationManager,
strategyManager,
<<<<<<< HEAD
eigenLayerPauserReg,
=======
permissionController,
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
25 changes: 2 additions & 23 deletions script/deploy/local/Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,9 @@ contract DeployFromScratch is Script, Test {

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

<<<<<<< HEAD
<<<<<<< HEAD
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);
=======
delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, MIN_WITHDRAWAL_DELAY);
=======
delegationImplementation = new DelegationManager(avsDirectory, strategyManager, eigenPodManager, allocationManager, permissionController, MIN_WITHDRAWAL_DELAY);
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)
strategyManagerImplementation = new StrategyManager(delegation);
avsDirectoryImplementation = new AVSDirectory(delegation);
>>>>>>> 735d131f (test(wip): avsd passing)
eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit,
eigenPodBeacon,
Expand All @@ -263,27 +253,16 @@ contract DeployFromScratch is Script, Test {
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegation,
strategyManager,
<<<<<<< HEAD
eigenLayerPauserReg,
=======
permissionController,
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)
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
);
<<<<<<< HEAD
<<<<<<< HEAD
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
=======
allocationManagerImplementation = new AllocationManager(delegation, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
>>>>>>> 7d7d800c (test: ALM compiling + but not passing)
=======
allocationManagerImplementation = new AllocationManager(delegation, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
permissionControllerImplementation = new PermissionController();
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
{
Expand Down
3 changes: 0 additions & 3 deletions script/deploy/mainnet/v0.3.0-mainnet-rewards.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ contract MainnetRewardsCoordinatorDeploy is ExistingDeploymentParser {
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegationManager,
strategyManager,
<<<<<<< HEAD
eigenLayerPauserReg,
=======
permissionController,
>>>>>>> 95f8eb86 (fix: compilations; prev tests passing)
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
Expand Down
14 changes: 3 additions & 11 deletions src/contracts/core/AllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract AllocationManager is
constructor(
IDelegationManager _delegation,
IPauserRegistry _pauserRegistry,
IPermissionController _permissionController,
uint32 _DEALLOCATION_DELAY,
uint32 _ALLOCATION_CONFIGURATION_DELAY
)
Expand Down Expand Up @@ -295,21 +296,12 @@ contract AllocationManager is
}

/// @inheritdoc IAllocationManager
<<<<<<< HEAD
function updateAVSMetadataURI(
string calldata metadataURI
) external {
emit AVSMetadataURIUpdated(msg.sender, metadataURI);
function updateAVSMetadataURI(address avs, string calldata metadataURI) external checkCanCall(avs) {
emit AVSMetadataURIUpdated(avs, metadataURI);
}

/// @inheritdoc IAllocationManager
function createOperatorSets(
address avs,
CreateSetParams[] calldata params
) external checkCanCall(avs) {
=======
function createOperatorSets(address avs, CreateSetParams[] calldata params) external checkCanCall(avs) {
>>>>>>> 152ebbc4 (chore: format; fix stack too deep)
for (uint256 i = 0; i < params.length; i++) {
OperatorSet memory operatorSet = OperatorSet(avs, params[i].operatorSetId);

Expand Down
3 changes: 2 additions & 1 deletion src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ contract DelegationManager is
IEigenPodManager _eigenPodManager,
IAllocationManager _allocationManager,
IPauserRegistry _pauserRegistry,
IPermissionController _permissionController,
uint32 _MIN_WITHDRAWAL_DELAY
)
DelegationManagerStorage(
Expand Down Expand Up @@ -149,7 +150,7 @@ contract DelegationManager is
require(staker != address(0), InputAddressZero());
address operator = delegatedTo[staker];
require(
msg.sender == staker || msg.sender == operator
msg.sender == staker || _checkCanCall(operator)
|| msg.sender == _operatorDetails[operator].delegationApprover,
CallerCannotUndelegate()
);
Expand Down
10 changes: 5 additions & 5 deletions src/contracts/core/RewardsCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ contract RewardsCoordinator is
IDelegationManager _delegationManager,
IStrategyManager _strategyManager,
IPauserRegistry _pauserRegistry,
IPermissionController _permissionController,
uint32 _CALCULATION_INTERVAL_SECONDS,
uint32 _MAX_REWARDS_DURATION,
uint32 _MAX_RETROACTIVE_LENGTH,
Expand Down Expand Up @@ -216,18 +217,17 @@ contract RewardsCoordinator is
}

/// @inheritdoc IRewardsCoordinator
function setClaimerForStaker(
function setClaimerFor(
address claimer
) external {
require(!delegationManager.isOperator(msg.sender), UnauthorizedCaller());
address earner = msg.sender;
_setClaimer(earner, claimer);
}

/// @inheritdoc IRewardsCoordinator
function setClaimerForOperator(address operator, address claimer) external checkCanCall(operator) {
require(delegationManager.isOperator(operator), UnauthorizedCaller());
_setClaimer(operator, claimer);
function setClaimerFor(address earner, address claimer) external checkCanCall(earner) {
require(delegationManager.isOperator(earner), EarnerNotOperator());
_setClaimer(earner, claimer);
}

/// @inheritdoc IRewardsCoordinator
Expand Down
37 changes: 12 additions & 25 deletions src/contracts/interfaces/IAllocationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
/**
* @notice Called by an AVS to slash an operator in a given operator set
*/
function slashOperator(
address avs,
SlashingParams calldata params
) external;
function slashOperator(address avs, SlashingParams calldata params) external;

/**
* @notice Modifies the proportions of slashable stake allocated to an operator set from a list of strategies
Expand All @@ -237,10 +234,7 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
* @dev Updates encumberedMagnitude for the updated strategies
* @dev msg.sender is used as operator
*/
function modifyAllocations(
address operator,
AllocateParams[] calldata params
) external;
function modifyAllocations(address operator, AllocateParams[] calldata params) external;

/**
* @notice This function takes a list of strategies and for each strategy, removes from the deallocationQueue
Expand All @@ -265,10 +259,7 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
* @dev After registering within the ALM, this method calls `avs.registerOperator` to complete
* registration. This call MUST succeed in order for registration to be successful.
*/
function registerForOperatorSets(
address operator,
RegisterParams calldata params
) external;
function registerForOperatorSets(address operator, RegisterParams calldata params) external;

/**
* @notice Allows an operator or AVS to deregister the operator from one or more of the AVS's operator sets.
Expand All @@ -288,18 +279,15 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
* @param operator The operator to set the delay on behalf of.
* @param delay the allocation delay in blocks
*/
function setAllocationDelay(address operator, uint32 delay) external;
function setAllocationDelay(address operator, uint32 delay) external;

/**
* @notice Called by an AVS to configure the address that is called when an operator registers
* or is deregistered from the AVS's operator sets. If not set (or set to 0), defaults
* to the AVS's address.
* @param registrar the new registrar address
*/
function setAVSRegistrar(
address avs,
IAVSRegistrar registrar
) external;
function setAVSRegistrar(address avs, IAVSRegistrar registrar) external;

/**
* @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated.
Expand All @@ -308,17 +296,12 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
*
* @dev Note that the `metadataURI` is *never stored* and is only emitted in the `AVSMetadataURIUpdated` event.
*/
function updateAVSMetadataURI(
string calldata metadataURI
) external;
function updateAVSMetadataURI(address avs, string calldata metadataURI) external;

/**
* @notice Allows an AVS to create new operator sets, defining strategies that the operator set uses
*/
function createOperatorSets(
address avs,
CreateSetParams[] calldata params
) external;
function createOperatorSets(address avs, CreateSetParams[] calldata params) external;

/**
* @notice Allows an AVS to add strategies to an operator set
Expand All @@ -336,7 +319,11 @@ interface IAllocationManager is ISignatureUtils, IAllocationManagerErrors, IAllo
* @param operatorSetId the operator set to remove strategies from
* @param strategies the strategies to remove
*/
function removeStrategiesFromOperatorSet(address avs, uint32 operatorSetId, IStrategy[] calldata strategies) external;
function removeStrategiesFromOperatorSet(
address avs,
uint32 operatorSetId,
IStrategy[] calldata strategies
) external;

/**
*
Expand Down
35 changes: 27 additions & 8 deletions src/contracts/interfaces/IPermissionController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pragma solidity ^0.8.27;

interface IPermissionControllerErrors {
/// @notice Thrown when a caller cannot set an admin for a given account
error CannotSetAdmin();
/// @notice Thrown when an admin is set to the zero address
error InvalidAdmin();
/// @notice Thrown when the caller is not the admin
error NotAdmin();
/// @notice Thrown when an admin is set to the zero address
error AdminAlreadySet();
/// @notice Thrown when the admin to remove is not an admin
error AdminNotSet();
/// @notice Thrown when a delegate is already set for the account's function
error DelegateAlreadySet();
/// @notice Thrown when a delegate is not set for the account's function
Expand All @@ -22,17 +22,29 @@ interface IPermissionControllerEvents {
event DelegateRemoved(address indexed account, address indexed delegate, address target, bytes4 selector);

/// @notice Emitted when an admin is set for a given account
event AdminSet(address indexed account, address oldAdmin, address newAdmin);
event AdminSet(address indexed account, address admin);

/// @notice Emitted when an admin is removed for a given account
event AdminRemoved(address indexed account, address admin);
}

interface IPermissionController is IPermissionControllerErrors, IPermissionControllerEvents {
/**
* @notice Set the admin of an account
* @param account to set admin for
* @param admin to set
* @dev Multiple admins can be set for an account
*/
function setAdmin(address account, address admin) external;

/**
* @notice Remove an admin of an account
* @param account to remove admin for
* @param admin to remove
* @dev Only the admin of the account can remove an admin
*/
function removeAdmin(address account, address admin) external;

/**
* @notice Set a delegate for a given account
* @param account to set delegate for
Expand All @@ -50,17 +62,24 @@ interface IPermissionController is IPermissionControllerErrors, IPermissionContr
* @param target to remove delegate for
* @param selector to remove delegate for
* @dev Only the admin of the account can remove a delegate
* @dev If all admins are removed, the original account is now the admin
*/
function removeDelegate(address account, address delegate, address target, bytes4 selector) external;

/**
* @notice Get the admin of an account
* @notice Checks if the given caller is an admin of the account
* @dev If the account has no admin, the caller is checked to be the account itself
*/
function isAdmin(address account, address caller) external view returns (bool);

/**
* @notice Get the admins of an account
* @param account The account to get the admin of
* @dev If the account has no admin, the account itself is returned
*/
function getAdmin(
function getAdmins(
address account
) external view returns (address);
) external view returns (address[] memory);

/**
* @notice Checks if the given caller has permissions to call the fucntion
Expand Down
26 changes: 12 additions & 14 deletions src/contracts/interfaces/IRewardsCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import "./IStrategy.sol";
interface IRewardsCoordinatorErrors {
/// @dev Thrown when msg.sender is not allowed to call a function
error UnauthorizedCaller();
/// @dev Thrown when a earner is not an operator
error EarnerNotOperator();

/// Invalid Inputs

Expand Down Expand Up @@ -276,10 +278,7 @@ interface IRewardsCoordinator is IRewardsCoordinatorErrors, IRewardsCoordinatorE
* @dev This function will revert if the `rewardsSubmission` is malformed,
* e.g. if the `strategies` and `weights` arrays are of non-equal lengths
*/
function createAVSRewardsSubmission(
address avs,
RewardsSubmission[] calldata rewardsSubmissions
) external;
function createAVSRewardsSubmission(address avs, RewardsSubmission[] calldata rewardsSubmissions) external;

/**
* @notice similar to `createAVSRewardsSubmission` except the rewards are split amongst *all* stakers
Expand Down Expand Up @@ -333,24 +332,23 @@ interface IRewardsCoordinator is IRewardsCoordinatorErrors, IRewardsCoordinatorE
) external;

/**
* @notice Sets the address of the entity that can call `processClaim` on behalf of a staker
* @notice Sets the address of the entity that can call `processClaim` on ehalf of an earner
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
* @dev Only callable by the `earner` if it is a staker
* @dev Assumes msg.sender is the earner
*/
function setClaimerForStaker(
function setClaimerFor(
address claimer
) external;

/**
* @notice Sets the address of the entity that can call `processClaim` on behalf of an operator
* @param operator The address to set the claimer for
* @notice Sets the address of the entity that can call `processClaim` on behalf of an earner
* @param earner The address to set the claimer for
* @param claimer The address of the entity that can call `processClaim` on behalf of the earner
* @dev Only callable by or on behalf of an operator.
* @dev Only callable by operators, because we have no way of determining whether an address
* is an AVS via the AVS Directory. Once we deprecate that contract this function
* will be updated to allow AVSs to set their own claimers.
*/
function setClaimerForOperator(
address operator,
address claimer
) external;
function setClaimerFor(address earner, address claimer) external;

/**
* @notice Sets the delay in timestamp before a posted root can be claimed against
Expand Down
Loading

0 comments on commit 6216df3

Please sign in to comment.