Skip to content

Commit a3879ff

Browse files
committed
forge: fmt
1 parent 7b4031c commit a3879ff

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

src/OperatorStateRetriever.sol

+21-12
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,31 @@ contract OperatorStateRetriever {
9797

9898
/**
9999
* @notice This function is intended to to be called by AVS operators every time a new task is created (i.e.)
100-
* the AVS coordinator makes a request to AVS operators. Since all of the crucial information is kept onchain,
100+
* the AVS coordinator makes a request to AVS operators. Since all of the crucial information is kept onchain,
101101
* operators don't need to run indexers to fetch the data.
102102
* @param registryCoordinator is the registry coordinator to fetch the AVS registry information from
103-
* @param operatorId the id of the operator to fetch the quorums lists
103+
* @param operatorId the id of the operator to fetch the quorums lists
104104
* @param blockNumber is the block number to get the operator state for
105105
* @return quorumBitmap the quorumBitmap of the operator at the given blockNumber
106106
* @return operators a 2d array of Operators. For each quorum, an ordered list of Operators
107107
* @return sockets a 2d array of sockets. For each quorum, an ordered list of sockets
108108
*/
109109
function getOperatorStateWithSocket(
110-
ISlashingRegistryCoordinator registryCoordinator,
111-
bytes32 operatorId,
110+
ISlashingRegistryCoordinator registryCoordinator,
111+
bytes32 operatorId,
112112
uint32 blockNumber
113-
) external view returns (uint256 quorumBitmap, Operator[][] memory operators, string[][] memory sockets) {
113+
)
114+
external
115+
view
116+
returns (uint256 quorumBitmap, Operator[][] memory operators, string[][] memory sockets)
117+
{
114118
bytes32[] memory operatorIds = new bytes32[](1);
115119
operatorIds[0] = operatorId;
116-
uint256 index = registryCoordinator.getQuorumBitmapIndicesAtBlockNumber(blockNumber, operatorIds)[0];
117-
118-
quorumBitmap = registryCoordinator.getQuorumBitmapAtBlockNumberByIndex(operatorId, blockNumber, index);
120+
uint256 index =
121+
registryCoordinator.getQuorumBitmapIndicesAtBlockNumber(blockNumber, operatorIds)[0];
122+
123+
quorumBitmap =
124+
registryCoordinator.getQuorumBitmapAtBlockNumberByIndex(operatorId, blockNumber, index);
119125

120126
bytes memory quorumNumbers = BitmapUtils.bitmapToBytesArray(quorumBitmap);
121127

@@ -132,15 +138,15 @@ contract OperatorStateRetriever {
132138
}
133139

134140
/**
135-
* @notice returns the ordered list of operators (id, stake, socket) for each quorum. The AVS coordinator
141+
* @notice returns the ordered list of operators (id, stake, socket) for each quorum. The AVS coordinator
136142
* may call this function directly to get the operator state for a given block number
137143
* @param registryCoordinator is the registry coordinator to fetch the AVS registry information from
138144
* @param quorumNumbers are the ids of the quorums to get the operator state for
139145
* @param blockNumber is the block number to get the operator state for
140146
* @return operators a 2d array of Operators. For each quorum, an ordered list of Operators
141147
* @return sockets a 2d array of sockets. For each quorum, an ordered list of sockets
142148
*/
143-
function getOperatorStateWithSocket(
149+
function getOperatorStateWithSocket(
144150
ISlashingRegistryCoordinator registryCoordinator,
145151
bytes memory quorumNumbers,
146152
uint32 blockNumber
@@ -156,14 +162,17 @@ contract OperatorStateRetriever {
156162
sockets = new string[][](quorumNumbers.length);
157163
for (uint256 i = 0; i < quorumNumbers.length; i++) {
158164
uint8 quorumNumber = uint8(quorumNumbers[i]);
159-
bytes32[] memory operatorIds = registries.indexRegistry.getOperatorListAtBlockNumber(quorumNumber, blockNumber);
165+
bytes32[] memory operatorIds =
166+
registries.indexRegistry.getOperatorListAtBlockNumber(quorumNumber, blockNumber);
160167
operators[i] = new Operator[](operatorIds.length);
161168
sockets[i] = new string[](operatorIds.length);
162169
for (uint256 j = 0; j < operatorIds.length; j++) {
163170
operators[i][j] = Operator({
164171
operator: registries.blsApkRegistry.getOperatorFromPubkeyHash(operatorIds[j]),
165172
operatorId: bytes32(operatorIds[j]),
166-
stake: registries.stakeRegistry.getStakeAtBlockNumber(bytes32(operatorIds[j]), quorumNumber, blockNumber)
173+
stake: registries.stakeRegistry.getStakeAtBlockNumber(
174+
bytes32(operatorIds[j]), quorumNumber, blockNumber
175+
)
167176
});
168177
sockets[i][j] = registries.socketRegistry.getOperatorSocket(bytes32(operatorIds[j]));
169178
}

test/unit/OperatorStateRetrieverUnit.t.sol

+15-10
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer {
153153
);
154154
}
155155

156-
157-
158-
function test_getOperatorStateWithSocket_revert_registeredFirstAfterReferenceBlockNumber() public {
156+
function test_getOperatorStateWithSocket_revert_registeredFirstAfterReferenceBlockNumber()
157+
public
158+
{
159159
cheats.roll(registrationBlockNumber);
160160
_registerOperatorWithCoordinator(defaultOperator, 1, defaultPubKey);
161161

@@ -213,22 +213,28 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer {
213213
);
214214
}
215215

216-
function test_getOperatorStateWithSocket_revert_quorumNotCreatedAtReferenceBlockNumber() public {
216+
function test_getOperatorStateWithSocket_revert_quorumNotCreatedAtReferenceBlockNumber()
217+
public
218+
{
217219
cheats.roll(registrationBlockNumber);
218-
ISlashingRegistryCoordinator.OperatorSetParam memory operatorSetParams = ISlashingRegistryCoordinatorTypes
219-
.OperatorSetParam({
220+
ISlashingRegistryCoordinator.OperatorSetParam memory operatorSetParams =
221+
ISlashingRegistryCoordinatorTypes.OperatorSetParam({
220222
maxOperatorCount: defaultMaxOperatorCount,
221223
kickBIPsOfOperatorStake: defaultKickBIPsOfOperatorStake,
222224
kickBIPsOfTotalStake: defaultKickBIPsOfTotalStake
223225
});
224226
uint96 minimumStake = 1;
225227
IStakeRegistry.StrategyParams[] memory strategyParams =
226228
new IStakeRegistry.StrategyParams[](1);
227-
strategyParams[0] =
228-
IStakeRegistryTypes.StrategyParams({strategy: IStrategy(address(1000)), multiplier: 1e16});
229+
strategyParams[0] = IStakeRegistryTypes.StrategyParams({
230+
strategy: IStrategy(address(1000)),
231+
multiplier: 1e16
232+
});
229233

230234
cheats.prank(registryCoordinator.owner());
231-
registryCoordinator.createTotalDelegatedStakeQuorum(operatorSetParams, minimumStake, strategyParams);
235+
registryCoordinator.createTotalDelegatedStakeQuorum(
236+
operatorSetParams, minimumStake, strategyParams
237+
);
232238

233239
cheats.expectRevert(
234240
"IndexRegistry._operatorCountAtBlockNumber: quorum did not exist at given block number"
@@ -240,7 +246,6 @@ contract OperatorStateRetrieverUnitTests is MockAVSDeployer {
240246
);
241247
}
242248

243-
244249
function test_getOperatorStateWithSocket_returnsCorrect() public {
245250
uint256 quorumBitmapOne = 1;
246251
uint256 quorumBitmapThree = 3;

0 commit comments

Comments
 (0)