Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avs registrar interface #398

Open
wants to merge 2 commits into
base: test/slashing-release
Choose a base branch
from
Open
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 lib/eigenlayer-contracts
Submodule eigenlayer-contracts updated 98 files
+28 −27 README.md
+ audits/Rewards v2 - SigmaPrime - Dec 2024.pdf
+0 −1 docs/core/EigenPodManager.md
+1 −4 docs/core/StrategyManager.md
+57 −61 docs/storage-report/RewardsCoordinator.md
+37 −41 docs/storage-report/RewardsCoordinatorStorage.md
+2 −2 docs/storage-report/StrategyManager.md
+2 −2 docs/storage-report/StrategyManagerStorage.md
+1 −0 foundry.toml
+1 −1 pkg/bindings/AVSDirectory/binding.go
+95 −33 pkg/bindings/AllocationManager/binding.go
+94 −32 pkg/bindings/AllocationManagerStorage/binding.go
+1 −1 pkg/bindings/BackingEigen/binding.go
+1 −1 pkg/bindings/BeaconChainProofs/binding.go
+1 −1 pkg/bindings/BytesLib/binding.go
+1 −1 pkg/bindings/DelegationManager/binding.go
+1 −1 pkg/bindings/Eigen/binding.go
+1 −1 pkg/bindings/EigenPod/binding.go
+14 −14 pkg/bindings/EigenPodManager/binding.go
+13 −13 pkg/bindings/EigenPodManagerStorage/binding.go
+1 −1 pkg/bindings/EigenStrategy/binding.go
+1 −1 pkg/bindings/Endian/binding.go
+94 −1 pkg/bindings/IAllocationManager/binding.go
+13 −13 pkg/bindings/IEigenPodManager/binding.go
+1 −393 pkg/bindings/IRewardsCoordinator/binding.go
+13 −13 pkg/bindings/IShareManager/binding.go
+82 −20 pkg/bindings/IStrategyManager/binding.go
+1 −1 pkg/bindings/Merkle/binding.go
+1 −1 pkg/bindings/OperatorSetLib/binding.go
+1 −1 pkg/bindings/PauserRegistry/binding.go
+1 −1 pkg/bindings/PermissionController/binding.go
+11 −434 pkg/bindings/RewardsCoordinator/binding.go
+10 −433 pkg/bindings/RewardsCoordinatorStorage/binding.go
+1 −1 pkg/bindings/SlashingLib/binding.go
+1 −1 pkg/bindings/Snapshots/binding.go
+1 −1 pkg/bindings/StrategyBase/binding.go
+1 −1 pkg/bindings/StrategyBaseTVLLimits/binding.go
+1 −1 pkg/bindings/StrategyFactory/binding.go
+83 −52 pkg/bindings/StrategyManager/binding.go
+82 −51 pkg/bindings/StrategyManagerStorage/binding.go
+2 −2 script/tasks/register_operator_to_operatorSet.s.sol
+2 −2 script/utils/ExistingDeploymentParser.sol
+104 −47 src/contracts/core/AllocationManager.sol
+1 −3 src/contracts/core/AllocationManagerStorage.sol
+8 −1 src/contracts/core/DelegationManager.sol
+6 −58 src/contracts/core/RewardsCoordinator.sol
+8 −19 src/contracts/core/RewardsCoordinatorStorage.sol
+32 −14 src/contracts/core/StrategyManager.sol
+5 −3 src/contracts/core/StrategyManagerStorage.sol
+9 −2 src/contracts/interfaces/IAVSRegistrar.sol
+31 −2 src/contracts/interfaces/IAllocationManager.sol
+3 −0 src/contracts/interfaces/IDelegationManager.sol
+0 −69 src/contracts/interfaces/IRewardsCoordinator.sol
+1 −7 src/contracts/interfaces/IShareManager.sol
+16 −2 src/contracts/interfaces/IStrategyManager.sol
+0 −7 src/contracts/libraries/SlashingLib.sol
+8 −3 src/contracts/pods/EigenPodManager.sol
+32 −0 src/test/harnesses/AllocationManagerHarness.sol
+1,142 −223 src/test/integration/IntegrationBase.t.sol
+521 −38 src/test/integration/IntegrationChecks.t.sol
+285 −438 src/test/integration/IntegrationDeployer.t.sol
+2 −2 src/test/integration/TimeMachine.t.sol
+26 −0 src/test/integration/TypeImporter.t.sol
+38 −0 src/test/integration/UpgradeTest.t.sol
+3 −0 src/test/integration/mocks/BeaconChainMock.t.sol
+431 −0 src/test/integration/tests/ALM_Multi.t.sol
+229 −0 src/test/integration/tests/ALM_RegisterAndModify.t.sol
+6 −24 src/test/integration/tests/Delegate_Deposit_Queue_Complete.t.sol
+0 −466 src/test/integration/tests/Deposit_Delegate_Allocate.t.sol
+179 −0 src/test/integration/tests/Deposit_Delegate_Allocate_Slash_Queue_Redeposit.t.sol
+10 −52 src/test/integration/tests/Deposit_Delegate_Queue_Complete.t.sol
+37 −80 src/test/integration/tests/Deposit_Delegate_Redelegate_Complete.t.sol
+11 −48 src/test/integration/tests/Deposit_Delegate_Undelegate_Complete.t.sol
+1 −1 src/test/integration/tests/Deposit_Delegate_UpdateBalance.t.sol
+4 −22 src/test/integration/tests/Deposit_Queue_Complete.t.sol
+4 −23 src/test/integration/tests/Deposit_Register_QueueWithdrawal_Complete.t.sol
+287 −0 src/test/integration/tests/SlashingWithdrawals.t.sol
+32 −62 src/test/integration/tests/eigenpod/VerifyWC_StartCP_CompleteCP.t.sol
+107 −0 src/test/integration/tests/upgrade/Complete_PreSlashing_Withdrawal.t.sol
+40 −0 src/test/integration/tests/upgrade/Delegate_Upgrade_Allocate.t.sol
+133 −0 src/test/integration/tests/upgrade/EigenPod_Negative_Shares.t.sol
+11 −20 src/test/integration/tests/upgrade/EigenPod_Slashing_Migration.t.sol
+45 −0 src/test/integration/tests/upgrade/README.md
+6 −1 src/test/integration/users/AVS.t.sol
+22 −29 src/test/integration/users/User.t.sol
+1 −1 src/test/integration/users/User_M2.t.sol
+2 −13 src/test/mocks/AllocationManagerMock.sol
+1 −2 src/test/mocks/DelegationManagerMock.sol
+0 −1 src/test/mocks/EigenPodManagerMock.sol
+1 −2 src/test/mocks/StrategyManagerMock.sol
+448 −23 src/test/unit/AllocationManagerUnit.t.sol
+65 −15 src/test/unit/DelegationUnit.t.sol
+69 −5 src/test/unit/EigenPodManagerUnit.t.sol
+1 −1,128 src/test/unit/RewardsCoordinatorUnit.t.sol
+92 −13 src/test/unit/StrategyManagerUnit.t.sol
+1 −0 src/test/unit/libraries/SnapshotsUnit.t.sol
+1 −0 src/test/unit/mixins/SignatureUtilsUnit.t.sol
+44 −5 src/test/utils/Logger.t.sol
4 changes: 4 additions & 0 deletions src/SlashingRegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ contract SlashingRegistryCoordinator is
/// @inheritdoc ISlashingRegistryCoordinator
function registerOperator(
address operator,
address avs,
uint32[] memory operatorSetIds,
bytes calldata data
) external override onlyAllocationManager onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
require(avs == accountIdentifier, InvalidAVS());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accountIdentifier name could be improved..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avsIdentifier?

bytes memory quorumNumbers = _getQuorumNumbers(operatorSetIds);

(
Expand Down Expand Up @@ -222,8 +224,10 @@ contract SlashingRegistryCoordinator is
/// @inheritdoc ISlashingRegistryCoordinator
function deregisterOperator(
address operator,
address avs,
uint32[] memory operatorSetIds
) external override onlyAllocationManager onlyWhenNotPaused(PAUSED_DEREGISTER_OPERATOR) {
require(avs == accountIdentifier, InvalidAVS());
bytes memory quorumNumbers = _getQuorumNumbers(operatorSetIds);
_deregisterOperator(operator, quorumNumbers);
}
Expand Down
11 changes: 10 additions & 1 deletion src/interfaces/ISlashingRegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ interface ISlashingRegistryCoordinatorErrors {
error NotSorted();
/// @notice Thrown when maximum quorum count is reached.
error MaxQuorumsReached();
/// @notice Thrown when registering/deregistering for the wrong AVS
error InvalidAVS();
}

interface ISlashingRegistryCoordinatorTypes {
Expand Down Expand Up @@ -306,6 +308,7 @@ interface ISlashingRegistryCoordinator is
/**
* @notice Registers an operator through the allocation manager for operator set quorums.
* @param operator The operator address to register.
* @param avs The address of the AVS to register for.
* @param operatorSetIds The operator set IDs to register for (corresponds to quorum numbers).
* @param data Additional registration data containing the operator's socket and BLS public key parameters.
* @dev Can only be called by the allocation manager.
Expand All @@ -314,19 +317,25 @@ interface ISlashingRegistryCoordinator is
*/
function registerOperator(
address operator,
address avs,
uint32[] memory operatorSetIds,
bytes memory data
) external;

/**
* @notice Deregisters an operator through the allocation manager from operator set quorums.
* @param operator The operator address to deregister.
* @param avs The address of the AVS to deregister from.
* @param operatorSetIds The operator set IDs to deregister from (corresponds to quorum numbers).
* @dev Can only be called by the allocation manager.
* @dev Will revert if operator sets are not enabled or if deregistering from M2 quorums.
* @dev This function implements the Slashing deregistration pathway specified by the IAVSRegistrar interface.
*/
function deregisterOperator(address operator, uint32[] memory operatorSetIds) external;
function deregisterOperator(
address operator,
address avs,
uint32[] memory operatorSetIds
) external;

/**
* @notice Updates stake weights for specified operators. If any operator is found to be below
Expand Down
2 changes: 2 additions & 0 deletions test/mocks/AVSRegistrarMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSR
contract AVSRegistrarMock is IAVSRegistrar {
function registerOperator(
address operator,
address avs,
uint32[] calldata operatorSetIds,
bytes calldata data
) external override {}

function deregisterOperator(
address operator,
address avs,
uint32[] calldata operatorSetIds
) external override {}
}
16 changes: 16 additions & 0 deletions test/mocks/AllocationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ contract AllocationManagerIntermediate is IAllocationManager {
uint32 futureBlock
) external view virtual returns (uint256[][] memory slashableStake) {}

function getAllocatedStake(
OperatorSet memory operatorSet,
address[] memory operators,
IStrategy[] memory strategies
) public view returns (uint256[][] memory) {}

function getEncumberedMagnitude(
address operator,
IStrategy strategy
) external view returns (uint64) {}

function isOperatorSlashable(
address operator,
OperatorSet memory operatorSet
) public view returns (bool) {}

function isMemberOfOperatorSet(
address operator,
OperatorSet memory operatorSet
Expand Down
1 change: 0 additions & 1 deletion test/mocks/EigenPodManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ contract EigenPodManagerMock is Test, Pausable, IEigenPodManager {
function addShares(
address staker,
IStrategy strategy,
IERC20 token,
uint256 shares
) external returns (uint256, uint256) {}

Expand Down
16 changes: 0 additions & 16 deletions test/mocks/RewardsCoordinatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ contract RewardsCoordinatorMock is IRewardsCoordinator {
RewardsSubmission[] calldata rewardsSubmissions
) external override {}

function createOperatorDirectedOperatorSetRewardsSubmission(
OperatorSet calldata operatorSet,
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
) external override {}

function getOperatorSetSplit(
address operator,
OperatorSet calldata operatorSet
) external view override returns (uint16) {}

function setOperatorSetSplit(
address operator,
OperatorSet calldata operatorSet,
uint16 split
) external override {}

function createOperatorDirectedAVSRewardsSubmission(
address avs,
OperatorDirectedRewardsSubmission[] calldata operatorDirectedRewardsSubmissions
Expand Down
95 changes: 87 additions & 8 deletions test/unit/RegistryCoordinatorUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,10 @@ contract RegistryCoordinatorUnitTests_BeforeMigration is RegistryCoordinatorUnit
cheats.prank(address(registryCoordinator.allocationManager()));
cheats.expectRevert();
registryCoordinator.registerOperator(
defaultOperator, new uint32[](0), abi.encode(defaultSocket, pubkeyRegistrationParams)
defaultOperator,
address(serviceManager),
new uint32[](0),
abi.encode(defaultSocket, pubkeyRegistrationParams)
);
}

Expand All @@ -2345,7 +2348,9 @@ contract RegistryCoordinatorUnitTests_BeforeMigration is RegistryCoordinatorUnit
operatorSetIds[0] = 0;
cheats.prank(address(registryCoordinator.allocationManager()));
cheats.expectRevert();
registryCoordinator.deregisterOperator(defaultOperator, operatorSetIds);
registryCoordinator.deregisterOperator(
defaultOperator, address(serviceManager), operatorSetIds
);
}

function test_CreateTotalDelegatedStakeQuorum() public {
Expand Down Expand Up @@ -2577,7 +2582,9 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT
abi.encode(ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, params);

cheats.prank(address(registryCoordinator.allocationManager()));
registryCoordinator.registerOperator(defaultOperator, operatorSetIds, data);
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);
}

function test_registerHook_WithChurn() public {
Expand Down Expand Up @@ -2634,7 +2641,9 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT

// Prank as allocation manager and call register hook
cheats.prank(address(registryCoordinator.allocationManager()));
registryCoordinator.registerOperator(defaultOperator, operatorSetIds, data);
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);
}

function test_updateStakesForQuorum() public {
Expand Down Expand Up @@ -2703,7 +2712,9 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT
abi.encode(ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, params);

cheats.startPrank(address(registryCoordinator.allocationManager()));
registryCoordinator.registerOperator(defaultOperator, operatorSetIds, data);
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);

// registryCoordinator.deregisterOperator(defaultOperator, operatorSetIds);

Expand Down Expand Up @@ -2748,7 +2759,9 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT
abi.encode(ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, params);

vm.expectRevert();
registryCoordinator.registerOperator(defaultOperator, operatorSetIds, data);
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);
}

function test_deregisterHook_Reverts_WhenNotALM() public {
Expand Down Expand Up @@ -2792,10 +2805,76 @@ contract RegistryCoordinatorUnitTests_AfterMigration is RegistryCoordinatorUnitT
abi.encode(ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, params);

cheats.prank(address(registryCoordinator.allocationManager()));
registryCoordinator.registerOperator(defaultOperator, operatorSetIds, data);
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);

cheats.expectRevert();
registryCoordinator.deregisterOperator(defaultOperator, operatorSetIds);
registryCoordinator.deregisterOperator(
defaultOperator, address(serviceManager), operatorSetIds
);
}

function test_deregisterHook_Reverts_WhenInvalidAVS() public {
_deployMockEigenLayerAndAVS(0);
address invalidAVS = address(0x1);

// Create quorum params
ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams =
ISlashingRegistryCoordinatorTypes.OperatorSetParam({
maxOperatorCount: 10,
kickBIPsOfOperatorStake: 1000,
kickBIPsOfTotalStake: 100
});

uint96 minimumStake = 100;
IStakeRegistryTypes.StrategyParams[] memory strategyParams =
new IStakeRegistryTypes.StrategyParams[](1);
strategyParams[0] =
IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1)), multiplier: 10000});

// Create total delegated stake quorum
cheats.prank(registryCoordinatorOwner);
registryCoordinator.createTotalDelegatedStakeQuorum(operatorSetParams, 0, strategyParams);

// operator sets should be enabled after creating a new quorum
assertTrue(registryCoordinator.operatorSetsEnabled(), "operatorSetsEnabled should be true");

// Prank as allocation manager and call register hook
uint32[] memory operatorSetIds = new uint32[](1);
operatorSetIds[0] = 0;

string memory socket = "socket";
IBLSApkRegistryTypes.PubkeyRegistrationParams memory params;
// TODO:
// params = IBLSApkRegistryTypes.PubkeyRegistrationParams({
// pubkeyG1: defaultPubKey,
// pubkeyG2: defaultPubKeyG2,
// pubkeySignature: defaultPubKeySignature
// });

bytes memory data =
abi.encode(ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, socket, params);

// Check revert case when register callback is for wrong AVS
cheats.prank(address(registryCoordinator.allocationManager()));
cheats.expectRevert(ISlashingRegistryCoordinatorErrors.InvalidAVS.selector);
registryCoordinator.registerOperator(defaultOperator, invalidAVS, operatorSetIds, data);

cheats.prank(address(registryCoordinator.allocationManager()));
registryCoordinator.registerOperator(
defaultOperator, address(serviceManager), operatorSetIds, data
);

// Check revert case when deregistering for wrong AVS
cheats.prank(address(registryCoordinator.allocationManager()));
cheats.expectRevert(ISlashingRegistryCoordinatorErrors.InvalidAVS.selector);
registryCoordinator.deregisterOperator(defaultOperator, invalidAVS, operatorSetIds);

cheats.prank(address(registryCoordinator.allocationManager()));
registryCoordinator.deregisterOperator(
defaultOperator, address(serviceManager), operatorSetIds
);
}

function test_DeregisterHook_Reverts_WhenM2Quorum() public {
Expand Down
Loading