-
Notifications
You must be signed in to change notification settings - Fork 114
feat: poc for OperatorSets #263
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
Closed
Closed
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
76a4912
feat: add strategies to OSM
8sunyuan 9015229
feat: opsets reg/dereg with strategy migration
8sunyuan 7384f3a
chore: fix add require
8sunyuan db81923
feat: operator set migration
8sunyuan f4b0d57
chore: fmt
8sunyuan 2425104
chore: natspec
8sunyuan b777600
feat: eject nonmigrated operators
8sunyuan 9880a8d
fix: comments
8sunyuan 78f35d4
fix: added require in eject
8sunyuan 5bd70a6
fix: eject just the one operatorSet
8sunyuan 9fbe3c4
Merge branch 'dev' into feat/operator-sets
stevennevins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,31 +72,37 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt | |
| ) internal virtual onlyInitializing { | ||
| _transferOwnership(initialOwner); | ||
| _setRewardsInitiator(_rewardsInitiator); | ||
| isStrategiesMigrated = true; | ||
| } | ||
|
|
||
| /// TODO: natspec | ||
| /** | ||
| * @notice called by the AVS StakeRegistry whenever a new IStrategy is added to a quorum/operatorSet | ||
| * @dev calls operatorSetManager.addStrategiesToOperatorSet() | ||
| */ | ||
| function addStrategiesToOperatorSet( | ||
| uint32 operatorSetID, | ||
| IStrategy[] calldata strategies | ||
| ) external onlyStakeRegistry { | ||
| _operatorSetManager.addStrategiesToOperatorSet(operatorSetID, strategies); | ||
| } | ||
|
|
||
| /// TODO: natspec | ||
| /** | ||
| * @notice called by the AVS StakeRegistry whenever a new IStrategy is removed from a quorum/operatorSet | ||
| * @dev calls operatorSetManager.removeStrategiesFromOperatorSet() | ||
| */ | ||
| function removeStrategiesFromOperatorSet( | ||
| uint32 operatorSetID, | ||
| IStrategy[] calldata strategies | ||
| ) external onlyStakeRegistry { | ||
| _operatorSetManager.removeStrategiesFromOperatorSet(operatorSetID, strategies); | ||
| } | ||
|
|
||
| /// @notice migrates all existing operators and strategies to operator sets | ||
| /** | ||
| * @notice One-time call that migrates all existing strategies for each quorum to their respective operator sets | ||
| * Note: a separate migration per operator must be performed to migrate an existing operator to the operator set | ||
| * See migrateOperatorToOperatorSets() below | ||
| * @dev calls operatorSetManager.addStrategiesToOperatorSet() | ||
| */ | ||
| function migrateStrategiesToOperatorSets() external { | ||
| require( | ||
| !isStrategiesMigrated, | ||
| "ServiceManagerBase.migrateStrategiesToOperatorSets: already migrated" | ||
| ); | ||
| uint8 quorumCount = _registryCoordinator.quorumCount(); | ||
| for (uint8 i = 0; i < quorumCount; ++i) { | ||
| uint256 numStrategies = _stakeRegistry.strategyParamsLength(i); | ||
|
|
@@ -105,24 +111,34 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt | |
| for (uint256 j = 0; j < numStrategies; ++j) { | ||
| IStrategy strategy = _stakeRegistry.strategyParamsByIndex(i, j).strategy; | ||
| strategies[j] = strategy; | ||
| require( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we just not check this at all and have the call to OSM revert? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also works assuming it will revert |
||
| !_operatorSetManager.operatorSetStrategies(address(this), uint32(i), strategy), | ||
| "ServiceManagerBase.migrateStrategiesToOperatorSets: strategy already part of OperatorSet" | ||
| ); | ||
| } | ||
|
|
||
| _operatorSetManager.addStrategiesToOperatorSet(uint32(i), strategies); | ||
| emit OperatorSetStrategiesMigrated(uint32(i), strategies); | ||
| } | ||
| isStrategiesMigrated = true; | ||
| } | ||
|
|
||
| /** | ||
| * @notice the operator needs to provide a signature over the operatorSetIds they will be registering | ||
| * for. This can be called externally by getOperatorSetIds | ||
| * @notice One-time call to migrate an existing operator to the respective operator sets. | ||
| * The operator needs to provide a signature over the operatorSetIds they are currently registered for. | ||
| * This can be retrieved externally by calling getOperatorSetIds. | ||
| * @param operator the address of the operator to be migrated | ||
| * @param signature the signature of the operator on their intent to migrate | ||
| * @dev calls operatorSetManager.registerOperatorToOperatorSets() | ||
| */ | ||
| function migrateOperatorToOperatorSets( | ||
| address operator, | ||
| ISignatureUtils.SignatureWithSaltAndExpiry memory signature | ||
| ) external { | ||
| // check if operator is already migrated, that is they are registered operators with 0 operatorSet count | ||
| require( | ||
| !isOperatorMigrated[operator], | ||
| _operatorSetManager.avsOperatorStatus(address(this), operator) | ||
| == IOperatorSetManager.OperatorAVSRegistrationStatus.REGISTERED | ||
| && _operatorSetManager.operatorAVSOperatorSetCount(address(this), operator) == 0, | ||
| "ServiceManagerBase.migrateOperatorToOperatorSets: already migrated" | ||
| ); | ||
| uint32[] memory operatorSetIds = getOperatorSetIds(operator); | ||
|
|
@@ -136,24 +152,24 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt | |
| * The ServiceManager owner can eject any operators that have yet to completely migrate fully to operator sets. | ||
| * This final step of the migration process will ensure the full migration of all operators to operator sets. | ||
| * @param operators The list of operators to eject for the given OperatorSet | ||
| * @param operatorSet The OperatorSet to eject the operators from | ||
| * @param operatorSetId This AVS's operatorSetId to eject operators from | ||
| * @dev The RegistryCoordinator MUST set this ServiceManager contract to be the ejector address for this call to succeed | ||
| */ | ||
| function ejectNonmigratedOperators( | ||
| address[] calldata operators, | ||
| IOperatorSetManager.OperatorSet calldata operatorSet | ||
| uint32 operatorSetId | ||
| ) external onlyOwner { | ||
| require( | ||
| operatorSet.avs == address(this), | ||
| "ServiceManagerBase.ejectNonmigratedOperators: operatorSet is not for this AVS" | ||
| ); | ||
| require( | ||
| operatorSet.id < _registryCoordinator.quorumCount(), | ||
| operatorSetId < _registryCoordinator.quorumCount(), | ||
| "ServiceManagerBase.ejectNonmigratedOperators: operatorSet does not exist" | ||
| ); | ||
| IOperatorSetManager.OperatorSet memory operatorSet = | ||
| IOperatorSetManager.OperatorSet({avs: address(this), id: operatorSetId}); | ||
| for (uint256 i = 0; i < operators.length; ++i) { | ||
| require( | ||
| !_operatorSetManager.isOperatorInOperatorSet(operators[i], operatorSet), | ||
| _operatorSetManager.avsOperatorStatus(address(this), operator) | ||
| == IOperatorSetManager.OperatorAVSRegistrationStatus.REGISTERED | ||
| && !_operatorSetManager.isOperatorInOperatorSet(operators[i], operatorSet), | ||
8sunyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "ServiceManagerBase.removeNonmigratedOperators: operator already registered to operator set" | ||
| ); | ||
| bytes32 operatorId = _registryCoordinator.getOperatorId(operators[i]); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.