1
1
// SPDX-License-Identifier: MIT
2
2
pragma solidity ^ 0.8.12 ;
3
3
4
+ import {Vm} from "forge-std/Vm.sol " ;
5
+ import {stdJson} from "forge-std/StdJson.sol " ;
4
6
import {Test, console2 as console} from "forge-std/Test.sol " ;
5
7
import {OperatorLib} from "./utils/OperatorLib.sol " ;
6
- import {CoreDeployLib} from "./utils/CoreDeployLib.sol " ;
7
8
import {UpgradeableProxyLib} from "./unit/UpgradeableProxyLib.sol " ;
8
9
import {MiddlewareDeployLib} from "./utils/MiddlewareDeployLib.sol " ;
9
10
import {BN254} from "../src/libraries/BN254.sol " ;
@@ -31,8 +32,26 @@ import {IStrategyFactory} from "eigenlayer-contracts/src/contracts/interfaces/IS
31
32
import {IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
32
33
33
34
contract End2EndForkTest is Test {
35
+ using stdJson for string ;
34
36
using OperatorLib for * ;
35
37
38
+ struct DeploymentData {
39
+ address delegationManager;
40
+ address avsDirectory;
41
+ address allocationManager;
42
+ address strategyManager;
43
+ address eigenPodManager;
44
+ address rewardsCoordinator;
45
+ address eigenPodBeacon;
46
+ address pauserRegistry;
47
+ address strategyFactory;
48
+ address strategyBeacon;
49
+ address eigenStrategy;
50
+ address eigen;
51
+ address backingEigen;
52
+ address permissionController;
53
+ }
54
+
36
55
struct ConfigData {
37
56
address admin;
38
57
address token;
@@ -88,7 +107,7 @@ contract End2EndForkTest is Test {
88
107
function testEndToEndSetup_M2Migration () public {
89
108
(
90
109
OperatorLib.Operator[] memory operators ,
91
- CoreDeployLib. DeploymentData memory coreDeployment ,
110
+ DeploymentData memory coreDeployment ,
92
111
MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment ,
93
112
ConfigData memory middlewareConfig
94
113
) = _setupInitialState ();
@@ -107,20 +126,54 @@ contract End2EndForkTest is Test {
107
126
_executeSlashing (operators, middlewareConfig, middlewareDeployment);
108
127
}
109
128
129
+ function _deployMiddlewareWithCore (
130
+ address proxyAdmin ,
131
+ address owner
132
+ )
133
+ internal
134
+ returns (
135
+ MiddlewareDeployLib.MiddlewareDeployData memory middleware ,
136
+ DeploymentData memory core
137
+ )
138
+ {
139
+ string memory rpcUrl = vm.envString ("HOLESKY_RPC_URL " );
140
+ vm.createSelectFork (rpcUrl);
141
+ // Read core deployment data from json
142
+ core = _readCoreDeploymentJson ("./script/config " , 17000 , "preprod " );
143
+
144
+ // Deploy proxies
145
+ middleware = MiddlewareDeployLib.deployEmptyProxies (proxyAdmin);
146
+
147
+ // Deploy pauser registry
148
+ middleware.pauserRegistry = MiddlewareDeployLib.deployPauserRegistry (proxyAdmin);
149
+
150
+ // Upgrade the proxies
151
+ MiddlewareDeployLib.upgradeRegistriesM2Coordinator (
152
+ core.delegationManager, core.avsDirectory, core.allocationManager, middleware
153
+ );
154
+ MiddlewareDeployLib.ugpradeServiceManager (
155
+ core.avsDirectory, core.rewardsCoordinator, core.allocationManager, middleware, owner
156
+ );
157
+ MiddlewareDeployLib.upgradeM2Coordinator (core.allocationManager, middleware, owner);
158
+
159
+ return (middleware, core);
160
+ }
161
+
110
162
function _setupInitialState ()
111
163
internal
112
164
returns (
113
165
OperatorLib.Operator[] memory operators ,
114
- CoreDeployLib. DeploymentData memory coreDeployment ,
166
+ DeploymentData memory coreDeployment ,
115
167
MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment ,
116
168
ConfigData memory middlewareConfig
117
169
)
118
170
{
119
- // Fork Holesky testnet
120
- string memory rpcUrl = vm.envString ("HOLESKY_RPC_URL " );
121
- vm.createSelectFork (rpcUrl);
122
- // Read core deployment data from json
123
- coreDeployment = CoreDeployLib.readCoreDeploymentJson ("./script/config " , 17000 , "preprod " );
171
+ middlewareConfig.proxyAdmin = UpgradeableProxyLib.deployProxyAdmin ();
172
+ middlewareConfig.admin = address (this );
173
+
174
+ // Deploy middleware with core
175
+ (middlewareDeployment, coreDeployment) =
176
+ deployMiddlewareWithCore (middlewareConfig.proxyAdmin, middlewareConfig.admin);
124
177
125
178
// // Create 5 operators using helper function
126
179
operators = _createOperators (5 , 100 );
@@ -129,8 +182,6 @@ contract End2EndForkTest is Test {
129
182
(address token , address strategy ) = _deployTokenAndStrategy (coreDeployment.strategyFactory);
130
183
131
184
// Setup middleware deployment data
132
- middlewareConfig.proxyAdmin = UpgradeableProxyLib.deployProxyAdmin ();
133
- middlewareConfig.admin = address (this );
134
185
middlewareConfig.numQuorums = 1 ;
135
186
middlewareConfig.operatorParams = new uint256 [](3 );
136
187
middlewareConfig.operatorParams[0 ] = 10 ;
@@ -140,10 +191,6 @@ contract End2EndForkTest is Test {
140
191
middlewareConfig.token = token;
141
192
middlewareConfig.operators = _getAndSortOperators (operators);
142
193
143
- middlewareDeployment = MiddlewareDeployLib.deployMiddlewareWithCore (
144
- middlewareConfig.proxyAdmin, middlewareConfig.admin, coreDeployment
145
- );
146
-
147
194
vm.startPrank (middlewareDeployment.serviceManager);
148
195
AllocationManager (coreDeployment.allocationManager).updateAVSMetadataURI (
149
196
middlewareDeployment.serviceManager, "metadata "
@@ -194,7 +241,7 @@ contract End2EndForkTest is Test {
194
241
195
242
function _setupOperatorsAndTokens (
196
243
OperatorLib.Operator[] memory operators ,
197
- CoreDeployLib. DeploymentData memory coreDeployment ,
244
+ DeploymentData memory coreDeployment ,
198
245
ConfigData memory middlewareConfig
199
246
) internal {
200
247
// Verify and register operators
@@ -243,7 +290,7 @@ contract End2EndForkTest is Test {
243
290
function _setupFirstQuorumAndOperatorSet (
244
291
OperatorLib.Operator[] memory operators ,
245
292
ConfigData memory middlewareConfig ,
246
- CoreDeployLib. DeploymentData memory coreDeployment ,
293
+ DeploymentData memory coreDeployment ,
247
294
MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment
248
295
) internal {
249
296
vm.startPrank (middlewareConfig.admin);
@@ -297,7 +344,7 @@ contract End2EndForkTest is Test {
297
344
function _setupSecondQuorumAndOperatorSet (
298
345
OperatorLib.Operator[] memory operators ,
299
346
ConfigData memory middlewareConfig ,
300
- CoreDeployLib. DeploymentData memory coreDeployment ,
347
+ DeploymentData memory coreDeployment ,
301
348
MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment
302
349
) internal {
303
350
// Create second quorum
@@ -354,7 +401,7 @@ contract End2EndForkTest is Test {
354
401
355
402
function _setupOperatorAllocations (
356
403
OperatorLib.Operator[] memory operators ,
357
- CoreDeployLib. DeploymentData memory coreDeployment ,
404
+ DeploymentData memory coreDeployment ,
358
405
MiddlewareDeployLib.MiddlewareDeployData memory middlewareDeployment ,
359
406
address strategy
360
407
) internal {
@@ -439,4 +486,51 @@ contract End2EndForkTest is Test {
439
486
440
487
return registeredOperators;
441
488
}
489
+
490
+ function _readCoreDeploymentJson (
491
+ string memory path ,
492
+ uint256 chainId
493
+ ) internal returns (DeploymentData memory ) {
494
+ string memory filePath = string (abi.encodePacked (path, "/ " , vm.toString (chainId), ".json " ));
495
+ return _parseZeusJson (filePath);
496
+ }
497
+
498
+ function _readCoreDeploymentJson (
499
+ string memory path ,
500
+ uint256 chainId ,
501
+ string memory environment
502
+ ) internal returns (DeploymentData memory ) {
503
+ string memory filePath =
504
+ string (abi.encodePacked (path, "/ " , vm.toString (chainId), "- " , environment, ".json " ));
505
+ return _parseZeusJson (filePath);
506
+ }
507
+
508
+ function _parseZeusJson (
509
+ string memory filePath
510
+ ) internal returns (DeploymentData memory ) {
511
+ string memory json = vm.readFile (filePath);
512
+ require (vm.exists (filePath), "Deployment file does not exist " );
513
+ DeploymentData memory deploymentData;
514
+
515
+ deploymentData.delegationManager =
516
+ json.readAddress (".ZEUS_DEPLOYED_DelegationManager_Proxy " );
517
+ deploymentData.avsDirectory = json.readAddress (".ZEUS_DEPLOYED_AVSDirectory_Proxy " );
518
+ deploymentData.strategyManager = json.readAddress (".ZEUS_DEPLOYED_StrategyManager_Proxy " );
519
+ deploymentData.allocationManager =
520
+ json.readAddress (".ZEUS_DEPLOYED_AllocationManager_Proxy " );
521
+ deploymentData.eigenPodManager = json.readAddress (".ZEUS_DEPLOYED_EigenPodManager_Proxy " );
522
+ deploymentData.rewardsCoordinator =
523
+ json.readAddress (".ZEUS_DEPLOYED_RewardsCoordinator_Proxy " );
524
+ deploymentData.eigenPodBeacon = json.readAddress (".ZEUS_DEPLOYED_EigenPod_Beacon " );
525
+ deploymentData.pauserRegistry = json.readAddress (".ZEUS_DEPLOYED_PauserRegistry_Impl " );
526
+ deploymentData.strategyFactory = json.readAddress (".ZEUS_DEPLOYED_StrategyFactory_Proxy " );
527
+ deploymentData.strategyBeacon = json.readAddress (".ZEUS_DEPLOYED_StrategyBase_Beacon " );
528
+ deploymentData.eigenStrategy = json.readAddress (".ZEUS_DEPLOYED_EigenStrategy_Proxy " );
529
+ deploymentData.eigen = json.readAddress (".ZEUS_DEPLOYED_Eigen_Proxy " );
530
+ deploymentData.backingEigen = json.readAddress (".ZEUS_DEPLOYED_BackingEigen_Proxy " );
531
+ deploymentData.permissionController =
532
+ json.readAddress (".ZEUS_DEPLOYED_PermissionController_Proxy " );
533
+
534
+ return deploymentData;
535
+ }
442
536
}
0 commit comments