Skip to content

Commit e282e12

Browse files
uri-99JuArcetaturosati
authored
feat: add onlyAggregator to respondToTask (#883)
Co-authored-by: JuArce <[email protected]> Co-authored-by: taturosati <“[email protected]”>
1 parent 81b290d commit e282e12

13 files changed

+344
-28
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ anvil_upgrade_index_registry:
7171
@echo "Upgrading Index Registry Contracts..."
7272
. contracts/scripts/anvil/upgrade_index_registry.sh
7373

74+
anvil_upgrade_add_aggregator:
75+
@echo "Adding Aggregator to Aligned Contracts..."
76+
. contracts/scripts/anvil/upgrade_add_aggregator_to_service_manager.sh
77+
7478
lint_contracts:
7579
@cd contracts && npm run lint:sol
7680

@@ -429,6 +433,10 @@ upgrade_stake_registry: ## Upgrade Stake Registry
429433
@echo "Upgrading Stake Registry..."
430434
@. contracts/scripts/.env && . contracts/scripts/upgrade_stake_registry.sh
431435

436+
upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
437+
@echo "Adding Aggregator to Aligned Contracts..."
438+
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
439+
432440
deploy_verify_batch_inclusion_caller:
433441
@echo "Deploying VerifyBatchInclusionCaller contract..."
434442
@. examples/verify/.env && . examples/verify/scripts/deploy_verify_batch_inclusion_caller.sh

contracts/bindings/AlignedLayerServiceManager/binding.go

Lines changed: 87 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/script/deploy/AlignedLayerDeployer.s.sol

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
3434
address public pauser;
3535
uint256 public initalPausedStatus;
3636
address public deployer;
37+
address public alignedLayerAggregator;
3738

3839
BLSApkRegistry public apkRegistry;
3940
AlignedLayerServiceManager public alignedLayerServiceManager;
@@ -95,6 +96,11 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
9596
);
9697
emit log_named_address("You are deploying from", deployer);
9798

99+
alignedLayerAggregator = stdJson.readAddress(
100+
config_data,
101+
".permissions.aggregator"
102+
);
103+
98104
vm.startBroadcast();
99105

100106
// deploy proxy admin for ability to upgrade proxy contracts
@@ -242,7 +248,8 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
242248
abi.encodeWithSelector(
243249
AlignedLayerServiceManager.initialize.selector,
244250
deployer,
245-
deployer
251+
deployer,
252+
alignedLayerAggregator
246253
)
247254
);
248255

@@ -792,6 +799,10 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
792799
config_data,
793800
".permissions.ejector"
794801
);
802+
address alignedLayerAggregator = stdJson.readAddress(
803+
config_data,
804+
".permissions.aggregator"
805+
);
795806
string memory permissions = "permissions";
796807
vm.serializeAddress(
797808
permissions,
@@ -804,7 +815,11 @@ contract AlignedLayerDeployer is ExistingDeploymentParser {
804815
alignedLayerUpgrader
805816
);
806817
vm.serializeAddress(permissions, "alignedLayerChurner", churner);
818+
807819
vm.serializeAddress(permissions, "pauserRegistry", pauser);
820+
821+
vm.serializeAddress(permissions, "alignedLayerAggregator", alignedLayerAggregator);
822+
808823
string memory permissions_output = vm.serializeAddress(
809824
permissions,
810825
"alignedLayerEjector",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"permissions": {
66
"owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
7-
"aggregator": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
7+
"aggregator": "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
88
"upgrader": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
99
"churner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
1010
"ejector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",

contracts/script/output/devnet/alignedlayer_deployment_output.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"deploymentBlock": 0
2222
},
2323
"permissions": {
24+
"alignedLayerAggregator": "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
2425
"alignedLayerChurner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
2526
"alignedLayerEjector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
2627
"alignedLayerOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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 AlignedLayerSetAggregator is Script {
15+
function run(
16+
string memory eigenLayerDeploymentFilePath,
17+
string memory alignedLayerDeploymentFilePath,
18+
string memory alignedConfigFilePath
19+
) external returns (address, address) {
20+
string memory eigen_deployment_file = vm.readFile(
21+
eigenLayerDeploymentFilePath
22+
);
23+
24+
string memory aligned_deployment_file = vm.readFile(
25+
alignedLayerDeploymentFilePath
26+
);
27+
28+
string memory aligned_config_file = vm.readFile(
29+
alignedConfigFilePath
30+
);
31+
32+
ProxyAdmin alignedLayerProxyAdmin = ProxyAdmin(
33+
stdJson.readAddress(
34+
aligned_deployment_file,
35+
".addresses.alignedLayerProxyAdmin"
36+
)
37+
);
38+
39+
RegistryCoordinator registryCoordinator = RegistryCoordinator(
40+
stdJson.readAddress(
41+
aligned_deployment_file,
42+
".addresses.registryCoordinator"
43+
)
44+
);
45+
46+
AVSDirectory avsDirectory = AVSDirectory(
47+
stdJson.readAddress(
48+
eigen_deployment_file,
49+
".addresses.avsDirectory"
50+
)
51+
);
52+
53+
StakeRegistry stakeRegistry = StakeRegistry(
54+
stdJson.readAddress(
55+
aligned_deployment_file,
56+
".addresses.stakeRegistry"
57+
)
58+
);
59+
60+
IRewardsCoordinator rewardsCoordinator = IRewardsCoordinator(
61+
stdJson.readAddress(
62+
eigen_deployment_file,
63+
".addresses.rewardsCoordinator"
64+
)
65+
);
66+
67+
address alignedLayerAggregator = stdJson.readAddress(
68+
aligned_config_file,
69+
".permissions.aggregator"
70+
);
71+
72+
vm.startBroadcast();
73+
74+
AlignedLayerServiceManager alignedLayerServiceManagerImplementation = new AlignedLayerServiceManager(
75+
avsDirectory,
76+
rewardsCoordinator,
77+
registryCoordinator,
78+
stakeRegistry
79+
);
80+
81+
vm.stopBroadcast();
82+
vm.startBroadcast();
83+
84+
// alignedLayerServiceManager is the proxy
85+
AlignedLayerServiceManager alignedLayerServiceManager = AlignedLayerServiceManager(
86+
payable(
87+
stdJson.readAddress(
88+
aligned_deployment_file,
89+
".addresses.alignedLayerServiceManager"
90+
)
91+
)
92+
);
93+
94+
vm.stopBroadcast();
95+
vm.startBroadcast();
96+
97+
alignedLayerProxyAdmin.upgrade(
98+
TransparentUpgradeableProxy(
99+
payable(address(alignedLayerServiceManager))
100+
),
101+
address(alignedLayerServiceManagerImplementation)
102+
);
103+
104+
vm.stopBroadcast();
105+
vm.startBroadcast();
106+
107+
alignedLayerServiceManager.initializeAggregator(
108+
alignedLayerAggregator
109+
);
110+
111+
vm.stopBroadcast();
112+
113+
return (
114+
address(alignedLayerServiceManager),
115+
address(alignedLayerServiceManagerImplementation)
116+
);
117+
}
118+
}

contracts/scripts/anvil/deploy_aligned_contracts.sh

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ batcher_payment_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print
4949
batcher_payment_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
5050

5151
# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file
52-
jq --arg batcher_payment_service_proxy "$batcher_payment_service_proxy" '.addresses.batcherPaymentService = $batcher_payment_service_proxy' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp.temp.json"
53-
jq --arg batcher_payment_service_implementation "$batcher_payment_service_implementation" '.addresses.batcherPaymentServiceImplementation = $batcher_payment_service_implementation' "script/output/devnet/alignedlayer_deployment_output.temp.temp.json" > "script/output/devnet/alignedlayer_deployment_output.temp.json"
54-
52+
jq --arg batcher_payment_service_proxy "$batcher_payment_service_proxy" '.addresses.batcherPaymentService = $batcher_payment_service_proxy' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp1.json"
53+
jq --arg batcher_payment_service_implementation "$batcher_payment_service_implementation" '.addresses.batcherPaymentServiceImplementation = $batcher_payment_service_implementation' "script/output/devnet/alignedlayer_deployment_output.temp1.json" > "script/output/devnet/alignedlayer_deployment_output.temp2.json"
5554

5655
# Replace the original file with the temporary file
57-
mv "script/output/devnet/alignedlayer_deployment_output.temp.json" "script/output/devnet/alignedlayer_deployment_output.json"
56+
mv "script/output/devnet/alignedlayer_deployment_output.temp2.json" "script/output/devnet/alignedlayer_deployment_output.json"
5857

5958
# Delete the temporary file
60-
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.json"
61-
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.temp.json"
62-
59+
rm -f "script/output/devnet/alignedlayer_deployment_output.temp1.json"
60+
rm -f "script/output/devnet/alignedlayer_deployment_output.temp2.json"
6361

6462

6563
# Kill the anvil process to save state

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
jq 'del(.block)' scripts/anvil/state/alignedlayer-deployed-anvil-state.json > scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json
11+
12+
cp -f scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json scripts/anvil/state/alignedlayer-deployed-anvil-state.json
13+
14+
rm scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json
15+
16+
anvil --load-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json --dump-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json &
17+
18+
sleep 2
19+
20+
# Save the output to a variable to later extract the address of the new deployed contract
21+
forge_output=$(forge script script/upgrade/AlignedLayerUpgradeAddAggregator.s.sol \
22+
"./script/output/devnet/eigenlayer_deployment_output.json" \
23+
"./script/output/devnet/alignedlayer_deployment_output.json" \
24+
"./script/deploy/config/devnet/aligned.devnet.config.json" \
25+
--rpc-url "http://localhost:8545" \
26+
--private-key "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" \
27+
--broadcast \
28+
--sig "run(string memory eigenLayerDeploymentFilePath, string memory alignedLayerDeploymentFilePath, string memory alignedConfigFilePath)")
29+
30+
echo "$forge_output"
31+
32+
pkill anvil
33+
34+
ALIGNED_LAYER_AGGREGATOR_ADDRESS=$(jq -r '.permissions.aggregator' ./script/deploy/config/devnet/aligned.devnet.config.json)
35+
jq --arg alignedLayerAggregator "$ALIGNED_LAYER_AGGREGATOR_ADDRESS" '.permissions += {"alignedLayerAggregator": $alignedLayerAggregator}' "script/output/devnet/alignedlayer_deployment_output.json" > "script/output/devnet/alignedlayer_deployment_output.temp.json"
36+
37+
mv "script/output/devnet/alignedlayer_deployment_output.temp.json" "script/output/devnet/alignedlayer_deployment_output.json"
38+
rm -f "script/output/devnet/alignedlayer_deployment_output.temp.json"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 ../../contracts
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/AlignedLayerUpgradeAddAggregator.s.sol \
12+
$EXISTING_DEPLOYMENT_INFO_PATH \
13+
$OUTPUT_PATH \
14+
$DEPLOY_CONFIG_PATH \
15+
--rpc-url $RPC_URL \
16+
--private-key $PRIVATE_KEY \
17+
--broadcast \
18+
--verify \
19+
--etherscan-api-key $ETHERSCAN_API_KEY \
20+
--sig "run(string memory eigenLayerDeploymentFilePath, string memory alignedLayerDeploymentFilePath, string memory alignedConfigFilePath)")
21+
22+
echo "$forge_output"
23+
24+
# Extract the alignedLayerServiceManagerImplementation value from the output
25+
new_aligned_layer_service_manager_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
26+
27+
# Use the extracted value to replace the alignedLayerServiceManagerImplementation value in alignedlayer_deployment_output.json and save it to a temporary file
28+
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"
29+
30+
# Write aggregator addres to deployment output file
31+
ALIGNED_LAYER_AGGREGATOR_ADDRESS=$(jq -r '.permissions.aggregator' $DEPLOY_CONFIG_PATH)
32+
jq --arg alignedLayerAggregator "$ALIGNED_LAYER_AGGREGATOR_ADDRESS" '.permissions += {"alignedLayerAggregator": $alignedLayerAggregator}' "script/output/holesky/alignedlayer_deployment_output.temp.json" > "script/output/holesky/alignedlayer_deployment_output.temp2.json"
33+
34+
# Replace the original file with the temporary file
35+
mv "script/output/holesky/alignedlayer_deployment_output.temp2.json" $OUTPUT_PATH
36+
37+
# Delete the temporary file
38+
rm -f "script/output/holesky/alignedlayer_deployment_output.temp.json"

0 commit comments

Comments
 (0)