Skip to content

Commit 7a15d39

Browse files
PatStilesuri-99JulianVenturaavilagaston9
authored
Feat(contracts): Add script + guide to set aggregator address (#1487)
Co-authored-by: Uriel Mihura <[email protected]> Co-authored-by: Julian Ventura <[email protected]> Co-authored-by: avilagaston9 <[email protected]>
1 parent 9f401df commit 7a15d39

15 files changed

+205
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,16 @@ upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
604604
@echo "Adding Aggregator to Aligned Contracts..."
605605
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh
606606

607+
set_aggregator_address:
608+
@echo "Setting Aggregator Address in Aligned Service Manager Contract on $(NETWORK) network..."
609+
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
610+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/set_aggregator_address.sh $(AGGREGATOR_ADDRESS)
611+
612+
set_aggregator_address_devnet:
613+
@echo "Setting Aggregator Address in Aligned Service Manager Contract..."
614+
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
615+
RPC_URL="http://localhost:8545" PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" OUTPUT_PATH=./script/output/devnet/alignedlayer_deployment_output.json ./contracts/scripts/set_aggregator_address.sh $(AGGREGATOR_ADDRESS)
616+
607617
upgrade_initialize_disabled_verifiers:
608618
@echo "Adding disabled verifiers to Aligned Service Manager..."
609619
@. contracts/scripts/.env && . contracts/scripts/upgrade_disabled_verifiers_in_service_manager.sh
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# Check if the number of arguments is correct
12+
if [ "$#" -ne 1 ]; then
13+
echo "Usage: set_aggregator_address.sh <AGGREGATOR_ADDRESS>"
14+
exit 1
15+
fi
16+
17+
AGGREGATOR_ADDRESS=$1
18+
19+
# Read the service manager address from the JSON file
20+
SERVICE_MANAGER=$(jq -r '.addresses.alignedLayerServiceManager' "$OUTPUT_PATH")
21+
22+
# Check if the servide manager address is empty
23+
if [ -z "$SERVICE_MANAGER" ]; then
24+
echo "Service manager address is empty"
25+
exit 1
26+
fi
27+
28+
# Check if the Ethereum RPC URL is empty
29+
if [ -z "$RPC_URL" ]; then
30+
echo "Ethereum RPC URL is empty"
31+
exit 1
32+
fi
33+
34+
# Check if the private key is empty
35+
if [ -z "$PRIVATE_KEY" ]; then
36+
echo "Private key is empty"
37+
exit 1
38+
fi
39+
40+
# Call the setAggregator(address _alignedAggregator) function on the contract
41+
cast send \
42+
--private-key=$PRIVATE_KEY \
43+
--rpc-url=$RPC_URL \
44+
$SERVICE_MANAGER "setAggregator(address)" \
45+
$AGGREGATOR_ADDRESS
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Setting Aggregator Address
2+
This doc contains a guide on how to call `setAggregator(address)` to set the `alignedAggregator` value of the AlignedServiceManager.sol contract.
3+
4+
### NOTE:
5+
- This guide assumes the Aligned layer contracts have been sucessfully deployed and the deployment outputs are within `./contracts/script/output/<DEPLOYMENT_FOLDER>`
6+
7+
1. Locate the deployed Aligned Aggregator Address
8+
9+
The address of Aligned Aggregator can be found in `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json` within:
10+
```
11+
"permissions": {
12+
...
13+
"alignedLayerAggregator": "<AGGREGATOR_ADDRESS",
14+
...
15+
}
16+
```
17+
18+
2. Locate the Aligned Service Manager Address
19+
20+
The address of Aligned Service Manager can be found in `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json` within:
21+
```
22+
"addresses": {
23+
...
24+
"alignedLayerServiceManager": "<ALIGNED_SERVICE_MANAGER_ADDRESS>",
25+
...
26+
}
27+
```
28+
29+
3. Set Environment Variables
30+
31+
To run the make targets specified in this guide, you must first set the following env vars within `./contracts/scripts/.env.<NETWORK>`:
32+
```
33+
RPC_URL=<rpc_url>
34+
PRIVATE_KEY=<aligned_service_manager_owner_private_key>
35+
ALIGNED_SERVICE_MANAGER_ADDRESS=<aligned_service_manager_address>
36+
```
37+
38+
4. Check the current value of `alignedAggregator` within AlignedServiceManager.sol
39+
40+
```
41+
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
42+
```
43+
44+
You should see that the returned address matches the address from `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json`
45+
46+
5. Change the value of `alignedAggregator` within AlignedServiceManager.sol
47+
48+
Set the environment variable `AGGREGATOR_ADDRESS` to the new address of the aggregator.
49+
```
50+
export AGGREGATOR_ADDRESS=<aggregator_address>
51+
make set_aggregator_address
52+
```
53+
54+
6. Verify the Aligned Aggreagtor Address has changed
55+
```
56+
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
57+
```
58+
59+
You should observe that the printed address matches the address in `AGGREGATOR_ADDRESS`.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Propose the Transaction for Setting Aggregator Address using Multisig
2+
3+
If you want to set the Aggregator Address, you can propose the set Aggregator Address transaction using the multisig wallet.
4+
5+
## Prerequisites
6+
7+
- You need to have deployed the contracts following the [Deploy Contracts Guide](./2_deploy_contracts.md).
8+
9+
## Propose transaction for Set Aggregator Address
10+
11+
To propose the set aggregator address transaction you can follow the steps below:
12+
13+
1. Go to [Safe](https://app.safe.global/home)
14+
15+
2. Click on `New transaction` -> `Transaction Builder`
16+
17+
![New transaction](./images/7_b_1_set_aggregator_address_1.png)
18+
19+
![Transaction Builder](./images/7_b_1_set_aggregator_address_2.png)
20+
21+
3. Get the `AlignedLayerServiceManager` address from ```contracts/script/output/mainnet/alignedlayer_deployment_output.json``` or ```contracts/script/output/holesky/alignedlayer_deployment_output.json``` or ```contracts/script/output/sepolia/alignedlayer_deployment_output.json```
22+
23+
4. Paste the `AlignedLayerServiceManager` address on `Enter Address or ENS Name`
24+
25+
![Enter Address](./images/7_b_1_set_aggregator_address_3.png)
26+
27+
5. As this is a Proxy contract, choose `Use Implementation ABI`
28+
29+
![Use Implementation ABI](./images/7_b_1_set_aggregator_address_4.png)
30+
31+
6. In `contract method selector` choose `setAggregator()` and within `_alignedAggregator(address)` enter the ethereum new address of the aggregator.
32+
33+
![Choose set_aggregator](./images/7_b_1_set_aggregator_address_5.png)
34+
35+
7. Click on `+ Add new transaction`
36+
37+
You should see the new transaction to be executed
38+
39+
8. Click on `Create batch` to create the transaction.
40+
41+
![create batch](./images/7_b_1_set_aggregator_address_6.png)
42+
43+
9. Simulate the transaction by clicking on `Simulate`
44+
45+
10. If everything is correct, click on `Send batch` to send the transaction.
46+
47+
![Send batch](./images/7_b_1_set_aggregator_address_7.png)
48+
49+
11. Simulate the transaction, and if everything is correct, click on `Sign`.
50+
51+
![Send batch](./images/7_b_1_set_aggregator_address_8.png)
52+
53+
> [!NOTE]
54+
> In the `call` field, you will see `fallback`.
55+
12. Wait for the transaction to be executed. You can check the transaction status on the `Transactions` tab.
56+
57+
13. Verify the Aligned Aggreagtor Address has changed
58+
```
59+
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
60+
```
61+
62+
You should observe that the printed address matches the address in `AGGREGATOR_ADDRESS`.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Approve the Set Aggregator Address Transaction
2+
3+
Once the transaction is proposed, the multisig owners must approve the transaction.
4+
5+
## Approve the new Address for the Aggregator
6+
7+
1. Go to [Safe](https://app.safe.global/home) and connect your wallet.
8+
9+
2. Go to the `Transactions` tab and find the transaction that was proposed.
10+
11+
3. Get the expected raw data by running by running:
12+
13+
```bash
14+
cast calldata "setAggregator(address)()" <NEW_AGGREGATOR_ADDRESS>
15+
```
16+
17+
4. Click on the transaction, and then click on ```Advanced Details```.
18+
19+
![Check details](images/7_b_2_set_aggregator_address_1.png)
20+
21+
5. Copy the ```Raw Data```, paste it in a text editor and verify it is the same value as the one you got in step 3.
22+
23+
6. If the data is correct, click on the `Confirm` button.
24+
25+
7. Simulate the transaction. If everything is correct, click on the `Sign` button (or `Execute`, if you are the last one signing the transaction).
26+
27+
![Sign transaction](images/7_b_2_set_aggregator_address_2.png)
28+
29+
8. Once the transaction is executed, the change will be effective.
506 KB
Loading
314 KB
Loading
443 KB
Loading
65 KB
Loading
431 KB
Loading

0 commit comments

Comments
 (0)