Skip to content

Commit

Permalink
ELIP-001:reduce error message
Browse files Browse the repository at this point in the history
  • Loading branch information
daring5920 committed Jan 6, 2025
1 parent fa830e3 commit 53bd8b6
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract RegistryCoordinator is
using BN254 for BN254.G1Point;

modifier onlyEjector {
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
require(msg.sender == ejector, "CoordinatoronlyEjector: caller is not the ejector");
_;
}

Expand All @@ -50,7 +50,7 @@ contract RegistryCoordinator is
modifier quorumExists(uint8 quorumNumber) {
require(
quorumNumber < quorumCount,
"RegistryCoordinator.quorumExists: quorum does not exist"
"CoordinatorquorumExists: quorum does not exist"
);
_;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ contract RegistryCoordinator is
) external initializer {
require(
_operatorSetParams.length == _minimumStakes.length && _minimumStakes.length == _strategyParams.length,
"RegistryCoordinator.initialize: input length mismatch"
"Coordinatorinitialize: input length mismatch"
);

// Initialize roles
Expand Down Expand Up @@ -159,7 +159,7 @@ contract RegistryCoordinator is

require(
numOperatorsPerQuorum[i] <= _quorumParams[quorumNumber].maxOperatorCount,
"RegistryCoordinator.registerOperator: operator count exceeds maximum"
"CoordinatorregisterOperator: operator count exceeds maximum"
);
}
}
Expand All @@ -184,7 +184,7 @@ contract RegistryCoordinator is
SignatureWithSaltAndExpiry memory churnApproverSignature,
SignatureWithSaltAndExpiry memory operatorSignature
) external onlyWhenNotPaused(PAUSED_REGISTER_OPERATOR) {
require(operatorKickParams.length == quorumNumbers.length, "RegistryCoordinator.registerOperatorWithChurn: input length mismatch");
require(operatorKickParams.length == quorumNumbers.length, "CoordinatorregisterOperatorWithChurn: input length mismatch");

/**
* If the operator has NEVER registered a pubkey before, use `params` to register
Expand Down Expand Up @@ -295,7 +295,7 @@ contract RegistryCoordinator is
uint192 quorumBitmap = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount));
require(
operatorsPerQuorum.length == quorumNumbers.length,
"RegistryCoordinator.updateOperatorsForQuorum: input length mismatch"
"CoordinatorupdateOperatorsForQuorum: input length mismatch"
);

// For each quorum, update ALL registered operators
Expand All @@ -306,7 +306,7 @@ contract RegistryCoordinator is
address[] calldata currQuorumOperators = operatorsPerQuorum[i];
require(
currQuorumOperators.length == indexRegistry.totalOperatorsForQuorum(quorumNumber),
"RegistryCoordinator.updateOperatorsForQuorum: number of updated operators does not match quorum total"
"CoordinatorupdateOperatorsForQuorum: number of updated operators does not match quorum total"
);

address prevOperatorAddress = address(0);
Expand All @@ -325,12 +325,12 @@ contract RegistryCoordinator is
// Check that the operator is registered
require(
BitmapUtils.isSet(currentBitmap, quorumNumber),
"RegistryCoordinator.updateOperatorsForQuorum: operator not in quorum"
"CoordinatorupdateOperatorsForQuorum: operator not in quorum"
);
// Prevent duplicate operators
require(
operator > prevOperatorAddress,
"RegistryCoordinator.updateOperatorsForQuorum: operators array must be sorted in ascending address order"
"CoordinatorupdateOperatorsForQuorum: operators array must be sorted in ascending address order"
);
}

Expand Down Expand Up @@ -478,12 +478,12 @@ contract RegistryCoordinator is
*/
uint192 quorumsToAdd = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount));
uint192 currentBitmap = _currentOperatorBitmap(operatorId);
require(!quorumsToAdd.isEmpty(), "RegistryCoordinator._registerOperator: bitmap cannot be 0");
require(quorumsToAdd.noBitsInCommon(currentBitmap), "RegistryCoordinator._registerOperator: operator already registered for some quorums being registered for");
require(!quorumsToAdd.isEmpty(), "Coordinator_registerOperator: bitmap cannot be 0");
require(quorumsToAdd.noBitsInCommon(currentBitmap), "Coordinator_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");
require(lastEjectionTimestamp[operator] + ejectionCooldown < block.timestamp, "Coordinator_registerOperator: operator cannot reregister yet");

/**
* Update operator's bitmap, socket, and status. Only update operatorInfo if needed:
Expand Down Expand Up @@ -586,18 +586,18 @@ contract RegistryCoordinator is
) internal view {
address operatorToKick = kickParams.operator;
bytes32 idToKick = _operatorInfo[operatorToKick].operatorId;
require(newOperator != operatorToKick, "RegistryCoordinator._validateChurn: cannot churn self");
require(kickParams.quorumNumber == quorumNumber, "RegistryCoordinator._validateChurn: quorumNumber not the same as signed");
require(newOperator != operatorToKick, "Coordinator_validateChurn: cannot churn self");
require(kickParams.quorumNumber == quorumNumber, "Coordinator_validateChurn: quorumNumber not the same as signed");

// Get the target operator's stake and check that it is below the kick thresholds
uint96 operatorToKickStake = stakeRegistry.getCurrentStake(idToKick, quorumNumber);
require(
newOperatorStake > _individualKickThreshold(operatorToKickStake, setParams),
"RegistryCoordinator._validateChurn: incoming operator has insufficient stake for churn"
"Coordinator_validateChurn: incoming operator has insufficient stake for churn"
);
require(
operatorToKickStake < _totalKickThreshold(totalQuorumStake, setParams),
"RegistryCoordinator._validateChurn: cannot kick operator with more than kickBIPsOfTotalStake"
"Coordinator_validateChurn: cannot kick operator with more than kickBIPsOfTotalStake"
);
}

Expand All @@ -613,7 +613,7 @@ contract RegistryCoordinator is
// Fetch the operator's info and ensure they are registered
OperatorInfo storage operatorInfo = _operatorInfo[operator];
bytes32 operatorId = operatorInfo.operatorId;
require(operatorInfo.status == OperatorStatus.REGISTERED, "RegistryCoordinator._deregisterOperator: operator is not registered");
require(operatorInfo.status == OperatorStatus.REGISTERED, "Coordinator_deregisterOperator: operator is not registered");

/**
* Get bitmap of quorums to deregister from and operator's current bitmap. Validate that:
Expand All @@ -624,8 +624,8 @@ contract RegistryCoordinator is
*/
uint192 quorumsToRemove = uint192(BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers, quorumCount));
uint192 currentBitmap = _currentOperatorBitmap(operatorId);
require(!quorumsToRemove.isEmpty(), "RegistryCoordinator._deregisterOperator: bitmap cannot be 0");
require(quorumsToRemove.isSubsetOf(currentBitmap), "RegistryCoordinator._deregisterOperator: operator is not registered for specified quorums");
require(!quorumsToRemove.isEmpty(), "Coordinator_deregisterOperator: bitmap cannot be 0");
require(quorumsToRemove.isSubsetOf(currentBitmap), "Coordinator_deregisterOperator: operator is not registered for specified quorums");
uint192 newBitmap = uint192(currentBitmap.minus(quorumsToRemove));

// Update operator's bitmap and status
Expand Down Expand Up @@ -697,8 +697,8 @@ contract RegistryCoordinator is
SignatureWithSaltAndExpiry memory churnApproverSignature
) internal {
// make sure the salt hasn't been used already
require(!isChurnApproverSaltUsed[churnApproverSignature.salt], "RegistryCoordinator._verifyChurnApproverSignature: churnApprover salt already used");
require(churnApproverSignature.expiry >= block.timestamp, "RegistryCoordinator._verifyChurnApproverSignature: churnApprover signature expired");
require(!isChurnApproverSaltUsed[churnApproverSignature.salt], "Coordinator_verifyChurnApproverSignature: churnApprover salt already used");
require(churnApproverSignature.expiry >= block.timestamp, "Coordinator_verifyChurnApproverSignature: churnApprover signature expired");

// set salt used to true
isChurnApproverSaltUsed[churnApproverSignature.salt] = true;
Expand Down Expand Up @@ -726,7 +726,7 @@ contract RegistryCoordinator is
) internal {
// Increment the total quorum count. Fails if we're already at the max
uint8 prevQuorumCount = quorumCount;
require(prevQuorumCount < MAX_QUORUM_COUNT, "RegistryCoordinator.createQuorum: max quorums reached");
require(prevQuorumCount < MAX_QUORUM_COUNT, "CoordinatorcreateQuorum: max quorums reached");
quorumCount = prevQuorumCount + 1;
emit QuorumCountUpdated(quorumCount);

Expand Down Expand Up @@ -810,7 +810,7 @@ contract RegistryCoordinator is
}

revert(
"RegistryCoordinator.getQuorumBitmapIndexAtBlockNumber: no bitmap update found for operatorId at block number"
"CoordinatorgetQuorumBitmapIndexAtBlockNumber: no bitmap update found for operatorId at block number"
);
}

Expand Down Expand Up @@ -899,11 +899,11 @@ contract RegistryCoordinator is
*/
require(
blockNumber >= quorumBitmapUpdate.updateBlockNumber,
"RegistryCoordinator.getQuorumBitmapAtBlockNumberByIndex: quorumBitmapUpdate is from after blockNumber"
"CoordinatorgetQuorumBitmapAtBlockNumberByIndex: quorumBitmapUpdate is from after blockNumber"
);
require(
quorumBitmapUpdate.nextUpdateBlockNumber == 0 || blockNumber < quorumBitmapUpdate.nextUpdateBlockNumber,
"RegistryCoordinator.getQuorumBitmapAtBlockNumberByIndex: quorumBitmapUpdate is from before blockNumber"
"CoordinatorgetQuorumBitmapAtBlockNumberByIndex: quorumBitmapUpdate is from before blockNumber"
);

return quorumBitmapUpdate.quorumBitmap;
Expand Down

0 comments on commit 53bd8b6

Please sign in to comment.