Skip to content

Commit ec9fc68

Browse files
authored
docs: natspec updates (#521)
**Motivation:** *Explain here the context, and why you're making that change. What is the problem you're trying to solve.* **Modifications:** *Describe the modifications you've done.* **Result:** *After your change, what will change.*
1 parent ec35d75 commit ec9fc68

6 files changed

Lines changed: 54 additions & 15 deletions

File tree

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/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
@@ -21,13 +21,20 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator {
2121
/// @notice KeyRegistrar contract for managing operator keys
2222
IKeyRegistrar public immutable keyRegistrar;
2323

24+
/**
25+
* @notice Constructor to initialize the ECDSATableCalculatorBase
26+
* @param _keyRegistrar The KeyRegistrar contract for managing operator ECDSA public keys
27+
*/
2428
constructor(
2529
IKeyRegistrar _keyRegistrar
2630
) {
2731
keyRegistrar = _keyRegistrar;
2832
}
2933

3034
/// @inheritdoc IECDSATableCalculator
35+
/**
36+
* @dev Only returns operators that have registered their ECDSA keys with the KeyRegistrar and have non-zero stake
37+
*/
3138
function calculateOperatorTable(
3239
OperatorSet calldata operatorSet
3340
) external view virtual returns (ECDSAOperatorInfo[] memory operatorInfos) {
@@ -84,10 +91,11 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator {
8491
/**
8592
* @notice Calculates the operator table for a given operatorSet
8693
* @param operatorSet The operatorSet to calculate the operator table for
87-
* @return operatorInfos The operator table for the given operatorSet
94+
* @return operatorInfos The array of ECDSAOperatorInfo structs for operators with registered ECDSA keys
8895
* @dev This function:
8996
* 1. Gets operator weights from the weight calculator
9097
* 2. Creates ECDSAOperatorInfo structs for each operator with registered ECDSA keys
98+
* @dev Returns empty array if no operators have registered keys or non-zero weights
9199
*/
92100
function _calculateOperatorTable(
93101
OperatorSet calldata operatorSet

0 commit comments

Comments
 (0)