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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[submodule "lib/eigenlayer-contracts"]
path = lib/eigenlayer-contracts
url = https://github.com/Layr-labs/eigenlayer-contracts
branch = dev
branch = release-dev/multichain
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
Expand Down
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
38 changes: 32 additions & 6 deletions test/integration/IntegrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol";
import "eigenlayer-contracts/src/contracts/pods/EigenPod.sol";
import "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol";
import "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol";
import "eigenlayer-contracts/src/contracts/core/SlashEscrowFactory.sol";
import "eigenlayer-contracts/src/contracts/core/SlashEscrow.sol";
import "eigenlayer-contracts/src/test/mocks/ETHDepositMock.sol";

// Middleware contracts
Expand Down Expand Up @@ -62,6 +64,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
ETHPOSDepositMock ethPOSDeposit;
AllocationManager public allocationManager;
PermissionController permissionController;
SlashEscrowFactory slashEscrowFactory;

// Base strategy implementation in case we want to create more strategies later
StrategyBase baseStrategyImplementation;
Expand Down Expand Up @@ -188,8 +191,14 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
)
);

slashEscrowFactory = SlashEscrowFactory(
address(
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
)
);

// Deploy EigenPod Contracts
pod = new EigenPod(ethPOSDeposit, eigenPodManager, GENESIS_TIME_LOCAL, "v0.0.1");
pod = new EigenPod(ethPOSDeposit, eigenPodManager, "v0.0.1");

eigenPodBeacon = new UpgradeableBeacon(address(pod));

Expand All @@ -206,7 +215,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
"v0.0.1"
);
StrategyManager strategyManagerImplementation =
new StrategyManager(delegationManager, pauserRegistry, "v0.0.1");
new StrategyManager(delegationManager, slashEscrowFactory, pauserRegistry, "v0.0.1");
EigenPodManager eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit, eigenPodBeacon, delegationManager, pauserRegistry, "v0.0.1"
);
Expand Down Expand Up @@ -238,6 +247,14 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
"v0.0.1" // Added config parameter
);

// Deploy SlashEscrow implementation
SlashEscrow slashEscrowImpl = new SlashEscrow();

// Deploy SlashEscrowFactory implementation
SlashEscrowFactory slashEscrowFactoryImplementation = new SlashEscrowFactory(
allocationManager, strategyManager, pauserRegistry, slashEscrowImpl, "v0.0.1"
);

// Third, upgrade the proxy contracts to point to the implementations
uint256 minWithdrawalDelayBlocks = 7 days / 12 seconds;
IStrategy[] memory initializeStrategiesToSetDelayBlocks = new IStrategy[](0);
Expand All @@ -247,9 +264,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
ITransparentUpgradeableProxy(payable(address(delegationManager))),
address(delegationImplementation),
abi.encodeWithSelector(
DelegationManager.initialize.selector,
eigenLayerReputedMultisig, // initialOwner
0 /* initialPausedStatus */
DelegationManager.initialize.selector, 0 /* initialPausedStatus */
)
);
// StrategyManager
Expand Down Expand Up @@ -308,11 +323,22 @@ abstract contract IntegrationDeployer is Test, IUserDeployer {
address(allocationManagerImplementation),
abi.encodeWithSelector(
AllocationManager.initialize.selector,
eigenLayerReputedMultisig, // initialOwner
0 // initialPausedStatus
)
);

// SlashEscrowFactory
proxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(payable(address(slashEscrowFactory))),
address(slashEscrowFactoryImplementation),
abi.encodeWithSelector(
SlashEscrowFactory.initialize.selector,
eigenLayerReputedMultisig, // initialOwner
0, // initialPausedStatus
7 days / 12 // initialGlobalDelayBlocks (7 days worth of blocks)
)
);

// Deploy and whitelist strategies
baseStrategyImplementation = new StrategyBase(strategyManager, pauserRegistry, "v0.0.1");
for (uint256 i = 0; i < MAX_STRATEGY_COUNT; i++) {
Expand Down
73 changes: 71 additions & 2 deletions test/mocks/AllocationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVe
contract AllocationManagerIntermediate is IAllocationManager {
function initialize(address initialOwner, uint256 initialPausedStatus) external virtual {}

function slashOperator(address avs, SlashingParams calldata params) external virtual {}
function slashOperator(
address avs,
SlashingParams calldata params
) external virtual returns (uint256 slashId, uint256[] memory shares) {}

function modifyAllocations(
address operator,
Expand Down Expand Up @@ -183,10 +186,76 @@ contract AllocationManagerIntermediate is IAllocationManager {
function version() external pure virtual returns (string memory) {
return "v0.0.1";
}

function DEALLOCATION_DELAY() external pure virtual returns (uint32) {}

function createRedistributingOperatorSets(
address avs,
CreateSetParams[] calldata params,
address[] calldata redistributionRecipients
) external virtual {}

function getRedistributionRecipient(
OperatorSet memory operatorSet
) external pure virtual returns (address) {}

function getSlashCount(
OperatorSet memory operatorSet
) external pure virtual returns (uint256) {}

function initialize(
uint256 initialPausedStatus
) external virtual {}

function isOperatorRedistributable(
address operator
) external pure virtual returns (bool) {}

function isRedistributingOperatorSet(
OperatorSet memory operatorSet
) external pure virtual returns (bool) {}
}

contract AllocationManagerMock is AllocationManagerIntermediate {
uint32 public constant DEALLOCATION_DELAY = 86400;
uint32 internal constant _DEALLOCATION_DELAY = 86400;

function DEALLOCATION_DELAY() external pure override returns (uint32) {
return _DEALLOCATION_DELAY;
}

function createRedistributingOperatorSets(
address avs,
CreateSetParams[] calldata params,
address[] calldata redistributionRecipients
) external override {}

function getRedistributionRecipient(
OperatorSet memory operatorSet
) external pure override returns (address) {
return address(0);
}

function getSlashCount(
OperatorSet memory operatorSet
) external pure override returns (uint256) {
return 0;
}

function initialize(
uint256 initialPausedStatus
) external override {}

function isOperatorRedistributable(
address operator
) external pure override returns (bool) {
return false;
}

function isRedistributingOperatorSet(
OperatorSet memory operatorSet
) external pure override returns (bool) {
return false;
}

function getAllocatedStake(
address operator,
Expand Down
18 changes: 18 additions & 0 deletions test/mocks/DelegationMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ import {
} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol";
import {ISemVerMixin} from "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol";
import {SlashingLib} from "eigenlayer-contracts/src/contracts/libraries/SlashingLib.sol";
import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol";

contract DelegationIntermediate is IDelegationManager {
function initialize(address initialOwner, uint256 initialPausedStatus) external virtual {}

function initialize(
uint256 initialPausedStatus
) external virtual {}

function registerAsOperator(
OperatorDetails calldata registeringOperatorDetails,
uint32 allocationDelay,
Expand Down Expand Up @@ -240,6 +245,15 @@ contract DelegationIntermediate is IDelegationManager {
uint64 newMaxMagnitude
) external {}

function slashOperatorShares(
address operator,
OperatorSet calldata operatorSet,
uint256 slashId,
IStrategy strategy,
uint64 prevMaxMagnitude,
uint64 newMaxMagnitude
) external virtual returns (uint256 totalDepositSharesToSlash) {}

function getQueuedWithdrawal(
bytes32 withdrawalRoot
)
Expand Down Expand Up @@ -309,6 +323,10 @@ contract DelegationMock is DelegationIntermediate {
mapping(address => bool) internal _isOperator;
mapping(address => mapping(IStrategy => uint256)) internal _weightOf;

function initialize(
uint256 initialPausedStatus
) external override {}

function setOperatorShares(
address operator,
IStrategy strategy,
Expand Down
8 changes: 8 additions & 0 deletions test/mocks/EigenPodManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "forge-std/Test.sol";
import "eigenlayer-contracts/src/contracts/permissions/Pausable.sol";
import "eigenlayer-contracts/src/contracts/interfaces/IEigenPodManager.sol";
import "eigenlayer-contracts/src/contracts/interfaces/ISemVerMixin.sol";
import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol";

contract EigenPodManagerMock is Test, Pausable, IEigenPodManager {
receive() external payable {}
Expand Down Expand Up @@ -126,6 +127,13 @@ contract EigenPodManagerMock is Test, Pausable, IEigenPodManager {

function increaseBurnableShares(IStrategy strategy, uint256 addedSharesToBurn) external {}

function increaseBurnOrRedistributableShares(
OperatorSet calldata operatorSet,
uint256 slashId,
IStrategy strategy,
uint256 addedSharesToBurn
) external {}

/**
* @notice Returns the version of the contract
* @return The version string
Expand Down
15 changes: 13 additions & 2 deletions test/mocks/KeyRegistrarMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ contract KeyRegistrarMock is IKeyRegistrar {
address operator
) external pure returns (bool) {}

function getOperatorSetConfig(
function getOperatorSetCurveType(
OperatorSet memory operatorSet
) external pure returns (OperatorSetConfig memory) {}
) external pure returns (CurveType) {}

function getBN254Key(
OperatorSet memory operatorSet,
Expand All @@ -73,6 +73,17 @@ contract KeyRegistrarMock is IKeyRegistrar {
address operator
) external pure returns (bytes memory) {}

/**
* @notice Gets the ECDSA public key for an operator with a specific operator set
* @param operatorSet The operator set to get the key for
* @param operator Address of the operator
* @return pubkey The ECDSA public key
*/
function getECDSAAddress(
OperatorSet memory operatorSet,
address operator
) external pure returns (address) {}

function isKeyGloballyRegistered(
bytes32 keyHash
) external view returns (bool) {}
Expand Down
1 change: 1 addition & 0 deletions test/unit/middlewareV2/AVSRegistrarAllowlistUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ contract AVSRegistrarWithAllowlistUnitTests_deregisterOperator is
address notAllocationManager
) public {
cheats.assume(notAllocationManager != address(allocationManagerMock));
cheats.assume(notAllocationManager != address(proxyAdmin));

cheats.prank(notAllocationManager);
cheats.expectRevert(NotAllocationManager.selector);
Expand Down
1 change: 1 addition & 0 deletions test/unit/middlewareV2/AVSRegistrarSocketUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ contract AVSRegistrarSocketUnitTests_updateSocket is AVSRegistrarSocketUnitTests
) public {
_registerOperator(defaultOperatorSetId.toArrayU32());
cheats.assume(notOperator != defaultOperator);
cheats.assume(notOperator != address(proxyAdmin));

cheats.prank(notOperator);
cheats.expectRevert(CallerNotOperator.selector);
Expand Down
2 changes: 2 additions & 0 deletions test/unit/middlewareV2/AVSRegistrarUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract AVSRegistrarUnitTests_RegisterOperator is AVSRegistrarUnitTests {
address notAllocationManager
) public {
cheats.assume(notAllocationManager != address(allocationManagerMock));
cheats.assume(notAllocationManager != address(proxyAdmin));

cheats.prank(notAllocationManager);
cheats.expectRevert(NotAllocationManager.selector);
Expand Down Expand Up @@ -66,6 +67,7 @@ contract AVSRegistrarUnitTests_DeregisterOperator is AVSRegistrarUnitTests {
address notAllocationManager
) public {
cheats.assume(notAllocationManager != address(allocationManagerMock));
cheats.assume(notAllocationManager != address(proxyAdmin));

cheats.prank(notAllocationManager);
cheats.expectRevert(NotAllocationManager.selector);
Expand Down
Loading