|
| 1 | +// SPDX-License-Identifier: UNLICENSED |
| 2 | +pragma solidity =0.8.12; |
| 3 | + |
| 4 | +import {Script} from "forge-std/Script.sol"; |
| 5 | +import "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; |
| 6 | +import {RegistryCoordinator} from "eigenlayer-middleware/RegistryCoordinator.sol"; |
| 7 | +import {StakeRegistry} from "eigenlayer-middleware/StakeRegistry.sol"; |
| 8 | +import {BLSApkRegistry} from "eigenlayer-middleware/BLSApkRegistry.sol"; |
| 9 | +import {IndexRegistry} from "eigenlayer-middleware/IndexRegistry.sol"; |
| 10 | +import {AlignedLayerServiceManager} from "src/core/AlignedLayerServiceManager.sol"; |
| 11 | +import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol"; |
| 12 | +import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; |
| 13 | +import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; |
| 14 | +import "forge-std/StdJson.sol"; |
| 15 | + |
| 16 | +contract RegistryCoordinatorUpgrader is Script { |
| 17 | + function run( |
| 18 | + string memory eigenLayerDeploymentFilePath, |
| 19 | + string memory alignedLayerDeploymentFilePath |
| 20 | + ) external returns (address, address) { |
| 21 | + // Load files |
| 22 | + string memory eigen_deployment_file = vm.readFile( |
| 23 | + eigenLayerDeploymentFilePath |
| 24 | + ); |
| 25 | + string memory aligned_deployment_file = vm.readFile( |
| 26 | + alignedLayerDeploymentFilePath |
| 27 | + ); |
| 28 | + |
| 29 | + // Load proxy admin |
| 30 | + ProxyAdmin alignedLayerProxyAdmin = ProxyAdmin( |
| 31 | + stdJson.readAddress( |
| 32 | + aligned_deployment_file, |
| 33 | + ".addresses.alignedLayerProxyAdmin" |
| 34 | + ) |
| 35 | + ); |
| 36 | + |
| 37 | + // Load RegistryCoordinator Proxy |
| 38 | + TransparentUpgradeableProxy registryCoordinator = TransparentUpgradeableProxy( |
| 39 | + payable(stdJson.readAddress( |
| 40 | + aligned_deployment_file, |
| 41 | + ".addresses.registryCoordinator" |
| 42 | + )) |
| 43 | + ); |
| 44 | + |
| 45 | + // Load RegistryCoordinator dependencies |
| 46 | + AlignedLayerServiceManager alignedLayerServiceManager = AlignedLayerServiceManager( |
| 47 | + stdJson.readAddress( |
| 48 | + aligned_deployment_file, |
| 49 | + ".addresses.alignedLayerServiceManager" |
| 50 | + ) |
| 51 | + ); |
| 52 | + StakeRegistry stakeRegistry = StakeRegistry( |
| 53 | + stdJson.readAddress( |
| 54 | + aligned_deployment_file, |
| 55 | + ".addresses.stakeRegistry" |
| 56 | + ) |
| 57 | + ); |
| 58 | + BLSApkRegistry apkRegistry = BLSApkRegistry( |
| 59 | + stdJson.readAddress( |
| 60 | + aligned_deployment_file, |
| 61 | + ".addresses.blsApkRegistry" |
| 62 | + ) |
| 63 | + ); |
| 64 | + IndexRegistry indexRegistry = IndexRegistry( |
| 65 | + stdJson.readAddress( |
| 66 | + aligned_deployment_file, |
| 67 | + ".addresses.indexRegistry" |
| 68 | + ) |
| 69 | + ); |
| 70 | + |
| 71 | + // Create a new instance of the RegistryCoordinatorImplementation |
| 72 | + vm.startBroadcast(); |
| 73 | + RegistryCoordinator registryCoordinatorImplementation = new RegistryCoordinator( |
| 74 | + IServiceManager(address(alignedLayerServiceManager)), |
| 75 | + stakeRegistry, |
| 76 | + apkRegistry, |
| 77 | + indexRegistry |
| 78 | + ); |
| 79 | + vm.stopBroadcast(); |
| 80 | + |
| 81 | + vm.startBroadcast(); |
| 82 | + alignedLayerProxyAdmin.upgrade( |
| 83 | + registryCoordinator, |
| 84 | + address(registryCoordinatorImplementation) |
| 85 | + ); |
| 86 | + vm.stopBroadcast(); |
| 87 | + |
| 88 | + return ( |
| 89 | + address(registryCoordinator), |
| 90 | + address(registryCoordinatorImplementation) |
| 91 | + ); |
| 92 | + } |
| 93 | +} |
0 commit comments