2024-07-19 05:27:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
|
|
|
bridge_assets_map_file="/app/deployment/bridge-assets-map.toml"
|
|
|
|
bridge_config_file="/app/bridge.toml"
|
|
|
|
|
|
|
|
echo "Using the following environment variables:"
|
2024-07-23 06:40:19 +00:00
|
|
|
echo "NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL}"
|
|
|
|
echo "NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL}"
|
|
|
|
echo "NITRO_CHAIN_PK: ${NITRO_CHAIN_PK}"
|
|
|
|
echo "NITRO_SC_PK: ${NITRO_SC_PK}"
|
|
|
|
echo "NITRO_L1_MSG_PORT: ${NITRO_L1_MSG_PORT}"
|
|
|
|
echo "NITRO_L2_MSG_PORT: ${NITRO_L2_MSG_PORT}"
|
|
|
|
echo "NITRO_RPC_PORT: ${NITRO_RPC_PORT}"
|
|
|
|
echo "NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST}"
|
2024-07-23 11:46:46 +00:00
|
|
|
echo "NITRO_L1_EXT_MULTIADDR: ${NITRO_L1_EXT_MULTIADDR}"
|
|
|
|
echo "NITRO_L2_EXT_MULTIADDR: ${NITRO_L2_EXT_MULTIADDR}"
|
2024-07-23 06:40:19 +00:00
|
|
|
|
|
|
|
echo "Waiting for $bridge_assets_map_file to be ready"
|
|
|
|
|
|
|
|
while [ ! -e "$bridge_assets_map_file" ]; do
|
|
|
|
sleep 3
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "File $bridge_assets_map_file found"
|
2024-07-19 05:27:46 +00:00
|
|
|
|
|
|
|
# Create required certs
|
|
|
|
./create-certs.sh
|
|
|
|
|
|
|
|
# Create the bridge config file
|
|
|
|
cat <<EOF > "$bridge_config_file"
|
2024-07-23 06:40:19 +00:00
|
|
|
chainpk = "$NITRO_CHAIN_PK"
|
|
|
|
statechannelpk = "$NITRO_SC_PK"
|
|
|
|
l1chainurl = "$NITRO_L1_CHAIN_URL"
|
|
|
|
l2chainurl = "$NITRO_L2_CHAIN_URL"
|
|
|
|
nodel1msgport = $NITRO_L1_MSG_PORT
|
|
|
|
nodel2msgport = $NITRO_L2_MSG_PORT
|
|
|
|
rpcport = $NITRO_RPC_PORT
|
|
|
|
bridgepublicip = "$NITRO_PUBLIC_P2P_HOST"
|
2024-07-23 11:46:46 +00:00
|
|
|
nodel1ExtMultiAddr = "$NITRO_L1_EXT_MULTIADDR"
|
|
|
|
nodel2ExtMultiAddr = "$NITRO_L2_EXT_MULTIADDR"
|
2024-07-19 05:27:46 +00:00
|
|
|
assetmapfilepath = "$bridge_assets_map_file"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Export contract addresses
|
2024-07-23 06:40:19 +00:00
|
|
|
export NA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address" ${nitro_addresses_file})
|
|
|
|
export CA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address" ${nitro_addresses_file})
|
|
|
|
export VPA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address" ${nitro_addresses_file})
|
|
|
|
export BRIDGE_ADDRESS=$(jq -r ".\"$OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address" ${nitro_addresses_file})
|
2024-07-19 05:27:46 +00:00
|
|
|
|
|
|
|
# Start bridge
|
2024-07-23 06:40:19 +00:00
|
|
|
echo "Starting nitro-bridge"
|
2024-07-19 05:27:46 +00:00
|
|
|
./nitro-bridge -config $bridge_config_file
|