Skip to content

Commit 5a70c22

Browse files
committed
chore: update documentation
1 parent 7aedea4 commit 5a70c22

File tree

3 files changed

+57
-25
lines changed

3 files changed

+57
-25
lines changed

docs/middlewareV2/OperatorTableCalculator.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ The `ECDSATableCalculatorBase` provides base functionality for calculating ECDSA
4848

4949
```solidity
5050
/**
51-
* @notice A struct that contains information about a single operator
51+
* @notice A struct that contains information about a single operator for an ECDSA signing key
5252
* @param pubkey The address of the signing ECDSA key of the operator and not the operator address itself.
53-
* This is read from the KeyRegistrar contract.
5453
* @param weights The weights of the operator for a single operatorSet
55-
* @dev The `weights` array can be defined as a list of arbitrary groupings. For example,
56-
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]
57-
* @dev The `weights` array should be the same length for each operator in the operatorSet.
54+
*
55+
* @dev The `weights` array can be defined as a list of arbitrary stake types. For example,
56+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
57+
*
58+
* @dev It is up to the AVS to define the `weights` array, which is used by the `IECDSACertificateVerifier` to verify Certificates
59+
*
60+
* @dev For each operator, the `weights` array should be the same length and composition, otherwise verification issues can arise
5861
*/
5962
struct ECDSAOperatorInfo {
6063
address pubkey;
@@ -88,9 +91,10 @@ Calculates and returns an array of `ECDSAOperatorInfo` structs containing public
8891

8992
```solidity
9093
/**
91-
* @notice Calculates the operator table bytes for a given operatorSet
92-
* @param operatorSet The operatorSet to calculate the operator table for
93-
* @return operatorTableBytes The encoded operator table bytes
94+
* @notice Calculates the operator table, in bytes, for a given operatorSet
95+
* @param operatorSet the operatorSet to calculate the operator table for
96+
* @return operatorTableBytes the operatorTableBytes for the given operatorSet
97+
* @dev The `operatorTableBytes` is used by the offchain multichain protocol to calculate and merkleize the operator table
9498
*/
9599
function calculateOperatorTableBytes(
96100
OperatorSet calldata operatorSet
@@ -111,14 +115,21 @@ Returns the ABI-encoded bytes representation of the operator table, which is use
111115
* @notice Abstract function to get the operator weights for a given operatorSet
112116
* @param operatorSet The operatorSet to get the weights for
113117
* @return operators The addresses of the operators in the operatorSet
114-
* @return weights The weights for each operator in the operatorSet
118+
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
119+
* and the second index is the type of weight
120+
* @dev Each single `weights` array is as a list of arbitrary stake types. For example,
121+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
122+
* @dev Must be implemented by derived contracts to define specific weight calculation logic
123+
* @dev The certificate verification assumes the composition weights array for each operator is the same.
124+
* If the length of the array is different or the stake types are different, then verification issues can arise, including
125+
* verification failing silently for multiple operators with different weights structures
115126
*/
116127
function _getOperatorWeights(
117128
OperatorSet calldata operatorSet
118129
) internal view virtual returns (address[] memory operators, uint256[][] memory weights);
119130
```
120131

121-
Must be implemented by derived contracts to define the weight calculation strategy. See [stakeWeighting](#stake-weighting) for more information.
132+
Must be implemented by derived contracts to define the weight calculation strategy. See [stakeWeighting](#stake-weighting) for more information. When implementing this function, AVSs must ensure that all operators have an identical weights structure and length types. Failure to do so can result in certificates being verified with silent failures.
122133

123134
An example integration is in [`ECDSATableCalculator`](../../src/middlewareV2/tableCalculator/ECDSATableCalculator.sol)
124135

@@ -134,30 +145,35 @@ The `BN254TableCalculatorBase` provides base functionality for calculating BN254
134145

135146
```solidity
136147
/**
137-
* @notice A struct that contains information about a single operator
138-
* @param pubkey The G1 public key of the operator.
139-
* @param weights The weights of the operator for a single operatorSet.
140-
* @dev The `weights` array can be defined as a list of arbitrary groupings. For example,
141-
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]
148+
* @notice A struct that contains information about a single operator for a given BN254 operatorSet
149+
* @param pubkey The G1 public key of the operator
150+
* @param weights The weights of the operator for a single operatorSet
151+
*
152+
* @dev The `weights` array is as a list of arbitrary stake types. For example,
153+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
154+
*
155+
* @dev It is up to the AVS to define the `weights` array, which is used by the `IBN254CertificateVerifier` to verify Certificates
156+
*
157+
* @dev For each operator, the `weights` array should be the same length and composition, otherwise verification issues can arise
142158
*/
143159
struct BN254OperatorInfo {
144160
BN254.G1Point pubkey;
145161
uint256[] weights;
146162
}
147163
148164
/**
149-
* @notice A struct that contains information about all operators for a given operatorSet
150-
* @param operatorInfoTreeRoot The root of the operatorInfo tree. Each leaf is a `BN254OperatorInfo` struct
151-
* @param numOperators The number of operators in the operatorSet.
152-
* @param aggregatePubkey The aggregate G1 public key of the operators in the operatorSet.
153-
* @param totalWeights The total weights of the operators in the operatorSet.
165+
* @notice A struct that contains information about all operators for a given BN254operatorSet
166+
* @param operatorInfoTreeRoot The root of the operatorInfo tree
167+
* @param numOperators The number of operators in the operatorSet
168+
* @param aggregatePubkey The aggregate G1 public key of the operators in the operatorSet
169+
* @param totalWeights The total stake weights of the operators in the operatorSet
154170
*
155171
* @dev The operatorInfoTreeRoot is the root of a merkle tree that contains the operatorInfos for each operator in the operatorSet.
156-
* It is calculated in this function and used by the `IBN254CertificateVerifier` to verify stakes against the non-signing operators
172+
* It is calculated on-chain by the `BN254TableCalculator` and used by the `IBN254CertificateVerifier` to verify stakes against the non-signing operators
157173
*
158-
* @dev Retrieval of the `aggregatePubKey` depends on maintaining a key registry contract, see `BN254TableCalculatorBase` for an example implementation.
174+
* @dev Retrieval of the `aggregatePubKey` depends on maintaining a key registry contract, see `KeyRegistrar` for an example implementation
159175
*
160-
* @dev The `totalWeights` array should be the same length as each individual `weights` array in `operatorInfos`.
176+
* @dev The `totalWeights` array should be the same length and composition as each individual `weights` array in `BN254OperatorInfo`
161177
*/
162178
struct BN254OperatorSetInfo {
163179
bytes32 operatorInfoTreeRoot;
@@ -243,13 +259,20 @@ Returns an array of `BN254OperatorInfo` structs for all operators in the operato
243259
* @notice Abstract function to get the operator weights for a given operatorSet
244260
* @param operatorSet The operatorSet to get the weights for
245261
* @return operators The addresses of the operators in the operatorSet
246-
* @return weights The weights for each operator in the operatorSet
262+
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
263+
* and the second index is the type of weight
264+
* @dev Each single `weights` array is as a list of arbitrary stake types. For example,
265+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
266+
* @dev Must be implemented by derived contracts to define specific weight calculation logic
267+
* @dev The certificate verification assumes the composition weights array for each operator is the same.
268+
* If the length of the array is different or the stake types are different, then verification issues can arise, including
269+
* verification failing silently for multiple operators with different weights structures
247270
*/
248271
function _getOperatorWeights(
249272
OperatorSet calldata operatorSet
250273
) internal view virtual returns (address[] memory operators, uint256[][] memory weights);
251274
```
252275

253-
Must be implemented by derived contracts to define the weight calculation strategy. Similar to ECDSA, weights are a 2D array supporting multiple weight types per operator.
276+
Must be implemented by derived contracts to define the weight calculation strategy. Similar to ECDSA, weights are a 2D array supporting multiple weight types per operator. When implementing this function, AVSs must ensure that all operators have an identical weights structure and length types. Failure to do so can result in certificates being verified with silent failures.
254277

255278
An example integration is defined in [`BN254TableCalculator`](../../src/middlewareV2/tableCalculator/BN254TableCalculator.sol).

src/middlewareV2/tableCalculator/BN254TableCalculatorBase.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ abstract contract BN254TableCalculatorBase is IBN254TableCalculator {
9595
* @return operators The addresses of the operators in the operatorSet
9696
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
9797
* and the second index is the type of weight
98+
* @dev Each single `weights` array is as a list of arbitrary stake types. For example,
99+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
98100
* @dev Must be implemented by derived contracts to define specific weight calculation logic
101+
* @dev The certificate verification assumes the composition weights array for each operator is the same.
102+
* If the length of the array is different or the stake types are different, then verification issues can arise, including
103+
* verification failing silently for multiple operators with different weights structures
99104
*/
100105
function _getOperatorWeights(
101106
OperatorSet calldata operatorSet

src/middlewareV2/tableCalculator/ECDSATableCalculatorBase.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ abstract contract ECDSATableCalculatorBase is IECDSATableCalculator {
7171
* @return operators The addresses of the operators in the operatorSet
7272
* @return weights The weights for each operator in the operatorSet, this is a 2D array where the first index is the operator
7373
* and the second index is the type of weight
74+
* @dev Each single `weights` array is as a list of arbitrary stake types. For example,
75+
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]. Each stake type is an index in the array
7476
* @dev Must be implemented by derived contracts to define specific weight calculation logic
77+
* @dev The certificate verification assumes the composition weights array for each operator is the same.
78+
* If the length of the array is different or the stake types are different, then verification issues can arise
7579
*/
7680
function _getOperatorWeights(
7781
OperatorSet calldata operatorSet

0 commit comments

Comments
 (0)