-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
001dc6e
commit 0f6f0fd
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {console2} from "forge-std/Test.sol"; | ||
import {UpgradeableProxyLib} from "./utils/UpgradeableProxyLib.sol"; | ||
import {HelloWorldDeploymentLib} from "./utils/HelloWorldDeploymentLib.sol"; | ||
import {CoreDeploymentLib} from "./utils/CoreDeploymentLib.sol"; | ||
import {ECDSAStakeRegistry} from "@eigenlayer-middleware/src/unaudited/ECDSAStakeRegistry.sol"; | ||
import {HelloWorldServiceManager} from "../src/HelloWorldServiceManager.sol"; | ||
import {IDelegationManager} from "@eigenlayer/contracts/interfaces/IDelegationManager.sol"; | ||
|
||
contract ExampleUpgrade is Script { | ||
using UpgradeableProxyLib for address; | ||
using CoreDeploymentLib for *; | ||
|
||
address private deployer; | ||
address proxyAdmin; | ||
HelloWorldDeploymentLib.DeploymentData helloWorldDeployment; | ||
CoreDeploymentLib.DeploymentData coreDeployment; | ||
|
||
function setUp() public virtual { | ||
deployer = vm.rememberKey(vm.envUint("PRIVATE_KEY")); | ||
vm.label(deployer, "Deployer"); | ||
|
||
// Read existing deployments | ||
coreDeployment = CoreDeploymentLib.readDeploymentJson("deployments/core/", block.chainid); | ||
helloWorldDeployment = HelloWorldDeploymentLib.readDeploymentJson(block.chainid); | ||
proxyAdmin = helloWorldDeployment.proxyAdmin; | ||
} | ||
|
||
function run() external { | ||
vm.startBroadcast(deployer); | ||
|
||
/// Deploy new implementation contracts | ||
address newStakeRegistryImpl = address( | ||
new ECDSAStakeRegistry(IDelegationManager(coreDeployment.delegationManager)) | ||
); | ||
|
||
address newHelloWorldServiceManagerImpl = address( | ||
new HelloWorldServiceManager( | ||
coreDeployment.avsDirectory, | ||
helloWorldDeployment.stakeRegistry, | ||
coreDeployment.rewardsCoordinator, | ||
coreDeployment.delegationManager | ||
) | ||
); | ||
|
||
/// This is where you will actually perform your upgrade | ||
helloWorldDeployment.helloWorldServiceManager.upgrade(newHelloWorldServiceManagerImpl); | ||
helloWorldDeployment.stakeRegistry.upgrade(newStakeRegistryImpl); | ||
|
||
vm.stopBroadcast(); | ||
|
||
verifyUpgrade(); | ||
HelloWorldDeploymentLib.writeDeploymentJson(helloWorldDeployment); | ||
} | ||
|
||
function verifyUpgrade() internal view { | ||
require( | ||
helloWorldDeployment.helloWorldServiceManager.getImplementation() != address(0), | ||
"HelloWorldServiceManager implementation cannot be zero" | ||
); | ||
require( | ||
helloWorldDeployment.stakeRegistry.getImplementation() != address(0), | ||
"StakeRegistry implementation cannot be zero" | ||
); | ||
} | ||
} |