From 4030c0a0d2988f9267ecc3926478d0058500592d Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Sat, 14 Oct 2023 09:47:55 +0530 Subject: [PATCH] Add a separate pod for ipld-eth-server with payments (#583) * Add a separate pod for ipld-eth-server with payments * Wait for nitro contracts to become available --- ...ocker-compose-ipld-eth-server-payments.yml | 63 +++++++++++++++++++ .../docker-compose-ipld-eth-server.yml | 22 ------- app/data/config/go-nitro/run-nitro-node.sh | 7 ++- app/data/config/ipld-eth-server/entrypoint.sh | 41 +++++------- app/data/pod-list.txt | 1 + app/data/stacks/fixturenet-payments/stack.yml | 3 +- 6 files changed, 86 insertions(+), 51 deletions(-) create mode 100644 app/data/compose/docker-compose-ipld-eth-server-payments.yml diff --git a/app/data/compose/docker-compose-ipld-eth-server-payments.yml b/app/data/compose/docker-compose-ipld-eth-server-payments.yml new file mode 100644 index 00000000..4fe97c6b --- /dev/null +++ b/app/data/compose/docker-compose-ipld-eth-server-payments.yml @@ -0,0 +1,63 @@ +version: "3.2" +services: + ipld-eth-server: + restart: unless-stopped + depends_on: + ipld-eth-db: + condition: service_healthy + image: cerc/ipld-eth-server:local + environment: + SERVER_HTTP_PATH: 0.0.0.0:8081 + SERVER_GRAPHQL: "true" + SERVER_GRAPHQLPATH: 0.0.0.0:8082 + VDB_COMMAND: "serve" + ETH_CHAIN_CONFIG: "/tmp/chain.json" + DATABASE_NAME: cerc_testing + DATABASE_HOSTNAME: ipld-eth-db + DATABASE_PORT: 5432 + DATABASE_USER: "vdbm" + DATABASE_PASSWORD: "password" + ETH_CHAIN_ID: 99 + ETH_FORWARD_ETH_CALLS: "false" + ETH_FORWARD_GET_STORAGE_AT: "false" + ETH_PROXY_ON_ERROR: "false" + METRICS: "true" + PROM_HTTP: "true" + PROM_HTTP_ADDR: "0.0.0.0" + PROM_HTTP_PORT: "8090" + LOG_LEVEL: "debug" + CERC_REMOTE_DEBUG: ${CERC_REMOTE_DEBUG:-true} + NITRO_PK: ${CERC_NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d} + NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597} + NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} + NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-false} + NITRO_DURABLE_STORE_FOLDER: ${CERC_NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store} + CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} + CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} + CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} + entrypoint: ["bash", "-c", "/app/entrypoint.sh"] + volumes: + - type: bind + source: ../config/ipld-eth-server/chain.json + target: /tmp/chain.json + - eth_server_nitro_data:/app/data + - nitro_deployment:/app/deployment + - ../config/ipld-eth-server/entrypoint.sh:/app/entrypoint.sh + ports: + - "8081" + - "8082" + - "8090" + - "40000" + - "3005" + - "4005:4005" + - "5005:5005" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "8081"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + +volumes: + eth_server_nitro_data: + nitro_deployment: diff --git a/app/data/compose/docker-compose-ipld-eth-server.yml b/app/data/compose/docker-compose-ipld-eth-server.yml index ca5d0e02..a408dff1 100644 --- a/app/data/compose/docker-compose-ipld-eth-server.yml +++ b/app/data/compose/docker-compose-ipld-eth-server.yml @@ -5,9 +5,6 @@ services: depends_on: ipld-eth-db: condition: service_healthy - # Wait for Nitro contracts to be deployed - nitro-contracts: - condition: service_completed_successfully image: cerc/ipld-eth-server:local environment: SERVER_HTTP_PATH: 0.0.0.0:8081 @@ -30,37 +27,18 @@ services: PROM_HTTP_PORT: "8090" LOG_LEVEL: "debug" CERC_REMOTE_DEBUG: ${CERC_REMOTE_DEBUG:-true} - NITRO_PK: ${CERC_NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d} - NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597} - NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-false} - NITRO_DURABLE_STORE_FOLDER: ${CERC_NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store} - CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} - CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} - CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - entrypoint: ["bash", "-c", "/app/entrypoint.sh"] volumes: - type: bind source: ../config/ipld-eth-server/chain.json target: /tmp/chain.json - - eth_server_nitro_data:/app/data - - nitro_deployment:/app/deployment - - ../config/ipld-eth-server/entrypoint.sh:/app/entrypoint.sh ports: - "8081" - "8082" - "8090" - "40000" - - "3005" - - "4005:4005" - - "5005:5005" healthcheck: test: ["CMD", "nc", "-v", "localhost", "8081"] interval: 20s timeout: 5s retries: 15 start_period: 5s - -volumes: - eth_server_nitro_data: - nitro_deployment: diff --git a/app/data/config/go-nitro/run-nitro-node.sh b/app/data/config/go-nitro/run-nitro-node.sh index edfb1cdf..546e9448 100755 --- a/app/data/config/go-nitro/run-nitro-node.sh +++ b/app/data/config/go-nitro/run-nitro-node.sh @@ -29,12 +29,13 @@ fi echo "Running Nitro node" +# Assuming CERC_NITRO_CHAIN_URL is of format ://host:port +ws_host=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1) +ws_port=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2) + # Wait till chain endpoint is available retry_interval=5 while true; do - # Assuming CERC_NITRO_CHAIN_URL is of format ://host:port - ws_host=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1) - ws_port=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2) nc -z -w 1 "$ws_host" "$ws_port" if [ $? -eq 0 ]; then diff --git a/app/data/config/ipld-eth-server/entrypoint.sh b/app/data/config/ipld-eth-server/entrypoint.sh index c58fbece..effe9dee 100755 --- a/app/data/config/ipld-eth-server/entrypoint.sh +++ b/app/data/config/ipld-eth-server/entrypoint.sh @@ -12,34 +12,25 @@ if [ -n "$CERC_NA_ADDRESS" ]; then export NITRO_NA_ADDRESS=${CERC_NA_ADDRESS} export NITRO_VPA_ADDRESS=${CERC_VPA_ADDRESS} export NITRO_CA_ADDRESS=${CERC_CA_ADDRESS} -elif [ -f ${nitro_addresses_file} ]; then - echo "Reading Nitro addresses from ${nitro_addresses_file}" - - export NITRO_NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file}) - export NITRO_VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file}) - export NITRO_CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file}) else - echo "File ${nitro_addresses_file} not found" - exit 1 + # Read addresses from a file + # Keep retrying until found + echo "Reading Nitro addresses from ${nitro_addresses_file}" + retry_interval=5 + while true; do + if [[ -e "$nitro_addresses_file" ]]; then + export NITRO_NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file}) + export NITRO_VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file}) + export NITRO_CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file}) + + break + else + echo "File not yet available, retrying in $retry_interval seconds..." + sleep $retry_interval + fi + done fi -# Wait till chain endpoint is available -retry_interval=5 -while true; do - # Assuming NITRO_CHAIN_URL is of format ://host:port - ws_host=$(echo "$NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1) - ws_port=$(echo "$NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2) - nc -z -w 1 "$ws_host" "$ws_port" - - if [ $? -eq 0 ]; then - echo "Chain endpoint is available" - break - fi - - echo "Chain endpoint not yet available, retrying in $retry_interval seconds..." - sleep $retry_interval -done - echo "Beginning the ipld-eth-server process" START_CMD="./ipld-eth-server" diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index c65ef22c..06bb7561 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -43,3 +43,4 @@ nitro-contracts nitro-reverse-payment-proxy mobymask-snap ponder +ipld-eth-server-payments diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index 7ed6e228..14aba43b 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -6,6 +6,7 @@ repos: - git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5 - git.vdb.to/cerc-io/lighthouse - git.vdb.to/cerc-io/ipld-eth-db@v5 + # ipld-eth-server with payments -- to be used by ipld-eth-server-payments pod - git.vdb.to/cerc-io/ipld-eth-server@payments # nitro repo - github.com/cerc-io/ts-nitro@v0.1.13 @@ -43,7 +44,7 @@ containers: - cerc/ponder pods: - fixturenet-eth - - ipld-eth-server + - ipld-eth-server-payments - ipld-eth-db - nitro-contracts # - go-nitro