Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ anvil_upgrade_batcher_payment_service: ## Upgrade BatcherPaymentService contract
@echo "Upgrading BatcherPayments contract..."
. contracts/scripts/anvil/upgrade_batcher_payment_service.sh

anvil_upgrade_aggregation_mode_payment_service: ## Upgrade AggregationModePaymentService contract on ANVIL
@echo "Upgrading AggregationModePaymentService contract..."
. contracts/scripts/anvil/upgrade_aggregation_mode_payment_service.sh

anvil_upgrade_registry_coordinator: ## Upgrade Registry Coordinator Contracts on ANVIL
@echo "Upgrading Registry Coordinator Contracts..."
. contracts/scripts/anvil/upgrade_registry_coordinator.sh
Expand Down Expand Up @@ -993,6 +997,10 @@ upgrade_proof_aggregator: ## Upgrade ProofAggregator contract. Parameters: NETWO
@echo "Upgrading ProofAggregator Contract on $(NETWORK) network..."
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/upgrade_proof_aggregator.sh

upgrade_aggregation_mode_payment_service: ## Upgrade AggregationModePaymentService. Parameters: NETWORK=<mainnet|holesky|sepolia>
@echo "Upgrading AggregationModePaymentService Contract on $(NETWORK) network..."
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/upgrade_aggregation_mode_payment_service.sh

deploy_agg_mode_payment_service:
@echo "Deploying Agg Mode Payment Service contract on $(NETWORK) network..."
@. contracts/scripts/.env.$(NETWORK) && . contracts/scripts/deploy_agg_mode_payment_service.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.12;

import {AggregationModePaymentService} from "../../src/core/AggregationModePaymentService.sol";

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";

contract AggregationModePaymentServiceUpgrader is Script {
function run(
string memory alignedLayerDeploymentFilePath
) external returns (address, address) {
string memory aligned_deployment_file = vm.readFile(
alignedLayerDeploymentFilePath
);

vm.startBroadcast();

AggregationModePaymentService aggregationModePaymentServiceProxy =
AggregationModePaymentService(payable(
stdJson.readAddress(
aligned_deployment_file,
".addresses.aggregationModePaymentService"
)
));

AggregationModePaymentService newAggregationModePaymentServiceImplementation =
new AggregationModePaymentService();

// Not link the new implementation to the proxy
// Because this must be executed in the multisig

vm.stopBroadcast();

return (
address(aggregationModePaymentServiceProxy),
address(newAggregationModePaymentServiceImplementation)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/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 )

cd "$parent_path"

cd ../../

jq 'del(.block)' scripts/anvil/state/alignedlayer-deployed-anvil-state.json > scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json

cp -f scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json scripts/anvil/state/alignedlayer-deployed-anvil-state.json

rm scripts/anvil/state/alignedlayer-deployed-anvil-state-tmp.json

anvil --load-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json --dump-state scripts/anvil/state/alignedlayer-deployed-anvil-state.json &

sleep 2

# Deploy new Aggregation Mode Payment Service implementation, but don't upgrade yet
forge_output=$(forge script script/upgrade/AggregationModePaymentServiceUpgrader.s.sol \
"./script/output/devnet/proof_aggregation_service_deployment_output.json" \
--rpc-url "http://localhost:8545" \
--private-key "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356" \
--broadcast \
--legacy \
--verify \
--sig "run(string memory alignedLayerDeploymentFilePath)")

echo "$forge_output"

# Extract the aggregation mode payment service values from the output
aggregation_mode_payment_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}')
aggregation_mode_payment_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')

data=$(cast calldata "upgradeToAndCall(address, bytes)" $aggregation_mode_payment_service_implementation "0x")

MULTISIG=false # hardcoding non-multisig for devnet
if [ "$MULTISIG" = false ]; then
echo "Executing upgrade transaction"
cast send $aggregation_mode_payment_service_proxy $data \
--rpc-url "http://localhost:8545" \
--private-key "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
else
echo "You can propose the upgrade transaction with the multisig using this calldata"
echo $data
fi

pkill anvil

# Use the extracted value to replace the aggregation mode payment service values and save it to a temporary file
jq --arg aggregation_mode_payment_service_implementation "$aggregation_mode_payment_service_implementation" \
'.addresses.aggregationModePaymentServiceImplementation = $aggregation_mode_payment_service_implementation' \
"./script/output/devnet/proof_aggregation_service_deployment_output.json" > \
"./script/output/devnet/proof_aggregation_service_deployment_output.temp.json"

# Replace the original file with the temporary file
mv "./script/output/devnet/proof_aggregation_service_deployment_output.temp.json" \
"./script/output/devnet/proof_aggregation_service_deployment_output.json"

# Delete the temporary file
rm -f "./script/output/devnet/proof_aggregation_service_deployment_output.temp.json"
69 changes: 69 additions & 0 deletions contracts/scripts/upgrade_aggregation_mode_payment_service.sh
Original file line number Diff line number Diff line change
@@ -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/AggregationModePaymentServiceUpgrader.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 aggregation mode payment service values from the output
aggregation_mode_payment_service_proxy=$(echo "$forge_output" | awk '/0: address/ {print $3}')
aggregation_mode_payment_service_implementation=$(echo "$forge_output" | awk '/1: address/ {print $3}')

# Use the extracted value to replace the aggregation mode payment service values and save it to a temporary file
jq --arg aggregation_mode_payment_service_implementation "$aggregation_mode_payment_service_implementation" \
'.addresses.aggregationModePaymentServiceImplementation = $aggregation_mode_payment_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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file was deleted during the move step.


echo "The new Aggregation Mode Payment Service Implementation is $aggregation_mode_payment_service_implementation"

data=$(cast calldata "upgradeTo(address)" $aggregation_mode_payment_service_implementation)

if [ "$MULTISIG" = false ]; then
echo "Executing upgrade transaction"
cast send $aggregation_mode_payment_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
Loading