|
|
@@ -1,6 +1,10 @@
|
|
|
#!/bin/bash
|
|
|
|
|
|
-#MNEMONIC= ./sh/upgrade.sh testnet Core blast
|
|
|
+# For testnet:
|
|
|
+#MNEMONIC= GUARDIAN_MNEMONIC= ./sh/upgrade.sh testnet Core blast
|
|
|
+
|
|
|
+# For mainnet:
|
|
|
+#MNEMONIC= ./sh/upgrade.sh mainnet Core blast
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
@@ -8,16 +12,25 @@ network=$1
|
|
|
module=$2
|
|
|
chain=$3
|
|
|
|
|
|
+secret=$MNEMONIC
|
|
|
+guardian_secret=""
|
|
|
+
|
|
|
+if [ "$network" = testnet ]; then
|
|
|
+ guardian_secret=$GUARDIAN_MNEMONIC
|
|
|
+fi
|
|
|
+
|
|
|
SCRIPT=""
|
|
|
verify_module=""
|
|
|
case "$module" in
|
|
|
Core)
|
|
|
SCRIPT="DeployCoreImplementationOnly.s.sol:DeployCoreImplementationOnly"
|
|
|
+ SOLFILE="DeployCoreImplementationOnly.s.sol"
|
|
|
FILE="build-forge/Implementation.sol/Implementation.json"
|
|
|
verify_module="core"
|
|
|
;;
|
|
|
TokenBridge)
|
|
|
SCRIPT="DeployTokenBridgeImplementationOnly.s.sol:DeployTokenBridgeImplementationOnly"
|
|
|
+ SOLFILE="DeployTokenBridgeImplementationOnly.s.sol"
|
|
|
FILE="build-forge/BridgeImplementation.sol/BridgeImplementation.json"
|
|
|
verify_module="token_bridge"
|
|
|
;;
|
|
|
@@ -33,6 +46,8 @@ esac
|
|
|
ENV_FILE="env/.env.${chain}"
|
|
|
if [ "$network" = testnet ]; then
|
|
|
ENV_FILE="${ENV_FILE}.testnet"
|
|
|
+else
|
|
|
+ ENV_FILE="${ENV_FILE}.mainnet"
|
|
|
fi
|
|
|
|
|
|
if ! [ -f ./$ENV_FILE ]; then
|
|
|
@@ -42,6 +57,8 @@ fi
|
|
|
|
|
|
. ./$ENV_FILE
|
|
|
|
|
|
+exit 1
|
|
|
+
|
|
|
[[ -z $INIT_EVM_CHAIN_ID ]] && { echo "Missing INIT_EVM_CHAIN_ID"; exit 1; }
|
|
|
[[ -z $MNEMONIC ]] && { echo "Missing MNEMONIC"; exit 1; }
|
|
|
|
|
|
@@ -54,6 +71,10 @@ if [ -z ${RPC_URL+x} ]; then
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
+if [ -z ${FORGE_ARGS+x} ]; then
|
|
|
+ FORGE_ARGS=""
|
|
|
+fi
|
|
|
+
|
|
|
ret=0
|
|
|
implementation=$(worm evm info -c "$chain" -m "$module" -n "$network" -i 2>/dev/null) || ret=$?
|
|
|
|
|
|
@@ -70,13 +91,27 @@ if [ $ret = 0 ]; then
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
-echo "Implementation: ${implementation}"
|
|
|
-echo "ret: ${ret}"
|
|
|
-
|
|
|
-exit 0
|
|
|
-
|
|
|
-
|
|
|
forge script ./forge-scripts/${SCRIPT} \
|
|
|
--rpc-url "$RPC_URL" \
|
|
|
--private-key "$MNEMONIC" \
|
|
|
- --broadcast --slow
|
|
|
+ --broadcast ${FORGE_ARGS}
|
|
|
+
|
|
|
+returnInfo=$(cat ./broadcast/${SOLFILE}/$INIT_EVM_CHAIN_ID/run-latest.json)
|
|
|
+# Extract the address values from 'returnInfo'
|
|
|
+new_implementation=$(jq -r '.returns.deployedAddress.value' <<< "$returnInfo")
|
|
|
+
|
|
|
+ret=0
|
|
|
+(./verify -n "$network" -c "$chain" $FILE "$new_implementation" > /dev/null) || ret=$?
|
|
|
+
|
|
|
+if [ $ret = 0 ]; then
|
|
|
+ printf "✔ %s %s: deployed (%s)\n" "$chain" "$module" "$new_implementation"
|
|
|
+else
|
|
|
+ printf "✘ %s %s: deployed (%s) but failed to match bytecode\n" "$chain" "$module" "$new_implementation"
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+if [ "$network" = testnet ]; then
|
|
|
+ worm submit $(worm generate upgrade -c "$chain" -a "$new_implementation" -m "$module" -g "$guardian_secret") -n "$network"
|
|
|
+else
|
|
|
+ echo "../scripts/contract-upgrade-governance.sh -c $chain -m $verify_module -a $new_implementation"
|
|
|
+fi
|