Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eth: Make registerAllChainsOnTokenBridge not require worm support #4083

Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ethereum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ethereum$ MNEMONIC= ./sh/upgrade.sh testnet TokenBridge blast
#### Registering Other Chains on a New TokenBridge

```shell
ethereum$ MNEMONIC= ./sh/registerAllChainsOnTokenBridge.sh.sh testnet blast
ethereum$ MNEMONIC= ./sh/registerAllChainsOnTokenBridge.sh <network> <chainName> <tokenBridgeAddress>
```

### Deploying using Truffle (deprecated)
Expand Down
48 changes: 16 additions & 32 deletions ethereum/sh/registerAllChainsOnTokenBridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,40 @@
# find a VAA for that chain in the CSV file (as a sanity check). Please be sure to generate
# the registation VAA for this chain and add it to the file before running this script.

# MNEMONIC=<redacted> ./sh/registerAllChainsOnTokenBridge.sh testnet blast
# MNEMONIC=<redacted> ./sh/registerAllChainsOnTokenBridge.sh <network> <chainName> <tokenBridgeAddress>

if [ $# != 2 ]; then
echo "Usage: $0 testnet blast" >&2
if [ $# != 3 ]; then
echo "Usage: $0 <network> <chainName> <tokenBridgeAddress>" >&2
exit 1
fi

[[ -z $MNEMONIC ]] && { echo "Missing MNEMONIC"; exit 1; }

network=$1
chain=$2
token_bridge_address=$3

# Figure out which file of VAAs to use.
# Figure out which env file and VAA files to use.
env_file=""
input_file=""
case "$network" in
mainnet)
env_file="env/.env.${chain}"
input_file="../deployments/mainnet/tokenBridgeVAAs.csv"
;;
testnet)
env_file="env/.env.${chain}.testnet"
input_file="../deployments/testnet/tokenBridgeVAAs.csv"
;;
*) echo "unknown network $network, must be testnet or mainnet" >&2
exit 1
;;
esac

# Use the worm cli to get the chain parameters.
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

chain_id=$(worm info chain-id "$chain")
if [ $? != 0 ]; then
echo -e "\nERROR: failed to look up the chain id for ${chain}, please make sure the worm binary is current!" >&2
exit 1
fi
# Source in the env file to get the RPC and forge arguments.
. ${env_file}

rpc_url=$(worm info rpc "$network" "$chain")
if [ $? != 0 ]; then
echo -e "\nERROR: failed to look up the RPC for ${chain}, please make sure the worm binary is current!" >&2
exit 1
fi

token_bridge_address=$(worm info contract "$network" "$chain" TokenBridge)
if [ $? != 0 ]; then
echo -e "\nERROR: failed to look up the token bridge address for ${chain}, please make sure the worm binary is current!" >&2
exit 1
fi
[[ -z $RPC_URL ]] && { echo "Missing RPC_URL"; exit 1; }

# Build one long string of all the vaas in the input file.
vaas=""
Expand All @@ -73,7 +57,7 @@ do
vaa=`echo $line | cut -d, -f2`

# Skip this chain. (We don't want to register this chain on itself.)
echo $tag | grep "(${chain_id})" > /dev/null
echo $tag | grep -i ${chain} > /dev/null
if [ $? == 0 ]; then
found_us=1
continue
Expand All @@ -89,17 +73,17 @@ do
done < "$input_file"

if [ $found_us == 0 ]; then
echo "ERROR: failed to find chain id ${chain_id} in ${input_file}, something is not right!" >&2
echo "ERROR: failed to find chain ${chain} in ${input_file}, something is not right!" >&2
exit 1
fi

# Make it look like an array.
vaas="[${vaas}]"
echo $vaas

echo "Submitting ${count} VAAs to ${network} ${chain} token bridge at address ${token_bridge_address} and rpc ${rpc_url}"
echo "Submitting ${count} VAAs to ${network} ${chain} token bridge at address ${token_bridge_address} and rpc ${RPC_URL}"
forge script ./forge-scripts/RegisterChainsTokenBridge.s.sol:RegisterChainsTokenBridge \
--sig "run(address,bytes[])" $token_bridge_address $vaas \
--rpc-url $rpc_url \
--rpc-url $RPC_URL \
--private-key $MNEMONIC \
--broadcast
--broadcast ${FORGE_ARGS}
Loading