Skip to content

Commit

Permalink
refactor: slashing registry coordinator
Browse files Browse the repository at this point in the history
refactor: registry coordinator

refactor: remove sm calls

fix: tests wip
  • Loading branch information
8sunyuan committed Jan 22, 2025
1 parent 7e8aeff commit 47b560d
Show file tree
Hide file tree
Showing 38 changed files with 4,290 additions and 2,033 deletions.
6 changes: 3 additions & 3 deletions src/BLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.27;

import {BLSApkRegistryStorage} from "./BLSApkRegistryStorage.sol";

import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";

import {BN254} from "./libraries/BN254.sol";

Expand All @@ -18,8 +18,8 @@ contract BLSApkRegistry is BLSApkRegistryStorage {

/// @notice Sets the (immutable) `registryCoordinator` address
constructor(
IRegistryCoordinator _registryCoordinator
) BLSApkRegistryStorage(_registryCoordinator) {}
ISlashingRegistryCoordinator _slashingRegistryCoordinator
) BLSApkRegistryStorage(_slashingRegistryCoordinator) {}

/**
*
Expand Down
8 changes: 3 additions & 5 deletions src/BLSApkRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.27;

import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";

import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";

Expand Down Expand Up @@ -30,10 +30,8 @@ abstract contract BLSApkRegistryStorage is Initializable, IBLSApkRegistry {
/// @notice maps quorumNumber => current aggregate pubkey of quorum
mapping(uint8 => BN254.G1Point) public currentApk;

constructor(
IRegistryCoordinator _registryCoordinator
) {
registryCoordinator = address(_registryCoordinator);
constructor(ISlashingRegistryCoordinator _slashingRegistryCoordinator) {
registryCoordinator = address(_slashingRegistryCoordinator);
// disable initializers so that the implementation contract cannot be initialized
_disableInitializers();
}
Expand Down
8 changes: 3 additions & 5 deletions src/BLSSignatureChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.27;

import {IBLSSignatureChecker} from "./interfaces/IBLSSignatureChecker.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
import {IStakeRegistry, IDelegationManager} from "./interfaces/IStakeRegistry.sol";

Expand All @@ -23,7 +23,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
// gas cost of multiplying 2 pairings
uint256 internal constant PAIRING_EQUALITY_CHECK_GAS = 120_000;

IRegistryCoordinator public immutable registryCoordinator;
ISlashingRegistryCoordinator public immutable registryCoordinator;
IStakeRegistry public immutable stakeRegistry;
IBLSApkRegistry public immutable blsApkRegistry;
IDelegationManager public immutable delegation;
Expand All @@ -35,9 +35,7 @@ contract BLSSignatureChecker is IBLSSignatureChecker {
_;
}

constructor(
IRegistryCoordinator _registryCoordinator
) {
constructor(ISlashingRegistryCoordinator _registryCoordinator) {
registryCoordinator = _registryCoordinator;
stakeRegistry = _registryCoordinator.stakeRegistry();
blsApkRegistry = _registryCoordinator.blsApkRegistry();
Expand Down
9 changes: 6 additions & 3 deletions src/EjectionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.27;

import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
import {IEjectionManager} from "./interfaces/IEjectionManager.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";

/**
Expand All @@ -18,7 +18,7 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable {
uint8 internal constant MAX_QUORUM_COUNT = 192;

/// @notice the RegistryCoordinator contract that is the entry point for ejection
IRegistryCoordinator public immutable registryCoordinator;
ISlashingRegistryCoordinator public immutable registryCoordinator;
/// @notice the StakeRegistry contract that keeps track of quorum stake
IStakeRegistry public immutable stakeRegistry;

Expand All @@ -30,7 +30,10 @@ contract EjectionManager is IEjectionManager, OwnableUpgradeable {
/// @notice Ratelimit parameters for each quorum
mapping(uint8 => QuorumEjectionParams) public quorumEjectionParams;

constructor(IRegistryCoordinator _registryCoordinator, IStakeRegistry _stakeRegistry) {
constructor(
ISlashingRegistryCoordinator _registryCoordinator,
IStakeRegistry _stakeRegistry
) {
registryCoordinator = _registryCoordinator;
stakeRegistry = _stakeRegistry;

Expand Down
6 changes: 3 additions & 3 deletions src/IndexRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.27;

import {IndexRegistryStorage} from "./IndexRegistryStorage.sol";
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";

/**
* @title A `Registry` that keeps track of an ordered list of operators for each quorum
Expand All @@ -17,8 +17,8 @@ contract IndexRegistry is IndexRegistryStorage {

/// @notice sets the (immutable) `registryCoordinator` address
constructor(
IRegistryCoordinator _registryCoordinator
) IndexRegistryStorage(_registryCoordinator) {}
ISlashingRegistryCoordinator _slashingRegistryCoordinator
) IndexRegistryStorage(_slashingRegistryCoordinator) {}

/**
*
Expand Down
8 changes: 4 additions & 4 deletions src/IndexRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.27;

import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";

import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol";

/**
Expand All @@ -30,9 +30,9 @@ abstract contract IndexRegistryStorage is Initializable, IIndexRegistry {
mapping(uint8 => QuorumUpdate[]) internal _operatorCountHistory;

constructor(
IRegistryCoordinator _registryCoordinator
) {
registryCoordinator = address(_registryCoordinator);
ISlashingRegistryCoordinator _slashingRegistryCoordinator
){
registryCoordinator = address(_slashingRegistryCoordinator);
// disable initializers so that the implementation contract cannot be initialized
_disableInitializers();
}
Expand Down
14 changes: 7 additions & 7 deletions src/OperatorStateRetriever.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;

import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
import {ISlashingRegistryCoordinator} from "./interfaces/ISlashingRegistryCoordinator.sol";
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";
import {IIndexRegistry} from "./interfaces/IIndexRegistry.sol";
Expand Down Expand Up @@ -40,7 +40,7 @@ contract OperatorStateRetriever {
* was a part of at `blockNumber`, an ordered list of operators.
*/
function getOperatorState(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
bytes32 operatorId,
uint32 blockNumber
) external view returns (uint256, Operator[][] memory) {
Expand All @@ -66,7 +66,7 @@ contract OperatorStateRetriever {
* @return 2d array of Operators. For each quorum, an ordered list of Operators
*/
function getOperatorState(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
bytes memory quorumNumbers,
uint32 blockNumber
) public view returns (Operator[][] memory) {
Expand Down Expand Up @@ -109,7 +109,7 @@ contract OperatorStateRetriever {
* 4) the indices of the quorum apks for each of the provided quorums at the given blocknumber
*/
function getCheckSignaturesIndices(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
uint32 referenceBlockNumber,
bytes calldata quorumNumbers,
bytes32[] calldata nonSignerOperatorIds
Expand Down Expand Up @@ -185,7 +185,7 @@ contract OperatorStateRetriever {
* @param blockNumber is the block number to get the quorumBitmaps for
*/
function getQuorumBitmapsAtBlockNumber(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
bytes32[] memory operatorIds,
uint32 blockNumber
) external view returns (uint256[] memory) {
Expand All @@ -207,7 +207,7 @@ contract OperatorStateRetriever {
* @dev if an operator is not registered, the operatorId will be 0
*/
function getBatchOperatorId(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
address[] memory operators
) external view returns (bytes32[] memory operatorIds) {
operatorIds = new bytes32[](operators.length);
Expand All @@ -223,7 +223,7 @@ contract OperatorStateRetriever {
* @dev if an operator is not registered, the operator address will be 0
*/
function getBatchOperatorFromId(
IRegistryCoordinator registryCoordinator,
ISlashingRegistryCoordinator registryCoordinator,
bytes32[] memory operatorIds
) external view returns (address[] memory operators) {
operators = new address[](operatorIds.length);
Expand Down
Loading

0 comments on commit 47b560d

Please sign in to comment.