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

fix: remove circular dependency #108

Merged
merged 1 commit into from
Dec 13, 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
4 changes: 2 additions & 2 deletions src/BLSApkRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract contract BLSApkRegistryStorage is Initializable, IBLSApkRegistry {
bytes32 internal constant ZERO_PK_HASH = hex"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5";

/// @notice the registry coordinator contract
IRegistryCoordinator public immutable registryCoordinator;
address public immutable registryCoordinator;

// storage for individual pubkeys
/// @notice maps operator address to pubkey hash
Expand All @@ -30,7 +30,7 @@ abstract contract BLSApkRegistryStorage is Initializable, IBLSApkRegistry {
mapping(uint8 => BN254.G1Point) public currentApk;

constructor(IRegistryCoordinator _registryCoordinator) {
registryCoordinator = _registryCoordinator;
registryCoordinator = address(_registryCoordinator);
// disable initializers so that the implementation contract cannot be initialized
_disableInitializers();
}
Expand Down
4 changes: 2 additions & 2 deletions src/IndexRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract contract IndexRegistryStorage is Initializable, IIndexRegistry {
bytes32 public constant OPERATOR_DOES_NOT_EXIST_ID = bytes32(0);

/// @notice The RegistryCoordinator contract for this middleware
IRegistryCoordinator public immutable registryCoordinator;
address public immutable registryCoordinator;

/// @notice maps quorumNumber => operator id => current index
mapping(uint8 => mapping(bytes32 => uint32)) public currentOperatorIndex;
Expand All @@ -29,7 +29,7 @@ abstract contract IndexRegistryStorage is Initializable, IIndexRegistry {
constructor(
IRegistryCoordinator _registryCoordinator
){
registryCoordinator = _registryCoordinator;
registryCoordinator = address(_registryCoordinator);
// disable initializers so that the implementation contract cannot be initialized
_disableInitializers();
}
Expand Down
2 changes: 1 addition & 1 deletion src/StakeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract StakeRegistry is StakeRegistryStorage {
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/StakeRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract contract StakeRegistryStorage is IStakeRegistry {
IDelegationManager public immutable delegation;

/// @notice the coordinator contract that this registry is associated with
IRegistryCoordinator public immutable registryCoordinator;
address public immutable registryCoordinator;

/// @notice In order to register for a quorum i, an operator must have at least `minimumStakeForQuorum[i]`
/// evaluated by this contract's 'VoteWeigher' logic.
Expand All @@ -47,7 +47,7 @@ abstract contract StakeRegistryStorage is IStakeRegistry {
IRegistryCoordinator _registryCoordinator,
IDelegationManager _delegationManager
) {
registryCoordinator = _registryCoordinator;
registryCoordinator = address(_registryCoordinator);
delegation = _delegationManager;
}

Expand Down
4 changes: 1 addition & 3 deletions src/interfaces/IRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;

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

/**
* @title Minimal interface for a `Registry`-type contract.
* @author Layr Labs, Inc.
Expand All @@ -11,5 +9,5 @@ import {IRegistryCoordinator} from "./IRegistryCoordinator.sol";
* because their function signatures may vary significantly.
*/
interface IRegistry {
function registryCoordinator() external view returns (IRegistryCoordinator);
function registryCoordinator() external view returns (address);
}
2 changes: 1 addition & 1 deletion test/mocks/StakeRegistryMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "src/interfaces/IRegistryCoordinator.sol";
*/
contract StakeRegistryMock is IStakeRegistry {

function registryCoordinator() external view returns (IRegistryCoordinator) {}
function registryCoordinator() external view returns (address) {}

/**
* @notice Registers the `operator` with `operatorId` for the specified `quorumNumbers`.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/BLSApkRegistryUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract BLSApkRegistryUnitTests is Test {
}

function testConstructorArgs() public view {
require(blsApkRegistry.registryCoordinator() == registryCoordinator, "registryCoordinator not set correctly");
require(blsApkRegistry.registryCoordinator() == address(registryCoordinator), "registryCoordinator not set correctly");
}

function testCallRegisterOperatorFromNonCoordinatorAddress(address nonCoordinatorAddress) public {
Expand Down