From 698d8187ce756dd84fa47273c351d6f43c053f01 Mon Sep 17 00:00:00 2001 From: wadealexc Date: Thu, 2 Nov 2023 15:41:00 +0000 Subject: [PATCH] style: remove unused index registry function --- src/IndexRegistry.sol | 31 ------------------- src/interfaces/IIndexRegistry.sol | 8 ----- test/unit/IndexRegistryUnit.t.sol | 51 ------------------------------- 3 files changed, 90 deletions(-) diff --git a/src/IndexRegistry.sol b/src/IndexRegistry.sol index 54582cf2..2cfddb89 100644 --- a/src/IndexRegistry.sol +++ b/src/IndexRegistry.sol @@ -324,37 +324,6 @@ contract IndexRegistry is IndexRegistryStorage { return _latestIndexUpdate(quorumNumber, index); } - /** - * @notice Looks up the number of total operators for `quorumNumber` at the specified `blockNumber`. - * @param quorumNumber is the quorum number for which the total number of operators is desired - * @param blockNumber is the block number at which the total number of operators is desired - * @param index is the index of the entry in the dynamic array `_operatorCountHistory[quorumNumber]` to read data from - * @dev Function will revert in the event that the specified `index` input is outisde the bounds of the provided `blockNumber` - */ - function getTotalOperatorsForIndexAtBlockNumber( - uint8 quorumNumber, - uint32 blockNumber, - uint32 index - ) external view returns (uint32){ - QuorumUpdate memory quorumUpdate = _operatorCountHistory[quorumNumber][index]; - - // blocknumber must be at or after the "index'th" entry's fromBlockNumber - require( - blockNumber >= quorumUpdate.fromBlockNumber, - "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: provided index is too far in the past for provided block number" - ); - - // if there is an index update after the "index'th" update, the blocknumber must be before the next entry's fromBlockNumber - if (index != _operatorCountHistory[quorumNumber].length - 1){ - QuorumUpdate memory nextQuorumUpdate = _operatorCountHistory[quorumNumber][index + 1]; - require( - blockNumber < nextQuorumUpdate.fromBlockNumber, - "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: provided index is too far in the future for provided block number" - ); - } - return quorumUpdate.numOperators; - } - /// @notice Returns an ordered list of operators of the services for the given `quorumNumber` at the given `blockNumber` function getOperatorListAtBlockNumber( uint8 quorumNumber, diff --git a/src/interfaces/IIndexRegistry.sol b/src/interfaces/IIndexRegistry.sol index 9875e50f..83c6b872 100644 --- a/src/interfaces/IIndexRegistry.sol +++ b/src/interfaces/IIndexRegistry.sol @@ -72,14 +72,6 @@ interface IIndexRegistry is IRegistry { /// @notice Returns the _operatorCountHistory entry for the specified `quorumNumber` at the specified `index` function getQuorumUpdateAtIndex(uint8 quorumNumber, uint32 index) external view returns (QuorumUpdate memory); - /** - * @notice Looks up the number of total operators for `quorumNumber` at the specified `blockNumber`. - * @param quorumNumber is the quorum number for which the total number of operators is desired - * @param blockNumber is the block number at which the total number of operators is desired - * @param index is the index of the entry in the dynamic array `_operatorCountHistory[quorumNumber]` to read data from - */ - function getTotalOperatorsForIndexAtBlockNumber(uint8 quorumNumber, uint32 blockNumber, uint32 index) external view returns (uint32); - /// @notice Returns the current number of operators of this service for `quorumNumber`. function totalOperatorsForQuorum(uint8 quorumNumber) external view returns (uint32); diff --git a/test/unit/IndexRegistryUnit.t.sol b/test/unit/IndexRegistryUnit.t.sol index 83005d39..fea65d80 100644 --- a/test/unit/IndexRegistryUnit.t.sol +++ b/test/unit/IndexRegistryUnit.t.sol @@ -333,57 +333,6 @@ contract IndexRegistryUnitTests is Test { UNIT TESTS - GETTERS *******************************************************************************/ - function testGetTotalOperatorsForQuorumAtBlockNumberByIndex_revert_indexTooEarly() public { - // Add operator - bytes memory quorumNumbers = new bytes(1); - quorumNumbers[0] = bytes1(defaultQuorumNumber); - _registerOperator(operatorId1, quorumNumbers); - - cheats.expectRevert( - "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: provided index is too far in the past for provided block number" - ); - indexRegistry.getTotalOperatorsForIndexAtBlockNumber(defaultQuorumNumber, uint32(block.number - 1), 0); - } - - function testGetTotalOperatorsForQuorumAtBlockNumberByIndex_revert_indexBlockMismatch() public { - // Add two operators - bytes memory quorumNumbers = new bytes(1); - quorumNumbers[0] = bytes1(defaultQuorumNumber); - _registerOperator(operatorId1, quorumNumbers); - vm.roll(block.number + 10); - _registerOperator(operatorId2, quorumNumbers); - - cheats.expectRevert( - "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: provided index is too far in the future for provided block number" - ); - indexRegistry.getTotalOperatorsForIndexAtBlockNumber(defaultQuorumNumber, uint32(block.number), 0); - } - - function testGetTotalOperatorsForIndexAtBlockNumber() public { - // Add two operators - bytes memory quorumNumbers = new bytes(1); - quorumNumbers[0] = bytes1(defaultQuorumNumber); - _registerOperator(operatorId1, quorumNumbers); - vm.roll(block.number + 10); - _registerOperator(operatorId2, quorumNumbers); - - // Check that the first total is correct - uint32 prevTotal = indexRegistry.getTotalOperatorsForIndexAtBlockNumber( - defaultQuorumNumber, - uint32(block.number - 10), - 0 - ); - require(prevTotal == 1, "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: prev total not 1"); - - // Check that the total is correct - uint32 currentTotal = indexRegistry.getTotalOperatorsForIndexAtBlockNumber( - defaultQuorumNumber, - uint32(block.number), - 1 - ); - require(currentTotal == 2, "IndexRegistry.getTotalOperatorsForIndexAtBlockNumber: current total not 2"); - } - function testGetOperatorListForQuorumAtBlockNumber() public { // Register two operators bytes memory quorumNumbers = new bytes(1);