Skip to content

Commit 83576e3

Browse files
feat: proof aggregator upgrade scripts (#1888)
Co-authored-by: JuArce <[email protected]>
1 parent 42c7549 commit 83576e3

File tree

8 files changed

+104
-32
lines changed

8 files changed

+104
-32
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,10 @@ deploy_proof_aggregator:
711711
@echo "Deploying ProofAggregator contract on $(NETWORK) network..."
712712
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/deploy_proof_aggregator.sh
713713

714+
upgrade_proof_aggregator:
715+
@echo "Upgrading ProofAggregator Contract on $(NETWORK) network..."
716+
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/upgrade_proof_aggregator.sh
717+
714718
build_aligned_contracts:
715719
@cd contracts/src/core && forge build --via-ir
716720

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"addresses": {
33
"alignedProofAggregationService": "0x7Eace34A8d4C4CacE633946C6F7CF4BeF3F33513",
4-
"alignedProofAggregationServiceImplementation": "0xb12386C57ed3cfb31Ca358fB541dB46b14573fC7"
4+
"alignedProofAggregationServiceImplementation": "0x6454e81F80E9f45583F63cB1fCEbEc1cE3AB9559"
55
}
66
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.12;
3+
4+
import {AlignedProofAggregationService} from "../../src/core/AlignedProofAggregationService.sol";
5+
6+
import "forge-std/Script.sol";
7+
import "forge-std/StdJson.sol";
8+
9+
contract AlignedProofAggregationServiceUpgrader is Script {
10+
function run(string memory alignedLayerDeploymentFilePath) external returns (address, address) {
11+
string memory aligned_deployment_file = vm.readFile(alignedLayerDeploymentFilePath);
12+
13+
vm.startBroadcast();
14+
15+
AlignedProofAggregationService proofAggregationServiceProxy = AlignedProofAggregationService(
16+
payable(stdJson.readAddress(aligned_deployment_file, ".addresses.alignedProofAggregationService"))
17+
);
18+
19+
AlignedProofAggregationService newProofAggregatorServiceImplementation = new AlignedProofAggregationService();
20+
21+
// Not link the new implementation to the proxy
22+
// Because this must be executed in the multisig
23+
24+
vm.stopBroadcast();
25+
26+
return (address(proofAggregationServiceProxy), address(newProofAggregatorServiceImplementation));
27+
}
28+
}

contracts/scripts/deploy_proof_aggregator.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \
3535
--verify \
3636
--etherscan-api-key $ETHERSCAN_API_KEY \
3737
--slow \
38-
--sig "run(string configPath, string outputPath)"
38+
--sig "run(string configPath, string outputPath)" \
39+
--via-ir

contracts/scripts/proof_aggregator_service/.env.example

Lines changed: 0 additions & 5 deletions
This file was deleted.

contracts/scripts/proof_aggregator_service/deploy.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

contracts/scripts/proof_aggregator_service/upgrade.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
# ENV VARIABLES
4+
#
5+
# MULTISIG=true|false whether the contract is deployed under a multisig account
6+
#
7+
# PROOF_AGGREGATOR_OUTPUT_PATH: Path to the proof aggregator output file
8+
# - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json
9+
# - Holesky Prod: ./script/output/holesky/proof_aggregation_service_deployment_output.json
10+
#
11+
# RPC_URL: The RPC URL to connect to the Ethereum network
12+
#
13+
# PRIVATE_KEY: The private key to use for the deployment
14+
#
15+
# ETHERSCAN_API_KEY: The Etherscan API key to use for verification
16+
#
17+
18+
if [ -z "$MULTISIG" ]; then
19+
echo "Missing MULTISIG env variable"
20+
exit 1
21+
fi
22+
23+
# cd to the directory of this script so that this can be run from anywhere
24+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
25+
26+
cd "$parent_path"
27+
28+
cd ../
29+
30+
# Save the output to a variable to later extract the address of the new deployed contract
31+
forge_output=$(forge script script/upgrade/ProofAggregatorServiceUpgrader.s.sol \
32+
$PROOF_AGGREGATOR_OUTPUT_PATH \
33+
--rpc-url $RPC_URL \
34+
--private-key $PRIVATE_KEY \
35+
--broadcast \
36+
--verify \
37+
--etherscan-api-key $ETHERSCAN_API_KEY \
38+
--sig "run(string memory alignedLayerDeploymentFilePath)")
39+
40+
echo "$forge_output"
41+
42+
# Extract the proof aggregator service values from the output
43+
proof_aggregator_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}')
44+
proof_aggregator_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')
45+
46+
# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file
47+
jq --arg proof_aggregator_service_implementation "$proof_aggregator_service_implementation" '.addresses.alignedProofAggregationServiceImplementation = $proof_aggregator_service_implementation' $PROOF_AGGREGATOR_OUTPUT_PATH > "$PROOF_AGGREGATOR_OUTPUT_PATH.temp"
48+
49+
# Replace the original file with the temporary file
50+
mv "$PROOF_AGGREGATOR_OUTPUT_PATH.temp" $PROOF_AGGREGATOR_OUTPUT_PATH
51+
52+
# Delete the temporary file
53+
rm -f "$PROOF_AGGREGATOR_OUTPUT_PATH.temp"
54+
55+
echo "The new Proof Aggregator Service Implementation is $proof_aggregator_service_implementation"
56+
57+
data=$(cast calldata "upgradeTo(address)" $proof_aggregator_service_implementation)
58+
59+
echo "The new ProofAggregator Service Implementation is $proof_aggregator_service_implementation"
60+
61+
if [ "$MULTISIG" = false ]; then
62+
echo "Executing upgrade transaction"
63+
cast send $proof_aggregator_service_proxy $data \
64+
--rpc-url $RPC_URL \
65+
--private-key $PRIVATE_KEY
66+
else
67+
echo "You can propose the upgrade transaction with the multisig using this calldata"
68+
echo $data
69+
fi

0 commit comments

Comments
 (0)