Skip to content

Commit

Permalink
fix(contracts): fix tests, operator map bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 9, 2024
1 parent eb5c531 commit 67df143
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
16 changes: 6 additions & 10 deletions bolt-contracts/src/contracts/BoltManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
/// @notice Set of operator addresses that have opted in to Bolt Protocol.
EnumerableMap.OperatorMap private operators;

/// @notice Mapping of operator addresses to RPC endpoints.
mapping(address => string) private operatorRPCs;

/// @notice Set of restaking protocols supported. Each address corresponds to the
/// associated Bolt Middleware contract.
EnumerableSet.AddressSet private restakingProtocols;
Expand Down Expand Up @@ -119,24 +116,23 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
// ========= OPERATOR FUNCTIONS ====== //

/// @notice Registers an operator with Bolt. Only callable by a supported middleware contract.
function registerOperator(address operator, string calldata rpc) external onlyMiddleware {
if (operators.contains(operator)) {
function registerOperator(address operatorAddr, string calldata rpc) external onlyMiddleware {
if (operators.contains(operatorAddr)) {
revert OperatorAlreadyRegistered();
}

operators.add(operator);
operators.enable(operator);
// Timestamp will be set when we enable the operator below
Operator memory operator = Operator(rpc, msg.sender, 0);

operatorRPCs[operator] = rpc;
operators.set(operatorAddr, operator);
operators.enable(operatorAddr);
}

/// @notice De-registers an operator from Bolt. Only callable by a supported middleware contract.
function deregisterOperator(
address operator
) public onlyMiddleware {
operators.remove(operator);

delete operatorRPCs[operator];
}

/// @notice Allow an operator to signal indefinite opt-out from Bolt Protocol.
Expand Down
8 changes: 4 additions & 4 deletions bolt-contracts/test/BoltManager.EigenLayer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ contract BoltManagerEigenLayerTest is Test {
assertEq(middleware.isStrategyEnabled(address(eigenLayerDeployer.wethStrat())), true);
}

function test_deregisterEigenLayerOperatorFromAVS() public {
function testDeregisterOperatorFromAVS() public {
_eigenLayerOptInRoutine();
vm.prank(operator);
middleware.deregisterOperator();
Expand All @@ -195,7 +195,7 @@ contract BoltManagerEigenLayerTest is Test {
// assertEq(totalStake, 1 ether);
// }

function test_getEigenLayerProposerStatus() public {
function testProposerStatus() public {
_eigenLayerOptInRoutine();

bytes32 pubkeyHash = _pubkeyHash(validatorPubkey);
Expand Down Expand Up @@ -229,7 +229,7 @@ contract BoltManagerEigenLayerTest is Test {
assertEq(statuses.length, 10);
}

function testGetNonExistentProposerStatus() public {
function testNonExistentProposerStatus() public {
_eigenLayerOptInRoutine();

bytes32 pubkeyHash = bytes32(uint256(1));
Expand All @@ -238,7 +238,7 @@ contract BoltManagerEigenLayerTest is Test {
manager.getProposerStatus(pubkeyHash);
}

function testGetWhitelistedCollaterals() public {
function testWhitelistedCollaterals() public {
_adminRoutine();
address[] memory collaterals = middleware.getWhitelistedCollaterals();
assertEq(collaterals.length, 1);
Expand Down

0 comments on commit 67df143

Please sign in to comment.