Skip to content
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
15 changes: 11 additions & 4 deletions script/Deployments.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import { StdStorage, stdStorage } from "forge-std/Test.sol";

import { IEigenLayerMiddleware } from "src/interfaces/IEigenLayerMiddleware.sol";

import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

contract Deploy is Script, Test {
using stdStorage for StdStorage;

Expand All @@ -70,6 +72,8 @@ contract Deploy is Script, Test {
address public urc;
address public implOwner;

uint256 public urcMinCollateral;

// Constant for admin storage slot
bytes32 constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
Expand Down Expand Up @@ -302,7 +306,7 @@ contract Deploy is Script, Test {
registry: urc,
slasher: address(linglongSlasherInfo.proxy),
allocationManager: allocationManager,
registrationMinCollateral: 0
registrationMinCollateral: urcMinCollateral
});
ProxyAdmin(eigenLayerMiddlewareInfo.admin).upgradeAndCall(
ITransparentUpgradeableProxy(address(deployedContracts.eigenLayerMiddleware)),
Expand Down Expand Up @@ -363,9 +367,9 @@ contract Deploy is Script, Test {
vm.stopBroadcast();

deployEigenLayer(configFileName);

vm.startBroadcast();
IRegistry.Config memory registryConfig = IRegistry.Config({
minCollateralWei: 0.1 ether,
minCollateralWei: SafeCast.toUint80(urcMinCollateral),
fraudProofWindow: 7200,
unregistrationDelay: 7200,
slashWindow: 7200,
Expand All @@ -376,6 +380,8 @@ contract Deploy is Script, Test {
emit log_address(address(registry));
urc = address(registry);
vm.serializeAddress(taiyiAddresses, "urc", address(registry));
vm.serializeUint(taiyiAddresses, "urcMinCollateral", urcMinCollateral);
vm.stopBroadcast();
}

function setupHoleskyAddresses() internal {
Expand All @@ -391,7 +397,8 @@ contract Deploy is Script, Test {
urc = 0x0000000000000000000000000000000000000000;
}

function run(string memory configFileName) public {
function run(string memory configFileName, uint256 minCollateral) public {
urcMinCollateral = minCollateral;
// Get deployer address from private key
(uint256 proxyDeployerPrivateKey, uint256 implPrivateKey) = getPrivateKeys();
deployer = vm.addr(proxyDeployerPrivateKey);
Expand Down
4 changes: 2 additions & 2 deletions script/SetupContract.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ contract SetupContract is Script, Test {
strategies[0] = IStrategy(wethStrategyAddr);

uint32 validatorOperatorSetId = eigenLayerMiddleware.createOperatorSet(
strategies, OperatorSubsetLib.VALIDATOR_SUBSET_TYPE, 0
strategies, OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID, 0
);
uint32 underwriterOperatorSetId = eigenLayerMiddleware.createOperatorSet(
strategies, OperatorSubsetLib.UNDERWRITER_SUBSET_TYPE, 0
strategies, OperatorSubsetLib.EIGENLAYER_UNDERWRITER_SUBSET_ID, 0
);

OperatorSet memory opSet;
Expand Down
4 changes: 2 additions & 2 deletions script/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fi
export FOUNDRY_PROFILE=ci
forge script --rpc-url $EXECUTION_URL \
-vvvv --broadcast ./script/Deployments.s.sol:Deploy \
--sig "run(string memory configFile)" \
-- eigenlayer-deploy-config-devnet.json
--sig "run(string memory configFile, uint256 minCollateral)" \
-- eigenlayer-deploy-config-devnet.json 0.1ether
20 changes: 11 additions & 9 deletions src/eigenlayer-avs/EigenLayerMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ contract EigenLayerMiddleware is
/// @dev Validates that msg.sender is registered in the validator operatorSet with ID 0
modifier onlyValidatorOperatorSet() {
if (
REGISTRY_COORDINATOR.isEigenLayerOperatorInSet(uint32(0), msg.sender) == false
!REGISTRY_COORDINATOR.isOperatorInLinglongSubset(
OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID, msg.sender
)
) {
revert
EigenLayerMiddlewareLib
Expand Down Expand Up @@ -226,8 +228,8 @@ contract EigenLayerMiddleware is
returns (bytes32)
{
if (
!REGISTRY_COORDINATOR.getEigenLayerOperatorFromOperatorSet(
OperatorSubsetLib.VALIDATOR_SUBSET_TYPE, msg.sender
!REGISTRY_COORDINATOR.isOperatorInLinglongSubset(
OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID, msg.sender
)
) {
revert
Expand Down Expand Up @@ -259,8 +261,8 @@ contract EigenLayerMiddleware is
/// @dev Removes all delegations and unregisters from the Registry contract
function unregisterValidators(bytes32 registrationRoot) external {
if (
!REGISTRY_COORDINATOR.getEigenLayerOperatorFromOperatorSet(
OperatorSubsetLib.VALIDATOR_SUBSET_TYPE, msg.sender
!REGISTRY_COORDINATOR.isOperatorInLinglongSubset(
OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID, msg.sender
)
) {
revert
Expand Down Expand Up @@ -337,8 +339,8 @@ contract EigenLayerMiddleware is
external
{
if (
!REGISTRY_COORDINATOR.getEigenLayerOperatorFromOperatorSet(
OperatorSubsetLib.VALIDATOR_SUBSET_TYPE, msg.sender
!REGISTRY_COORDINATOR.isOperatorInLinglongSubset(
OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID, msg.sender
)
) {
revert
Expand All @@ -347,8 +349,8 @@ contract EigenLayerMiddleware is
}

if (
!REGISTRY_COORDINATOR.getEigenLayerOperatorFromOperatorSet(
OperatorSubsetLib.UNDERWRITER_SUBSET_TYPE, delegateeAddress
!REGISTRY_COORDINATOR.isOperatorInLinglongSubset(
OperatorSubsetLib.EIGENLAYER_UNDERWRITER_SUBSET_ID, delegateeAddress
)
) {
revert
Expand Down
5 changes: 3 additions & 2 deletions src/eigenlayer-avs/EigenLayerRewardsHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
IRewardsCoordinatorTypes
} from "@eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";

import { OperatorSubsetLib } from "../libs/OperatorSubsetLib.sol";
import { BLS } from "@urc/lib/BLS.sol";

/// @title EigenLayerRewardsHandler
Expand Down Expand Up @@ -116,7 +117,7 @@ contract EigenLayerRewardsHandler {

// Get underwriter operators and total staked amount
address[] memory underwriterOperators = middleware.getRegistryCoordinator()
.getEigenLayerOperatorSetOperators(uint32(0));
.getLinglongSubsetOperators(OperatorSubsetLib.EIGENLAYER_UNDERWRITER_SUBSET_ID);

if (underwriterOperators.length == 0) {
revert NoUnderwriterOperators();
Expand Down Expand Up @@ -159,7 +160,7 @@ contract EigenLayerRewardsHandler {
{
// Get validator operators for this AVS
address[] memory operators = middleware.getRegistryCoordinator()
.getEigenLayerOperatorSetOperators(uint32(0));
.getLinglongSubsetOperators(OperatorSubsetLib.EIGENLAYER_VALIDATOR_SUBSET_ID);

if (operators.length == 0) {
revert NoUnderwriterOperators();
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/ILinglongChallenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ interface ILinglongChallenger {

/// @notice Check if slashing is in progress for an operator
/// @param operator The operator address
/// @param operatorSetId The operator set ID
/// @param linglongSubsetId The operator set ID
/// @return inProgress Whether slashing is in progress
/// @return slashingId The ID of the slashing
function isSlashingInProgress(
address operator,
uint96 operatorSetId
uint32 linglongSubsetId
)
external
view
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/ILinglongSlasher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ interface ILinglongSlasher is ISlasher {

/// @notice Check if a slashing request is currently in progress for an operator
/// @param operator The operator address to check
/// @param operatorSetId The operator set ID
/// @param linglongSubsetId The operator set ID
/// @param challengeContract The challenger contract to check
/// @return inProgress Whether a slashing is in progress
/// @return slashingId The ID of the slashing request (if any)
function isSlashingInProgress(
address operator,
uint96 operatorSetId,
uint32 linglongSubsetId,
address challengeContract
)
external
Expand Down
Loading