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: Slashing AVSD Happy Path Test Fixes #817

Merged
merged 1 commit into from
Oct 14, 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
20 changes: 14 additions & 6 deletions src/contracts/core/AVSDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract AVSDirectory is
// Assert operator's signature has not expired.
require(operatorSignature.expiry >= block.timestamp, SignatureExpired());
// Assert `operator` is actually an operator.
require(delegation.isOperator(operator), OperatorNotRegistered());
require(delegation.isOperator(operator), OperatorNotRegisteredToEigenLayer());
// Assert that the AVS is an operator set AVS.
require(isOperatorSetAVS[msg.sender], InvalidAVS());
// Assert operator's signature `salt` has not already been spent.
Expand Down Expand Up @@ -302,13 +302,13 @@ contract AVSDirectory is
require(!isOperatorSetAVS[msg.sender], InvalidAVS());

// Assert that the `operator` is not actively registered to the AVS.
require(avsOperatorStatus[msg.sender][operator] != OperatorAVSRegistrationStatus.REGISTERED, InvalidOperator());
require(avsOperatorStatus[msg.sender][operator] != OperatorAVSRegistrationStatus.REGISTERED, OperatorAlreadyRegisteredToAVS());

// Assert `operator` has not already spent `operatorSignature.salt`.
require(!operatorSaltIsSpent[operator][operatorSignature.salt], SaltSpent());

// Assert `operator` is a registered operator.
require(delegation.isOperator(operator), OperatorNotRegistered());
require(delegation.isOperator(operator), OperatorNotRegisteredToEigenLayer());

// Assert that `operatorSignature.signature` is a valid signature for the operator AVS registration.
_checkIsValidSignatureNow({
Expand Down Expand Up @@ -345,7 +345,7 @@ contract AVSDirectory is
) external override onlyWhenNotPaused(PAUSED_OPERATOR_REGISTER_DEREGISTER_TO_AVS) {
// Assert that operator is registered for the AVS.
require(
avsOperatorStatus[msg.sender][operator] == OperatorAVSRegistrationStatus.REGISTERED, OperatorNotRegistered()
avsOperatorStatus[msg.sender][operator] == OperatorAVSRegistrationStatus.REGISTERED, OperatorNotRegisteredToAVS()
);
// Assert that the AVS is not an operator set AVS.
require(!isOperatorSetAVS[msg.sender], InvalidAVS());
Expand Down Expand Up @@ -377,7 +377,7 @@ contract AVSDirectory is

bytes32 encodedOperatorSet = _encodeOperatorSet(operatorSet);

require(_operatorSetsMemberOf[operator].add(encodedOperatorSet), InvalidOperator());
_operatorSetsMemberOf[operator].add(encodedOperatorSet);

_operatorSetMembers[encodedOperatorSet].add(operator);

Expand Down Expand Up @@ -406,10 +406,18 @@ contract AVSDirectory is

bytes32 encodedOperatorSet = _encodeOperatorSet(operatorSet);

require(_operatorSetsMemberOf[operator].remove(encodedOperatorSet), InvalidOperator());
_operatorSetsMemberOf[operator].remove(encodedOperatorSet);

_operatorSetMembers[encodedOperatorSet].remove(operator);

OperatorSetRegistrationStatus storage registrationStatus =
operatorSetStatus[avs][operator][operatorSetIds[i]];

require(registrationStatus.registered, InvalidOperator());

registrationStatus.registered = false;
registrationStatus.lastDeregisteredTimestamp = uint32(block.timestamp);

emit OperatorRemovedFromOperatorSet(operator, operatorSet);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/contracts/interfaces/IAVSDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ interface IAVSDirectoryErrors {
/// Operator Status

/// @dev Thrown when an operator does not exist in the DelegationManager
error OperatorNotRegistered();
error OperatorNotRegisteredToEigenLayer();
/// @dev Thrown when an operator is already registered to an AVS.
error OperatorNotRegisteredToAVS();
/// @dev Thrown when `operator` is already registered to the AVS.
error OperatorAlreadyRegistered();
error OperatorAlreadyRegisteredToAVS();

/// @notice Enum representing the status of an operator's registration with an AVS
/// @dev Thrown when an invalid AVS is provided.
Expand Down
2 changes: 0 additions & 2 deletions src/test/mocks/AllocationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ contract AllocationManagerMock is Test {

return maxMagnitudes;
}


}
Loading
Loading