From c7204044c3cec47c02f205d069c2f29246496ab4 Mon Sep 17 00:00:00 2001 From: gpsanant Date: Mon, 17 Jul 2023 12:42:25 -0700 Subject: [PATCH] added an extra comment --- .../BLSRegistryCoordinatorWithIndices.sol | 33 ++++++++++--------- ...LSRegistryCoordinatorWithIndicesUnit.t.sol | 18 +++++----- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol b/src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol index f05a9863e..80c621434 100644 --- a/src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol +++ b/src/contracts/middleware/BLSRegistryCoordinatorWithIndices.sol @@ -48,7 +48,7 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin address[] public registries; modifier onlyServiceManagerOwner { - require(msg.sender == serviceManager.owner(), "BLSIndexRegistryCoordinator.onlyServiceManagerOwner: caller is not the service manager owner"); + require(msg.sender == serviceManager.owner(), "BLSRegistryCoordinatorWithIndices.onlyServiceManagerOwner: caller is not the service manager owner"); _; } @@ -73,7 +73,7 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin registries.push(address(indexRegistry)); // set the operator set params - require(IVoteWeigher(address(stakeRegistry)).quorumCount() == _operatorSetParams.length, "BLSIndexRegistryCoordinator: operator set params length mismatch"); + require(IVoteWeigher(address(stakeRegistry)).quorumCount() == _operatorSetParams.length, "BLSRegistryCoordinatorWithIndices: operator set params length mismatch"); for (uint8 i = 0; i < _operatorSetParams.length; i++) { _setOperatorSetParams(i, _operatorSetParams[i]); } @@ -104,7 +104,7 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin require( _operatorIdToQuorumBitmapHistory[operatorIds[i]][length - j - 1].nextUpdateBlockNumber == 0 || _operatorIdToQuorumBitmapHistory[operatorIds[i]][length - j - 1].nextUpdateBlockNumber > blockNumber, - "BLSRegistryCoordinator.getQuorumBitmapIndicesByOperatorIdsAtBlockNumber: operatorId has no quorumBitmaps at blockNumber" + "BLSRegistryCoordinatorWithIndices.getQuorumBitmapIndicesByOperatorIdsAtBlockNumber: operatorId has no quorumBitmaps at blockNumber" ); indices[i] = length - j - 1; break; @@ -122,13 +122,13 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin QuorumBitmapUpdate memory quorumBitmapUpdate = _operatorIdToQuorumBitmapHistory[operatorId][index]; require( quorumBitmapUpdate.updateBlockNumber <= blockNumber, - "BLSRegistryCoordinator.getQuorumBitmapByOperatorIdAtBlockNumberByIndex: quorumBitmapUpdate is from after blockNumber" + "BLSRegistryCoordinatorWithIndices.getQuorumBitmapByOperatorIdAtBlockNumberByIndex: quorumBitmapUpdate is from after blockNumber" ); // if the next update is at or before the block number, then the quorum provided index is too early // if the nex update block number is 0, then this is the latest update require( quorumBitmapUpdate.nextUpdateBlockNumber > blockNumber || quorumBitmapUpdate.nextUpdateBlockNumber == 0, - "BLSRegistryCoordinator.getQuorumBitmapByOperatorIdAtBlockNumberByIndex: quorumBitmapUpdate is from before blockNumber" + "BLSRegistryCoordinatorWithIndices.getQuorumBitmapByOperatorIdAtBlockNumberByIndex: quorumBitmapUpdate is from before blockNumber" ); return quorumBitmapUpdate.quorumBitmap; } @@ -194,7 +194,8 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin * while maintaining the limit, the operator chooses another registered opeerator with lower stake to kick. * @param quorumNumbers are the bytes representing the quorum numbers that the operator is registering for * @param pubkey is the BLS public key of the operator - * @param operatorKickParams are the parameters for the deregistration of the operator that is being kicked + * @param operatorKickParams are the parameters for the deregistration of the operator that is being kicked from each + * quorum that will be filled after the operator registers. */ function registerOperatorWithCoordinator( bytes calldata quorumNumbers, @@ -229,13 +230,13 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin // check the registering operator has more than the kick BIPs of the operator to kick's stake require( registeringOperatorStake > operatorToKickStake * operatorSetParam.kickBIPsOfOperatorStake / BIPS_DENOMINATOR, - "BLSIndexRegistryCoordinator.registerOperatorWithCoordinator: registering operator has less than kickBIPsOfOperatorStake" + "BLSRegistryCoordinatorWithIndices.registerOperatorWithCoordinator: registering operator has less than kickBIPsOfOperatorStake" ); // check the that the operator to kick has less than the kick BIPs of the total stake require( operatorToKickStake < totalStakeForQuorum * operatorSetParam.kickBIPsOfTotalStake / BIPS_DENOMINATOR, - "BLSIndexRegistryCoordinator.registerOperatorWithCoordinator: operator to kick has more than kickBIPSOfTotalStake" + "BLSRegistryCoordinatorWithIndices.registerOperatorWithCoordinator: operator to kick has more than kickBIPSOfTotalStake" ); } @@ -289,13 +290,13 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin // ); // check that the sender is not already registered - require(_operators[operator].status != OperatorStatus.REGISTERED, "BLSIndexRegistryCoordinator._registerOperatorWithCoordinator: operator already registered"); + require(_operators[operator].status != OperatorStatus.REGISTERED, "BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinator: operator already registered"); // get the quorum bitmap from the quorum numbers uint256 quorumBitmap = BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers); - require(quorumBitmap != 0, "BLSIndexRegistryCoordinator._registerOperatorWithCoordinator: quorumBitmap cannot be 0"); - require(quorumBitmap <= MiddlewareUtils.MAX_QUORUM_BITMAP, "BLSIndexRegistryCoordinator._registerOperatorWithCoordinator: quorumBitmap exceeds of max bitmap size"); + require(quorumBitmap != 0, "BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinator: quorumBitmap cannot be 0"); + require(quorumBitmap <= MiddlewareUtils.MAX_QUORUM_BITMAP, "BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinator: quorumBitmap exceeds of max bitmap size"); // register the operator with the BLSPubkeyRegistry and get the operatorId (in this case, the pubkeyHash) back bytes32 operatorId = blsPubkeyRegistry.registerOperator(operator, quorumNumbers, pubkey); @@ -332,27 +333,27 @@ contract BLSRegistryCoordinatorWithIndices is Initializable, IBLSRegistryCoordin for (uint i = 0; i < numOperatorsPerQuorum.length; i++) { require( numOperatorsPerQuorum[i] <= _quorumOperatorSetParams[uint8(quorumNumbers[i])].maxOperatorCount, - "BLSIndexRegistryCoordinator._registerOperatorWithCoordinatorAndNoOverfilledQuorums: quorum is overfilled" + "BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinatorAndNoOverfilledQuorums: quorum is overfilled" ); } } function _deregisterOperatorWithCoordinator(address operator, bytes calldata quorumNumbers, BN254.G1Point memory pubkey, bytes32[] memory operatorIdsToSwap) internal { - require(_operators[operator].status == OperatorStatus.REGISTERED, "BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: operator is not registered"); + require(_operators[operator].status == OperatorStatus.REGISTERED, "BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: operator is not registered"); // get the operatorId of the operator bytes32 operatorId = _operators[operator].operatorId; - require(operatorId == pubkey.hashG1Point(), "BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: operatorId does not match pubkey hash"); + require(operatorId == pubkey.hashG1Point(), "BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: operatorId does not match pubkey hash"); // get the quorumNumbers of the operator uint256 quorumsToRemoveBitmap = BitmapUtils.orderedBytesArrayToBitmap(quorumNumbers); - require(quorumsToRemoveBitmap <= MiddlewareUtils.MAX_QUORUM_BITMAP, "BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: quorumsToRemoveBitmap exceeds of max bitmap size"); + require(quorumsToRemoveBitmap <= MiddlewareUtils.MAX_QUORUM_BITMAP, "BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: quorumsToRemoveBitmap exceeds of max bitmap size"); uint256 operatorQuorumBitmapHistoryLengthMinusOne = _operatorIdToQuorumBitmapHistory[operatorId].length - 1; uint192 quorumBitmapBeforeUpdate = _operatorIdToQuorumBitmapHistory[operatorId][operatorQuorumBitmapHistoryLengthMinusOne].quorumBitmap; // check that the quorumNumbers of the operator matches the quorumNumbers passed in require( quorumBitmapBeforeUpdate & quorumsToRemoveBitmap == quorumsToRemoveBitmap, - "BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: cannot deregister operator for quorums that it is not a part of" + "BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: cannot deregister operator for quorums that it is not a part of" ); // check if the operator is completely deregistering bool completeDeregistration = quorumBitmapBeforeUpdate == quorumsToRemoveBitmap; diff --git a/src/test/unit/BLSRegistryCoordinatorWithIndicesUnit.t.sol b/src/test/unit/BLSRegistryCoordinatorWithIndicesUnit.t.sol index 8413e7b4c..a95cb05fe 100644 --- a/src/test/unit/BLSRegistryCoordinatorWithIndicesUnit.t.sol +++ b/src/test/unit/BLSRegistryCoordinatorWithIndicesUnit.t.sol @@ -56,7 +56,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { function testRegisterOperatorWithCoordinator_EmptyQuorumNumbers_Reverts() public { bytes memory emptyQuorumNumbers = new bytes(0); - cheats.expectRevert("BLSIndexRegistryCoordinator._registerOperatorWithCoordinator: quorumBitmap cannot be 0"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinator: quorumBitmap cannot be 0"); cheats.prank(defaultOperator); registryCoordinator.registerOperatorWithCoordinator(emptyQuorumNumbers, defaultPubKey, defaultSocket); } @@ -64,7 +64,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { function testRegisterOperatorWithCoordinator_QuorumNumbersTooLarge_Reverts() public { bytes memory quorumNumbersTooLarge = new bytes(1); quorumNumbersTooLarge[0] = 0xC0; - cheats.expectRevert("BLSIndexRegistryCoordinator._registerOperatorWithCoordinator: quorumBitmap exceeds of max bitmap size"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinator: quorumBitmap exceeds of max bitmap size"); registryCoordinator.registerOperatorWithCoordinator(quorumNumbersTooLarge, defaultPubKey, defaultSocket); } @@ -195,7 +195,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { stakeRegistry.setOperatorWeight(defaultQuorumNumber, operatorToRegister, defaultStake); cheats.prank(operatorToRegister); - cheats.expectRevert("BLSIndexRegistryCoordinator._registerOperatorWithCoordinatorAndNoOverfilledQuorums: quorum is overfilled"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._registerOperatorWithCoordinatorAndNoOverfilledQuorums: quorum is overfilled"); registryCoordinator.registerOperatorWithCoordinator(quorumNumbers, operatorToRegisterPubKey, defaultSocket); } @@ -203,7 +203,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { bytes memory quorumNumbers = new bytes(1); quorumNumbers[0] = bytes1(defaultQuorumNumber); - cheats.expectRevert("BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: operator is not registered"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: operator is not registered"); cheats.prank(defaultOperator); registryCoordinator.deregisterOperatorWithCoordinator(quorumNumbers, defaultPubKey, new bytes32[](0)); } @@ -217,7 +217,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { BN254.G1Point memory incorrectPubKey = BN254.hashToG1(bytes32(uint256(123))); - cheats.expectRevert("BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: operatorId does not match pubkey hash"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: operatorId does not match pubkey hash"); cheats.prank(defaultOperator); registryCoordinator.deregisterOperatorWithCoordinator(quorumNumbers, incorrectPubKey, new bytes32[](0)); } @@ -233,7 +233,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { quorumNumbers[0] = bytes1(defaultQuorumNumber); quorumNumbers[1] = bytes1(uint8(192)); - cheats.expectRevert("BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: quorumsToRemoveBitmap exceeds of max bitmap size"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: quorumsToRemoveBitmap exceeds of max bitmap size"); cheats.prank(defaultOperator); registryCoordinator.deregisterOperatorWithCoordinator(quorumNumbers, defaultPubKey, new bytes32[](0)); } @@ -249,7 +249,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { quorumNumbers[0] = bytes1(defaultQuorumNumber); quorumNumbers[1] = bytes1(defaultQuorumNumber + 1); - cheats.expectRevert("BLSIndexRegistryCoordinator._deregisterOperatorWithCoordinator: cannot deregister operator for quorums that it is not a part of"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices._deregisterOperatorWithCoordinator: cannot deregister operator for quorums that it is not a part of"); cheats.prank(defaultOperator); registryCoordinator.deregisterOperatorWithCoordinator(quorumNumbers, defaultPubKey, new bytes32[](0)); } @@ -591,7 +591,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { cheats.prank(operatorToRegister); cheats.roll(registrationBlockNumber); - cheats.expectRevert("BLSIndexRegistryCoordinator.registerOperatorWithCoordinator: registering operator has less than kickBIPsOfOperatorStake"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices.registerOperatorWithCoordinator: registering operator has less than kickBIPsOfOperatorStake"); registryCoordinator.registerOperatorWithCoordinator(quorumNumbers, operatorToRegisterPubKey, defaultSocket, operatorKickParams); } @@ -649,7 +649,7 @@ contract BLSRegistryCoordinatorWithIndicesUnit is MockAVSDeployer { cheats.prank(operatorToRegister); cheats.roll(registrationBlockNumber); - cheats.expectRevert("BLSIndexRegistryCoordinator.registerOperatorWithCoordinator: operator to kick has more than kickBIPSOfTotalStake"); + cheats.expectRevert("BLSRegistryCoordinatorWithIndices.registerOperatorWithCoordinator: operator to kick has more than kickBIPSOfTotalStake"); registryCoordinator.registerOperatorWithCoordinator(quorumNumbers, operatorToRegisterPubKey, defaultSocket, operatorKickParams); } } \ No newline at end of file