Skip to content

Commit

Permalink
feat: natpsec with inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Jan 27, 2025
1 parent 74e90da commit b717632
Show file tree
Hide file tree
Showing 16 changed files with 660 additions and 808 deletions.
6 changes: 3 additions & 3 deletions docs/storage-report/RegistryCoordinator.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
| quorumCount | uint8 | 150 | 0 | 1 | src/RegistryCoordinator.sol:RegistryCoordinator |
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
| _quorumParams | mapping(uint8 => struct IRegistryCoordinatorTypes.OperatorSetParam) | 151 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
| _quorumParams | mapping(uint8 => struct ISlashingRegistryCoordinatorTypes.OperatorSetParam) | 151 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
| _operatorBitmapHistory | mapping(bytes32 => struct IRegistryCoordinatorTypes.QuorumBitmapUpdate[]) | 152 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
| _operatorBitmapHistory | mapping(bytes32 => struct ISlashingRegistryCoordinatorTypes.QuorumBitmapUpdate[]) | 152 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
| _operatorInfo | mapping(address => struct IRegistryCoordinatorTypes.OperatorInfo) | 153 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
| _operatorInfo | mapping(address => struct ISlashingRegistryCoordinatorTypes.OperatorInfo) | 153 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
| isChurnApproverSaltUsed | mapping(bytes32 => bool) | 154 | 0 | 32 | src/RegistryCoordinator.sol:RegistryCoordinator |
|-----------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------------------|
Expand Down
6 changes: 3 additions & 3 deletions docs/storage-report/RegistryCoordinatorStorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
+=============================================================================================================================================================================================+
| quorumCount | uint8 | 0 | 0 | 1 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
|-------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------------------|
| _quorumParams | mapping(uint8 => struct IRegistryCoordinatorTypes.OperatorSetParam) | 1 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
| _quorumParams | mapping(uint8 => struct ISlashingRegistryCoordinatorTypes.OperatorSetParam) | 1 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
|-------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------------------|
| _operatorBitmapHistory | mapping(bytes32 => struct IRegistryCoordinatorTypes.QuorumBitmapUpdate[]) | 2 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
| _operatorBitmapHistory | mapping(bytes32 => struct ISlashingRegistryCoordinatorTypes.QuorumBitmapUpdate[]) | 2 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
|-------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------------------|
| _operatorInfo | mapping(address => struct IRegistryCoordinatorTypes.OperatorInfo) | 3 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
| _operatorInfo | mapping(address => struct ISlashingRegistryCoordinatorTypes.OperatorInfo) | 3 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
|-------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------------------|
| isChurnApproverSaltUsed | mapping(bytes32 => bool) | 4 | 0 | 32 | src/RegistryCoordinatorStorage.sol:RegistryCoordinatorStorage |
|-------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------------------|
Expand Down
31 changes: 22 additions & 9 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";

import {BitmapUtils} from "./libraries/BitmapUtils.sol";
import {SlashingRegistryCoordinator} from "./SlashingRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";


/**
* @title A `RegistryCoordinator` that has three registries:
Expand All @@ -21,7 +24,7 @@ import {SlashingRegistryCoordinator} from "./SlashingRegistryCoordinator.sol";
*
* @author Layr Labs, Inc.
*/
contract RegistryCoordinator is SlashingRegistryCoordinator {
contract RegistryCoordinator is IRegistryCoordinator, SlashingRegistryCoordinator {
using BitmapUtils for *;

/// @notice the ServiceManager for this AVS, which forwards calls onto EigenLayer's core contracts
Expand Down Expand Up @@ -52,7 +55,7 @@ contract RegistryCoordinator is SlashingRegistryCoordinator {
*
*/

// /// @inheritdoc IRegistryCoordinator
/// @inheritdoc IRegistryCoordinator
function registerOperator(
bytes memory quorumNumbers,
string memory socket,
Expand Down Expand Up @@ -100,7 +103,7 @@ contract RegistryCoordinator is SlashingRegistryCoordinator {
}
}

// /// @inheritdoc IRegistryCoordinator
/// @inheritdoc IRegistryCoordinator
function registerOperatorWithChurn(
bytes calldata quorumNumbers,
string memory socket,
Expand Down Expand Up @@ -140,34 +143,34 @@ contract RegistryCoordinator is SlashingRegistryCoordinator {
}
}

// /// @inheritdoc IRegistryCoordinator
/// @inheritdoc IRegistryCoordinator
function deregisterOperator(
bytes memory quorumNumbers
) external onlyWhenNotPaused(PAUSED_DEREGISTER_OPERATOR) {
) external override onlyWhenNotPaused(PAUSED_DEREGISTER_OPERATOR) {
// Check that the quorum numbers are M2 quorums
for (uint256 i = 0; i < quorumNumbers.length; i++) {
require(
!operatorSetsEnabled || _isM2Quorum(uint8(quorumNumbers[i])),
OperatorSetsAlreadyEnabled()
OperatorSetQuorum()
);
}
_deregisterOperator({operator: msg.sender, quorumNumbers: quorumNumbers});
}

// /// @inheritdoc IRegistryCoordinator
/// @inheritdoc IRegistryCoordinator
function enableOperatorSets() external onlyOwner {
require(!operatorSetsEnabled, OperatorSetsAlreadyEnabled());

// Set the bitmap for M2 quorums
M2quorumBitmap = _getQuorumBitmap(quorumCount);
uint256 M2quorumBitmap = _getQuorumBitmap(quorumCount);

// Enable operator sets mode
operatorSetsEnabled = true;

emit OperatorSetsEnabled();
}

// /// @inheritdoc IRegistryCoordinator
/// @inheritdoc IRegistryCoordinator
function disableM2QuorumRegistration() external onlyOwner {
require(operatorSetsEnabled, OperatorSetsNotEnabled());

Expand Down Expand Up @@ -203,4 +206,14 @@ contract RegistryCoordinator is SlashingRegistryCoordinator {
// This is a safe operation since we limit MAX_QUORUM_COUNT to 192
return (1 << quorumCount) - 1;
}

/// @dev need to override function here since its defined in both these contracts
function owner()
public
view
override(SlashingRegistryCoordinator, ISlashingRegistryCoordinator)
returns (address)
{
return OwnableUpgradeable.owner();
}
}
6 changes: 3 additions & 3 deletions src/SlashingRegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ contract SlashingRegistryCoordinator is
Pausable,
OwnableUpgradeable,
SlashingRegistryCoordinatorStorage,
IAVSRegistrar,
ISignatureUtils
{
using BitmapUtils for *;
Expand Down Expand Up @@ -160,7 +159,7 @@ contract SlashingRegistryCoordinator is
address operator,
uint32[] memory operatorSetIds,
bytes calldata data
) external onlyAllocationManager onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
) external override onlyAllocationManager onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
require(operatorSetsEnabled, OperatorSetsNotEnabled());
bytes memory quorumNumbers = _getQuorumNumbers(operatorSetIds);

Expand Down Expand Up @@ -240,7 +239,7 @@ contract SlashingRegistryCoordinator is
function deregisterOperator(
address operator,
uint32[] memory operatorSetIds
) external onlyAllocationManager onlyWhenNotPaused(PAUSED_DEREGISTER_OPERATOR) {
) external override onlyAllocationManager onlyWhenNotPaused(PAUSED_DEREGISTER_OPERATOR) {
require(operatorSetsEnabled, OperatorSetsNotEnabled());
bytes memory quorumNumbers = _getQuorumNumbers(operatorSetIds);
_deregisterOperator(operator, quorumNumbers);
Expand Down Expand Up @@ -1121,6 +1120,7 @@ contract SlashingRegistryCoordinator is
function owner()
public
view
virtual
override(OwnableUpgradeable, ISlashingRegistryCoordinator)
returns (address)
{
Expand Down
Loading

0 comments on commit b717632

Please sign in to comment.