From 781dd263ab46d3bf357639dd7e3c4d6ee484d482 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 19 Apr 2024 17:41:39 -0500 Subject: [PATCH] Refactor to nitro-auth --- .../compose/docker-compose-go-nitro-auth.yml | 113 ------------------ .../compose/docker-compose-nitro-auth.yml | 0 .../{go-nitro-auth => nitro-auth}/alice.env | 0 .../{go-nitro-auth => nitro-auth}/bob.env | 0 .../bootnode.env | 0 .../caddy/Caddyfile | 0 .../data/config/nitro-auth/charlie.env | 19 +++ .../data/config/ts-nitro/run.sh | 45 +++++++ .../cerc-fixturenet-eth-geth/run-el.sh | 2 +- .../container-build/cerc-ts-nitro/Dockerfile | 12 ++ .../container-build/cerc-ts-nitro/build.sh | 9 ++ .../{go-nitro-auth => nitro-auth}/README.md | 0 .../{go-nitro-auth => nitro-auth}/stack.yml | 11 +- 13 files changed, 92 insertions(+), 119 deletions(-) delete mode 100644 stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml create mode 100644 stack_orchestrator/data/compose/docker-compose-nitro-auth.yml rename stack_orchestrator/data/config/{go-nitro-auth => nitro-auth}/alice.env (100%) rename stack_orchestrator/data/config/{go-nitro-auth => nitro-auth}/bob.env (100%) rename stack_orchestrator/data/config/{go-nitro-auth => nitro-auth}/bootnode.env (100%) rename stack_orchestrator/data/config/{go-nitro-auth => nitro-auth}/caddy/Caddyfile (100%) create mode 100644 stack_orchestrator/data/config/nitro-auth/charlie.env create mode 100755 stack_orchestrator/data/config/ts-nitro/run.sh create mode 100644 stack_orchestrator/data/container-build/cerc-ts-nitro/Dockerfile create mode 100755 stack_orchestrator/data/container-build/cerc-ts-nitro/build.sh rename stack_orchestrator/data/stacks/{go-nitro-auth => nitro-auth}/README.md (100%) rename stack_orchestrator/data/stacks/{go-nitro-auth => nitro-auth}/stack.yml (54%) diff --git a/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml b/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml deleted file mode 100644 index 7fa6a90f..00000000 --- a/stack_orchestrator/data/compose/docker-compose-go-nitro-auth.yml +++ /dev/null @@ -1,113 +0,0 @@ -version: '3.7' - -services: - go-nitro-alice: - image: cerc/go-nitro:local - hostname: go-nitro-alice - restart: on-failure - depends_on: - - go-nitro-bootnode - environment: - CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK_ALICE:-888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218} - CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} - CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} - CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - env_file: - - ../config/go-nitro-auth/alice.env - entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"] - volumes: - - nitro_deployment:/app/deployment - - go_nitro_data_alice:/app/data - - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh - healthcheck: - test: ["CMD", "nc", "-vz", "localhost", "4006"] - interval: 5s - timeout: 5s - retries: 100 - start_period: 100s - ports: - - "3006" - - "4006" - - "5006" - - "4106" - - "4206" - - "4216" - - go-nitro-bob: - image: cerc/go-nitro:local - hostname: go-nitro-bob - restart: on-failure - depends_on: - - go-nitro-bootnode - environment: - CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK_BOB:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597} - CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} - CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} - CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - env_file: - - ../config/go-nitro-auth/bob.env - entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"] - volumes: - - nitro_deployment:/app/deployment - - go_nitro_data_bob:/app/data - - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh - healthcheck: - test: ["CMD", "nc", "-vz", "localhost", "4007"] - interval: 5s - timeout: 5s - retries: 100 - start_period: 100s - ports: - - "3007" - - "4007" - - "5007" - - "4107" - - "4207" - - "4217" - - go-nitro-bootnode: - image: cerc/go-nitro:local - hostname: go-nitro-bootnode - restart: on-failure - environment: - CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} - CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} - CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} - CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - CERC_NITRO_RELAY_ON: true - env_file: - - ../config/go-nitro-auth/bootnode.env - entrypoint: [ "bash", "-c", "/app/run-nitro-node.sh" ] - volumes: - - nitro_deployment:/app/deployment - - go_nitro_data_bootnode:/app/data - - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh - healthcheck: - test: [ "CMD", "nc", "-vz", "localhost", "4008" ] - interval: 5s - timeout: 5s - retries: 100 - start_period: 100s - ports: - - "9090" - - nitro-caddy: - image: caddy:2-alpine - restart: always - environment: - CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT:-http://fixturenet-eth-geth-1:8545} - volumes: - - ../config/go-nitro-auth/caddy/Caddyfile:/etc/caddy/Caddyfile - ports: - - "5678" - depends_on: - - go-nitro-alice - - go-nitro-bob - -volumes: - go_nitro_data_alice: - go_nitro_data_bob: - go_nitro_data_bootnode: - nitro_deployment: \ No newline at end of file diff --git a/stack_orchestrator/data/compose/docker-compose-nitro-auth.yml b/stack_orchestrator/data/compose/docker-compose-nitro-auth.yml new file mode 100644 index 00000000..e69de29b diff --git a/stack_orchestrator/data/config/go-nitro-auth/alice.env b/stack_orchestrator/data/config/nitro-auth/alice.env similarity index 100% rename from stack_orchestrator/data/config/go-nitro-auth/alice.env rename to stack_orchestrator/data/config/nitro-auth/alice.env diff --git a/stack_orchestrator/data/config/go-nitro-auth/bob.env b/stack_orchestrator/data/config/nitro-auth/bob.env similarity index 100% rename from stack_orchestrator/data/config/go-nitro-auth/bob.env rename to stack_orchestrator/data/config/nitro-auth/bob.env diff --git a/stack_orchestrator/data/config/go-nitro-auth/bootnode.env b/stack_orchestrator/data/config/nitro-auth/bootnode.env similarity index 100% rename from stack_orchestrator/data/config/go-nitro-auth/bootnode.env rename to stack_orchestrator/data/config/nitro-auth/bootnode.env diff --git a/stack_orchestrator/data/config/go-nitro-auth/caddy/Caddyfile b/stack_orchestrator/data/config/nitro-auth/caddy/Caddyfile similarity index 100% rename from stack_orchestrator/data/config/go-nitro-auth/caddy/Caddyfile rename to stack_orchestrator/data/config/nitro-auth/caddy/Caddyfile diff --git a/stack_orchestrator/data/config/nitro-auth/charlie.env b/stack_orchestrator/data/config/nitro-auth/charlie.env new file mode 100644 index 00000000..b410baa7 --- /dev/null +++ b/stack_orchestrator/data/config/nitro-auth/charlie.env @@ -0,0 +1,19 @@ +# SET ME! Your on-chain private key. +#CERC_NITRO_CHAIN_PK= + +# Default is CERC_NITRO_CHAIN_PK. +#CERC_NITRO_PK= + +# SET ME! The WebSocket to connect to. +#CERC_NITRO_CHAIN_URL=wss://linea-sepolia.infura.io/ws/v3/ + +CERC_NITRO_AUTH_ON=false +CERC_NITRO_AUTH_RPC_PORT=4009 +CERC_NITRO_AUTH_UI_PORT=4209 +CERC_NITRO_BOOT_PEERS="/dns4/go-nitro-bootnode/tcp/3008/p2p/16Uiu2HAmFYz5YPf3GtkfQsAwYJfDsKSm34U9qAiTwxW7RJUVGMRK" +CERC_NITRO_DURABLE_STORE_FOLDER=/app/data/nitro-store +CERC_NITRO_MSG_PORT=3009 +CERC_NITRO_RPC_PORT=4009 +CERC_NITRO_UI_PORT=4109 +CERC_NITRO_USE_DURABLE_STORE=true +CERC_NITRO_WS_MSG_PORT=5009 diff --git a/stack_orchestrator/data/config/ts-nitro/run.sh b/stack_orchestrator/data/config/ts-nitro/run.sh new file mode 100755 index 00000000..6157017b --- /dev/null +++ b/stack_orchestrator/data/config/ts-nitro/run.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +if [ -z "$CERC_NITRO_CHAIN_PK" ] || [ -z "$CERC_NITRO_CHAIN_URL" ]; then + echo "You most set both CERC_NITRO_CHAIN_PK and CERC_NITRO_CHAIN_URL." 1>&2 + exit 1 +fi + +nitro_addresses_file="/app/deployment/nitro-addresses.json" + +# Check if CERC_NA_ADDRESS environment variable is set +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} ]; then + echo "Reading Nitro addresses from ${nitro_addresses_file}" + + NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file}) + VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file}) + CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file}) +else + echo "File ${nitro_addresses_file} not found" + exit 1 +fi + +cd /app/packages/example-web-app +cat > .env < /dev/null && pwd ) + +docker build -t cerc/ts-nitro:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ts-nitro diff --git a/stack_orchestrator/data/stacks/go-nitro-auth/README.md b/stack_orchestrator/data/stacks/nitro-auth/README.md similarity index 100% rename from stack_orchestrator/data/stacks/go-nitro-auth/README.md rename to stack_orchestrator/data/stacks/nitro-auth/README.md diff --git a/stack_orchestrator/data/stacks/go-nitro-auth/stack.yml b/stack_orchestrator/data/stacks/nitro-auth/stack.yml similarity index 54% rename from stack_orchestrator/data/stacks/go-nitro-auth/stack.yml rename to stack_orchestrator/data/stacks/nitro-auth/stack.yml index 42b10950..03a05bc0 100644 --- a/stack_orchestrator/data/stacks/go-nitro-auth/stack.yml +++ b/stack_orchestrator/data/stacks/nitro-auth/stack.yml @@ -1,16 +1,17 @@ version: "1.0" -name: go-nitro-auth +name: nitro-auth description: "Stack to demonstrate payments between various services" repos: - # for nitro-contracts - - github.com/cerc-io/ts-nitro@v0.1.15 - # for go-nitro and nitro-rpc-client + # for nitro-contracts and ts-nitro example app + - github.com/cerc-io/ts-nitro@telackey/demo-auth + # for go-nitro, nitro-rpc-client, and go-nitro-auth example app - github.com/cerc-io/go-nitro@telackey/update containers: # nitro - cerc/nitro-contracts + - cerc/ts-nitro - cerc/go-nitro - cerc/nitro-rpc-client pods: - nitro-contracts - - go-nitro-auth \ No newline at end of file + - nitro-auth \ No newline at end of file