@@ -50,14 +50,13 @@ import {StakeRegistry} from "../../src/StakeRegistry.sol";
50
50
import {BLSApkRegistry} from "../../src/BLSApkRegistry.sol " ;
51
51
import {IndexRegistry} from "../../src/IndexRegistry.sol " ;
52
52
import {SocketRegistry} from "../../src/SocketRegistry.sol " ;
53
+ import {MiddlewareDeployLib} from "../utils/MiddlewareDeployLib.sol " ;
53
54
54
55
contract InstantSlasherTest is Test {
55
56
InstantSlasher public instantSlasher;
56
- InstantSlasher public instantSlasherImplementation;
57
57
ProxyAdmin public proxyAdmin;
58
58
EmptyContract public emptyContract;
59
59
SlashingRegistryCoordinator public slashingRegistryCoordinator;
60
- SlashingRegistryCoordinator public slashingRegistryCoordinatorImplementation;
61
60
CoreDeploymentLib.DeploymentData public coreDeployment;
62
61
PauserRegistry public pauserRegistry;
63
62
ERC20Mock public mockToken;
@@ -149,108 +148,51 @@ contract InstantSlasherTest is Test {
149
148
IERC20 (address (mockToken))
150
149
)
151
150
);
152
-
153
- // Deploy empty proxies for all registries
154
- stakeRegistry = StakeRegistry (
155
- address (
156
- new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
157
- )
158
- );
159
-
160
- blsApkRegistry = BLSApkRegistry (
161
- address (
162
- new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
163
- )
164
- );
165
-
166
- indexRegistry = IndexRegistry (
167
- address (
168
- new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
169
- )
170
- );
171
-
172
- socketRegistry = SocketRegistry (
173
- address (
174
- new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
175
- )
176
- );
177
-
178
- slashingRegistryCoordinatorImplementation = new SlashingRegistryCoordinator (
179
- IStakeRegistry (address (stakeRegistry)),
180
- IBLSApkRegistry (address (blsApkRegistry)),
181
- IIndexRegistry (address (indexRegistry)),
182
- ISocketRegistry (address (socketRegistry)),
183
- IAllocationManager (coreDeployment.allocationManager),
184
- IPauserRegistry (address (pauserRegistry))
185
- );
186
-
187
- slashingRegistryCoordinator = SlashingRegistryCoordinator (
188
- address (
189
- new TransparentUpgradeableProxy (
190
- address (slashingRegistryCoordinatorImplementation), address (proxyAdmin), ""
191
- )
192
- )
193
- );
194
-
195
- // Deploy registry implementations pointing to the coordinator
196
- StakeRegistry stakeRegistryImplementation = new StakeRegistry (
197
- ISlashingRegistryCoordinator (address (slashingRegistryCoordinator)),
198
- IDelegationManager (coreDeployment.delegationManager),
199
- IAVSDirectory (coreDeployment.avsDirectory),
200
- IAllocationManager (coreDeployment.allocationManager)
201
- );
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)));
208
-
209
- // Upgrade all registry proxies
210
- proxyAdmin.upgrade (
211
- TransparentUpgradeableProxy (payable (address (stakeRegistry))),
212
- address (stakeRegistryImplementation)
213
- );
214
- proxyAdmin.upgrade (
215
- TransparentUpgradeableProxy (payable (address (blsApkRegistry))),
216
- address (blsApkRegistryImplementation)
217
- );
218
- proxyAdmin.upgrade (
219
- TransparentUpgradeableProxy (payable (address (indexRegistry))),
220
- address (indexRegistryImplementation)
221
- );
222
- proxyAdmin.upgrade (
223
- TransparentUpgradeableProxy (payable (address (socketRegistry))),
224
- address (socketRegistryImplementation)
225
- );
226
-
227
- // Initialize the SlashingRegistryCoordinator first
228
- slashingRegistryCoordinator.initialize (
229
- proxyAdminOwner, churnApprover, ejector, 0 , serviceManager
230
- );
231
-
232
151
vm.stopPrank ();
233
152
234
- instantSlasherImplementation = new InstantSlasher (
235
- IAllocationManager (coreDeployment.allocationManager),
236
- ISlashingRegistryCoordinator (slashingRegistryCoordinator),
237
- slasher
238
- );
153
+ MiddlewareDeployLib.MiddlewareDeployConfig memory middlewareConfig;
154
+ middlewareConfig.instantSlasher.initialOwner = proxyAdminOwner;
155
+ middlewareConfig.instantSlasher.slasher = slasher;
156
+ middlewareConfig.slashingRegistryCoordinator.initialOwner = proxyAdminOwner;
157
+ middlewareConfig.slashingRegistryCoordinator.churnApprover = churnApprover;
158
+ middlewareConfig.slashingRegistryCoordinator.ejector = ejector;
159
+ middlewareConfig.slashingRegistryCoordinator.initPausedStatus = 0 ;
160
+ middlewareConfig.slashingRegistryCoordinator.serviceManager = serviceManager;
161
+ middlewareConfig.socketRegistry.initialOwner = proxyAdminOwner;
162
+ middlewareConfig.indexRegistry.initialOwner = proxyAdminOwner;
163
+ middlewareConfig.stakeRegistry.initialOwner = proxyAdminOwner;
164
+ middlewareConfig.stakeRegistry.minimumStake = 1 ether ;
165
+ middlewareConfig.stakeRegistry.strategyParams = 0 ;
166
+ middlewareConfig.stakeRegistry.delegationManager = coreDeployment.delegationManager;
167
+ middlewareConfig.stakeRegistry.avsDirectory = coreDeployment.avsDirectory;
168
+ {
169
+ IStakeRegistryTypes.StrategyParams[] memory stratParams =
170
+ new IStakeRegistryTypes.StrategyParams [](1 );
171
+ stratParams[0 ] =
172
+ IStakeRegistryTypes.StrategyParams ({strategy: mockStrategy, multiplier: 1 ether });
173
+ middlewareConfig.stakeRegistry.strategyParamsArray = stratParams;
174
+ }
175
+ middlewareConfig.stakeRegistry.lookAheadPeriod = 0 ;
176
+ middlewareConfig.stakeRegistry.stakeType = IStakeRegistryTypes.StakeType (1 );
177
+ middlewareConfig.blsApkRegistry.initialOwner = proxyAdminOwner;
239
178
240
179
vm.startPrank (proxyAdminOwner);
241
- instantSlasher = InstantSlasher (
242
- address (
243
- new TransparentUpgradeableProxy (address (emptyContract), address (proxyAdmin), "" )
244
- )
245
- );
246
-
247
- proxyAdmin.upgrade (
248
- TransparentUpgradeableProxy (payable (address (instantSlasher))),
249
- address (instantSlasherImplementation)
180
+ MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployments = MiddlewareDeployLib
181
+ .deployMiddleware (
182
+ address (proxyAdmin),
183
+ coreDeployment.allocationManager,
184
+ address (pauserRegistry),
185
+ middlewareConfig
250
186
);
251
187
vm.stopPrank ();
252
188
253
- instantSlasher.initialize (slasher);
189
+ instantSlasher = InstantSlasher (middlewareDeployments.instantSlasher);
190
+ slashingRegistryCoordinator =
191
+ SlashingRegistryCoordinator (middlewareDeployments.slashingRegistryCoordinator);
192
+ stakeRegistry = StakeRegistry (middlewareDeployments.stakeRegistry);
193
+ blsApkRegistry = BLSApkRegistry (middlewareDeployments.blsApkRegistry);
194
+ indexRegistry = IndexRegistry (middlewareDeployments.indexRegistry);
195
+ socketRegistry = SocketRegistry (middlewareDeployments.socketRegistry);
254
196
255
197
vm.startPrank (serviceManager);
256
198
PermissionController (coreDeployment.permissionController).setAppointee (
@@ -295,12 +237,7 @@ contract InstantSlasherTest is Test {
295
237
vm.stopPrank ();
296
238
297
239
vm.label (address (instantSlasher), "InstantSlasher Proxy " );
298
- vm.label (address (instantSlasherImplementation), "InstantSlasher Implementation " );
299
240
vm.label (address (slashingRegistryCoordinator), "SlashingRegistryCoordinator Proxy " );
300
- vm.label (
301
- address (slashingRegistryCoordinatorImplementation),
302
- "SlashingRegistryCoordinator Implementation "
303
- );
304
241
vm.label (address (proxyAdmin), "ProxyAdmin " );
305
242
vm.label (coreDeployment.allocationManager, "AllocationManager Proxy " );
306
243
}
0 commit comments