Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove ServiceManagerBase and add RegistryCoordinator owner #98

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
51 changes: 32 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 @@ -27,7 +27,15 @@ import {BitmapUtils} from "src/libraries/BitmapUtils.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 *;

/// @notice The EIP-712 typehash for the `DelegationApproval` struct used by the contract
Expand All @@ -48,8 +56,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 @@ -78,11 +84,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 @@ -98,19 +99,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 @@ -125,6 +127,7 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
);

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

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

/**
Expand All @@ -366,38 +369,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 @@ -810,4 +813,14 @@ contract RegistryCoordinator is EIP712, Initializable, IRegistryCoordinator, ISo
// calculate the digest hash
return _hashTypedDataV4(keccak256(abi.encode(OPERATOR_CHURN_APPROVAL_TYPEHASH, registeringOperatorId, operatorKickParams, salt, expiry)));
}

/// @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();
}
}
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