Skip to content

Commit

Permalink
style: remove unused index registry function
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc committed Nov 2, 2023
1 parent 5cd0d96 commit 698d818
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 90 deletions.
31 changes: 0 additions & 31 deletions src/IndexRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions src/interfaces/IIndexRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
51 changes: 0 additions & 51 deletions test/unit/IndexRegistryUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 698d818

Please sign in to comment.