Skip to content

Commit 8d42bef

Browse files
committed
refactor: natspec + interfaces
docs: `RegistryCoordinator` natspec chore: forge fmt refactor: named mapping params docs: natspec `BLSApkRegistry` docs: natspec `BLSApkRegistry` docs: natspec `BLSApkRegistry` refactor: interface structure refactor: separate `BLSSignatureChecker` storage refactor: rename -> `IECDSAStakeRegistry` docs: natspec docs: natspec `ECDSAStakeRegistry` docs: natspec `EjectionManager` + separate storage docs: natspec docs: natspec `IndexRegistry` refactor: remove `IRegistry` chore: forge fmt
1 parent d2bfd57 commit 8d42bef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2419
-1869
lines changed

docs/RegistryCoordinator.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ These methods allow operators to register for/deregister from one or more quorum
4242
function registerOperator(
4343
bytes calldata quorumNumbers,
4444
string calldata socket,
45-
IBLSApkRegistry.PubkeyRegistrationParams calldata params,
45+
IBLSApkRegistryTypes.PubkeyRegistrationParams calldata params,
4646
SignatureWithSaltAndExpiry memory operatorSignature
4747
)
4848
external
@@ -88,7 +88,7 @@ If the Operator was not currently registered for any quorums, this method will r
8888
function registerOperatorWithChurn(
8989
bytes calldata quorumNumbers,
9090
string calldata socket,
91-
IBLSApkRegistry.PubkeyRegistrationParams calldata params,
91+
IBLSApkRegistryTypes.PubkeyRegistrationParams calldata params,
9292
OperatorKickParam[] calldata operatorKickParams,
9393
SignatureWithSaltAndExpiry memory churnApproverSignature,
9494
SignatureWithSaltAndExpiry memory operatorSignature
@@ -256,7 +256,7 @@ These methods are used by the Owner to configure the `RegistryCoordinator`:
256256
function createQuorum(
257257
OperatorSetParam memory operatorSetParams,
258258
uint96 minimumStake,
259-
IStakeRegistry.StrategyParams[] memory strategyParams
259+
IStakeRegistryTypes.StrategyParams[] memory strategyParams
260260
)
261261
external
262262
virtual

docs/storage-report/StakeRegistry.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|
99
| operatorStakeHistory | mapping(bytes32 => mapping(uint8 => struct IStakeRegistry.StakeUpdate[])) | 2 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
1010
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|
11-
| strategyParams | mapping(uint8 => struct IStakeRegistry.StrategyParams[]) | 3 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
11+
| strategyParams | mapping(uint8 => struct IStakeRegistryTypes.StrategyParams[]) | 3 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
1212
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|
1313
| strategiesPerQuorum | mapping(uint8 => contract IStrategy[]) | 4 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
1414
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|
15-
| stakeTypePerQuorum | mapping(uint8 => enum StakeType) | 5 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
15+
| stakeTypePerQuorum | mapping(uint8 => enum IStakeRegistryTypes.StakeType) | 5 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
1616
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|
1717
| slashableStakeLookAheadPerQuorum | mapping(uint8 => uint32) | 6 | 0 | 32 | src/StakeRegistry.sol:StakeRegistry |
1818
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+-------------------------------------|

docs/storage-report/StakeRegistryStorage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|
99
| operatorStakeHistory | mapping(bytes32 => mapping(uint8 => struct IStakeRegistry.StakeUpdate[])) | 2 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
1010
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|
11-
| strategyParams | mapping(uint8 => struct IStakeRegistry.StrategyParams[]) | 3 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
11+
| strategyParams | mapping(uint8 => struct IStakeRegistryTypes.StrategyParams[]) | 3 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
1212
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|
1313
| strategiesPerQuorum | mapping(uint8 => contract IStrategy[]) | 4 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
1414
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|
15-
| stakeTypePerQuorum | mapping(uint8 => enum StakeType) | 5 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
15+
| stakeTypePerQuorum | mapping(uint8 => enum IStakeRegistryTypes.StakeType) | 5 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
1616
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|
1717
| slashableStakeLookAheadPerQuorum | mapping(uint8 => uint32) | 6 | 0 | 32 | src/StakeRegistryStorage.sol:StakeRegistryStorage |
1818
|----------------------------------+---------------------------------------------------------------------------+------+--------+-------+---------------------------------------------------|

src/BLSApkRegistry.sol

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.27;
33

4-
import {BLSApkRegistryStorage} from "./BLSApkRegistryStorage.sol";
4+
import {BLSApkRegistryStorage, IBLSApkRegistry} from "./BLSApkRegistryStorage.sol";
55

66
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
77

@@ -27,17 +27,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
2727
*
2828
*/
2929

30-
/**
31-
* @notice Registers the `operator`'s pubkey for the specified `quorumNumbers`.
32-
* @param operator The address of the operator to register.
33-
* @param quorumNumbers The quorum numbers the operator is registering for, where each byte is an 8 bit integer quorumNumber.
34-
* @dev access restricted to the RegistryCoordinator
35-
* @dev Preconditions (these are assumed, not validated in this contract):
36-
* 1) `quorumNumbers` has no duplicates
37-
* 2) `quorumNumbers.length` != 0
38-
* 3) `quorumNumbers` is ordered in ascending order
39-
* 4) the operator is not already registered
40-
*/
30+
/// @inheritdoc IBLSApkRegistry
4131
function registerOperator(
4232
address operator,
4333
bytes memory quorumNumbers
@@ -49,21 +39,10 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
4939
_processQuorumApkUpdate(quorumNumbers, pubkey);
5040

5141
// Return pubkeyHash, which will become the operator's unique id
52-
emit OperatorAddedToQuorums(operator, getOperatorId(operator), quorumNumbers);
42+
emit OperatorAddedToQuorums(operator, operatorToPubkeyHash[operator], quorumNumbers);
5343
}
5444

55-
/**
56-
* @notice Deregisters the `operator`'s pubkey for the specified `quorumNumbers`.
57-
* @param operator The address of the operator to deregister.
58-
* @param quorumNumbers The quorum numbers the operator is deregistering from, where each byte is an 8 bit integer quorumNumber.
59-
* @dev access restricted to the RegistryCoordinator
60-
* @dev Preconditions (these are assumed, not validated in this contract):
61-
* 1) `quorumNumbers` has no duplicates
62-
* 2) `quorumNumbers.length` != 0
63-
* 3) `quorumNumbers` is ordered in ascending order
64-
* 4) the operator is not already deregistered
65-
* 5) `quorumNumbers` is a subset of the quorumNumbers that the operator is registered for
66-
*/
45+
/// @inheritdoc IBLSApkRegistry
6746
function deregisterOperator(
6847
address operator,
6948
bytes memory quorumNumbers
@@ -73,13 +52,10 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
7352

7453
// Update each quorum's aggregate pubkey
7554
_processQuorumApkUpdate(quorumNumbers, pubkey.negate());
76-
emit OperatorRemovedFromQuorums(operator, getOperatorId(operator), quorumNumbers);
55+
emit OperatorRemovedFromQuorums(operator, operatorToPubkeyHash[operator], quorumNumbers);
7756
}
7857

79-
/**
80-
* @notice Initializes a new quorum by pushing its first apk update
81-
* @param quorumNumber The number of the new quorum
82-
*/
58+
/// @inheritdoc IBLSApkRegistry
8359
function initializeQuorum(
8460
uint8 quorumNumber
8561
) public virtual onlyRegistryCoordinator {
@@ -94,12 +70,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
9470
);
9571
}
9672

97-
/**
98-
* @notice Called by the RegistryCoordinator register an operator as the owner of a BLS public key.
99-
* @param operator is the operator for whom the key is being registered
100-
* @param params contains the G1 & G2 public keys of the operator, and a signature proving their ownership
101-
* @param pubkeyRegistrationMessageHash is a hash that the operator must sign to prove key ownership
102-
*/
73+
/// @inheritdoc IBLSApkRegistry
10374
function registerBLSPublicKey(
10475
address operator,
10576
PubkeyRegistrationParams calldata params,
@@ -190,10 +161,8 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
190161
* VIEW FUNCTIONS
191162
*
192163
*/
193-
/**
194-
* @notice Returns the pubkey and pubkey hash of an operator
195-
* @dev Reverts if the operator has not registered a valid pubkey
196-
*/
164+
165+
/// @inheritdoc IBLSApkRegistry
197166
function getRegisteredPubkey(
198167
address operator
199168
) public view returns (BN254.G1Point memory, bytes32) {
@@ -205,10 +174,7 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
205174
return (pubkey, pubkeyHash);
206175
}
207176

208-
/**
209-
* @notice Returns the indices of the quorumApks index at `blockNumber` for the provided `quorumNumbers`
210-
* @dev Returns the current indices if `blockNumber >= block.number`
211-
*/
177+
/// @inheritdoc IBLSApkRegistry
212178
function getApkIndicesAtBlockNumber(
213179
bytes calldata quorumNumbers,
214180
uint256 blockNumber
@@ -239,28 +205,22 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
239205
return indices;
240206
}
241207

242-
/// @notice Returns the current APK for the provided `quorumNumber `
208+
/// @inheritdoc IBLSApkRegistry
243209
function getApk(
244210
uint8 quorumNumber
245211
) external view returns (BN254.G1Point memory) {
246212
return currentApk[quorumNumber];
247213
}
248214

249-
/// @notice Returns the `ApkUpdate` struct at `index` in the list of APK updates for the `quorumNumber`
215+
/// @inheritdoc IBLSApkRegistry
250216
function getApkUpdateAtIndex(
251217
uint8 quorumNumber,
252218
uint256 index
253219
) external view returns (ApkUpdate memory) {
254220
return apkHistory[quorumNumber][index];
255221
}
256222

257-
/**
258-
* @notice get hash of the apk of `quorumNumber` at `blockNumber` using the provided `index`;
259-
* called by checkSignatures in BLSSignatureChecker.sol.
260-
* @param quorumNumber is the quorum whose ApkHash is being retrieved
261-
* @param blockNumber is the number of the block for which the latest ApkHash will be retrieved
262-
* @param index is the index of the apkUpdate being retrieved from the list of quorum apkUpdates in storage
263-
*/
223+
/// @inheritdoc IBLSApkRegistry
264224
function getApkHashAtBlockNumberAndIndex(
265225
uint8 quorumNumber,
266226
uint32 blockNumber,
@@ -283,22 +243,21 @@ contract BLSApkRegistry is BLSApkRegistryStorage {
283243
return quorumApkUpdate.apkHash;
284244
}
285245

286-
/// @notice Returns the length of ApkUpdates for the provided `quorumNumber`
246+
/// @inheritdoc IBLSApkRegistry
287247
function getApkHistoryLength(
288248
uint8 quorumNumber
289249
) external view returns (uint32) {
290250
return uint32(apkHistory[quorumNumber].length);
291251
}
292252

293-
/// @notice Returns the operator address for the given `pubkeyHash`
253+
/// @inheritdoc IBLSApkRegistry
294254
function getOperatorFromPubkeyHash(
295255
bytes32 pubkeyHash
296256
) public view returns (address) {
297257
return pubkeyHashToOperator[pubkeyHash];
298258
}
299259

300-
/// @notice returns the ID used to identify the `operator` within this AVS
301-
/// @dev Returns zero in the event that the `operator` has never registered for the AVS
260+
/// @inheritdoc IBLSApkRegistry
302261
function getOperatorId(
303262
address operator
304263
) public view returns (bytes32) {

src/BLSApkRegistryStorage.sol

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
// SPDX-License-Identifier: BUSL-1.1
22
pragma solidity ^0.8.27;
33

4-
import {IBLSApkRegistry} from "./interfaces/IBLSApkRegistry.sol";
4+
import {IBLSApkRegistry, IBLSApkRegistryTypes} from "./interfaces/IBLSApkRegistry.sol";
55
import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol";
66

77
import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
88

99
import {BN254} from "./libraries/BN254.sol";
1010

1111
abstract contract BLSApkRegistryStorage is Initializable, IBLSApkRegistry {
12-
/// @notice the hash of the zero pubkey aka BN254.G1Point(0,0)
12+
/// @dev Returns the hash of the zero pubkey aka BN254.G1Point(0,0)
1313
bytes32 internal constant ZERO_PK_HASH =
1414
hex"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5";
1515

16-
/// @notice the registry coordinator contract
16+
/// @inheritdoc IBLSApkRegistry
1717
address public immutable registryCoordinator;
1818

19-
// storage for individual pubkeys
20-
/// @notice maps operator address to pubkey hash
21-
mapping(address => bytes32) public operatorToPubkeyHash;
22-
/// @notice maps pubkey hash to operator address
23-
mapping(bytes32 => address) public pubkeyHashToOperator;
24-
/// @notice maps operator address to pubkeyG1
25-
mapping(address => BN254.G1Point) public operatorToPubkey;
19+
/// INDIVIDUAL PUBLIC KEY STORAGE
2620

27-
// storage for aggregate pubkeys (APKs)
28-
/// @notice maps quorumNumber => historical aggregate pubkey updates
29-
mapping(uint8 => ApkUpdate[]) public apkHistory;
30-
/// @notice maps quorumNumber => current aggregate pubkey of quorum
31-
mapping(uint8 => BN254.G1Point) public currentApk;
21+
/// @inheritdoc IBLSApkRegistry
22+
mapping(address operator => bytes32 operatorId) public operatorToPubkeyHash;
23+
24+
/// @inheritdoc IBLSApkRegistry
25+
mapping(bytes32 pubkeyHash => address operator) public pubkeyHashToOperator;
26+
27+
/// @inheritdoc IBLSApkRegistry
28+
mapping(address operator => BN254.G1Point pubkeyG1) public operatorToPubkey;
29+
30+
/// AGGREGATE PUBLIC KEY STORAGE
31+
32+
/// @inheritdoc IBLSApkRegistry
33+
mapping(uint8 quorumNumber => IBLSApkRegistryTypes.ApkUpdate[]) public apkHistory;
34+
35+
/// @inheritdoc IBLSApkRegistry
36+
mapping(uint8 quorumNumber => BN254.G1Point) public currentApk;
3237

3338
constructor(
3439
IRegistryCoordinator _registryCoordinator
@@ -38,6 +43,5 @@ abstract contract BLSApkRegistryStorage is Initializable, IBLSApkRegistry {
3843
_disableInitializers();
3944
}
4045

41-
// storage gap for upgradeability
4246
uint256[45] private __GAP;
4347
}

0 commit comments

Comments
 (0)