Read contract addresses from a volume when running the Nitro node

This commit is contained in:
Prathamesh Musale 2023-09-27 14:51:38 +05:30
parent 2b06cbecc2
commit 385489f4c4
3 changed files with 48 additions and 8 deletions

View File

@ -2,13 +2,15 @@ version: '3.7'
services:
go-nitro:
restart: always
image: cerc/go-nitro:local
hostname: go-nitro
restart: on-failure
depends_on:
# Wait for Nitro contracts to be deployed
nitro-contracts:
condition: service_completed_successfully
environment:
CHAIN_URL: ${CHAIN_URL:-ws://fixturenet-eth-geth-1:8546}
NA_ADDRESS: ${NA_ADDRESS}
VPA_ADDRESS: ${VPA_ADDRESS}
CA_ADDRESS: ${CA_ADDRESS}
MSG_PORT: ${MSG_PORT:-3005}
RPC_PORT: ${RPC_PORT:-4005}
WS_MSG_PORT: ${WS_MSG_PORT:-5005}
@ -16,10 +18,14 @@ services:
CHAIN_PK: ${CHAIN_PK}
USE_DURABLE_STORE: ${USE_DURABLE_STORE:-true}
DURABLE_STORE_FOLDER: ${DURABLE_STORE_FOLDER:-/app/data/nitro-store}
BOOT_PEERS: []
image: cerc/go-nitro:local
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"]
volumes:
go_nitro_data: /app/data
- go_nitro_data:/app/data
- nitro_deployment:/app/deployment
- ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "${MSG_PORT:-3005}"]
interval: 5s
@ -33,3 +39,4 @@ services:
volumes:
go_nitro_data:
nitro_deployment:

View File

@ -15,7 +15,7 @@ services:
volumes:
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
- nitro_deployment:/app/deployment
command: ["bash", "-c", "/app/deploy.sh && tail -f"]
command: ["bash", "-c", "/app/deploy.sh"]
extra_hosts:
- "host.docker.internal:host-gateway"

View File

@ -0,0 +1,33 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
NITRO_ADDRESSES_FILE_PATH="/app/deployment/nitro-addresses.json"
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
if [ -n "$CERC_NA_ADDRESS" ]; then
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
echo "Using the above Nitro addresses"
NA_ADDRESS=${CERC_NA_ADDRESS}
VPA_ADDRESS=${CERC_VPA_ADDRESS}
CA_ADDRESS=${CERC_CA_ADDRESS}
elif [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
echo "Reading Nitro addresses from ${NITRO_ADDRESSES_FILE_PATH}"
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${NITRO_ADDRESSES_FILE_PATH})
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
else
echo "${NITRO_ADDRESSES_FILE_PATH} not found"
exit 1
fi
echo "Running Nitro node"
./nitro -chainurl ${CHAIN_URL} -msgport ${MSG_PORT} -rpcport ${RPC_PORT} -wsmsgport ${WS_MSG_PORT} -pk ${PK} -chainpk ${CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${USE_DURABLE_STORE} -durablestorefolder ${DURABLE_STORE_FOLDER}