-
Notifications
You must be signed in to change notification settings - Fork 92
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: reregistration delay #246
Changes from all commits
f5ba67a
a71d3b2
1dc136b
03d40e1
2f6d7a5
b962174
271aad4
0e69039
0bad4f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,15 +359,28 @@ contract RegistryCoordinator is | |
* @notice Forcibly deregisters an operator from one or more quorums | ||
* @param operator the operator to eject | ||
* @param quorumNumbers the quorum numbers to eject the operator from | ||
* @dev possible race condition if prior to being ejected for a set of quorums the operator self deregisters from a subset | ||
*/ | ||
function ejectOperator( | ||
address operator, | ||
bytes calldata quorumNumbers | ||
) external onlyEjector { | ||
_deregisterOperator({ | ||
operator: operator, | ||
quorumNumbers: quorumNumbers | ||
}); | ||
lastEjectionTimestamp[operator] = block.timestamp; | ||
|
||
OperatorInfo storage operatorInfo = _operatorInfo[operator]; | ||
bytes32 operatorId = operatorInfo.operatorId; | ||
uint192 quorumsToRemove = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount)); | ||
uint192 currentBitmap = _currentOperatorBitmap(operatorId); | ||
if( | ||
operatorInfo.status == OperatorStatus.REGISTERED && | ||
!quorumsToRemove.isEmpty() && | ||
quorumsToRemove.isSubsetOf(currentBitmap) | ||
){ | ||
Comment on lines
+374
to
+378
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. so there's still some weird race condition where an operator can deregister from a subset of quorums to avoid being ejected for more, right? 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. perhaps we can just take the submitted 'quorumNumbers' and actually pass on a combination ('and'ing) of them with the operator's current quorums in the subsequent call? |
||
_deregisterOperator({ | ||
operator: operator, | ||
quorumNumbers: quorumNumbers | ||
}); | ||
} | ||
} | ||
|
||
/******************************************************************************* | ||
|
@@ -423,6 +436,16 @@ contract RegistryCoordinator is | |
_setEjector(_ejector); | ||
} | ||
|
||
/** | ||
* @notice Sets the ejection cooldown, which is the time an operator must wait in | ||
* seconds afer ejection before registering for any quorum | ||
* @param _ejectionCooldown the new ejection cooldown in seconds | ||
* @dev only callable by the owner | ||
*/ | ||
function setEjectionCooldown(uint256 _ejectionCooldown) external onlyOwner { | ||
ejectionCooldown = _ejectionCooldown; | ||
} | ||
|
||
/******************************************************************************* | ||
INTERNAL FUNCTIONS | ||
*******************************************************************************/ | ||
|
@@ -457,6 +480,9 @@ contract RegistryCoordinator is | |
require(quorumsToAdd.noBitsInCommon(currentBitmap), "RegistryCoordinator._registerOperator: operator already registered for some quorums being registered for"); | ||
uint192 newBitmap = uint192(currentBitmap.plus(quorumsToAdd)); | ||
|
||
// Check that the operator can reregister if ejected | ||
require(lastEjectionTimestamp[operator] + ejectionCooldown < block.timestamp, "RegistryCoordinator._registerOperator: operator cannot reregister yet"); | ||
|
||
/** | ||
* Update operator's bitmap, socket, and status. Only update operatorInfo if needed: | ||
* if we're `REGISTERED`, the operatorId and status are already correct. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about refactoring the ejection logic
This should clean up some of the branchy conditionals in this function