Skip to content

Commit 435d395

Browse files
committed
validate operator sets
1 parent de09d42 commit 435d395

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/contracts/core/EmissionsController.sol

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ contract EmissionsController is
3030
constructor(
3131
IEigen eigen,
3232
IBackingEigen backingEigen,
33+
IAllocationManager allocationManager,
3334
IRewardsCoordinator rewardsCoordinator,
3435
IPauserRegistry pauserRegistry,
3536
uint256 inflationRate,
3637
uint256 startTime,
3738
uint256 cooldownSeconds
3839
)
39-
EmissionsControllerStorage(eigen, backingEigen, rewardsCoordinator, inflationRate, startTime, cooldownSeconds)
40+
EmissionsControllerStorage(
41+
eigen, backingEigen, allocationManager, rewardsCoordinator, inflationRate, startTime, cooldownSeconds
42+
)
4043
Pausable(pauserRegistry)
4144
{
4245
_disableInitializers();
@@ -302,7 +305,17 @@ contract EmissionsController is
302305
Distribution calldata distribution,
303306
uint256 currentEpoch,
304307
uint256 totalWeightBefore
305-
) internal pure {
308+
) internal view {
309+
// Check if the operator set is registered (for OperatorSetTotalStake or OperatorSetUniqueStake distributions).
310+
if (
311+
distribution.distributionType == DistributionType.OperatorSetTotalStake
312+
|| distribution.distributionType == DistributionType.OperatorSetUniqueStake
313+
) {
314+
if (!ALLOCATION_MANAGER.isOperatorSet(distribution.operatorSet)) {
315+
revert OperatorSetNotRegistered();
316+
}
317+
}
318+
306319
// Check if the start epoch is in the future.
307320
// Prevents updating a distribution to a past or current epoch.
308321
if (currentEpoch != type(uint256).max) {

src/contracts/core/storage/EmissionsControllerStorage.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ abstract contract EmissionsControllerStorage is IEmissionsController {
1919
IEigen public immutable override EIGEN;
2020
/// @dev The backing Eigen token that will be minted for emissions.
2121
IBackingEigen public immutable override BACKING_EIGEN;
22+
/// @dev The AllocationManager contract for managing operator sets.
23+
IAllocationManager public immutable override ALLOCATION_MANAGER;
2224
/// @dev The RewardsCoordinator contract for submitting rewards.
2325
IRewardsCoordinator public immutable override REWARDS_COORDINATOR;
2426

@@ -46,13 +48,15 @@ abstract contract EmissionsControllerStorage is IEmissionsController {
4648
constructor(
4749
IEigen eigen,
4850
IBackingEigen backingEigen,
51+
IAllocationManager allocationManager,
4952
IRewardsCoordinator rewardsCoordinator,
5053
uint256 inflationRate,
5154
uint256 startTime,
5255
uint256 epochLength
5356
) {
5457
EIGEN = eigen;
5558
BACKING_EIGEN = backingEigen;
59+
ALLOCATION_MANAGER = allocationManager;
5660
REWARDS_COORDINATOR = rewardsCoordinator;
5761

5862
EMISSIONS_INFLATION_RATE = inflationRate;

src/contracts/interfaces/IEmissionsController.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ interface IEmissionsControllerErrors {
2525
error InvalidDistributionType();
2626
/// @dev Thrown when rewards submissions array is empty for a distribution that requires it.
2727
error RewardsSubmissionsCannotBeEmpty();
28+
/// @dev Thrown when the operator set is not registered.
29+
error OperatorSetNotRegistered();
2830
}
2931

3032
/// @title IEmissionsControllerTypes
@@ -128,6 +130,10 @@ interface IEmissionsController is IEmissionsControllerErrors, IEmissionsControll
128130
/// @dev Immutable/constant variable that requires an upgrade to modify.
129131
function BACKING_EIGEN() external view returns (IBackingEigen);
130132

133+
/// @notice The AllocationManager address.
134+
/// @dev Immutable/constant variable that requires an upgrade to modify.
135+
function ALLOCATION_MANAGER() external view returns (IAllocationManager);
136+
131137
/// @notice The RewardsCoordinator address.
132138
/// @dev Immutable/constant variable that requires an upgrade to modify.
133139
function REWARDS_COORDINATOR() external view returns (IRewardsCoordinator);

src/test/unit/EmissionsControllerUnit.t.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ contract EmissionsControllerUnitTests is EigenLayerUnitTestSetup, IEmissionsCont
2525
new EmissionsController(
2626
IEigen(address(eigenMock)),
2727
IBackingEigen(address(backingEigenMock)),
28+
IAllocationManager(address(allocationManagerMock)),
2829
IRewardsCoordinator(address(rewardsCoordinatorMock)),
2930
IPauserRegistry(address(pauserRegistry)),
3031
EMISSIONS_INFLATION_RATE,

0 commit comments

Comments
 (0)