Skip to content
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
2 changes: 1 addition & 1 deletion src/IndexRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ contract IndexRegistry is IndexRegistryStorage {
}
}

// we should only it this if the operatorIndex was never used before blockNumber
// we should only hit this if the operatorIndex was never used before blockNumber
return OPERATOR_DOES_NOT_EXIST_ID;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ServiceManagerBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol";

/**
* @title Minimal implementation of a ServiceManager-type contract.
* This contract can inherited from or simply used as a point-of-reference.
* This contract can be inherited from or simply used as a point-of-reference.
* @author Layr Labs, Inc.
*/
abstract contract ServiceManagerBase is IServiceManager, OwnableUpgradeable {
Expand Down
24 changes: 12 additions & 12 deletions src/StakeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ contract StakeRegistry is StakeRegistryStorage {
}

/**
* @notice Modifys the weights of existing strategies for a specific quorum
* @notice Modifies the weights of existing strategies for a specific quorum
* @param quorumNumber is the quorum number to which the strategies belong
* @param strategyIndices are the indices of the strategies to change
* @param newMultipliers are the new multipliers for the strategies
Expand Down Expand Up @@ -394,7 +394,7 @@ contract StakeRegistry is StakeRegistryStorage {
/**
* @notice Adds `strategyParams` to the `quorumNumber`-th quorum.
* @dev Checks to make sure that the *same* strategy cannot be added multiple times (checks against both against existing and new strategies).
* @dev This function has no check to make sure that the strategies for a single quorum have the same underlying asset. This is a concious choice,
* @dev This function has no check to make sure that the strategies for a single quorum have the same underlying asset. This is a conscious choice,
* since a middleware may want, e.g., a stablecoin quorum that accepts USDC, USDT, DAI, etc. as underlying assets and trades them as "equivalent".
*/
function _addStrategyParams(
Expand Down Expand Up @@ -445,23 +445,23 @@ contract StakeRegistry is StakeRegistryStorage {
}
}

/// @notice Validates that the `operatorStake` was accurate at the given `blockNumber`
function _validateOperatorStakeUpdateAtBlockNumber(
StakeUpdate memory operatorStakeUpdate,
/// @notice Checks that the `stakeUpdate` was valid at the given `blockNumber`
function _validateStakeUpdateAtBlockNumber(
StakeUpdate memory stakeUpdate,
uint32 blockNumber
) internal pure {
/**
* Validate that the update is valid for the given blockNumber:
* Check that the update is valid for the given blockNumber:
* - blockNumber should be >= the update block number
* - the next update block number should be either 0 or strictly greater than blockNumber
*/
require(
blockNumber >= operatorStakeUpdate.updateBlockNumber,
"StakeRegistry._validateOperatorStakeAtBlockNumber: operatorStakeUpdate is from after blockNumber"
blockNumber >= stakeUpdate.updateBlockNumber,
"StakeRegistry._validateStakeUpdateAtBlockNumber: stakeUpdate is from after blockNumber"
);
require(
operatorStakeUpdate.nextUpdateBlockNumber == 0 || blockNumber < operatorStakeUpdate.nextUpdateBlockNumber,
"StakeRegistry._validateOperatorStakeAtBlockNumber: there is a newer operatorStakeUpdate available before blockNumber"
stakeUpdate.nextUpdateBlockNumber == 0 || blockNumber < stakeUpdate.nextUpdateBlockNumber,
"StakeRegistry._validateStakeUpdateAtBlockNumber: there is a newer stakeUpdate available before blockNumber"
);
}

Expand Down Expand Up @@ -633,7 +633,7 @@ contract StakeRegistry is StakeRegistryStorage {
uint256 index
) external view returns (uint96) {
StakeUpdate memory operatorStakeUpdate = operatorStakeHistory[operatorId][quorumNumber][index];
_validateOperatorStakeUpdateAtBlockNumber(operatorStakeUpdate, blockNumber);
_validateStakeUpdateAtBlockNumber(operatorStakeUpdate, blockNumber);
return operatorStakeUpdate.stake;
}

Expand Down Expand Up @@ -682,7 +682,7 @@ contract StakeRegistry is StakeRegistryStorage {
uint256 index
) external view returns (uint96) {
StakeUpdate memory totalStakeUpdate = _totalStakeHistory[quorumNumber][index];
_validateOperatorStakeUpdateAtBlockNumber(totalStakeUpdate, blockNumber);
_validateStakeUpdateAtBlockNumber(totalStakeUpdate, blockNumber);
return totalStakeUpdate.stake;
}

Expand Down
2 changes: 1 addition & 1 deletion src/StakeRegistryStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract contract StakeRegistryStorage is IStakeRegistry {

/// @notice Constant used as a divisor in calculating weights.
uint256 public constant WEIGHTING_DIVISOR = 1e18;
/// @notice Maximum length of dynamic arrays in the `strategiesConsideredAndMultipliers` mapping.
/// @notice Maximum length of dynamic arrays in the `strategyParams` mapping.
uint8 public constant MAX_WEIGHING_FUNCTION_LENGTH = 32;
/// @notice Constant used as a divisor in dealing with BIPS amounts.
uint256 internal constant MAX_BIPS = 10000;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBLSApkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IRegistry} from "./IRegistry.sol";
import {BN254} from "../libraries/BN254.sol";

/**
* @title Minimal interface for a registry that keeps track of aggregate operator public keys for among many quorums.
* @title Minimal interface for a registry that keeps track of aggregate operator public keys across many quorums.
* @author Layr Labs, Inc.
*/
interface IBLSApkRegistry is IRegistry {
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IBLSSignatureChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface IBLSSignatureChecker {
uint32[] nonSignerQuorumBitmapIndices; // is the indices of all nonsigner quorum bitmaps
BN254.G1Point[] nonSignerPubkeys; // is the G1 pubkeys of all nonsigners
BN254.G1Point[] quorumApks; // is the aggregate G1 pubkey of each quorum
BN254.G2Point apkG2; // is the aggregate G2 pubkey of all signers and non signers
BN254.G2Point apkG2; // is the aggregate G2 pubkey of all signers
BN254.G1Point sigma; // is the aggregate G1 signature of all signers
uint32[] quorumApkIndices; // is the indices of each quorum aggregate pubkey
uint32[] totalStakeIndices; // is the indices of each quorums total stake
Expand Down
19 changes: 8 additions & 11 deletions src/libraries/BitmapUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,29 @@ library BitmapUtils {
* It also returns 'false' early for arrays with length in excess of MAX_BYTE_ARRAY_LENGTH (i.e. so long that they cannot be strictly ordered)
*/
function isArrayStrictlyAscendingOrdered(bytes calldata bytesArray) internal pure returns (bool) {
// return 'false' early for too-long (i.e. unorderable) arrays
// Return early if the array is too long, or has a length of 0
if (bytesArray.length > MAX_BYTE_ARRAY_LENGTH) {
return false;
}

// return 'true' early if length of array is 0
if (bytesArray.length == 0) {
return true;
}

// initialize an empty byte object, to be re-used inside the loop
bytes1 singleByte;
// Perform the 0-th loop iteration by pulling the 0th byte out of the array
bytes1 singleByte = bytesArray[0];

// perform the 0-th loop iteration with the ordering check *omitted* (otherwise it will break with an out-of-bounds error)
// pull the 0th byte out of the array
singleByte = bytesArray[0];

// loop through each byte in the array to construct the bitmap
// For each byte, validate that each entry is *strictly greater than* the previous
// If it isn't, return false as the array is not ordered
for (uint256 i = 1; i < bytesArray.length; ++i) {
// check if the entry is *less than or equal to* the previous entry. if it is, then the array isn't strictly ordered!
if (uint256(uint8(bytesArray[i])) <= uint256(uint8(singleByte))) {
return false;
}
// pull the next byte out of the array

// Pull the next byte out of the array
singleByte = bytesArray[i];
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/BLSSignatureCheckerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer {
// set the totalStakeIndices to a different value
nonSignerStakesAndSignature.totalStakeIndices[0] = 0;

cheats.expectRevert("StakeRegistry._validateOperatorStakeAtBlockNumber: there is a newer operatorStakeUpdate available before blockNumber");
cheats.expectRevert("StakeRegistry._validateStakeUpdateAtBlockNumber: there is a newer stakeUpdate available before blockNumber");
blsSignatureChecker.checkSignatures(
msgHash,
quorumNumbers,
Expand Down Expand Up @@ -398,7 +398,7 @@ contract BLSSignatureCheckerUnitTests is BLSMockAVSDeployer {
// set the nonSignerStakeIndices to a different value
nonSignerStakesAndSignature.nonSignerStakeIndices[0][0] = 1;

cheats.expectRevert("StakeRegistry._validateOperatorStakeAtBlockNumber: operatorStakeUpdate is from after blockNumber");
cheats.expectRevert("StakeRegistry._validateStakeUpdateAtBlockNumber: stakeUpdate is from after blockNumber");
blsSignatureChecker.checkSignatures(
msgHash,
quorumNumbers,
Expand Down