From 64718f8a6b5fca3c63e76820fda58d1fcca972f9 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 23 Apr 2025 11:00:47 -0300 Subject: [PATCH 1/7] feat: upgrade sol script for proof aggregator service --- .../ProofAggregatorServiceUpgrader.s.sol | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol diff --git a/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol new file mode 100644 index 0000000000..db5bdaaaed --- /dev/null +++ b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.12; + +import {AlignedProofAggregationService} from "../../src/core/AlignedProofAggregationService.sol"; + +import "forge-std/Script.sol"; +import "forge-std/StdJson.sol"; + +contract AlignedProofAggregationServiceUpgrader is Script { + function run(string memory alignedLayerDeploymentFilePath) external returns (address, address) { + string memory aligned_deployment_file = vm.readFile(alignedLayerDeploymentFilePath); + + vm.startBroadcast(); + + AlignedProofAggregationService proofAggregationServiceProxy = AlignedProofAggregationService( + payable(stdJson.readAddress(aligned_deployment_file, ".addresses.alignedProofAggregationService")) + ); + + AlignedProofAggregationService newProofAggregatorServiceImplementation = new AlignedProofAggregationService(); + + vm.stopBroadcast(); + + vm.startBroadcast(); + proofAggregationServiceProxy.upgradeToAndCall(address(newProofAggregatorServiceImplementation), ""); + vm.stopBroadcast(); + + return (address(proofAggregationServiceProxy), address(newProofAggregatorServiceImplementation)); + } +} From 2b51f250cdf01eb25302dba8788730800d87904f Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 23 Apr 2025 11:01:10 -0300 Subject: [PATCH 2/7] feat: deploy.sh script for proog agg service + --via-ir flag --- .../proof_aggregator_service/deploy.sh | 3 +- .../proof_aggregator_service/upgrade.sh | 37 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/contracts/scripts/proof_aggregator_service/deploy.sh b/contracts/scripts/proof_aggregator_service/deploy.sh index 12d78dce37..1c603d6091 100644 --- a/contracts/scripts/proof_aggregator_service/deploy.sh +++ b/contracts/scripts/proof_aggregator_service/deploy.sh @@ -19,4 +19,5 @@ forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \ --broadcast \ --verify \ --etherscan-api-key $ETHERSCAN_API_KEY \ - --sig "run(string memory batcherConfigPath, string memory outputPath)" + --sig "run(string memory configPath, string memory outputPath)" \ + --via-ir diff --git a/contracts/scripts/proof_aggregator_service/upgrade.sh b/contracts/scripts/proof_aggregator_service/upgrade.sh index e1d21d775f..d849184a7b 100644 --- a/contracts/scripts/proof_aggregator_service/upgrade.sh +++ b/contracts/scripts/proof_aggregator_service/upgrade.sh @@ -1,3 +1,38 @@ #!/bin/bash -# TODO +# cd to the directory of this script so that this can be run from anywhere +parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) + +cd "$parent_path" + +cd ../ + +# Save the output to a variable to later extract the address of the new deployed contract +forge_output=$(forge script script/upgrade/ProofAggregatorServiceUpgrader.s.sol \ + $EXISTING_DEPLOYMENT_INFO_PATH \ + $OUTPUT_PATH \ + --rpc-url $RPC_URL \ + --private-key $PRIVATE_KEY \ + --broadcast \ + --verify \ + --etherscan-api-key $ETHERSCAN_API_KEY \ + --sig "run(string memory alignedLayerDeploymentFilePath)") + +echo "$forge_output" + +# Extract the proof aggregator service values from the output +proof_aggregator_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}') +proof_aggregator_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}') + +# Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file +jq --arg proof_aggregator_service_implementation "$proof_aggregator_service_implementation" '.addresses.alignedProofAggregationServiceImplementation = $proof_aggregator_service_implementation' $OUTPUT_PATH > "$OUTPUT_PATH.temp" + +# Replace the original file with the temporary file +mv "$OUTPUT_PATH.temp" $OUTPUT_PATH + +# Delete the temporary file +rm -f "$OUTPUT_PATH.temp" + +data=$(cast calldata "upgradeTo(address)" $batcher_payment_service_implementation) + +echo "The new Proof Aggregator Service Implementation is $batcher_payment_service_implementation" From 2ce128fda7e88a3b342c78158004540f468f0652 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 23 Apr 2025 12:51:04 -0300 Subject: [PATCH 3/7] fix: .env missing variable and update names --- .../scripts/proof_aggregator_service/.env.example | 1 + .../scripts/proof_aggregator_service/upgrade.sh | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/contracts/scripts/proof_aggregator_service/.env.example b/contracts/scripts/proof_aggregator_service/.env.example index 422d972655..10df252f8b 100644 --- a/contracts/scripts/proof_aggregator_service/.env.example +++ b/contracts/scripts/proof_aggregator_service/.env.example @@ -1,5 +1,6 @@ RPC_URL= PRIVATE_KEY= +EXISTING_DEPLOYMENT_INFO_PATH=./script/output//proof_aggregation_service_deployment_output.json PROOF_AGGREGATION_SERVICE_CONFIG_PATH=./script/deploy/config//.holesky.config.json PROOF_AGGREGATION_SERVICE_OUTPUT_PATH=./script/output//proof-aggregator-service..config.json ETHERSCAN_API_KEY= diff --git a/contracts/scripts/proof_aggregator_service/upgrade.sh b/contracts/scripts/proof_aggregator_service/upgrade.sh index d849184a7b..1cc7ec6652 100644 --- a/contracts/scripts/proof_aggregator_service/upgrade.sh +++ b/contracts/scripts/proof_aggregator_service/upgrade.sh @@ -10,7 +10,7 @@ cd ../ # Save the output to a variable to later extract the address of the new deployed contract forge_output=$(forge script script/upgrade/ProofAggregatorServiceUpgrader.s.sol \ $EXISTING_DEPLOYMENT_INFO_PATH \ - $OUTPUT_PATH \ + $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH \ --rpc-url $RPC_URL \ --private-key $PRIVATE_KEY \ --broadcast \ @@ -25,14 +25,12 @@ proof_aggregator_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print proof_aggregator_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}') # Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file -jq --arg proof_aggregator_service_implementation "$proof_aggregator_service_implementation" '.addresses.alignedProofAggregationServiceImplementation = $proof_aggregator_service_implementation' $OUTPUT_PATH > "$OUTPUT_PATH.temp" +jq --arg proof_aggregator_service_implementation "$proof_aggregator_service_implementation" '.addresses.alignedProofAggregationServiceImplementation = $proof_aggregator_service_implementation' $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH > "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" # Replace the original file with the temporary file -mv "$OUTPUT_PATH.temp" $OUTPUT_PATH +mv "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH # Delete the temporary file -rm -f "$OUTPUT_PATH.temp" +rm -f "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" -data=$(cast calldata "upgradeTo(address)" $batcher_payment_service_implementation) - -echo "The new Proof Aggregator Service Implementation is $batcher_payment_service_implementation" +echo "The new Proof Aggregator Service Implementation is $proof_aggregator_service_implementation" From fe5350fa5a23bd524eb3afa0787c77444113f579 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 23 Apr 2025 18:35:34 -0300 Subject: [PATCH 4/7] chore: move upgrade files to root this is so we can reuse the existing .env files --- contracts/scripts/deploy_proof_aggregator.sh | 3 ++- .../proof_aggregator_service/.env.example | 6 ----- .../proof_aggregator_service/deploy.sh | 23 ------------------- ...upgrade.sh => upgrade_proof_aggregator.sh} | 17 ++++++++++++++ 4 files changed, 19 insertions(+), 30 deletions(-) delete mode 100644 contracts/scripts/proof_aggregator_service/.env.example delete mode 100644 contracts/scripts/proof_aggregator_service/deploy.sh rename contracts/scripts/{proof_aggregator_service/upgrade.sh => upgrade_proof_aggregator.sh} (68%) diff --git a/contracts/scripts/deploy_proof_aggregator.sh b/contracts/scripts/deploy_proof_aggregator.sh index aa9e9b1e70..8bc0107b44 100644 --- a/contracts/scripts/deploy_proof_aggregator.sh +++ b/contracts/scripts/deploy_proof_aggregator.sh @@ -35,4 +35,5 @@ forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \ --verify \ --etherscan-api-key $ETHERSCAN_API_KEY \ --slow \ - --sig "run(string configPath, string outputPath)" + --sig "run(string configPath, string outputPath)" \ + --via-ir diff --git a/contracts/scripts/proof_aggregator_service/.env.example b/contracts/scripts/proof_aggregator_service/.env.example deleted file mode 100644 index 10df252f8b..0000000000 --- a/contracts/scripts/proof_aggregator_service/.env.example +++ /dev/null @@ -1,6 +0,0 @@ -RPC_URL= -PRIVATE_KEY= -EXISTING_DEPLOYMENT_INFO_PATH=./script/output//proof_aggregation_service_deployment_output.json -PROOF_AGGREGATION_SERVICE_CONFIG_PATH=./script/deploy/config//.holesky.config.json -PROOF_AGGREGATION_SERVICE_OUTPUT_PATH=./script/output//proof-aggregator-service..config.json -ETHERSCAN_API_KEY= diff --git a/contracts/scripts/proof_aggregator_service/deploy.sh b/contracts/scripts/proof_aggregator_service/deploy.sh deleted file mode 100644 index 1c603d6091..0000000000 --- a/contracts/scripts/proof_aggregator_service/deploy.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 ../ - -source scripts/.env - -# Deploy Proof Aggregation Service Contract -forge script script/deploy/AlignedProofAggregationServiceDeployer.s.sol \ - $PROOF_AGGREGATION_SERVICE_CONFIG_PATH \ - $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH \ - --rpc-url $RPC_URL \ - --private-key $PRIVATE_KEY \ - --broadcast \ - --verify \ - --etherscan-api-key $ETHERSCAN_API_KEY \ - --sig "run(string memory configPath, string memory outputPath)" \ - --via-ir diff --git a/contracts/scripts/proof_aggregator_service/upgrade.sh b/contracts/scripts/upgrade_proof_aggregator.sh similarity index 68% rename from contracts/scripts/proof_aggregator_service/upgrade.sh rename to contracts/scripts/upgrade_proof_aggregator.sh index 1cc7ec6652..f63b1530b1 100644 --- a/contracts/scripts/proof_aggregator_service/upgrade.sh +++ b/contracts/scripts/upgrade_proof_aggregator.sh @@ -1,5 +1,22 @@ #!/bin/bash +# ENV VARIABLES +# +# EXISTING_DEPLOYMENT_INFO_PATH: Path to the proof aggregator deployment output file +# - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json +# - Holesky Prod: ./script/output/holesky/roof_aggregation_service_deployment_output.json +# +# PROOF_AGGREGATOR_OUTPUT_PATH: Path to the proof aggregator output file +# - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json +# - Holesky Prod: ./script/output/holesky/proof_aggregation_service_deployment_output.json +# +# RPC_URL: The RPC URL to connect to the Ethereum network +# +# PRIVATE_KEY: The private key to use for the deployment +# +# ETHERSCAN_API_KEY: The Etherscan API key to use for verification +# + # cd to the directory of this script so that this can be run from anywhere parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) From 1683f233e8efed40d77db67e8038b7ec20482683 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Wed, 23 Apr 2025 18:39:39 -0300 Subject: [PATCH 5/7] feat: proof aggregator service contract upgrade multisg compliant --- .../ProofAggregatorServiceUpgrader.s.sol | 5 ++--- contracts/scripts/upgrade_proof_aggregator.sh | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol index db5bdaaaed..389762e68a 100644 --- a/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol +++ b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol @@ -18,10 +18,9 @@ contract AlignedProofAggregationServiceUpgrader is Script { AlignedProofAggregationService newProofAggregatorServiceImplementation = new AlignedProofAggregationService(); - vm.stopBroadcast(); + // Not link the new implementation to the proxy + // Because this must be executed in the multisig - vm.startBroadcast(); - proofAggregationServiceProxy.upgradeToAndCall(address(newProofAggregatorServiceImplementation), ""); vm.stopBroadcast(); return (address(proofAggregationServiceProxy), address(newProofAggregatorServiceImplementation)); diff --git a/contracts/scripts/upgrade_proof_aggregator.sh b/contracts/scripts/upgrade_proof_aggregator.sh index f63b1530b1..fdfe3d192f 100644 --- a/contracts/scripts/upgrade_proof_aggregator.sh +++ b/contracts/scripts/upgrade_proof_aggregator.sh @@ -2,6 +2,8 @@ # ENV VARIABLES # +# MULTISIG=true|false whether the contract is deployed under a multisig account +# # EXISTING_DEPLOYMENT_INFO_PATH: Path to the proof aggregator deployment output file # - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json # - Holesky Prod: ./script/output/holesky/roof_aggregation_service_deployment_output.json @@ -17,6 +19,11 @@ # ETHERSCAN_API_KEY: The Etherscan API key to use for verification # +if [ -z "$MULTISIG" ]; then + echo "Missing MULTISIG env variable" + exit 1 +fi + # cd to the directory of this script so that this can be run from anywhere parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) @@ -51,3 +58,17 @@ mv "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" $PROOF_AGGREGATION_SERVICE_OUTP rm -f "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" echo "The new Proof Aggregator Service Implementation is $proof_aggregator_service_implementation" + +data=$(cast calldata "upgradeTo(address)" $proof_aggregator_service_implementation) + +echo "The new ProofAggregator Service Implementation is $proof_aggregator_service_implementation" + +if [ "$MULTISIG" = false ]; then + echo "Executing upgrade transaction" + cast send $proof_aggregator_service_proxy $data \ + --rpc-url $RPC_URL \ + --private-key $PRIVATE_KEY +else + echo "You can propose the upgrade transaction with the multisig using this calldata" + echo $data +fi From d8a5d24cdcf8c52bdf6bd69fc7a698533807aaea Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Thu, 24 Apr 2025 15:51:37 -0300 Subject: [PATCH 6/7] chore: add proof aggregator upgrade target --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 05383fe6b8..48d809e777 100644 --- a/Makefile +++ b/Makefile @@ -698,6 +698,10 @@ deploy_proof_aggregator: @echo "Deploying ProofAggregator contract on $(NETWORK) network..." @. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/deploy_proof_aggregator.sh +upgrade_proof_aggregator: + @echo "Upgrading ProofAggregator Contract on $(NETWORK) network..." + @. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/upgrade_proof_aggregator.sh + build_aligned_contracts: @cd contracts/src/core && forge build From 33ff32a701be25e82202931083caa6dda1ddb2da Mon Sep 17 00:00:00 2001 From: JuArce <52429267+JuArce@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:53:58 -0300 Subject: [PATCH 7/7] fix: file name --- ...aggregation_service_deployment_output.stage.json | 2 +- contracts/scripts/upgrade_proof_aggregator.sh | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/contracts/script/output/holesky/proof_aggregation_service_deployment_output.stage.json b/contracts/script/output/holesky/proof_aggregation_service_deployment_output.stage.json index 1b424ace8d..f89ebf66de 100644 --- a/contracts/script/output/holesky/proof_aggregation_service_deployment_output.stage.json +++ b/contracts/script/output/holesky/proof_aggregation_service_deployment_output.stage.json @@ -1,6 +1,6 @@ { "addresses": { "alignedProofAggregationService": "0x7Eace34A8d4C4CacE633946C6F7CF4BeF3F33513", - "alignedProofAggregationServiceImplementation": "0xb12386C57ed3cfb31Ca358fB541dB46b14573fC7" + "alignedProofAggregationServiceImplementation": "0x6454e81F80E9f45583F63cB1fCEbEc1cE3AB9559" } } diff --git a/contracts/scripts/upgrade_proof_aggregator.sh b/contracts/scripts/upgrade_proof_aggregator.sh index fdfe3d192f..8d0c6dc638 100644 --- a/contracts/scripts/upgrade_proof_aggregator.sh +++ b/contracts/scripts/upgrade_proof_aggregator.sh @@ -4,10 +4,6 @@ # # MULTISIG=true|false whether the contract is deployed under a multisig account # -# EXISTING_DEPLOYMENT_INFO_PATH: Path to the proof aggregator deployment output file -# - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json -# - Holesky Prod: ./script/output/holesky/roof_aggregation_service_deployment_output.json -# # PROOF_AGGREGATOR_OUTPUT_PATH: Path to the proof aggregator output file # - Holesky Stage: ./script/output/holesky/proof_aggregation_service_deployment_output.stage.json # - Holesky Prod: ./script/output/holesky/proof_aggregation_service_deployment_output.json @@ -33,8 +29,7 @@ cd ../ # Save the output to a variable to later extract the address of the new deployed contract forge_output=$(forge script script/upgrade/ProofAggregatorServiceUpgrader.s.sol \ - $EXISTING_DEPLOYMENT_INFO_PATH \ - $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH \ + $PROOF_AGGREGATOR_OUTPUT_PATH \ --rpc-url $RPC_URL \ --private-key $PRIVATE_KEY \ --broadcast \ @@ -49,13 +44,13 @@ proof_aggregator_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print proof_aggregator_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}') # Use the extracted value to replace the batcher payment service values in alignedlayer_deployment_output.json and save it to a temporary file -jq --arg proof_aggregator_service_implementation "$proof_aggregator_service_implementation" '.addresses.alignedProofAggregationServiceImplementation = $proof_aggregator_service_implementation' $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH > "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" +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" # Replace the original file with the temporary file -mv "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" $PROOF_AGGREGATION_SERVICE_OUTPUT_PATH +mv "$PROOF_AGGREGATOR_OUTPUT_PATH.temp" $PROOF_AGGREGATOR_OUTPUT_PATH # Delete the temporary file -rm -f "$PROOF_AGGREGATION_SERVICE_OUTPUT_PATH.temp" +rm -f "$PROOF_AGGREGATOR_OUTPUT_PATH.temp" echo "The new Proof Aggregator Service Implementation is $proof_aggregator_service_implementation"