Skip to content

Commit

Permalink
install
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk committed Apr 22, 2024
1 parent c5ac704 commit 8873f20
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "solidity/lib/eigenlayer-middleware"]
path = solidity/lib/eigenlayer-middleware
url = https://github.com/Layr-Labs/eigenlayer-middleware
[submodule "solidity/lib/eigenlayer-contracts"]
path = solidity/lib/eigenlayer-contracts
url = https://github.com/Layr-Labs/eigenlayer-contracts
94 changes: 94 additions & 0 deletions solidity/contracts/avs/HyperlaneServiceManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import {ISignatureUtils} from "@eigenlayer/core/interfaces/ISignatureUtils.sol";
import {IAVSDirectory} from "@eigenlayer/core/interfaces/IAVSDirectory.sol";

import {IStakeRegistry} from "@eigenlayer/middleware/interfaces/IStakeRegistry.sol";
import {IServiceManager} from "@eigenlayer/middleware/interfaces/IServiceManager.sol";

contract HyperlaneServiceManager is IServiceManager, OwnableUpgradeable {
IStakeRegistry internal immutable stakeRegistry;
IAVSDirectory internal immutable elAvsDirectory;

/// @notice when applied to a function, only allows the ECDSAStakeRegistry to call it
modifier onlyStakeRegistry() {
require(
msg.sender == address(stakeRegistry),
"HyperlaneServiceManager: caller is not the stake registry"
);
_;
}

constructor(IAVSDirectory _avsDirectory, IStakeRegistry _stakeRegistry) {
elAvsDirectory = _avsDirectory;
stakeRegistry = _stakeRegistry;
_disableInitializers();
}

/**
* @notice Updates the metadata URI for the AVS
* @param _metadataURI is the metadata URI for the AVS
* @dev only callable by the owner
*/
function updateAVSMetadataURI(
string memory _metadataURI
) public virtual onlyOwner {
elAvsDirectory.updateAVSMetadataURI(_metadataURI);
}

/**
* @notice Forwards a call to EigenLayer's AVSDirectory contract to confirm operator registration with the AVS
* @param operator The address of the operator to register.
* @param operatorSignature The signature, salt, and expiry of the operator's signature.
*/
function registerOperatorToAVS(
address operator,
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature
) public virtual onlyStakeRegistry {
elAvsDirectory.registerOperatorToAVS(operator, operatorSignature);
}

/**
* @notice Forwards a call to EigenLayer's AVSDirectory contract to confirm operator deregistration from the AVS
* @param operator The address of the operator to deregister.
*/
function deregisterOperatorFromAVS(
address operator
) public virtual onlyStakeRegistry {
elAvsDirectory.deregisterOperatorFromAVS(operator);
}

/**
* @notice Returns the list of strategies that the AVS supports for restaking
* @dev This function is intended to be called off-chain
* @dev No guarantee is made on uniqueness of each element in the returned array.
* The off-chain service should do that validation separately
*/
function getRestakeableStrategies()
external
view
returns (address[] memory)
{
// TODO
return new address[](0);
}

function getOperatorRestakedStrategies(
address operator
) external view returns (address[] memory) {
// TODO
return new address[](0);
}

/// @notice Returns the EigenLayer AVSDirectory contract.
function avsDirectory() external view override returns (address) {
return address(elAvsDirectory);
}

// storage gap for upgradeability
// slither-disable-next-line shadowing-state
uint256[50] private __GAP;
}
19 changes: 19 additions & 0 deletions solidity/contracts/interfaces/avs/ITownCrier.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;

/*@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@ HYPERLANE @@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@@
@@@@@@@@@ @@@@@@@@*/

interface ITownCrier {
function challengeDelayBlocks() external view returns (uint256);
function handleChallenge(address operator) external;
}
1 change: 1 addition & 0 deletions solidity/lib/eigenlayer-contracts
Submodule eigenlayer-contracts added at 7229f2
2 changes: 1 addition & 1 deletion solidity/lib/eigenlayer-middleware
3 changes: 3 additions & 0 deletions solidity/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@openzeppelin=../node_modules/@openzeppelin
@openzeppelin/contracts-upgradeable/=../node_modules/@openzeppelin/contracts-upgradeable/
@layerzerolabs=../node_modules/@layerzerolabs
@eth-optimism=../node_modules/@eth-optimism
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
@eigenlayer/core/=lib/eigenlayer-contracts/src/contracts/
@eigenlayer/middleware/=lib/eigenlayer-middleware/src/

0 comments on commit 8873f20

Please sign in to comment.