Skip to content

Commit 7f3bbd1

Browse files
committed
chore: forge fmt
1 parent 95228e4 commit 7f3bbd1

File tree

3 files changed

+210
-175
lines changed

3 files changed

+210
-175
lines changed

src/interfaces/ISlashingRegistryCoordinator.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ interface ISlashingRegistryCoordinator is
472472
* @notice Returns the hash of the message that operators must sign with their BLS key to register
473473
* @param operator The operator's Ethereum address
474474
*/
475-
function calculatePubkeyRegistrationMessageHash(address operator) external view returns (bytes32);
475+
function calculatePubkeyRegistrationMessageHash(
476+
address operator
477+
) external view returns (bytes32);
476478

477479
/**
478480
* @notice Returns the operator set parameters for a given quorum.

test/unit/InstantSlasher.t.sol

Lines changed: 97 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ pragma solidity ^0.8.27;
44
import {Test} from "forge-std/Test.sol";
55
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
66
import {InstantSlasher} from "../../src/slashers/InstantSlasher.sol";
7-
import {IAllocationManager, IAllocationManagerTypes} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
7+
import {
8+
IAllocationManager,
9+
IAllocationManagerTypes
10+
} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
811
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol";
912
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
1013
import {IRegistryCoordinator} from "../../src/interfaces/IRegistryCoordinator.sol";
@@ -13,22 +16,32 @@ import {ISlasher, ISlasherTypes, ISlasherErrors} from "../../src/interfaces/ISla
1316
import {ISlashingRegistryCoordinator} from "../../src/interfaces/ISlashingRegistryCoordinator.sol";
1417
import {IStakeRegistry, IStakeRegistryTypes} from "../../src/interfaces/IStakeRegistry.sol";
1518
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
16-
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
19+
import {TransparentUpgradeableProxy} from
20+
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
1721
import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol";
1822
import {AllocationManager} from "eigenlayer-contracts/src/contracts/core/AllocationManager.sol";
19-
import {PermissionController} from "eigenlayer-contracts/src/contracts/permissions/PermissionController.sol";
23+
import {PermissionController} from
24+
"eigenlayer-contracts/src/contracts/permissions/PermissionController.sol";
2025
import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol";
2126
import {IPauserRegistry} from "eigenlayer-contracts/src/contracts/interfaces/IPauserRegistry.sol";
22-
import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
27+
import {IDelegationManager} from
28+
"eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
2329
import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
2430
import {DelegationMock} from "../mocks/DelegationMock.sol";
25-
import {SlashingRegistryCoordinator }from "../../src/SlashingRegistryCoordinator.sol";
26-
import {ISlashingRegistryCoordinatorTypes} from "../../src/interfaces/ISlashingRegistryCoordinator.sol";
31+
import {SlashingRegistryCoordinator} from "../../src/SlashingRegistryCoordinator.sol";
32+
import {ISlashingRegistryCoordinatorTypes} from
33+
"../../src/interfaces/ISlashingRegistryCoordinator.sol";
2734
import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol";
2835
import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol";
2936
import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol";
3037
import {CoreDeploymentLib} from "../utils/CoreDeployLib.sol";
31-
import {OperatorWalletLib, Operator, Wallet, BLSWallet, SigningKeyOperationsLib} from "../utils/OperatorWalletLib.sol";
38+
import {
39+
OperatorWalletLib,
40+
Operator,
41+
Wallet,
42+
BLSWallet,
43+
SigningKeyOperationsLib
44+
} from "../utils/OperatorWalletLib.sol";
3245
import {OperatorSet} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol";
3346
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
3447
import {ERC20Mock} from "@openzeppelin/contracts/mocks/ERC20Mock.sol";
@@ -106,7 +119,8 @@ contract InstantSlasherTest is Test {
106119
configData.avsDirectory.initPausedStatus = 0;
107120

108121
configData.rewardsCoordinator.initialOwner = proxyAdminOwner;
109-
configData.rewardsCoordinator.rewardsUpdater = address(0x14dC79964da2C08b23698B3D3cc7Ca32193d9955);
122+
configData.rewardsCoordinator.rewardsUpdater =
123+
address(0x14dC79964da2C08b23698B3D3cc7Ca32193d9955);
110124
configData.rewardsCoordinator.initPausedStatus = 0;
111125
configData.rewardsCoordinator.activationDelay = 0;
112126
configData.rewardsCoordinator.defaultSplitBips = 1000;
@@ -124,50 +138,40 @@ contract InstantSlasherTest is Test {
124138
vm.stopPrank();
125139

126140
vm.startPrank(strategyManagerOwner);
127-
IStrategyManager(coreDeployment.strategyManager).setStrategyWhitelister(coreDeployment.strategyFactory);
141+
IStrategyManager(coreDeployment.strategyManager).setStrategyWhitelister(
142+
coreDeployment.strategyFactory
143+
);
128144
vm.stopPrank();
129145

130146
vm.startPrank(proxyAdminOwner);
131-
mockStrategy = IStrategy(StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy(IERC20(address(mockToken))));
147+
mockStrategy = IStrategy(
148+
StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy(
149+
IERC20(address(mockToken))
150+
)
151+
);
132152

133153
// Deploy empty proxies for all registries
134154
stakeRegistry = StakeRegistry(
135155
address(
136-
new TransparentUpgradeableProxy(
137-
address(emptyContract),
138-
address(proxyAdmin),
139-
""
140-
)
156+
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
141157
)
142158
);
143159

144160
blsApkRegistry = BLSApkRegistry(
145161
address(
146-
new TransparentUpgradeableProxy(
147-
address(emptyContract),
148-
address(proxyAdmin),
149-
""
150-
)
162+
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
151163
)
152164
);
153165

154166
indexRegistry = IndexRegistry(
155167
address(
156-
new TransparentUpgradeableProxy(
157-
address(emptyContract),
158-
address(proxyAdmin),
159-
""
160-
)
168+
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
161169
)
162170
);
163171

164172
socketRegistry = SocketRegistry(
165173
address(
166-
new TransparentUpgradeableProxy(
167-
address(emptyContract),
168-
address(proxyAdmin),
169-
""
170-
)
174+
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
171175
)
172176
);
173177

@@ -183,9 +187,7 @@ contract InstantSlasherTest is Test {
183187
slashingRegistryCoordinator = SlashingRegistryCoordinator(
184188
address(
185189
new TransparentUpgradeableProxy(
186-
address(slashingRegistryCoordinatorImplementation),
187-
address(proxyAdmin),
188-
""
190+
address(slashingRegistryCoordinatorImplementation), address(proxyAdmin), ""
189191
)
190192
)
191193
);
@@ -197,9 +199,12 @@ contract InstantSlasherTest is Test {
197199
IAVSDirectory(coreDeployment.avsDirectory),
198200
IAllocationManager(coreDeployment.allocationManager)
199201
);
200-
BLSApkRegistry blsApkRegistryImplementation = new BLSApkRegistry(ISlashingRegistryCoordinator(address(slashingRegistryCoordinator)));
201-
IndexRegistry indexRegistryImplementation = new IndexRegistry(ISlashingRegistryCoordinator(address(slashingRegistryCoordinator)));
202-
SocketRegistry socketRegistryImplementation = new SocketRegistry(IRegistryCoordinator(address(slashingRegistryCoordinator)));
202+
BLSApkRegistry blsApkRegistryImplementation =
203+
new BLSApkRegistry(ISlashingRegistryCoordinator(address(slashingRegistryCoordinator)));
204+
IndexRegistry indexRegistryImplementation =
205+
new IndexRegistry(ISlashingRegistryCoordinator(address(slashingRegistryCoordinator)));
206+
SocketRegistry socketRegistryImplementation =
207+
new SocketRegistry(IRegistryCoordinator(address(slashingRegistryCoordinator)));
203208

204209
// Upgrade all registry proxies
205210
proxyAdmin.upgrade(
@@ -221,11 +226,7 @@ contract InstantSlasherTest is Test {
221226

222227
// Initialize the SlashingRegistryCoordinator first
223228
slashingRegistryCoordinator.initialize(
224-
proxyAdminOwner,
225-
churnApprover,
226-
ejector,
227-
0,
228-
serviceManager
229+
proxyAdminOwner, churnApprover, ejector, 0, serviceManager
229230
);
230231

231232
vm.stopPrank();
@@ -239,11 +240,7 @@ contract InstantSlasherTest is Test {
239240
vm.startPrank(proxyAdminOwner);
240241
instantSlasher = InstantSlasher(
241242
address(
242-
new TransparentUpgradeableProxy(
243-
address(emptyContract),
244-
address(proxyAdmin),
245-
""
246-
)
243+
new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")
247244
)
248245
);
249246

@@ -279,31 +276,31 @@ contract InstantSlasherTest is Test {
279276
uint96[] memory minimumStakes = new uint96[](1);
280277
minimumStakes[0] = 1 ether;
281278

282-
IStakeRegistryTypes.StrategyParams[] memory strategyParams = new IStakeRegistryTypes.StrategyParams[](1);
283-
strategyParams[0] = IStakeRegistryTypes.StrategyParams({
284-
strategy: mockStrategy,
285-
multiplier: 1 ether
286-
});
279+
IStakeRegistryTypes.StrategyParams[] memory strategyParams =
280+
new IStakeRegistryTypes.StrategyParams[](1);
281+
strategyParams[0] =
282+
IStakeRegistryTypes.StrategyParams({strategy: mockStrategy, multiplier: 1 ether});
287283

288-
ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = ISlashingRegistryCoordinatorTypes.OperatorSetParam({
284+
ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams =
285+
ISlashingRegistryCoordinatorTypes.OperatorSetParam({
289286
maxOperatorCount: 10,
290287
kickBIPsOfOperatorStake: 0,
291288
kickBIPsOfTotalStake: 0
292289
});
293290

294291
vm.startPrank(proxyAdminOwner);
295292
slashingRegistryCoordinator.createSlashableStakeQuorum(
296-
operatorSetParams,
297-
1 ether,
298-
strategyParams,
299-
0
293+
operatorSetParams, 1 ether, strategyParams, 0
300294
);
301295
vm.stopPrank();
302296

303297
vm.label(address(instantSlasher), "InstantSlasher Proxy");
304298
vm.label(address(instantSlasherImplementation), "InstantSlasher Implementation");
305299
vm.label(address(slashingRegistryCoordinator), "SlashingRegistryCoordinator Proxy");
306-
vm.label(address(slashingRegistryCoordinatorImplementation), "SlashingRegistryCoordinator Implementation");
300+
vm.label(
301+
address(slashingRegistryCoordinatorImplementation),
302+
"SlashingRegistryCoordinator Implementation"
303+
);
307304
vm.label(address(proxyAdmin), "ProxyAdmin");
308305
vm.label(coreDeployment.allocationManager, "AllocationManager Proxy");
309306
}
@@ -312,7 +309,11 @@ contract InstantSlasherTest is Test {
312309
assertEq(instantSlasher.slasher(), slasher);
313310
}
314311

315-
function _createMockSlashingParams() internal view returns (IAllocationManagerTypes.SlashingParams memory) {
312+
function _createMockSlashingParams()
313+
internal
314+
view
315+
returns (IAllocationManagerTypes.SlashingParams memory)
316+
{
316317
IStrategy[] memory strategies = new IStrategy[](1);
317318
strategies[0] = mockStrategy;
318319

@@ -337,21 +338,29 @@ contract InstantSlasherTest is Test {
337338
function test_fulfillSlashingRequest() public {
338339
vm.skip(false);
339340
vm.startPrank(operatorWallet.key.addr);
340-
IDelegationManager(coreDeployment.delegationManager).registerAsOperator(address(0), 1, "metadata");
341+
IDelegationManager(coreDeployment.delegationManager).registerAsOperator(
342+
address(0), 1, "metadata"
343+
);
341344

342345
// Mint tokens and deposit into strategy
343346
uint256 depositAmount = 1 ether;
344347
mockToken.mint(operatorWallet.key.addr, depositAmount);
345348
mockToken.approve(address(coreDeployment.strategyManager), depositAmount);
346-
IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy(mockStrategy, mockToken, depositAmount);
349+
IStrategyManager(coreDeployment.strategyManager).depositIntoStrategy(
350+
mockStrategy, mockToken, depositAmount
351+
);
347352

348353
// Set allocation delay
349354
uint32 minDelay = 1;
350-
IAllocationManager(coreDeployment.allocationManager).setAllocationDelay(operatorWallet.key.addr, minDelay);
355+
IAllocationManager(coreDeployment.allocationManager).setAllocationDelay(
356+
operatorWallet.key.addr, minDelay
357+
);
351358
vm.stopPrank();
352359

353360
// Assert operator has allocation delay set
354-
(bool isSet, ) = IAllocationManager(coreDeployment.allocationManager).getAllocationDelay(operatorWallet.key.addr);
361+
(bool isSet,) = IAllocationManager(coreDeployment.allocationManager).getAllocationDelay(
362+
operatorWallet.key.addr
363+
);
355364
assertFalse(isSet, "Operator allocation delay not set");
356365

357366
vm.roll(block.number + ALLOCATION_CONFIGURATION_DELAY + 1);
@@ -363,41 +372,41 @@ contract InstantSlasherTest is Test {
363372
uint64[] memory magnitudes = new uint64[](1);
364373
magnitudes[0] = uint64(1 ether); // Allocate full magnitude
365374

366-
OperatorSet memory operatorSet = OperatorSet({
367-
avs: address(serviceManager),
368-
id: 0
369-
});
375+
OperatorSet memory operatorSet = OperatorSet({avs: address(serviceManager), id: 0});
370376

371377
vm.startPrank(serviceManager);
372-
IAllocationManagerTypes.CreateSetParams[] memory createParams = new IAllocationManagerTypes.CreateSetParams[](1);
373-
createParams[0] = IAllocationManagerTypes.CreateSetParams({
374-
operatorSetId: 0,
375-
strategies: allocStrategies
376-
});
378+
IAllocationManagerTypes.CreateSetParams[] memory createParams =
379+
new IAllocationManagerTypes.CreateSetParams[](1);
380+
createParams[0] =
381+
IAllocationManagerTypes.CreateSetParams({operatorSetId: 0, strategies: allocStrategies});
377382
IAllocationManager(coreDeployment.allocationManager).setAVSRegistrar(
378-
address(serviceManager),
379-
IAVSRegistrar(address(slashingRegistryCoordinator))
383+
address(serviceManager), IAVSRegistrar(address(slashingRegistryCoordinator))
380384
);
381385
vm.stopPrank();
382386

383387
vm.startPrank(operatorWallet.key.addr);
384388

385-
IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams[](1);
389+
IAllocationManagerTypes.AllocateParams[] memory allocParams =
390+
new IAllocationManagerTypes.AllocateParams[](1);
386391
allocParams[0] = IAllocationManagerTypes.AllocateParams({
387392
operatorSet: operatorSet,
388393
strategies: allocStrategies,
389394
newMagnitudes: magnitudes
390395
});
391396

392-
IAllocationManager(coreDeployment.allocationManager).modifyAllocations(operatorWallet.key.addr, allocParams);
397+
IAllocationManager(coreDeployment.allocationManager).modifyAllocations(
398+
operatorWallet.key.addr, allocParams
399+
);
393400
vm.roll(block.number + 100);
394401

395402
uint32[] memory operatorSetIds = new uint32[](1);
396403
operatorSetIds[0] = 0;
397404
// Create BLS signing key params
398-
bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash(operatorWallet.key.addr);
399-
IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams =
400-
IBLSApkRegistryTypes.PubkeyRegistrationParams({
405+
bytes32 messageHash = slashingRegistryCoordinator.calculatePubkeyRegistrationMessageHash(
406+
operatorWallet.key.addr
407+
);
408+
IBLSApkRegistryTypes.PubkeyRegistrationParams memory pubkeyParams = IBLSApkRegistryTypes
409+
.PubkeyRegistrationParams({
401410
pubkeyRegistrationSignature: SigningKeyOperationsLib.sign(
402411
operatorWallet.signingKey, messageHash
403412
),
@@ -407,23 +416,25 @@ contract InstantSlasherTest is Test {
407416

408417
// Encode registration data with socket and pubkey params
409418
bytes memory registrationData = abi.encode(
410-
ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL,
411-
"socket",
412-
pubkeyParams
419+
ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket", pubkeyParams
413420
);
414421

415-
IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes.RegisterParams({
422+
IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes
423+
.RegisterParams({
416424
avs: address(serviceManager),
417425
operatorSetIds: operatorSetIds,
418426
data: registrationData
419427
});
420-
IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets(operatorWallet.key.addr, registerParams);
428+
IAllocationManager(coreDeployment.allocationManager).registerForOperatorSets(
429+
operatorWallet.key.addr, registerParams
430+
);
421431
vm.stopPrank();
422432

423433
vm.roll(block.number + 100);
424434

425435
// Create slashing params
426-
IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams({
436+
IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes
437+
.SlashingParams({
427438
operator: operatorWallet.key.addr,
428439
operatorSetId: 0,
429440
strategies: allocStrategies,
@@ -432,12 +443,12 @@ contract InstantSlasherTest is Test {
432443
});
433444

434445
// Set each wad to slash to 1e18 (100% slash)
435-
for(uint256 i = 0; i < params.wadsToSlash.length; i++) {
446+
for (uint256 i = 0; i < params.wadsToSlash.length; i++) {
436447
params.wadsToSlash[i] = 1e18;
437448
}
438449

439450
// Execute slashing
440451
vm.prank(slasher);
441452
instantSlasher.fulfillSlashingRequest(params);
442453
}
443-
}
454+
}

0 commit comments

Comments
 (0)