diff --git a/Makefile b/Makefile index 5e8ae04da1..a4ea6c8cb7 100644 --- a/Makefile +++ b/Makefile @@ -711,6 +711,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 --via-ir 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/script/upgrade/ProofAggregatorServiceUpgrader.s.sol b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol new file mode 100644 index 0000000000..389762e68a --- /dev/null +++ b/contracts/script/upgrade/ProofAggregatorServiceUpgrader.s.sol @@ -0,0 +1,28 @@ +// 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(); + + // Not link the new implementation to the proxy + // Because this must be executed in the multisig + + vm.stopBroadcast(); + + return (address(proofAggregationServiceProxy), address(newProofAggregatorServiceImplementation)); + } +} 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 422d972655..0000000000 --- a/contracts/scripts/proof_aggregator_service/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -RPC_URL= -PRIVATE_KEY= -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 12d78dce37..0000000000 --- a/contracts/scripts/proof_aggregator_service/deploy.sh +++ /dev/null @@ -1,22 +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 batcherConfigPath, string memory outputPath)" diff --git a/contracts/scripts/proof_aggregator_service/upgrade.sh b/contracts/scripts/proof_aggregator_service/upgrade.sh deleted file mode 100644 index e1d21d775f..0000000000 --- a/contracts/scripts/proof_aggregator_service/upgrade.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -# TODO diff --git a/contracts/scripts/upgrade_proof_aggregator.sh b/contracts/scripts/upgrade_proof_aggregator.sh new file mode 100644 index 0000000000..8d0c6dc638 --- /dev/null +++ b/contracts/scripts/upgrade_proof_aggregator.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# ENV VARIABLES +# +# MULTISIG=true|false whether the contract is deployed under a multisig account +# +# 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 +# + +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 ) + +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 \ + $PROOF_AGGREGATOR_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' $PROOF_AGGREGATOR_OUTPUT_PATH > "$PROOF_AGGREGATOR_OUTPUT_PATH.temp" + +# Replace the original file with the temporary file +mv "$PROOF_AGGREGATOR_OUTPUT_PATH.temp" $PROOF_AGGREGATOR_OUTPUT_PATH + +# Delete the temporary file +rm -f "$PROOF_AGGREGATOR_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