Skip to content

Commit

Permalink
Feat(contracts): Add script + guide to set aggregator address (#1487)
Browse files Browse the repository at this point in the history
Co-authored-by: Uriel Mihura <[email protected]>
Co-authored-by: Julian Ventura <[email protected]>
Co-authored-by: avilagaston9 <[email protected]>
  • Loading branch information
4 people authored Dec 6, 2024
1 parent 9f401df commit 7a15d39
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,16 @@ upgrade_add_aggregator: ## Add Aggregator to Aligned Contracts
@echo "Adding Aggregator to Aligned Contracts..."
@. contracts/scripts/.env && . contracts/scripts/upgrade_add_aggregator_to_service_manager.sh

set_aggregator_address:
@echo "Setting Aggregator Address in Aligned Service Manager Contract on $(NETWORK) network..."
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/set_aggregator_address.sh $(AGGREGATOR_ADDRESS)

set_aggregator_address_devnet:
@echo "Setting Aggregator Address in Aligned Service Manager Contract..."
@echo "Aggregator address: $(AGGREGATOR_ADDRESS)"
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)

upgrade_initialize_disabled_verifiers:
@echo "Adding disabled verifiers to Aligned Service Manager..."
@. contracts/scripts/.env && . contracts/scripts/upgrade_disabled_verifiers_in_service_manager.sh
Expand Down
45 changes: 45 additions & 0 deletions contracts/scripts/set_aggregator_address.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# At this point we are in contracts/scripts
cd "$parent_path"

# At this point we are in contracts
cd ../

# Check if the number of arguments is correct
if [ "$#" -ne 1 ]; then
echo "Usage: set_aggregator_address.sh <AGGREGATOR_ADDRESS>"
exit 1
fi

AGGREGATOR_ADDRESS=$1

# Read the service manager address from the JSON file
SERVICE_MANAGER=$(jq -r '.addresses.alignedLayerServiceManager' "$OUTPUT_PATH")

# Check if the servide manager address is empty
if [ -z "$SERVICE_MANAGER" ]; then
echo "Service manager address is empty"
exit 1
fi

# Check if the Ethereum RPC URL is empty
if [ -z "$RPC_URL" ]; then
echo "Ethereum RPC URL is empty"
exit 1
fi

# Check if the private key is empty
if [ -z "$PRIVATE_KEY" ]; then
echo "Private key is empty"
exit 1
fi

# Call the setAggregator(address _alignedAggregator) function on the contract
cast send \
--private-key=$PRIVATE_KEY \
--rpc-url=$RPC_URL \
$SERVICE_MANAGER "setAggregator(address)" \
$AGGREGATOR_ADDRESS
59 changes: 59 additions & 0 deletions docs/0_internal/7_a_setting_aggregator_address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Setting Aggregator Address
This doc contains a guide on how to call `setAggregator(address)` to set the `alignedAggregator` value of the AlignedServiceManager.sol contract.

### NOTE:
- This guide assumes the Aligned layer contracts have been sucessfully deployed and the deployment outputs are within `./contracts/script/output/<DEPLOYMENT_FOLDER>`

1. Locate the deployed Aligned Aggregator Address

The address of Aligned Aggregator can be found in `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json` within:
```
"permissions": {
...
"alignedLayerAggregator": "<AGGREGATOR_ADDRESS",
...
}
```

2. Locate the Aligned Service Manager Address

The address of Aligned Service Manager can be found in `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json` within:
```
"addresses": {
...
"alignedLayerServiceManager": "<ALIGNED_SERVICE_MANAGER_ADDRESS>",
...
}
```

3. Set Environment Variables

To run the make targets specified in this guide, you must first set the following env vars within `./contracts/scripts/.env.<NETWORK>`:
```
RPC_URL=<rpc_url>
PRIVATE_KEY=<aligned_service_manager_owner_private_key>
ALIGNED_SERVICE_MANAGER_ADDRESS=<aligned_service_manager_address>
```

4. Check the current value of `alignedAggregator` within AlignedServiceManager.sol

```
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
```

You should see that the returned address matches the address from `./contracts/script/output/<DEPLOYMENT_FOLDER>/aligned_deployment_output.json`

5. Change the value of `alignedAggregator` within AlignedServiceManager.sol

Set the environment variable `AGGREGATOR_ADDRESS` to the new address of the aggregator.
```
export AGGREGATOR_ADDRESS=<aggregator_address>
make set_aggregator_address
```

6. Verify the Aligned Aggreagtor Address has changed
```
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
```

You should observe that the printed address matches the address in `AGGREGATOR_ADDRESS`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Propose the Transaction for Setting Aggregator Address using Multisig

If you want to set the Aggregator Address, you can propose the set Aggregator Address transaction using the multisig wallet.

## Prerequisites

- You need to have deployed the contracts following the [Deploy Contracts Guide](./2_deploy_contracts.md).

## Propose transaction for Set Aggregator Address

To propose the set aggregator address transaction you can follow the steps below:

1. Go to [Safe](https://app.safe.global/home)

2. Click on `New transaction` -> `Transaction Builder`

![New transaction](./images/7_b_1_set_aggregator_address_1.png)

![Transaction Builder](./images/7_b_1_set_aggregator_address_2.png)

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```

4. Paste the `AlignedLayerServiceManager` address on `Enter Address or ENS Name`

![Enter Address](./images/7_b_1_set_aggregator_address_3.png)

5. As this is a Proxy contract, choose `Use Implementation ABI`

![Use Implementation ABI](./images/7_b_1_set_aggregator_address_4.png)

6. In `contract method selector` choose `setAggregator()` and within `_alignedAggregator(address)` enter the ethereum new address of the aggregator.

![Choose set_aggregator](./images/7_b_1_set_aggregator_address_5.png)

7. Click on `+ Add new transaction`

You should see the new transaction to be executed

8. Click on `Create batch` to create the transaction.

![create batch](./images/7_b_1_set_aggregator_address_6.png)

9. Simulate the transaction by clicking on `Simulate`

10. If everything is correct, click on `Send batch` to send the transaction.

![Send batch](./images/7_b_1_set_aggregator_address_7.png)

11. Simulate the transaction, and if everything is correct, click on `Sign`.

![Send batch](./images/7_b_1_set_aggregator_address_8.png)

> [!NOTE]
> In the `call` field, you will see `fallback`.
12. Wait for the transaction to be executed. You can check the transaction status on the `Transactions` tab.

13. Verify the Aligned Aggreagtor Address has changed
```
cast call --rpc-url <RPC_URL> $ALIGNED_SERVICE_MANAGER_ADDRESS "alignedAggregator()(address)"
```

You should observe that the printed address matches the address in `AGGREGATOR_ADDRESS`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Approve the Set Aggregator Address Transaction

Once the transaction is proposed, the multisig owners must approve the transaction.

## Approve the new Address for the Aggregator

1. Go to [Safe](https://app.safe.global/home) and connect your wallet.

2. Go to the `Transactions` tab and find the transaction that was proposed.

3. Get the expected raw data by running by running:

```bash
cast calldata "setAggregator(address)()" <NEW_AGGREGATOR_ADDRESS>
```

4. Click on the transaction, and then click on ```Advanced Details```.

![Check details](images/7_b_2_set_aggregator_address_1.png)

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.

6. If the data is correct, click on the `Confirm` button.

7. Simulate the transaction. If everything is correct, click on the `Sign` button (or `Execute`, if you are the last one signing the transaction).

![Sign transaction](images/7_b_2_set_aggregator_address_2.png)

8. Once the transaction is executed, the change will be effective.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7a15d39

Please sign in to comment.