From 9c7726c33492a62dad54ed19c31335d18cb012ee Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 27 Sep 2023 16:50:54 +0530 Subject: [PATCH] Add a service for Nitro reverse payment proxy --- app/data/compose/docker-compose-go-nitro.yml | 24 ++++++++--------- ...er-compose-nitro-reverse-payment-proxy.yml | 27 +++++++++++++++++++ app/data/config/go-nitro/run-nitro-node.sh | 2 +- .../go-nitro/run-reverse-payment-proxy.sh | 14 ++++++++++ app/data/pod-list.txt | 1 + app/data/stacks/fixturenet-payments/stack.yml | 1 + 6 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml create mode 100755 app/data/config/go-nitro/run-reverse-payment-proxy.sh diff --git a/app/data/compose/docker-compose-go-nitro.yml b/app/data/compose/docker-compose-go-nitro.yml index e1776e1a..6f0b42e4 100644 --- a/app/data/compose/docker-compose-go-nitro.yml +++ b/app/data/compose/docker-compose-go-nitro.yml @@ -10,14 +10,14 @@ services: nitro-contracts: condition: service_completed_successfully environment: - CHAIN_URL: ${CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - MSG_PORT: ${MSG_PORT:-3005} - RPC_PORT: ${RPC_PORT:-4005} - WS_MSG_PORT: ${WS_MSG_PORT:-5005} - PK: ${PK} - CHAIN_PK: ${CHAIN_PK} - USE_DURABLE_STORE: ${USE_DURABLE_STORE:-true} - DURABLE_STORE_FOLDER: ${DURABLE_STORE_FOLDER:-/app/data/nitro-store} + NITRO_CHAIN_URL: ${NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} + NITRO_MSG_PORT: ${NITRO_MSG_PORT:-3005} + NITRO_RPC_PORT: ${NITRO_RPC_PORT:-4005} + NITRO_WS_MSG_PORT: ${NITRO_WS_MSG_PORT:-5005} + NITRO_PK: ${NITRO_PK} + NITRO_CHAIN_PK: ${NITRO_CHAIN_PK} + NITRO_USE_DURABLE_STORE: ${NITRO_USE_DURABLE_STORE:-true} + NITRO_DURABLE_STORE_FOLDER: ${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} @@ -27,15 +27,15 @@ services: - 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}"] + test: ["CMD", "nc", "-vz", "localhost", "${NITRO_RPC_PORT:-4005}"] interval: 5s timeout: 5s retries: 5 start_period: 5s ports: - - "3005" - - "4005" - - "5005" + - "${NITRO_MSG_PORT:-3005}" + - "${NITRO_RPC_PORT:-4005}" + - "${NITRO_WS_MSG_PORT:-5005}" volumes: go_nitro_data: diff --git a/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml b/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml new file mode 100644 index 00000000..eb5bb177 --- /dev/null +++ b/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml @@ -0,0 +1,27 @@ +version: '3.7' + +services: + nitro-reverse-payment-proxy: + image: cerc/go-nitro:local + hostname: nitro-reverse-payment-proxy + restart: on-failure + depends_on: + # Wait for the go-nitro node to start + go-nitro: + condition: service_healthy + environment: + PROXY_ADDRESS: localhost:${PROXY_PORT:-8081} + PROXY_NITRO_ENDPOINT: ${PROXY_NITRO_ENDPOINT:-go-nitro:${NITRO_RPC_PORT:-4005}/api/v1} + PROXY_DESTINATION_URL: ${PROXY_DESTINATION_URL:-http://ipld-eth-server:8081} + PROXY_COST_PER_BYTE: ${PROXY_COST_PER_BYTE:-1} + entrypoint: ["bash", "-c", "/app/run-reverse-payment-proxy.sh"] + volumes: + - ../config/go-nitro/run-reverse-payment-proxy.sh:/app/run-reverse-payment-proxy.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "${PROXY_PORT:-8081}"] + interval: 5s + timeout: 5s + retries: 5 + start_period: 5s + ports: + - "${PROXY_PORT:-8081}" diff --git a/app/data/config/go-nitro/run-nitro-node.sh b/app/data/config/go-nitro/run-nitro-node.sh index f96d9ece..7f4df4c4 100755 --- a/app/data/config/go-nitro/run-nitro-node.sh +++ b/app/data/config/go-nitro/run-nitro-node.sh @@ -30,4 +30,4 @@ 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} +./nitro -chainurl ${NITRO_CHAIN_URL} -msgport ${NITRO_MSG_PORT} -rpcport ${NITRO_RPC_PORT} -wsmsgport ${NITRO_WS_MSG_PORT} -pk ${NITRO_PK} -chainpk ${NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${NITRO_USE_DURABLE_STORE} -durablestorefolder ${NITRO_DURABLE_STORE_FOLDER} diff --git a/app/data/config/go-nitro/run-reverse-payment-proxy.sh b/app/data/config/go-nitro/run-reverse-payment-proxy.sh new file mode 100755 index 00000000..02102c14 --- /dev/null +++ b/app/data/config/go-nitro/run-reverse-payment-proxy.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +echo "Running Nitro reverse payment proxy" +echo "Using PROXY_ADDRESS ${PROXY_ADDRESS}" +echo "Using PROXY_NITRO_ENDPOINT ${PROXY_NITRO_ENDPOINT}" +echo "Using PROXY_DESTINATION_URL ${PROXY_DESTINATION_URL}" +echo "Using PROXY_COST_PER_BYTE ${PROXY_COST_PER_BYTE}" + +./start-reverse-payment-proxy -proxyaddress ${PROXY_ADDRESS} -nitroendpoint=${PROXY_NITRO_ENDPOINT} -destinationurl=${PROXY_DESTINATION_URL} -costperbyte ${PROXY_COST_PER_BYTE} diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index 477b39d3..563f32cc 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -39,3 +39,4 @@ watcher-mobymask-v3 mobymask-app-v3 go-nitro nitro-contracts +nitro-reverse-payment-proxy diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index c518a71f..37226308 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -27,3 +27,4 @@ pods: - ipld-eth-db - nitro-contracts - go-nitro + - nitro-reverse-payment-proxy