ethereum: Add scripts to verify/upgrade all contracts
This commit is contained in:
parent
860f91b2b8
commit
b5a8ba2361
|
@ -48,6 +48,15 @@ module.exports = {
|
|||
},
|
||||
network_id: "5",
|
||||
},
|
||||
ropsten_testnet: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
process.env.MNEMONIC,
|
||||
"https://rpc.ankr.com/eth_ropsten"
|
||||
);
|
||||
},
|
||||
network_id: "3",
|
||||
},
|
||||
bsc: {
|
||||
provider: () => {
|
||||
return new HDWalletProvider(
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
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="scripts/deploy_core_bridge.js"
|
||||
FILE="build/contracts/Implementation.json"
|
||||
verify_module="core"
|
||||
;;
|
||||
TokenBridge)
|
||||
SCRIPT="scripts/deploy_token_bridge.js"
|
||||
FILE="build/contracts/BridgeImplementation.json"
|
||||
verify_module="token_bridge"
|
||||
;;
|
||||
NFTBridge)
|
||||
SCRIPT="scripts/deploy_nft_bridge.js"
|
||||
FILE="build/contracts/NFTBridgeImplementation.json"
|
||||
verify_module="nft_bridge"
|
||||
;;
|
||||
*) echo "unknown module $module" >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
# TODO: add option to not compile (but compile by default)
|
||||
|
||||
truffle_network=""
|
||||
case "$network" in
|
||||
mainnet)
|
||||
truffle_network="$chain"
|
||||
;;
|
||||
testnet)
|
||||
truffle_network="$chain"_testnet
|
||||
esac
|
||||
|
||||
ret=0
|
||||
implementation=$(worm evm info -c "$chain" -m "$module" -n "$network" -i 2>/dev/null) || ret=$?
|
||||
|
||||
if [ $ret != 0 ]; then
|
||||
printf "☐ %s %s: skipping (no deployment available)\n" "$chain" "$module"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ret=0
|
||||
(./verify -n "$network" -c "$chain" $FILE "$implementation" > /dev/null) || ret=$?
|
||||
|
||||
if [ $ret = 0 ]; then
|
||||
printf "✔ %s %s: skipping (implementation matches same bytecode)\n" "$chain" "$module"
|
||||
exit
|
||||
fi
|
||||
|
||||
deploy_output=$(npx truffle exec $SCRIPT --network "$truffle_network") || ( echo "✘ $chain $module: $deploy_output" && exit 1 )
|
||||
new_implementation=$(echo "$deploy_output" | grep "address:" | cut -d' ' -f3)
|
||||
|
||||
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
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
set -uo pipefail
|
||||
|
||||
modules=(Core TokenBridge NFTBridge)
|
||||
network=testnet
|
||||
chains=$(worm evm chains)
|
||||
|
||||
|
||||
for module in ${modules[@]}; do
|
||||
for chain in ${chains[@]}; do
|
||||
./upgrade "$network" "$module" "$chain"
|
||||
done
|
||||
done
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
set -uo pipefail
|
||||
|
||||
function usage() {
|
||||
cat <<EOF >&2
|
||||
Usage:
|
||||
|
||||
$(basename "$0") [-h] [-n network] -- Verify that all deployed contracts match the local build artifact
|
||||
|
||||
where:
|
||||
-h show this help text
|
||||
-n set the network (mainnet, testnet, devnet)
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ! command -v worm &> /dev/null
|
||||
then
|
||||
echo "worm binary could not be found. See installation instructions in clients/js/README.md"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
network=""
|
||||
while getopts ':hn:' option; do
|
||||
case "$option" in
|
||||
h) usage
|
||||
;;
|
||||
n) network=$OPTARG
|
||||
;;
|
||||
:) printf "missing argument for -%s\n" "$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[ -z "$network" ] && usage
|
||||
|
||||
chains=$(worm evm chains)
|
||||
modules=(Core TokenBridge NFTBridge)
|
||||
|
||||
for module in ${modules[@]}; do
|
||||
for chain in ${chains[@]}; do
|
||||
FILE=""
|
||||
case "$module" in
|
||||
Core)
|
||||
FILE="build/contracts/Implementation.json"
|
||||
;;
|
||||
TokenBridge)
|
||||
FILE="build/contracts/BridgeImplementation.json"
|
||||
;;
|
||||
NFTBridge)
|
||||
FILE="build/contracts/NFTBridgeImplementation.json"
|
||||
;;
|
||||
*) echo "unknown module $module" >&2
|
||||
;;
|
||||
esac
|
||||
./verify -n $network -c "$chain" $FILE "$(worm evm info -c $chain -m $module -n $network -i)"
|
||||
done
|
||||
done
|
Loading…
Reference in New Issue