Skip to content

Commit

Permalink
chore: remove ServiceManagerBase and add RegistryCoordinator owner (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc authored and steven committed Dec 18, 2023
1 parent 02555d6 commit bbea0db
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 471 deletions.
29 changes: 14 additions & 15 deletions src/BLSSignatureChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity =0.8.12;
import {IBLSSignatureChecker} from "src/interfaces/IBLSSignatureChecker.sol";
import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
import {IBLSApkRegistry} from "src/interfaces/IBLSApkRegistry.sol";
import {IStakeRegistry, IDelegationManager, IServiceManager} from "src/interfaces/IStakeRegistry.sol";
import {IStakeRegistry, IDelegationManager} from "src/interfaces/IStakeRegistry.sol";

import {BitmapUtils} from "src/libraries/BitmapUtils.sol";
import {BN254} from "src/libraries/BN254.sol";
Expand All @@ -27,12 +27,11 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
IStakeRegistry public immutable stakeRegistry;
IBLSApkRegistry public immutable blsApkRegistry;
IDelegationManager public immutable delegation;
IServiceManager public immutable serviceManager;
/// @notice If true, check the staleness of the operator stakes and that its within the delegation withdrawalDelayBlocks window.
bool public staleStakesForbidden;

modifier onlyServiceManagerOwner {
require(msg.sender == serviceManager.owner(), "BLSSignatureChecker.onlyServiceManagerOwner: caller is not the service manager owner");
modifier onlyCoordinatorOwner() {
require(msg.sender == registryCoordinator.owner(), "BLSSignatureChecker.onlyCoordinatorOwner: caller is not the owner of the registryCoordinator");
_;
}

Expand All @@ -41,10 +40,20 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
stakeRegistry = _registryCoordinator.stakeRegistry();
blsApkRegistry = _registryCoordinator.blsApkRegistry();
delegation = stakeRegistry.delegation();
serviceManager = stakeRegistry.serviceManager();

staleStakesForbidden = true;
}

/**
* RegistryCoordinator owner can either enforce or not that operator stakes are staler
* than the delegation.withdrawalDelayBlocks() window.
* @param value to toggle staleStakesForbidden
*/
function setStaleStakesForbidden(bool value) external onlyCoordinatorOwner {
staleStakesForbidden = value;
emit StaleStakesForbiddenUpdate(value);
}

/**
* @notice This function is called by disperser when it has aggregated all the signatures of the operators
* that are part of the quorum for a particular taskNumber and is asserting them into onchain. The function
Expand Down Expand Up @@ -220,14 +229,4 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
PAIRING_EQUALITY_CHECK_GAS
);
}

/**
* ServiceManager owner can either enforce or not that operator stakes are staler
* than the delegation.withdrawalDelayBlocks() window.
* @param value to toggle staleStakesForbidden
*/
function setStaleStakesForbidden(bool value) external onlyServiceManagerOwner {
staleStakesForbidden = value;
emit StaleStakesForbiddenUpdate(value);
}
}
52 changes: 33 additions & 19 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;

import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";

Expand All @@ -12,7 +13,6 @@ import {ISlasher} from "eigenlayer-contracts/src/contracts/interfaces/ISlasher.s
import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
import {IBLSApkRegistry} from "src/interfaces/IBLSApkRegistry.sol";
import {IServiceManager} from "src/interfaces/IServiceManager.sol";
import {ISocketUpdater} from "src/interfaces/ISocketUpdater.sol";
import {IStakeRegistry} from "src/interfaces/IStakeRegistry.sol";
import {IIndexRegistry} from "src/interfaces/IIndexRegistry.sol";
Expand All @@ -28,7 +28,15 @@ import {BN254} from "src/libraries/BN254.sol";
*
* @author Layr Labs, Inc.
*/
contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISocketUpdater, ISignatureUtils, Pausable {
contract RegistryCoordinator is
EIP712,
Initializable,
Pausable,
OwnableUpgradeable,
IRegistryCoordinator,
ISocketUpdater,
ISignatureUtils
{
using BitmapUtils for *;
using BN254 for BN254.G1Point;

Expand All @@ -52,8 +60,6 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo

/// @notice the EigenLayer Slasher
ISlasher public immutable slasher;
/// @notice the Service Manager for the service that this contract is coordinating
IServiceManager public immutable serviceManager;
/// @notice the BLS Aggregate Pubkey Registry contract that will keep track of operators' aggregate BLS public keys per quorum
IBLSApkRegistry public immutable blsApkRegistry;
/// @notice the Stake Registry contract that will keep track of operators' stakes
Expand Down Expand Up @@ -82,11 +88,6 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
/// @notice the address of the entity allowed to eject operators from the AVS
address public ejector;

modifier onlyServiceManagerOwner {
require(msg.sender == serviceManager.owner(), "RegistryCoordinator.onlyServiceManagerOwner: caller is not the service manager owner");
_;
}

modifier onlyEjector {
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
_;
Expand All @@ -102,19 +103,20 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo

constructor(
ISlasher _slasher,
IServiceManager _serviceManager,
IStakeRegistry _stakeRegistry,
IBLSApkRegistry _blsApkRegistry,
IIndexRegistry _indexRegistry
) EIP712("AVSRegistryCoordinator", "v0.0.1") {
slasher = _slasher;
serviceManager = _serviceManager;
stakeRegistry = _stakeRegistry;
blsApkRegistry = _blsApkRegistry;
indexRegistry = _indexRegistry;

_disableInitializers();
}

function initialize(
address _initialOwner,
address _churnApprover,
address _ejector,
IPauserRegistry _pauserRegistry,
Expand All @@ -129,6 +131,7 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
);

// Initialize roles
_transferOwnership(_initialOwner);
_initializePauser(_pauserRegistry, _initialPausedStatus);
_setChurnApprover(_churnApprover);
_setEjector(_ejector);
Expand Down Expand Up @@ -377,7 +380,7 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
}

/*******************************************************************************
EXTERNAL FUNCTIONS - SERVICE MANAGER OWNER
EXTERNAL FUNCTIONS - OWNER
*******************************************************************************/

/**
Expand All @@ -387,38 +390,38 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
OperatorSetParam memory operatorSetParams,
uint96 minimumStake,
IStakeRegistry.StrategyParams[] memory strategyParams
) external virtual onlyServiceManagerOwner {
) external virtual onlyOwner {
_createQuorum(operatorSetParams, minimumStake, strategyParams);
}

/**
* @notice Updates a quorum's OperatorSetParams
* @param quorumNumber is the quorum number to set the maximum number of operators for
* @param operatorSetParams is the parameters of the operator set for the `quorumNumber`
* @dev only callable by the service manager owner
* @dev only callable by the owner
*/
function setOperatorSetParams(
uint8 quorumNumber,
OperatorSetParam memory operatorSetParams
) external onlyServiceManagerOwner quorumExists(quorumNumber) {
) external onlyOwner quorumExists(quorumNumber) {
_setOperatorSetParams(quorumNumber, operatorSetParams);
}

/**
* @notice Sets the churnApprover
* @param _churnApprover is the address of the churnApprover
* @dev only callable by the service manager owner
* @dev only callable by the owner
*/
function setChurnApprover(address _churnApprover) external onlyServiceManagerOwner {
function setChurnApprover(address _churnApprover) external onlyOwner {
_setChurnApprover(_churnApprover);
}

/**
* @notice Sets the ejector
* @param _ejector is the address of the ejector
* @dev only callable by the service manager owner
* @dev only callable by the owner
*/
function setEjector(address _ejector) external onlyServiceManagerOwner {
function setEjector(address _ejector) external onlyOwner {
_setEjector(_ejector);
}

Expand Down Expand Up @@ -832,6 +835,7 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
return _hashTypedDataV4(keccak256(abi.encode(OPERATOR_CHURN_APPROVAL_TYPEHASH, registeringOperatorId, operatorKickParams, salt, expiry)));
}

<<<<<<< HEAD
/**
* @notice Returns the message hash that an operator must sign to register their BLS public key.
* @param operator is the address of the operator registering their BLS public key
Expand All @@ -842,5 +846,15 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
keccak256(abi.encode(PUBKEY_REGISTRATION_TYPEHASH, operator))
)
);
=======
/// @dev need to override function here since its defined in both these contracts
function owner()
public
view
override(OwnableUpgradeable, IRegistryCoordinator)
returns (address)
{
return OwnableUpgradeable.owner();
>>>>>>> ecf7849 (chore: remove ServiceManagerBase and add RegistryCoordinator owner (#98))
}
}
91 changes: 0 additions & 91 deletions src/ServiceManagerBase.sol

This file was deleted.

18 changes: 8 additions & 10 deletions src/StakeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/
import {StakeRegistryStorage} from "src/StakeRegistryStorage.sol";

import {IRegistryCoordinator} from "src/interfaces/IRegistryCoordinator.sol";
import {IServiceManager} from "src/interfaces/IServiceManager.sol";
import {IStakeRegistry} from "src/interfaces/IStakeRegistry.sol";

import {BitmapUtils} from "src/libraries/BitmapUtils.sol";
Expand All @@ -30,8 +29,8 @@ contract StakeRegistry is StakeRegistryStorage {
_;
}

modifier onlyServiceManagerOwner() {
require(msg.sender == serviceManager.owner(), "StakeRegistry.onlyServiceManagerOwner: caller is not the owner of the serviceManager");
modifier onlyCoordinatorOwner() {
require(msg.sender == registryCoordinator.owner(), "StakeRegistry.onlyCoordinatorOwner: caller is not the owner of the registryCoordinator");
_;
}

Expand All @@ -42,9 +41,8 @@ contract StakeRegistry is StakeRegistryStorage {

constructor(
IRegistryCoordinator _registryCoordinator,
IDelegationManager _delegationManager,
IServiceManager _serviceManager
) StakeRegistryStorage(_registryCoordinator, _delegationManager, _serviceManager) {}
IDelegationManager _delegationManager
) StakeRegistryStorage(_registryCoordinator, _delegationManager) {}

/*******************************************************************************
EXTERNAL FUNCTIONS - REGISTRY COORDINATOR
Expand Down Expand Up @@ -208,7 +206,7 @@ contract StakeRegistry is StakeRegistryStorage {
function setMinimumStakeForQuorum(
uint8 quorumNumber,
uint96 minimumStake
) public virtual onlyServiceManagerOwner quorumExists(quorumNumber) {
) public virtual onlyCoordinatorOwner quorumExists(quorumNumber) {
_setMinimumStakeForQuorum(quorumNumber, minimumStake);
}

Expand All @@ -221,7 +219,7 @@ contract StakeRegistry is StakeRegistryStorage {
function addStrategies(
uint8 quorumNumber,
StrategyParams[] memory _strategyParams
) public virtual onlyServiceManagerOwner quorumExists(quorumNumber) {
) public virtual onlyCoordinatorOwner quorumExists(quorumNumber) {
_addStrategyParams(quorumNumber, _strategyParams);
}

Expand All @@ -233,7 +231,7 @@ contract StakeRegistry is StakeRegistryStorage {
function removeStrategies(
uint8 quorumNumber,
uint256[] memory indicesToRemove
) public virtual onlyServiceManagerOwner quorumExists(quorumNumber) {
) public virtual onlyCoordinatorOwner quorumExists(quorumNumber) {
uint256 toRemoveLength = indicesToRemove.length;
require(toRemoveLength > 0, "StakeRegistry.removeStrategies: no indices to remove provided");

Expand All @@ -259,7 +257,7 @@ contract StakeRegistry is StakeRegistryStorage {
uint8 quorumNumber,
uint256[] calldata strategyIndices,
uint96[] calldata newMultipliers
) public virtual onlyServiceManagerOwner quorumExists(quorumNumber) {
) public virtual onlyCoordinatorOwner quorumExists(quorumNumber) {
uint256 numStrats = strategyIndices.length;
require(numStrats > 0, "StakeRegistry.modifyStrategyParams: no strategy indices provided");
require(newMultipliers.length == numStrats, "StakeRegistry.modifyStrategyParams: input length mismatch");
Expand Down
Loading

0 comments on commit bbea0db

Please sign in to comment.