Skip to content

Commit 4ba4904

Browse files
committed
chore: add upgrade script to add Pausable to ServiceManager
1 parent fd7b01f commit 4ba4904

File tree

7 files changed

+307
-0
lines changed

7 files changed

+307
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,18 @@ deploy_aligned_contracts: ## Deploy Aligned Contracts
468468
@echo "Deploying Aligned Contracts..."
469469
@. contracts/scripts/.env && . contracts/scripts/deploy_aligned_contracts.sh
470470

471+
deploy_pauser_registry: ## Deploy Pauser Registry
472+
@echo "Deploying Pauser Registry..."
473+
@. contracts/scripts/.env && . contracts/scripts/deploy_pauser_registry.sh
474+
471475
upgrade_aligned_contracts: ## Upgrade Aligned Contracts
472476
@echo "Upgrading Aligned Contracts..."
473477
@. contracts/scripts/.env && . contracts/scripts/upgrade_aligned_contracts.sh
474478

479+
upgrade_aligned_contracts: ## Upgrade Aligned Contracts with Pauser initialization
480+
@echo "Upgrading Aligned Contracts with Pauser initialization..."
481+
@. contracts/scripts/.env && . contracts/scripts/upgrade_pauser_aligned_contracts.sh
482+
475483
upgrade_registry_coordinator: ## Upgrade Registry Coordinator
476484
@echo "Upgrading Registry Coordinator..."
477485
@. contracts/scripts/.env && . contracts/scripts/upgrade_registry_coordinator.sh
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity =0.8.12;
3+
4+
import {PauserRegistry} from "eigenlayer-core/contracts/permissions/PauserRegistry.sol";
5+
6+
import "script/deploy/utils/ExistingDeploymentParser.sol";
7+
import "forge-std/Test.sol";
8+
import "forge-std/Script.sol";
9+
import "forge-std/StdJson.sol";
10+
11+
// This script is only for deploying the PauserRegistry contract
12+
// In order to avoid redeploying previously deployed contracts, we will use the deployed contract addresses
13+
contract PauserRegistryDeployer is ExistingDeploymentParser {
14+
address public pauser;
15+
uint256 public initalPausedStatus;
16+
address public deployer;
17+
18+
PauserRegistry public pauserRegistry;
19+
20+
function run(
21+
string memory existingDeploymentInfoPath,
22+
string memory deployConfigPath,
23+
string memory outputPath
24+
) external {
25+
// get info on all the already-deployed contracts
26+
_parseDeployedContracts(existingDeploymentInfoPath);
27+
28+
// READ JSON CONFIG DATA
29+
string memory config_data = vm.readFile(deployConfigPath);
30+
31+
// check that the chainID matches the one in the config
32+
uint256 currentChainId = block.chainid;
33+
uint256 configChainId = stdJson.readUint(
34+
config_data,
35+
".chainInfo.chainId"
36+
);
37+
emit log_named_uint("You are deploying on ChainID", currentChainId);
38+
require(
39+
configChainId == currentChainId,
40+
"You are on the wrong chain for this config"
41+
);
42+
43+
initalPausedStatus = stdJson.readUint(
44+
config_data,
45+
".permissions.initalPausedStatus"
46+
);
47+
pauser = stdJson.readAddress(
48+
config_data,
49+
".permissions.pauser"
50+
);
51+
52+
deployer = stdJson.readAddress(config_data, ".permissions.deployer");
53+
require(
54+
deployer == tx.origin,
55+
"Deployer address must be the same as the tx.origin"
56+
);
57+
emit log_named_address("You are deploying from", deployer);
58+
59+
vm.startBroadcast();
60+
61+
//deploy pauser registry
62+
{
63+
address[] memory pausers = new address[](1);
64+
pausers[0] = pauser;
65+
pauserRegistry = new PauserRegistry(pausers, pauser); // (pausers, unpauser)
66+
}
67+
68+
vm.stopPrank();
69+
70+
//write output
71+
_writeOutput(config_data, outputPath);
72+
}
73+
74+
function _writeOutput(string memory config_data, string memory outputPath) internal {
75+
string memory parent_object = "parent object";
76+
77+
string memory deployed_addresses = "addresses";
78+
79+
string memory deployed_addresses_output = vm.serializeAddress(
80+
deployed_addresses,
81+
"pauserRegistry",
82+
address(pauserRegistry)
83+
);
84+
85+
string memory chain_info = "chainInfo";
86+
vm.serializeUint(chain_info, "deploymentBlock", block.number);
87+
string memory chain_info_output = vm.serializeUint(
88+
chain_info,
89+
"chainId",
90+
block.chainid
91+
);
92+
93+
address pauserAddress = stdJson.readAddress(
94+
config_data,
95+
".permissions.pauser"
96+
);
97+
string memory permissions = "permissions";
98+
99+
string memory permissions_output = vm.serializeAddress(
100+
permissions,
101+
"alignedLayerPauser",
102+
pauserAddress
103+
);
104+
105+
vm.serializeString(parent_object, chain_info, chain_info_output);
106+
vm.serializeString(
107+
parent_object,
108+
deployed_addresses,
109+
deployed_addresses_output
110+
);
111+
string memory finalJson = vm.serializeString(
112+
parent_object,
113+
permissions,
114+
permissions_output
115+
);
116+
vm.writeJson(finalJson, outputPath);
117+
}
118+
}

contracts/script/deploy/config/holesky/aligned.holesky.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"churner": "<churner_address>",
1010
"ejector": "<ejector_address>",
1111
"deployer": "<deployer_address>",
12+
"pauser": "<pauser_address>",
1213
"initalPausedStatus": 0
1314
},
1415
"minimumStakes": [
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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 {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol";
9+
import {AlignedLayerServiceManager} from "src/core/AlignedLayerServiceManager.sol";
10+
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
11+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
12+
import "forge-std/StdJson.sol";
13+
14+
contract AlignedLayerPauserUpgrader is Script {
15+
uint256 public initialPausedStatus;
16+
17+
function run(
18+
string memory eigenLayerDeploymentFilePath,
19+
string memory deployConfigPath,
20+
string memory alignedLayerDeploymentFilePath
21+
) external returns (address, address) {
22+
// READ JSON CONFIG DATA
23+
string memory config_data = vm.readFile(deployConfigPath);
24+
25+
string memory eigen_deployment_file = vm.readFile(
26+
eigenLayerDeploymentFilePath
27+
);
28+
29+
string memory aligned_deployment_file = vm.readFile(
30+
alignedLayerDeploymentFilePath
31+
);
32+
33+
ProxyAdmin alignedLayerProxyAdmin = ProxyAdmin(
34+
stdJson.readAddress(
35+
aligned_deployment_file,
36+
".addresses.alignedLayerProxyAdmin"
37+
)
38+
);
39+
40+
RegistryCoordinator registryCoordinator = RegistryCoordinator(
41+
stdJson.readAddress(
42+
aligned_deployment_file,
43+
".addresses.registryCoordinator"
44+
)
45+
);
46+
47+
AVSDirectory avsDirectory = AVSDirectory(
48+
stdJson.readAddress(
49+
eigen_deployment_file,
50+
".addresses.avsDirectory"
51+
)
52+
);
53+
54+
StakeRegistry stakeRegistry = StakeRegistry(
55+
stdJson.readAddress(
56+
aligned_deployment_file,
57+
".addresses.stakeRegistry"
58+
)
59+
);
60+
61+
IRewardsCoordinator rewardsCoordinator = IRewardsCoordinator(
62+
stdJson.readAddress(
63+
eigen_deployment_file,
64+
".addresses.rewardsCoordinator"
65+
)
66+
);
67+
68+
IPauserRegistry pauserRegistry = IPauserRegistry(
69+
stdJson.readAddress(
70+
aligned_deployment_file,
71+
".addresses.pauserRegistry"
72+
)
73+
);
74+
75+
initialPausedStatus = stdJson.readUint(
76+
config_data,
77+
".permissions.initalPausedStatus"
78+
);
79+
80+
vm.startBroadcast();
81+
82+
AlignedLayerServiceManager alignedLayerServiceManagerImplementation = new AlignedLayerServiceManager(
83+
avsDirectory,
84+
rewardsCoordinator,
85+
registryCoordinator,
86+
stakeRegistry
87+
);
88+
89+
vm.stopBroadcast();
90+
91+
// alignedLayerServiceManager is the proxy
92+
AlignedLayerServiceManager alignedLayerServiceManager = AlignedLayerServiceManager(
93+
stdJson.readAddress(
94+
aligned_deployment_file,
95+
".addresses.alignedLayerServiceManager"
96+
)
97+
);
98+
99+
vm.startBroadcast();
100+
101+
alignedLayerProxyAdmin.upgradeAndCall(
102+
TransparentUpgradeableProxy(
103+
payable(address(alignedLayerServiceManager))
104+
),
105+
address(alignedLayerServiceManagerImplementation),
106+
abi.encodeWithSelector(
107+
AlignedLayerServiceManager.initializePauser.selector,
108+
pauserRegistry,
109+
initialPausedStatus
110+
)
111+
);
112+
113+
vm.stopBroadcast();
114+
115+
return (
116+
address(alignedLayerServiceManager),
117+
address(alignedLayerServiceManagerImplementation)
118+
);
119+
}
120+
}
121+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
# At this point we are in contracts/scripts
6+
cd "$parent_path"
7+
8+
# At this point we are in contracts
9+
cd ../
10+
11+
# Deploy the contracts
12+
forge script script/deploy/PauserRegistryDeployer.s.sol \
13+
$EXISTING_DEPLOYMENT_INFO_PATH \
14+
$DEPLOY_CONFIG_PATH \
15+
$OUTPUT_PATH \
16+
--rpc-url $RPC_URL \
17+
--private-key $PRIVATE_KEY \
18+
--broadcast \
19+
--sig "run(string memory existingDeploymentInfoPath, string memory deployConfigPath, string memory outputPath)" \
20+
--slow
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
6+
cd "$parent_path"
7+
8+
cd ../
9+
10+
# Save the output to a variable to later extract the address of the new deployed contract
11+
forge_output=$(forge script script/upgrade/AlignedLayerPauserUpgrader.s.sol \
12+
$EXISTING_DEPLOYMENT_INFO_PATH \
13+
$DEPLOY_CONFIG_PATH \
14+
$OUTPUT_PATH \
15+
--rpc-url $RPC_URL \
16+
--private-key $PRIVATE_KEY \
17+
--broadcast \
18+
--sig "run(string memory eigenLayerDeploymentFilePath, string memory deployConfigPath, string memory alignedLayerDeploymentFilePath, )")
19+
20+
echo "$forge_output"
21+
22+
# Extract the alignedLayerServiceManagerImplementation value from the output
23+
new_aligned_layer_service_manager_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
24+
25+
# Use the extracted value to replace the alignedLayerServiceManagerImplementation value in alignedlayer_deployment_output.json and save it to a temporary file
26+
jq --arg new_aligned_layer_service_manager_implementation "$new_aligned_layer_service_manager_implementation" '.addresses.alignedLayerServiceManagerImplementation = $new_aligned_layer_service_manager_implementation' "$OUTPUT_PATH" > "script/output/holesky/alignedlayer_deployment_output.temp.json"
27+
28+
# Replace the original file with the temporary file
29+
mv "script/output/holesky/alignedlayer_deployment_output.temp.json" "$OUTPUT_PATH"
30+
31+
# Delete the temporary file
32+
rm -f "script/output/holesky/alignedlayer_deployment_output.temp.json"

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ contract AlignedLayerServiceManager is
6565
_initializePauser(_pauserRegistry, _initialPausedStatus);
6666
}
6767

68+
function initializePauser(
69+
IPauserRegistry _pauserRegistry,
70+
uint256 _initialPausedStatus
71+
) public reinitializer(2) {
72+
_initializePauser(_pauserRegistry, _initialPausedStatus);
73+
}
74+
6875
function createNewTask(
6976
bytes32 batchMerkleRoot,
7077
string calldata batchDataPointer

0 commit comments

Comments
 (0)