Skip to content

Commit 2db5d45

Browse files
ypatil12eigenmikem
andcommitted
docs: natspec review updates (#526)
**Motivation:** Natspec review updates **Modifications:** - Add error reason to natspec - Add event messages **Result:** Cleaner code --------- Co-authored-by: eigenmikem <[email protected]>
1 parent 4982292 commit 2db5d45

File tree

9 files changed

+65
-15
lines changed

9 files changed

+65
-15
lines changed

src/interfaces/IBN254TableCalculator.sol

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ import {
99

1010
interface IBN254TableCalculator is IOperatorTableCalculator, IOperatorTableCalculatorTypes {
1111
/**
12-
* @notice calculates the operatorInfos for a given operatorSet
13-
* @param operatorSet the operatorSet to calculate the operator table for
14-
* @return operatorSetInfo the operatorSetInfo for the given operatorSet
12+
* @notice Calculates the BN254 operator table info for a given operatorSet
13+
* @param operatorSet The operatorSet to calculate the operator table for
14+
* @return operatorSetInfo The BN254OperatorSetInfo containing merkle root, aggregate pubkey, and total weights
1515
* @dev The output of this function is used by the multichain protocol to transport operator stake weights to destination chains
16+
* @dev This function aggregates operator weights, creates a merkle tree of operator info, and calculates the aggregate BN254 public key
1617
*/
1718
function calculateOperatorTable(
1819
OperatorSet calldata operatorSet
1920
) external view returns (BN254OperatorSetInfo memory operatorSetInfo);
2021

2122
/**
22-
* @notice Get the operatorInfos for a given operatorSet
23-
* @param operatorSet the operatorSet to get the operatorInfos for
24-
* @return operatorInfos the operatorInfos for the given operatorSet
23+
* @notice Get the individual operator infos for a given operatorSet
24+
* @param operatorSet The operatorSet to get the operatorInfos for
25+
* @return operatorInfos The array of BN254OperatorInfo structs containing pubkeys and weights for registered operators
26+
* @dev Only returns operators that have registered their BN254 keys with the KeyRegistrar
2527
*/
2628
function getOperatorInfos(
2729
OperatorSet calldata operatorSet

src/interfaces/IECDSATableCalculator.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import {
99

1010
interface IECDSATableCalculator is IOperatorTableCalculator, IOperatorTableCalculatorTypes {
1111
/**
12-
* @notice calculates the operatorInfos for a given operatorSet
13-
* @param operatorSet the operatorSet to calculate the operator table for
14-
* @return operatorInfos the list of operatorInfos for the given operatorSet
12+
* @notice Calculates the ECDSA operator infos for a given operatorSet
13+
* @param operatorSet The operatorSet to calculate the operator table for
14+
* @return operatorInfos The array of ECDSAOperatorInfo structs containing ECDSA addresses and weights for registered operators
1515
* @dev The output of this function is used by the multichain protocol to transport operator stake weights to destination chains
16+
* @dev Only returns operators that have registered their ECDSA keys with the KeyRegistrar and have non-zero stake
1617
*/
1718
function calculateOperatorTable(
1819
OperatorSet calldata operatorSet

src/interfaces/ISocketRegistryV2.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface ISocketRegistryV2 is ISocketRegistryErrors, ISocketRegistryEvents {
2929
* @param operator The operator to set the socket for.
3030
* @param socket The socket to set for the operator.
3131
* @dev This function can only be called by the operator themselves.
32+
* @dev Reverts for:
33+
* - CallerNotOperator: The caller is not the operator
3234
*/
3335
function updateSocket(address operator, string memory socket) external;
3436
}

src/middlewareV2/registrar/AVSRegistrar.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ abstract contract AVSRegistrar is Initializable, AVSRegistrarStorage {
3939
}
4040

4141
/// @inheritdoc IAVSRegistrar
42+
/// @dev Reverts for:
43+
/// - NotAllocationManager: The caller is not the allocation manager
44+
/// - KeyNotRegistered: The operator has not registered a key for the given operator sets in the `KeyRegistrar`
4245
function registerOperator(
4346
address operator,
4447
address, /* avs */
@@ -56,6 +59,8 @@ abstract contract AVSRegistrar is Initializable, AVSRegistrarStorage {
5659
}
5760

5861
/// @inheritdoc IAVSRegistrar
62+
/// @dev Reverts for:
63+
/// - NotAllocationManager: The caller is not the allocation manager
5964
function deregisterOperator(
6065
address operator,
6166
address, /* avs */
@@ -85,6 +90,8 @@ abstract contract AVSRegistrar is Initializable, AVSRegistrarStorage {
8590
* @notice Validates that the operator has registered a key for the given operator sets in the `KeyRegistrar`
8691
* @param operator The operator to validate
8792
* @param operatorSetIds The operator sets to validate
93+
* @dev Reverts for:
94+
* - KeyNotRegistered: The operator has not registered a key for the given operator sets in the `KeyRegistrar`
8895
*/
8996
function _validateOperatorKeys(
9097
address operator,

src/middlewareV2/registrar/presets/AVSRegistrarWithAllowlist.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ contract AVSRegistrarWithAllowlist is AVSRegistrar, Allowlist, IAVSRegistrarWith
2525
}
2626

2727
/// @notice Before registering operator, check if the operator is in the allowlist
28+
/// @dev Reverts for:
29+
/// - OperatorNotInAllowlist: The operator is not in the allowlist
2830
function _beforeRegisterOperator(
2931
address operator,
3032
uint32[] calldata operatorSetIds,

src/middlewareV2/tableCalculator/BN254TableCalculator.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ contract BN254TableCalculator is BN254TableCalculatorBase {
2121
/// @notice The default lookahead blocks for the slashable stake lookup
2222
uint256 public immutable LOOKAHEAD_BLOCKS;
2323

24+
/**
25+
* @notice Constructor to initialize the BN254TableCalculator
26+
* @param _keyRegistrar The KeyRegistrar contract for managing operator BN254 keys
27+
* @param _allocationManager The AllocationManager contract for operator allocations and slashable stake
28+
* @param _LOOKAHEAD_BLOCKS The number of blocks to look ahead when calculating minimum slashable stake
29+
* @dev The lookahead blocks parameter helps ensure stake calculations account for future slashing events
30+
*/
2431
constructor(
2532
IKeyRegistrar _keyRegistrar,
2633
IAllocationManager _allocationManager,
@@ -31,11 +38,14 @@ contract BN254TableCalculator is BN254TableCalculatorBase {
3138
}
3239

3340
/**
34-
* @notice Get the operator weights for a given operatorSet based on the slashable stake.
41+
* @notice Get the operator weights for a given operatorSet based on the minimum slashable stake.
3542
* @param operatorSet The operatorSet to get the weights for
36-
* @return operators The addresses of the operators in the operatorSet
43+
* @return operators The addresses of the operators in the operatorSet with non-zero slashable stake
3744
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
3845
* and the second index is the type of weight. In this case its of length 1 and returns the slashable stake for the operatorSet.
46+
* @dev This implementation sums the minimum slashable stake across all strategies for each operator
47+
* @dev Only includes operators with non-zero total slashable stake to optimize gas usage
48+
* @dev The weights array contains only one element per operator representing their total slashable stake
3949
*/
4050
function _getOperatorWeights(
4151
OperatorSet calldata operatorSet

src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator {
2323
/// @notice KeyRegistrar contract for managing operator keys
2424
IKeyRegistrar public immutable keyRegistrar;
2525

26+
/**
27+
* @notice Constructor to initialize the BN254TableCalculatorBase
28+
* @param _keyRegistrar The KeyRegistrar contract for managing operator BN254 public keys
29+
*/
2630
constructor(
2731
IKeyRegistrar _keyRegistrar
2832
) {
@@ -68,6 +72,9 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator {
6872
}
6973

7074
/// @inheritdoc IBN254TableCalculator
75+
/**
76+
* @dev Only returns operators that have registered their BN254 keys with the KeyRegistrar
77+
*/
7178
function getOperatorInfos(
7279
OperatorSet calldata operatorSet
7380
) external view virtual returns (BN254OperatorInfo[] memory) {
@@ -109,13 +116,14 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator {
109116
/**
110117
* @notice Calculates the operator table for a given operatorSet, also calculates the aggregate pubkey for the operatorSet
111118
* @param operatorSet The operatorSet to calculate the operator table for
112-
* @return operatorSetInfo The operator table for the given operatorSet
119+
* @return operatorSetInfo The BN254OperatorSetInfo containing merkle root, operator count, aggregate pubkey, and total weights
113120
* @dev This function:
114121
* 1. Gets operator weights from the weight calculator
115122
* 2. Collates weights into total weights
116123
* 3. Creates a merkle tree of operator info
117124
* - assumes that the operator has a registered BN254 key
118125
* 4. Calculates the aggregate public key
126+
* @dev Returns empty operator set info if no operators have registered keys or non-zero weights
119127
*/
120128
function _calculateOperatorTable(
121129
OperatorSet calldata operatorSet

src/middlewareV2/tableCalculator/ECDSATableCalculator.sol

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ contract ECDSATableCalculator is ECDSATableCalculatorBase {
2121
/// @notice The default lookahead blocks for the slashable stake lookup
2222
uint256 public immutable LOOKAHEAD_BLOCKS;
2323

24+
/**
25+
* @notice Constructor to initialize the ECDSATableCalculator
26+
* @param _keyRegistrar The KeyRegistrar contract for managing operator ECDSA keys
27+
* @param _allocationManager The AllocationManager contract for operator allocations and slashable stake
28+
* @param _LOOKAHEAD_BLOCKS The number of blocks to look ahead when calculating minimum slashable stake
29+
* @dev The lookahead blocks parameter helps ensure stake calculations account for future slashing events
30+
*/
2431
constructor(
2532
IKeyRegistrar _keyRegistrar,
2633
IAllocationManager _allocationManager,
@@ -31,11 +38,14 @@ contract ECDSATableCalculator is ECDSATableCalculatorBase {
3138
}
3239

3340
/**
34-
* @notice Get the operator weights for a given operatorSet based on the slashable stake.
41+
* @notice Get the operator weights for a given operatorSet based on the minimum slashable stake.
3542
* @param operatorSet The operatorSet to get the weights for
36-
* @return operators The addresses of the operators in the operatorSet
43+
* @return operators The addresses of the operators in the operatorSet with non-zero slashable stake
3744
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
3845
* and the second index is the type of weight. In this case it's of length 1 and returns the slashable stake for the operatorSet.
46+
* @dev This implementation sums the minimum slashable stake across all strategies for each operator
47+
* @dev Only includes operators with non-zero total slashable stake to optimize gas usage
48+
* @dev The weights array contains only one element per operator representing their total slashable stake
3949
*/
4050
function _getOperatorWeights(
4151
OperatorSet calldata operatorSet

src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator {
1818
/// @notice KeyRegistrar contract for managing operator keys
1919
IKeyRegistrar public immutable keyRegistrar;
2020

21+
/**
22+
* @notice Constructor to initialize the ECDSATableCalculatorBase
23+
* @param _keyRegistrar The KeyRegistrar contract for managing operator ECDSA public keys
24+
*/
2125
constructor(
2226
IKeyRegistrar _keyRegistrar
2327
) {
2428
keyRegistrar = _keyRegistrar;
2529
}
2630

2731
/// @inheritdoc IECDSATableCalculator
32+
/**
33+
* @dev Only returns operators that have registered their ECDSA keys with the KeyRegistrar and have non-zero stake
34+
*/
2835
function calculateOperatorTable(
2936
OperatorSet calldata operatorSet
3037
) external view virtual returns (ECDSAOperatorInfo[] memory operatorInfos) {
@@ -81,10 +88,11 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator {
8188
/**
8289
* @notice Calculates the operator table for a given operatorSet
8390
* @param operatorSet The operatorSet to calculate the operator table for
84-
* @return operatorInfos The operator table for the given operatorSet
91+
* @return operatorInfos The array of ECDSAOperatorInfo structs for operators with registered ECDSA keys
8592
* @dev This function:
8693
* 1. Gets operator weights from the weight calculator
8794
* 2. Creates ECDSAOperatorInfo structs for each operator with registered ECDSA keys
95+
* @dev Returns empty array if no operators have registered keys or non-zero weights
8896
*/
8997
function _calculateOperatorTable(
9098
OperatorSet calldata operatorSet

0 commit comments

Comments
 (0)