Skip to content

Commit

Permalink
feat(contracts): consolidate EigenLayer registration, add deregister …
Browse files Browse the repository at this point in the history
…method
  • Loading branch information
mempirate committed Oct 7, 2024
1 parent b764a8e commit 7c8d63a
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, Ownable {
// ========= ERRORS =========

error StrategyNotAllowed();
error OperatorNotRegisteredToAVS();
error OperatorAlreadyRegisteredToAVS();

// ========= CONSTRUCTOR =========

Expand Down Expand Up @@ -165,8 +165,11 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, Ownable {

/// @notice Allow an operator to signal opt-in to Bolt Protocol.
/// @param operator The operator address to signal opt-in for.
/// @dev This requires calling the EigenLayer AVS Directory contract to register the operator.
/// EigenLayer internally contains a mapping from `msg.sender` (our AVS contract) to the operator
function registerOperator(
address operator
address operator,
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature
) public {
if (operators.contains(operator)) {
revert AlreadyRegistered();
Expand All @@ -176,14 +179,29 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, Ownable {
revert NotOperator();
}

if (!checkIfOperatorRegisteredToAVS(operator)) {
revert OperatorNotRegisteredToAVS();
if (checkIfOperatorRegisteredToAVS(operator)) {
revert OperatorAlreadyRegisteredToAVS();
}

AVS_DIRECTORY.registerOperatorToAVS(operator, operatorSignature);

operators.add(operator);
operators.enable(operator);
}

/// @notice Deregister an EigenLayer layer operator from working in Bolt Protocol.
/// @dev This requires calling the EigenLayer AVS Directory contract to deregister the operator.
/// EigenLayer internally contains a mapping from `msg.sender` (our AVS contract) to the operator.
function deregisterOperator() public {
if (!operators.contains(msg.sender)) {
revert NotRegistered();
}

operators.remove(msg.sender);

AVS_DIRECTORY.deregisterOperatorFromAVS(msg.sender);
}

/// @notice Allow an operator to signal indefinite opt-out from Bolt Protocol.
/// @dev Pausing activity does not prevent the operator from being slashable for
/// the current network epoch until the end of the slashing window.
Expand Down Expand Up @@ -413,13 +431,6 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, Ownable {
== IAVSDirectory.OperatorAVSRegistrationStatus.REGISTERED;
}

/// @notice Deregister an EigenLayer layer operator from working in Bolt Protocol.
/// @dev This requires calling the EigenLayer AVS Directory contract to deregister the operator.
/// EigenLayer internally contains a mapping from `msg.sender` (our AVS contract) to the operator.
function deregisterOperatorFromAVS() public {
AVS_DIRECTORY.deregisterOperatorFromAVS(msg.sender);
}

/// @notice emits an `AVSMetadataURIUpdated` event indicating the information has updated.
/// @param metadataURI The URI for metadata associated with an avs
function updateAVSMetadataURI(
Expand Down

0 comments on commit 7c8d63a

Please sign in to comment.