浏览代码

Eth: Upgrade scripts (#3921)

* Eth: Upgrade scripts

* Code review rework
bruce-riley 1 年之前
父节点
当前提交
557fc921d8

+ 3 - 0
ethereum/env/.env.acala.testnet

@@ -1,6 +1,9 @@
 # Acala testnet env
 # Rename to .env to use with truffle migrations
 
+# Gas price generated with ./sh/acala-gas-prices.sh
+FORGE_ARGS="--legacy --with-gas-price 213314634730"
+
 # Wormhole Core Migrations
 INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
 INIT_CHAIN_ID=0xc

+ 0 - 0
ethereum/env/.env.arbitrum.sepolia.testnet → ethereum/env/.env.arbitrum_sepolia.testnet


+ 15 - 0
ethereum/env/.env.avalanche.mainnet

@@ -0,0 +1,15 @@
+# Avalanche mainnet env
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"]
+INIT_CHAIN_ID=6
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=43114
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=6
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7
+BRIDGE_INIT_FINALITY=1

+ 19 - 0
ethereum/env/.env.avalanche.testnet

@@ -0,0 +1,19 @@
+# Avalanche testnet env
+# Rename to .env to use with forge deployment
+
+# Common config for forge deployment
+RPC_URL=https://api.avax-test.network/ext/bc/C/rpc
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
+INIT_CHAIN_ID=6
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=43113
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=6
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0xd00ae08403B9bbb9124bB305C09058E32C39A48c
+BRIDGE_INIT_FINALITY=1

+ 0 - 0
ethereum/env/.env.base.sepolia.testnet → ethereum/env/.env.base_sepolia.testnet


+ 15 - 0
ethereum/env/.env.bsc.mainnet

@@ -0,0 +1,15 @@
+# BSC mainnet env
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"]
+INIT_CHAIN_ID=4
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=56
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=4
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
+BRIDGE_INIT_FINALITY=1

+ 19 - 0
ethereum/env/.env.bsc.testnet

@@ -0,0 +1,19 @@
+# BSC testnet env
+# Rename to .env to use with forge deployment
+
+# Common config for forge deployment
+RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545/
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
+INIT_CHAIN_ID=4
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=97
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=4
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd
+BRIDGE_INIT_FINALITY=1

+ 15 - 0
ethereum/env/.env.ethereum.mainnet

@@ -0,0 +1,15 @@
+# Ethereum mainnet env
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"]
+INIT_CHAIN_ID=2
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=1
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=2
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
+BRIDGE_INIT_FINALITY=1

+ 5 - 2
ethereum/env/.env.fantom.testnet

@@ -1,5 +1,8 @@
-# Fantom testnet env
-# Rename to .env to use with truffle migrations
+# Fantom testnet env. To use for forge deployment, do:
+# ethereum$ ln -s env/.env.fantom.testnet .env
+
+# Common config for forge deployment
+RPC_URL=https://rpc.testnet.fantom.network/
 
 # Wormhole Core Migrations
 INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]

+ 6 - 2
ethereum/env/.env.karura.testnet

@@ -1,6 +1,10 @@
-# Karura testnet env
-# Rename to .env to use with truffle migrations
+# Karura testnet env. To use for forge deployment, do:
+# ethereum$ ln -s env/.env.karura.testnet .env
 
+# Gas price generated with ./sh/karura-gas-prices.sh
+RPC_URL=https://eth-rpc-karura.aca-api.network/
+FORGE_ARGS="--legacy --with-gas-price 214844572650"
+                 
 # Wormhole Core Migrations
 INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
 INIT_CHAIN_ID=0xb

+ 15 - 0
ethereum/env/.env.oasis.mainnet

@@ -0,0 +1,15 @@
+# Oasis mainnet env
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"]
+INIT_CHAIN_ID=7
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=42262
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=7
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0x21C718C22D52d0F3a789b752D4c2fD5908a8A733
+BRIDGE_INIT_FINALITY=1

+ 20 - 0
ethereum/env/.env.oasis.testnet

@@ -0,0 +1,20 @@
+# Oasis testnet env. To use for forge deployment, do:
+# ethereum$ ln -s env/.env.oasis.testnet .env
+
+# Common config for forge deployment
+RPC_URL=https://testnet.emerald.oasis.dev
+FORGE_ARGS="--slow --priority-gas-price 0 --gas-estimate-multiplier 130"
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
+INIT_CHAIN_ID=7
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=42261
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=7
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0x792296e2a15e6Ceb5f5039DecaE7A1f25b00B0B0
+BRIDGE_INIT_FINALITY=1

+ 2 - 0
ethereum/env/.env.optimism.sepolia.testnet → ethereum/env/.env.optimism_sepolia.testnet

@@ -1,6 +1,8 @@
 # Optimism on Sepolia testnet
 # Rename to .env to use with truffle migrations
 
+RPC_URL=https://sepolia.optimism.io
+
 # Wormhole Core Migrations
 INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
 INIT_CHAIN_ID=10005

+ 15 - 0
ethereum/env/.env.polygon.mainnet

@@ -0,0 +1,15 @@
+# Polygon mainnet env
+
+# Wormhole Core Migrations
+INIT_SIGNERS=["0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5"]
+INIT_CHAIN_ID=5
+INIT_GOV_CHAIN_ID=0x1
+INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+INIT_EVM_CHAIN_ID=137
+
+# Bridge Migrations
+BRIDGE_INIT_CHAIN_ID=5
+BRIDGE_INIT_GOV_CHAIN_ID=0x1
+BRIDGE_INIT_GOV_CONTRACT=0x0000000000000000000000000000000000000000000000000000000000000004
+BRIDGE_INIT_WETH=0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270
+BRIDGE_INIT_FINALITY=1

+ 0 - 0
ethereum/env/.env.polygon.sepolia → ethereum/env/.env.polygon_sepolia.testnet


+ 2 - 0
ethereum/env/.env.sepolia.testnet

@@ -1,6 +1,8 @@
 # Sepolia testnet read only env
 # Rename to .env to use with truffle migrations
 
+FORGE_ARGS="--gas-estimate-multiplier 200"
+
 # Wormhole Core Migrations
 INIT_SIGNERS=["0x13947Bd48b18E53fdAeEe77F3473391aC727C638"]
 INIT_CHAIN_ID=10002

+ 0 - 0
ethereum/acala-gas-prices → ethereum/sh/acala-gas-prices.sh


+ 0 - 0
ethereum/karura-gas-prices → ethereum/sh/karura-gas-prices.sh


+ 43 - 8
ethereum/sh/upgrade.sh

@@ -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

+ 28 - 0
ethereum/sh/upgrade_all_testnet.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Upgrade Core, TokenBridge and NFTBridge contracts on all chains:
+#MNEMONIC= GUARDIAN_MNEMONIC= ./sh/upgrade_all_testnet.sh
+
+# Upgrade TokenBridge on a few chains chains:
+#MNEMONIC= GUARDIAN_MNEMONIC= CHAINS="avalanche polygon oasis" MODULES=TokenBridge ./sh/upgrade_all_testnet.sh
+
+# Upgrade Core and TokenBridge contracts on all chains:
+#MNEMONIC= GUARDIAN_MNEMONIC= MODULES="Core TokenBridge" ./sh/upgrade_all_testnet.sh
+
+if [ "${CHAINS}X" == "X" ]; then
+  CHAINS=$(worm evm chains)
+fi
+
+if [ "${MODULES}X" == "X" ]; then
+  MODULES=(Core TokenBridge NFTBridge)
+fi
+
+set -uo pipefail
+network=testnet
+
+for module in ${MODULES[@]}; do
+  for chain in ${chains[@]}; do
+    echo "Upgrading ${chain} ${module} ********************************************************************"
+    ./sh/upgrade.sh "$network" "$module" "$chain"
+  done
+done