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

feat(contracts/avs): enabled operator deregistration #2577

Merged
merged 1 commit into from
Nov 26, 2024
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
50 changes: 26 additions & 24 deletions contracts/avs/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ OmniAVS_admin_Test:test_avsDirectory_succeeds() (gas: 17892)
OmniAVS_admin_Test:test_ejectOwner_byOwner_succeeds() (gas: 435687)
OmniAVS_admin_Test:test_ejectOwner_notOwner_reverts() (gas: 107965)
OmniAVS_admin_Test:test_getOPeratorRestakedStrategies_notOperator_succeeds() (gas: 108732)
OmniAVS_admin_Test:test_getOperatorRestakedStrategies_noStrategies_succeeds() (gas: 519211)
OmniAVS_admin_Test:test_getOperatorRestakedStrategies_succeeds() (gas: 584206)
OmniAVS_admin_Test:test_getRestakeableStrategies_noStrategies_succeeds() (gas: 27757)
OmniAVS_admin_Test:test_getRestakeableStrategies_succeeds() (gas: 90719)
OmniAVS_admin_Test:test_getOperatorRestakedStrategies_noStrategies_succeeds() (gas: 519233)
OmniAVS_admin_Test:test_getOperatorRestakedStrategies_succeeds() (gas: 584228)
OmniAVS_admin_Test:test_getRestakeableStrategies_noStrategies_succeeds() (gas: 27775)
OmniAVS_admin_Test:test_getRestakeableStrategies_succeeds() (gas: 90741)
OmniAVS_admin_Test:test_pause_byOwner_succeeds() (gas: 45167)
OmniAVS_admin_Test:test_registerOperator_whenPaused_reverts() (gas: 137959)
OmniAVS_admin_Test:test_setEthStakeInbox_notOwner_reverts() (gas: 18021)
Expand All @@ -22,39 +22,41 @@ OmniAVS_admin_Test:test_setOmniChainId_succeeds() (gas: 28211)
OmniAVS_admin_Test:test_setPortal_notOwner_reverts() (gas: 17912)
OmniAVS_admin_Test:test_setPortal_succeeds() (gas: 28290)
OmniAVS_admin_Test:test_setPortal_zeroAddress_reverts() (gas: 20448)
OmniAVS_admin_Test:test_setStrategyParams_duplicateStrategy_reverts() (gas: 38149)
OmniAVS_admin_Test:test_setStrategyParams_notOwner_reverts() (gas: 18373)
OmniAVS_admin_Test:test_setStrategyParams_succeds() (gas: 77503)
OmniAVS_admin_Test:test_setStrategyParams_twice_succeeds() (gas: 57942)
OmniAVS_admin_Test:test_setStrategyParams_zeroAddress_reverts() (gas: 36870)
OmniAVS_admin_Test:test_setStrategyParams_zeroMul_reverts() (gas: 37138)
OmniAVS_admin_Test:test_setStrategyParams_duplicateStrategy_reverts() (gas: 38171)
OmniAVS_admin_Test:test_setStrategyParams_notOwner_reverts() (gas: 18395)
OmniAVS_admin_Test:test_setStrategyParams_succeds() (gas: 77525)
OmniAVS_admin_Test:test_setStrategyParams_twice_succeeds() (gas: 57986)
OmniAVS_admin_Test:test_setStrategyParams_zeroAddress_reverts() (gas: 36892)
OmniAVS_admin_Test:test_setStrategyParams_zeroMul_reverts() (gas: 37160)
OmniAVS_admin_Test:test_setXCallGasLimits_notOwner_reverts() (gas: 18090)
OmniAVS_admin_Test:test_setXCallGasLimits_succeeds() (gas: 34141)
OmniAVS_admin_Test:test_syncWithOmni_whenPaused_reverts() (gas: 45198)
OmniAVS_admin_Test:test_unpause_byOwner_succeeds() (gas: 36175)
OmniAVS_allowlist_Test:test_addToAllowlist_notOwner_reverts() (gas: 108019)
OmniAVS_allowlist_Test:test_addToAllowlist_succeeds() (gas: 135727)
OmniAVS_allowlist_Test:test_disableAllowlist_alreadyDisabled_reverts() (gas: 32140)
OmniAVS_allowlist_Test:test_deregisterOperator_invalidOperator_reverts() (gas: 110545)
OmniAVS_allowlist_Test:test_deregisterOperator_succeeds() (gas: 420012)
OmniAVS_allowlist_Test:test_disableAllowlist_alreadyDisabled_reverts() (gas: 32184)
OmniAVS_allowlist_Test:test_disableAllowlist_notOwner_reverts() (gas: 17823)
OmniAVS_allowlist_Test:test_disableAllowlist_succeeds() (gas: 29389)
OmniAVS_allowlist_Test:test_enableAllowlist_alreadyEnabled_reverts() (gas: 26027)
OmniAVS_allowlist_Test:test_disableAllowlist_succeeds() (gas: 29433)
OmniAVS_allowlist_Test:test_enableAllowlist_alreadyEnabled_reverts() (gas: 26071)
OmniAVS_allowlist_Test:test_enableAllowlist_notOwner_reverts() (gas: 17844)
OmniAVS_allowlist_Test:test_enableAllowlist_succeeds() (gas: 29831)
OmniAVS_allowlist_Test:test_registerOperator_allowlistDisabled_succeeds() (gas: 522495)
OmniAVS_allowlist_Test:test_registerOperator_invalidPubkey_reverts() (gas: 314771)
OmniAVS_allowlist_Test:test_registerOperator_nowAllowed_reverts() (gas: 117028)
OmniAVS_allowlist_Test:test_enableAllowlist_succeeds() (gas: 29875)
OmniAVS_allowlist_Test:test_registerOperator_allowlistDisabled_succeeds() (gas: 522517)
OmniAVS_allowlist_Test:test_registerOperator_invalidPubkey_reverts() (gas: 314860)
OmniAVS_allowlist_Test:test_registerOperator_nowAllowed_reverts() (gas: 117050)
OmniAVS_allowlist_Test:test_registerOperator_succeeds() (gas: 540934)
OmniAVS_allowlist_Test:test_registerOperator_succeeds() (gas: 542787)
OmniAVS_allowlist_Test:test_registerOperator_succeeds() (gas: 542875)
OmniAVS_allowlist_Test:test_registerOperator_wrongPubkey_reverts() (gas: 404418)
OmniAVS_allowlist_Test:test_removeFromAllowlist_notOwner_reverts() (gas: 107967)
OmniAVS_allowlist_Test:test_removeFromAllowlist_succeeds() (gas: 242142)
OmniAVS_canRegister_Test:test_canRegister_allowed() (gas: 331230)
OmniAVS_canRegister_Test:test_canRegister_allowlistDisabled() (gas: 311203)
OmniAVS_canRegister_Test:test_canRegister_alreadyRegistered() (gas: 525300)
OmniAVS_canRegister_Test:test_canRegister_allowed() (gas: 331252)
OmniAVS_canRegister_Test:test_canRegister_allowlistDisabled() (gas: 311225)
OmniAVS_canRegister_Test:test_canRegister_alreadyRegistered() (gas: 525322)
OmniAVS_canRegister_Test:test_canRegister_maxOperatorsReached() (gas: 265051)
OmniAVS_canRegister_Test:test_canRegister_minStakeNotMet() (gas: 331770)
OmniAVS_canRegister_Test:test_canRegister_notAllowed() (gas: 225880)
OmniAVS_canRegister_Test:test_canRegister_minStakeNotMet() (gas: 331792)
OmniAVS_canRegister_Test:test_canRegister_notAllowed() (gas: 225902)
OmniAVS_canRegister_Test:test_canRegister_notOperator() (gas: 120672)
OmniAVS_initialize_Test:test_initialize_defaultParams_succeeds() (gas: 3596420)
OmniAVS_initialize_Test:test_initialize_defaultParams_succeeds() (gas: 3606316)
OmniAVS_syncWithOmni_Test:test_depositBeaconEth_succeeds() (gas: 638274)
OmniAVS_syncWithOmni_Test:test_unsupportedStrategyDeposit_succeeds() (gas: 1677678)
7 changes: 7 additions & 0 deletions contracts/avs/src/OmniAVS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ contract OmniAVS is IOmniAVS, IOmniAVSAdmin, OwnableUpgradeable, PausableUpgrade
emit OperatorAdded(operator);
}

/**
* @notice Deregister an operator from the AVS. Forwards a call to EigenLayer's AVSDirectory.
*/
function deregisterOperator() external whenNotPaused {
_deregisterOperator(msg.sender);
}

/**
* @notice Returns true if the operator is in the allowlist.
* @param operator The operator to check
Expand Down
5 changes: 5 additions & 0 deletions contracts/avs/src/interfaces/IOmniAVS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ interface IOmniAVS {
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature
) external;

/**
* @notice Deregister an operator from the AVS. Forwards a call to EigenLayer's AVSDirectory.
*/
function deregisterOperator() external;

/**
* @notice Check if an operator can register to the AVS.
* Returns true, with no reason, if the operator can register to the AVS.
Expand Down
23 changes: 23 additions & 0 deletions contracts/avs/test/OmniAVS_registration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,27 @@ contract OmniAVS_allowlist_Test is Base {
vm.prank(operator);
omniAVS.registerOperator(pubkey, emptySig);
}

/// @dev Test that an operator can deregister
function test_deregisterOperator_succeeds() public {
address operator = _operator(0);

_addToAllowlist(operator);
_registerAsOperator(operator);
_depositIntoSupportedStrategy(operator, minOperatorStake);
_registerOperatorWithAVS(operator);
_deregisterOperatorFromAVS(operator);

IOmniAVS.Operator[] memory operators = omniAVS.operators();
assertEq(operators.length, 0);
}

/// @dev Test that an invalid operator cannot deregister
function test_deregisterOperator_invalidOperator_reverts() public {
address operator = _operator(0);

vm.expectRevert("OmniAVS: not an operator");
vm.prank(operator);
omniAVS.deregisterOperator();
}
}
6 changes: 6 additions & 0 deletions contracts/avs/test/common/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ contract Utils is Fixtures {
omniAVS.registerOperator(_pubkey(operator), sig);
}

/// @dev deregister an operator from OmniAVS
function _deregisterOperatorFromAVS(address operator) internal {
vm.prank(operator);
omniAVS.deregisterOperator();
}

/// @dev add an operator to the allowlist
function _addToAllowlist(address operator) internal {
vm.prank(omniAVSOwner);
Expand Down
Loading
Loading