@@ -4,7 +4,10 @@ pragma solidity ^0.8.27;
4
4
import {Test} from "forge-std/Test.sol " ;
5
5
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol " ;
6
6
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 " ;
8
11
import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol " ;
9
12
import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol " ;
10
13
import {IRegistryCoordinator} from "../../src/interfaces/IRegistryCoordinator.sol " ;
@@ -13,22 +16,32 @@ import {ISlasher, ISlasherTypes, ISlasherErrors} from "../../src/interfaces/ISla
13
16
import {ISlashingRegistryCoordinator} from "../../src/interfaces/ISlashingRegistryCoordinator.sol " ;
14
17
import {IStakeRegistry, IStakeRegistryTypes} from "../../src/interfaces/IStakeRegistry.sol " ;
15
18
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 " ;
17
21
import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol " ;
18
22
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 " ;
20
25
import {PauserRegistry} from "eigenlayer-contracts/src/contracts/permissions/PauserRegistry.sol " ;
21
26
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 " ;
23
29
import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol " ;
24
30
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 " ;
27
34
import {IBLSApkRegistry, IBLSApkRegistryTypes} from "../../src/interfaces/IBLSApkRegistry.sol " ;
28
35
import {IIndexRegistry} from "../../src/interfaces/IIndexRegistry.sol " ;
29
36
import {ISocketRegistry} from "../../src/interfaces/ISocketRegistry.sol " ;
30
37
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 " ;
32
45
import {OperatorSet} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol " ;
33
46
import {IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
34
47
import {ERC20Mock } from "@openzeppelin/contracts/mocks/ERC20Mock.sol " ;
@@ -106,7 +119,8 @@ contract InstantSlasherTest is Test {
106
119
configData.avsDirectory.initPausedStatus = 0 ;
107
120
108
121
configData.rewardsCoordinator.initialOwner = proxyAdminOwner;
109
- configData.rewardsCoordinator.rewardsUpdater = address (0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 );
122
+ configData.rewardsCoordinator.rewardsUpdater =
123
+ address (0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 );
110
124
configData.rewardsCoordinator.initPausedStatus = 0 ;
111
125
configData.rewardsCoordinator.activationDelay = 0 ;
112
126
configData.rewardsCoordinator.defaultSplitBips = 1000 ;
@@ -124,50 +138,40 @@ contract InstantSlasherTest is Test {
124
138
vm.stopPrank ();
125
139
126
140
vm.startPrank (strategyManagerOwner);
127
- IStrategyManager (coreDeployment.strategyManager).setStrategyWhitelister (coreDeployment.strategyFactory);
141
+ IStrategyManager (coreDeployment.strategyManager).setStrategyWhitelister (
142
+ coreDeployment.strategyFactory
143
+ );
128
144
vm.stopPrank ();
129
145
130
146
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
+ );
132
152
133
153
// Deploy empty proxies for all registries
134
154
stakeRegistry = StakeRegistry (
135
155
address (
136
- new TransparentUpgradeableProxy (
137
- address (emptyContract),
138
- address (proxyAdmin),
139
- ""
140
- )
156
+ new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
141
157
)
142
158
);
143
159
144
160
blsApkRegistry = BLSApkRegistry (
145
161
address (
146
- new TransparentUpgradeableProxy (
147
- address (emptyContract),
148
- address (proxyAdmin),
149
- ""
150
- )
162
+ new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
151
163
)
152
164
);
153
165
154
166
indexRegistry = IndexRegistry (
155
167
address (
156
- new TransparentUpgradeableProxy (
157
- address (emptyContract),
158
- address (proxyAdmin),
159
- ""
160
- )
168
+ new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
161
169
)
162
170
);
163
171
164
172
socketRegistry = SocketRegistry (
165
173
address (
166
- new TransparentUpgradeableProxy (
167
- address (emptyContract),
168
- address (proxyAdmin),
169
- ""
170
- )
174
+ new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
171
175
)
172
176
);
173
177
@@ -183,9 +187,7 @@ contract InstantSlasherTest is Test {
183
187
slashingRegistryCoordinator = SlashingRegistryCoordinator (
184
188
address (
185
189
new TransparentUpgradeableProxy (
186
- address (slashingRegistryCoordinatorImplementation),
187
- address (proxyAdmin),
188
- ""
190
+ address (slashingRegistryCoordinatorImplementation), address (proxyAdmin), ""
189
191
)
190
192
)
191
193
);
@@ -197,9 +199,12 @@ contract InstantSlasherTest is Test {
197
199
IAVSDirectory (coreDeployment.avsDirectory),
198
200
IAllocationManager (coreDeployment.allocationManager)
199
201
);
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)));
203
208
204
209
// Upgrade all registry proxies
205
210
proxyAdmin.upgrade (
@@ -221,11 +226,7 @@ contract InstantSlasherTest is Test {
221
226
222
227
// Initialize the SlashingRegistryCoordinator first
223
228
slashingRegistryCoordinator.initialize (
224
- proxyAdminOwner,
225
- churnApprover,
226
- ejector,
227
- 0 ,
228
- serviceManager
229
+ proxyAdminOwner, churnApprover, ejector, 0 , serviceManager
229
230
);
230
231
231
232
vm.stopPrank ();
@@ -239,11 +240,7 @@ contract InstantSlasherTest is Test {
239
240
vm.startPrank (proxyAdminOwner);
240
241
instantSlasher = InstantSlasher (
241
242
address (
242
- new TransparentUpgradeableProxy (
243
- address (emptyContract),
244
- address (proxyAdmin),
245
- ""
246
- )
243
+ new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
247
244
)
248
245
);
249
246
@@ -279,31 +276,31 @@ contract InstantSlasherTest is Test {
279
276
uint96 [] memory minimumStakes = new uint96 [](1 );
280
277
minimumStakes[0 ] = 1 ether ;
281
278
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 });
287
283
288
- ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams = ISlashingRegistryCoordinatorTypes.OperatorSetParam ({
284
+ ISlashingRegistryCoordinatorTypes.OperatorSetParam memory operatorSetParams =
285
+ ISlashingRegistryCoordinatorTypes.OperatorSetParam ({
289
286
maxOperatorCount: 10 ,
290
287
kickBIPsOfOperatorStake: 0 ,
291
288
kickBIPsOfTotalStake: 0
292
289
});
293
290
294
291
vm.startPrank (proxyAdminOwner);
295
292
slashingRegistryCoordinator.createSlashableStakeQuorum (
296
- operatorSetParams,
297
- 1 ether,
298
- strategyParams,
299
- 0
293
+ operatorSetParams, 1 ether, strategyParams, 0
300
294
);
301
295
vm.stopPrank ();
302
296
303
297
vm.label (address (instantSlasher), "InstantSlasher Proxy " );
304
298
vm.label (address (instantSlasherImplementation), "InstantSlasher Implementation " );
305
299
vm.label (address (slashingRegistryCoordinator), "SlashingRegistryCoordinator Proxy " );
306
- vm.label (address (slashingRegistryCoordinatorImplementation), "SlashingRegistryCoordinator Implementation " );
300
+ vm.label (
301
+ address (slashingRegistryCoordinatorImplementation),
302
+ "SlashingRegistryCoordinator Implementation "
303
+ );
307
304
vm.label (address (proxyAdmin), "ProxyAdmin " );
308
305
vm.label (coreDeployment.allocationManager, "AllocationManager Proxy " );
309
306
}
@@ -312,7 +309,11 @@ contract InstantSlasherTest is Test {
312
309
assertEq (instantSlasher.slasher (), slasher);
313
310
}
314
311
315
- function _createMockSlashingParams () internal view returns (IAllocationManagerTypes.SlashingParams memory ) {
312
+ function _createMockSlashingParams ()
313
+ internal
314
+ view
315
+ returns (IAllocationManagerTypes.SlashingParams memory )
316
+ {
316
317
IStrategy[] memory strategies = new IStrategy [](1 );
317
318
strategies[0 ] = mockStrategy;
318
319
@@ -337,21 +338,29 @@ contract InstantSlasherTest is Test {
337
338
function test_fulfillSlashingRequest () public {
338
339
vm.skip (false );
339
340
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
+ );
341
344
342
345
// Mint tokens and deposit into strategy
343
346
uint256 depositAmount = 1 ether ;
344
347
mockToken.mint (operatorWallet.key.addr, depositAmount);
345
348
mockToken.approve (address (coreDeployment.strategyManager), depositAmount);
346
- IStrategyManager (coreDeployment.strategyManager).depositIntoStrategy (mockStrategy, mockToken, depositAmount);
349
+ IStrategyManager (coreDeployment.strategyManager).depositIntoStrategy (
350
+ mockStrategy, mockToken, depositAmount
351
+ );
347
352
348
353
// Set allocation delay
349
354
uint32 minDelay = 1 ;
350
- IAllocationManager (coreDeployment.allocationManager).setAllocationDelay (operatorWallet.key.addr, minDelay);
355
+ IAllocationManager (coreDeployment.allocationManager).setAllocationDelay (
356
+ operatorWallet.key.addr, minDelay
357
+ );
351
358
vm.stopPrank ();
352
359
353
360
// 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
+ );
355
364
assertFalse (isSet, "Operator allocation delay not set " );
356
365
357
366
vm.roll (block .number + ALLOCATION_CONFIGURATION_DELAY + 1 );
@@ -363,41 +372,41 @@ contract InstantSlasherTest is Test {
363
372
uint64 [] memory magnitudes = new uint64 [](1 );
364
373
magnitudes[0 ] = uint64 (1 ether); // Allocate full magnitude
365
374
366
- OperatorSet memory operatorSet = OperatorSet ({
367
- avs: address (serviceManager),
368
- id: 0
369
- });
375
+ OperatorSet memory operatorSet = OperatorSet ({avs: address (serviceManager), id: 0 });
370
376
371
377
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});
377
382
IAllocationManager (coreDeployment.allocationManager).setAVSRegistrar (
378
- address (serviceManager),
379
- IAVSRegistrar (address (slashingRegistryCoordinator))
383
+ address (serviceManager), IAVSRegistrar (address (slashingRegistryCoordinator))
380
384
);
381
385
vm.stopPrank ();
382
386
383
387
vm.startPrank (operatorWallet.key.addr);
384
388
385
- IAllocationManagerTypes.AllocateParams[] memory allocParams = new IAllocationManagerTypes.AllocateParams [](1 );
389
+ IAllocationManagerTypes.AllocateParams[] memory allocParams =
390
+ new IAllocationManagerTypes.AllocateParams [](1 );
386
391
allocParams[0 ] = IAllocationManagerTypes.AllocateParams ({
387
392
operatorSet: operatorSet,
388
393
strategies: allocStrategies,
389
394
newMagnitudes: magnitudes
390
395
});
391
396
392
- IAllocationManager (coreDeployment.allocationManager).modifyAllocations (operatorWallet.key.addr, allocParams);
397
+ IAllocationManager (coreDeployment.allocationManager).modifyAllocations (
398
+ operatorWallet.key.addr, allocParams
399
+ );
393
400
vm.roll (block .number + 100 );
394
401
395
402
uint32 [] memory operatorSetIds = new uint32 [](1 );
396
403
operatorSetIds[0 ] = 0 ;
397
404
// 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 ({
401
410
pubkeyRegistrationSignature: SigningKeyOperationsLib.sign (
402
411
operatorWallet.signingKey, messageHash
403
412
),
@@ -407,23 +416,25 @@ contract InstantSlasherTest is Test {
407
416
408
417
// Encode registration data with socket and pubkey params
409
418
bytes memory registrationData = abi.encode (
410
- ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL,
411
- "socket " ,
412
- pubkeyParams
419
+ ISlashingRegistryCoordinatorTypes.RegistrationType.NORMAL, "socket " , pubkeyParams
413
420
);
414
421
415
- IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes.RegisterParams ({
422
+ IAllocationManagerTypes.RegisterParams memory registerParams = IAllocationManagerTypes
423
+ .RegisterParams ({
416
424
avs: address (serviceManager),
417
425
operatorSetIds: operatorSetIds,
418
426
data: registrationData
419
427
});
420
- IAllocationManager (coreDeployment.allocationManager).registerForOperatorSets (operatorWallet.key.addr, registerParams);
428
+ IAllocationManager (coreDeployment.allocationManager).registerForOperatorSets (
429
+ operatorWallet.key.addr, registerParams
430
+ );
421
431
vm.stopPrank ();
422
432
423
433
vm.roll (block .number + 100 );
424
434
425
435
// Create slashing params
426
- IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes.SlashingParams ({
436
+ IAllocationManagerTypes.SlashingParams memory params = IAllocationManagerTypes
437
+ .SlashingParams ({
427
438
operator: operatorWallet.key.addr,
428
439
operatorSetId: 0 ,
429
440
strategies: allocStrategies,
@@ -432,12 +443,12 @@ contract InstantSlasherTest is Test {
432
443
});
433
444
434
445
// 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++ ) {
436
447
params.wadsToSlash[i] = 1e18 ;
437
448
}
438
449
439
450
// Execute slashing
440
451
vm.prank (slasher);
441
452
instantSlasher.fulfillSlashingRequest (params);
442
453
}
443
- }
454
+ }
0 commit comments