From 1a993a2c6dd4ddb389475918e7582cc040d30e76 Mon Sep 17 00:00:00 2001 From: nabarun Date: Tue, 2 May 2023 19:40:32 +0530 Subject: [PATCH 1/7] Setup gateway-server with watchers --- .../docker-compose-watcher-azimuth.yml | 98 +++++++++++++++++++ .../watcher-azimuth/gateway-watchers.json | 10 ++ .../watcher-configs/azimuth-watcher.toml | 66 +++++++++++++ .../watcher-configs/censures-watcher.toml | 66 +++++++++++++ .../cerc-watcher-azimuth/Dockerfile | 10 ++ .../cerc-watcher-azimuth/build.sh | 9 ++ app/data/container-image-list.txt | 1 + app/data/pod-list.txt | 1 + app/data/repository-list.txt | 1 + app/data/stacks/azimuth/README.md | 58 +++++++++++ app/data/stacks/azimuth/stack.yml | 8 ++ 11 files changed, 328 insertions(+) create mode 100644 app/data/compose/docker-compose-watcher-azimuth.yml create mode 100644 app/data/config/watcher-azimuth/gateway-watchers.json create mode 100644 app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml create mode 100644 app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml create mode 100644 app/data/container-build/cerc-watcher-azimuth/Dockerfile create mode 100755 app/data/container-build/cerc-watcher-azimuth/build.sh create mode 100644 app/data/stacks/azimuth/README.md create mode 100644 app/data/stacks/azimuth/stack.yml diff --git a/app/data/compose/docker-compose-watcher-azimuth.yml b/app/data/compose/docker-compose-watcher-azimuth.yml new file mode 100644 index 00000000..cc3a6e55 --- /dev/null +++ b/app/data/compose/docker-compose-watcher-azimuth.yml @@ -0,0 +1,98 @@ +version: '3.2' + +services: + # Starts the PostgreSQL database for watchers + watcher-db: + restart: unless-stopped + image: postgres:14-alpine + environment: + - POSTGRES_USER=vdbm + - POSTGRES_MULTIPLE_DATABASES=azimuth-watcher,azimuth-watcher-job-queue,censures-watcher,censures-watcher-job-queue,claims-watcher,claims-watcher-job-queue,conditional-star-release-watcher,conditional-star-release-watcher-job-queue,delegated-watcher,delegated-watcher-job-queue,ecliptic-watcher,ecliptic-watcher-job-queue,linear-star-release-watcher,linear-star-release-watcher-job-queue,polls-watcher,polls-watcher-job-queue + - POSTGRES_EXTENSION=azimuth-watcher-job-queue:pgcrypto,censures-watcher-job-queue:pgcrypto,claims-watcher-job-queue:pgcrypto,conditional-star-release-watcher-job-queue:pgcrypto,delegated-watcher-job-queue:pgcrypto,ecliptic-watcher-job-queue:pgcrypto,linear-star-release-watcher-job-queue:pgcrypto,polls-watcher-job-queue:pgcrypto, + - POSTGRES_PASSWORD=password + volumes: + - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh + - watcher_db_data:/var/lib/postgresql/data + ports: + - "0.0.0.0:15432:5432" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + + # Starts the azimuth-watcher server + azimuth-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/azimuth-watcher + command: "yarn server" + volumes: + - ../config/watcher-azimuth/watcher-configs/azimuth-watcher.toml:/app/packages/azimuth-watcher/environments/local.toml + # ports: + # - "0.0.0.0:3001:3001" + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3001"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the censures-watcher server + censures-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/censures-watcher + command: "yarn server" + volumes: + - ../config/watcher-azimuth/watcher-configs/censures-watcher.toml:/app/packages/censures-watcher/environments/local.toml + # ports: + # - "0.0.0.0:3001:3001" + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3002"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the gateway-server for proxying queries + gateway-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + azimuth-watcher-server: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/gateway-server + command: "yarn server" + volumes: + - ../config/watcher-azimuth/gateway-watchers.json:/app/packages/gateway-server/dist/watchers.json + ports: + - "0.0.0.0:4000:4000" + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "4000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + watcher_db_data: diff --git a/app/data/config/watcher-azimuth/gateway-watchers.json b/app/data/config/watcher-azimuth/gateway-watchers.json new file mode 100644 index 00000000..550da348 --- /dev/null +++ b/app/data/config/watcher-azimuth/gateway-watchers.json @@ -0,0 +1,10 @@ +[ + { + "endpoint": "http://azimuth-watcher-server:3001/graphql", + "prefix": "azimuth" + }, + { + "endpoint": "http://censures-watcher-server:3002/graphql", + "prefix": "censures" + } +] diff --git a/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml b/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml new file mode 100644 index 00000000..936c0176 --- /dev/null +++ b/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml @@ -0,0 +1,66 @@ +[server] + host = "0.0.0.0" + port = 3001 + kind = "lazy" + + # Checkpointing state. + checkpointing = true + + # Checkpoint interval in number of blocks. + checkpointInterval = 2000 + + # Enable state creation + # CAUTION: Disable only if state creation is not desired or can be filled subsequently + enableState = true + + # Boolean to filter logs by contract. + filterLogs = false + + # Max block range for which to return events in eventsInRange GQL query. + # Use -1 for skipping check on block range. + maxEventsBlockRange = 1000 + + # GQL cache settings + [server.gqlCache] + enabled = true + + # Max in-memory cache size (in bytes) (default 8 MB) + # maxCacheSize + + # GQL cache-control max-age settings (in seconds) + maxAge = 15 + +[metrics] + host = "127.0.0.1" + port = 9000 + [metrics.gql] + port = 9001 + +[database] + type = "postgres" + host = "watcher-db" + port = 5432 + database = "azimuth-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://host.docker.internal:8083/graphql" + rpcProviderEndpoint = "http://host.docker.internal:8082" + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@watcher-db/azimuth-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 100 + eventsInBatch = 50 + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml b/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml new file mode 100644 index 00000000..5caa692a --- /dev/null +++ b/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml @@ -0,0 +1,66 @@ +[server] + host = "0.0.0.0" + port = 3002 + kind = "lazy" + + # Checkpointing state. + checkpointing = true + + # Checkpoint interval in number of blocks. + checkpointInterval = 2000 + + # Enable state creation + # CAUTION: Disable only if state creation is not desired or can be filled subsequently + enableState = true + + # Boolean to filter logs by contract. + filterLogs = false + + # Max block range for which to return events in eventsInRange GQL query. + # Use -1 for skipping check on block range. + maxEventsBlockRange = 1000 + + # GQL cache settings + [server.gqlCache] + enabled = true + + # Max in-memory cache size (in bytes) (default 8 MB) + # maxCacheSize + + # GQL cache-control max-age settings (in seconds) + maxAge = 15 + +[metrics] + host = "127.0.0.1" + port = 9000 + [metrics.gql] + port = 9001 + +[database] + type = "postgres" + host = "watcher-db" + port = 5432 + database = "censures-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://host.docker.internal:8083/graphql" + rpcProviderEndpoint = "http://host.docker.internal:8082" + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@watcher-db/censures-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 100 + eventsInBatch = 50 + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/container-build/cerc-watcher-azimuth/Dockerfile b/app/data/container-build/cerc-watcher-azimuth/Dockerfile new file mode 100644 index 00000000..4cd65a0d --- /dev/null +++ b/app/data/container-build/cerc-watcher-azimuth/Dockerfile @@ -0,0 +1,10 @@ +FROM node:18.16.0-alpine3.16 + +RUN apk --update --no-cache add git python3 alpine-sdk + +WORKDIR /app + +COPY . . + +RUN echo "Building azimuth-watcher-ts" && \ + yarn && yarn build diff --git a/app/data/container-build/cerc-watcher-azimuth/build.sh b/app/data/container-build/cerc-watcher-azimuth/build.sh new file mode 100755 index 00000000..522f985b --- /dev/null +++ b/app/data/container-build/cerc-watcher-azimuth/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Build cerc/watcher-azimuth + +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + +# See: https://stackoverflow.com/a/246128/1701505 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/watcher-azimuth:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/azimuth-watcher-ts diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 0fe2be5c..ba0eaf23 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -37,3 +37,4 @@ cerc/optimism-op-batcher cerc/optimism-op-node cerc/optimism-op-proposer cerc/pocket +cerc/watcher-azimuth diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index a3ae8f44..34d66ba6 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -25,3 +25,4 @@ kubo foundry fixturenet-optimism fixturenet-pocket +watcher-azimuth diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 438b9bbb..7035de2a 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -29,3 +29,4 @@ ethereum-optimism/op-geth ethereum-optimism/optimism pokt-network/pocket-core pokt-network/pocket-core-deployments +cerc-io/azimuth-watcher-ts diff --git a/app/data/stacks/azimuth/README.md b/app/data/stacks/azimuth/README.md new file mode 100644 index 00000000..ecd2a730 --- /dev/null +++ b/app/data/stacks/azimuth/README.md @@ -0,0 +1,58 @@ +# Azimuth Watcher + +Instructions to setup and deploy Azimuth Watcher stack + +## Setup + +Clone required repositories: + +```bash +laconic-so --stack azimuth setup-repositories +``` + +NOTE: If the repository already exists and checked out to different versions, `setup-repositories` command will throw an error. +For getting around this, the `azimuth-watcher-ts` repository can be removed and then run the command. + +Checkout to the required versions and branches in repos + +```bash +# azimuth-watcher-ts +cd ~/cerc/azimuth-watcher-ts +# git checkout v0.1.0 +``` + +Build the container images: + +```bash +laconic-so --stack azimuth build-containers +``` + +This should create the required docker images in the local image registry. + +Deploy the stack: + +* Deploy the containers: + + ```bash + laconic-so --stack azimuth deploy-system up + ``` + +* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy` + +## Clean up + +Stop all the services running in background run: + +```bash +laconic-so --stack azimuth deploy-system down 30 +``` + +Clear volumes created by this stack: + +```bash +# List all relevant volumes +docker volume ls -q --filter "name=.*watcher_db_data" + +# Remove all the listed volumes +docker volume rm $(docker volume ls -q --filter "name=.*watcher_db_data") +``` diff --git a/app/data/stacks/azimuth/stack.yml b/app/data/stacks/azimuth/stack.yml new file mode 100644 index 00000000..fc3c8473 --- /dev/null +++ b/app/data/stacks/azimuth/stack.yml @@ -0,0 +1,8 @@ +version: "1.0" +name: azimuth +repos: + - cerc-io/azimuth-watcher-ts +containers: + - cerc/watcher-azimuth +pods: + - watcher-azimuth From 2bef7c004403c858abed0317a71082401965f731 Mon Sep 17 00:00:00 2001 From: nabarun Date: Wed, 3 May 2023 18:13:01 +0530 Subject: [PATCH 2/7] Add js script to merge toml config files --- .../docker-compose-watcher-azimuth.yml | 16 ++++----- app/data/config/watcher-azimuth/merge-toml.js | 33 +++++++++++++++++++ .../config/watcher-azimuth/start-server.sh | 29 ++++++++++++++++ .../watcher-azimuth/watcher-config.toml | 13 ++++++++ 4 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 app/data/config/watcher-azimuth/merge-toml.js create mode 100755 app/data/config/watcher-azimuth/start-server.sh create mode 100644 app/data/config/watcher-azimuth/watcher-config.toml diff --git a/app/data/compose/docker-compose-watcher-azimuth.yml b/app/data/compose/docker-compose-watcher-azimuth.yml index cc3a6e55..094eca94 100644 --- a/app/data/compose/docker-compose-watcher-azimuth.yml +++ b/app/data/compose/docker-compose-watcher-azimuth.yml @@ -32,11 +32,11 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} working_dir: /app/packages/azimuth-watcher - command: "yarn server" + command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-configs/azimuth-watcher.toml:/app/packages/azimuth-watcher/environments/local.toml - # ports: - # - "0.0.0.0:3001:3001" + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/azimuth-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/azimuth-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/azimuth-watcher/start-server.sh healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3001"] interval: 20s @@ -56,11 +56,11 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} working_dir: /app/packages/censures-watcher - command: "yarn server" + command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-configs/censures-watcher.toml:/app/packages/censures-watcher/environments/local.toml - # ports: - # - "0.0.0.0:3001:3001" + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/censures-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/censures-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/censures-watcher/start-server.sh healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3002"] interval: 20s diff --git a/app/data/config/watcher-azimuth/merge-toml.js b/app/data/config/watcher-azimuth/merge-toml.js new file mode 100644 index 00000000..11b91b10 --- /dev/null +++ b/app/data/config/watcher-azimuth/merge-toml.js @@ -0,0 +1,33 @@ +const fs = require('fs'); +const tomlJS = require('toml-js'); +const toml = require('toml'); +const { merge } = require('lodash') + +const main = () => { + const overrideConfigString = fs.readFileSync('environments/watcher-config.toml', 'utf-8'); + const configString = fs.readFileSync('environments/local.toml', 'utf-8'); + const overrideConfig = toml.parse(overrideConfigString) + const config = toml.parse(configString) + + // Merge configs + const updatedConfig = merge(config, overrideConfig); + + // Form dbConnectionString for jobQueue DB + const parts = config.jobQueue.dbConnectionString.split("://"); + const credsAndDB = parts[1].split("@"); + const creds = credsAndDB[0].split(":"); + creds[0] = overrideConfig.database.username; + creds[1] = overrideConfig.database.password; + credsAndDB[0] = creds.join(":"); + const dbName = credsAndDB[1].split("/")[1] + credsAndDB[1] = [overrideConfig.database.host, dbName].join("/"); + parts[1] = credsAndDB.join("@"); + + updatedConfig.jobQueue.dbConnectionString = parts.join("://"); + + updatedConfig.jobQueue.dbConnectionString = parts.join("://"); + + fs.writeFileSync('environments/local.toml', tomlJS.dump(updatedConfig), 'utf-8'); +} + +main(); diff --git a/app/data/config/watcher-azimuth/start-server.sh b/app/data/config/watcher-azimuth/start-server.sh new file mode 100755 index 00000000..5df6a2d1 --- /dev/null +++ b/app/data/config/watcher-azimuth/start-server.sh @@ -0,0 +1,29 @@ +#!/bin/sh +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +CERC_IPLD_ETH_RPC="${CERC_IPLD_ETH_RPC:-${DEFAULT_CERC_IPLD_ETH_RPC}}" +CERC_IPLD_GQL="${CERC_IPLD_GQL:-${DEFAULT_CERC_IPLD_GQL}}" + +echo "Using IPLD ETH RPC endpoint ${CERC_IPLD_ETH_RPC}" +echo "Using IPLD GQL endpoint ${CERC_IPLD_GQL}" + +# # TODO: Replace env variables in template TOML file +# # Read in the config template TOML file and modify it +# WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) +# WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ +# sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \ +# s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ") + +# # Write the modified content to a new file +# echo "$WATCHER_CONFIG" > environments/watcher-config.toml + +# Merge SO watcher config with existing config file +yarn add --dev --ignore-scripts toml-js +node merge-toml.js + + +echo 'yarn server' +yarn server diff --git a/app/data/config/watcher-azimuth/watcher-config.toml b/app/data/config/watcher-azimuth/watcher-config.toml new file mode 100644 index 00000000..eb5711f2 --- /dev/null +++ b/app/data/config/watcher-azimuth/watcher-config.toml @@ -0,0 +1,13 @@ +[server] + host = "0.0.0.0" + +[database] + host = "watcher-db" + port = 5432 + username = "vdbm" + password = "password" + +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://host.docker.internal:8083/graphql" + rpcProviderEndpoint = "http://host.docker.internal:8082" From 3b4bc8d5cb47f3709cc6183b743640f8a675330a Mon Sep 17 00:00:00 2001 From: nabarun Date: Wed, 3 May 2023 18:14:06 +0530 Subject: [PATCH 3/7] Remove individual watcher configs --- .../watcher-configs/azimuth-watcher.toml | 66 ------------------- .../watcher-configs/censures-watcher.toml | 66 ------------------- 2 files changed, 132 deletions(-) delete mode 100644 app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml delete mode 100644 app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml diff --git a/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml b/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml deleted file mode 100644 index 936c0176..00000000 --- a/app/data/config/watcher-azimuth/watcher-configs/azimuth-watcher.toml +++ /dev/null @@ -1,66 +0,0 @@ -[server] - host = "0.0.0.0" - port = 3001 - kind = "lazy" - - # Checkpointing state. - checkpointing = true - - # Checkpoint interval in number of blocks. - checkpointInterval = 2000 - - # Enable state creation - # CAUTION: Disable only if state creation is not desired or can be filled subsequently - enableState = true - - # Boolean to filter logs by contract. - filterLogs = false - - # Max block range for which to return events in eventsInRange GQL query. - # Use -1 for skipping check on block range. - maxEventsBlockRange = 1000 - - # GQL cache settings - [server.gqlCache] - enabled = true - - # Max in-memory cache size (in bytes) (default 8 MB) - # maxCacheSize - - # GQL cache-control max-age settings (in seconds) - maxAge = 15 - -[metrics] - host = "127.0.0.1" - port = 9000 - [metrics.gql] - port = 9001 - -[database] - type = "postgres" - host = "watcher-db" - port = 5432 - database = "azimuth-watcher" - username = "vdbm" - password = "password" - synchronize = true - logging = false - -[upstream] - [upstream.ethServer] - gqlApiEndpoint = "http://host.docker.internal:8083/graphql" - rpcProviderEndpoint = "http://host.docker.internal:8082" - - [upstream.cache] - name = "requests" - enabled = false - deleteOnStart = false - -[jobQueue] - dbConnectionString = "postgres://vdbm:password@watcher-db/azimuth-watcher-job-queue" - maxCompletionLagInSecs = 300 - jobDelayInMilliSecs = 100 - eventsInBatch = 50 - blockDelayInMilliSecs = 2000 - prefetchBlocksInMem = true - prefetchBlockCount = 10 diff --git a/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml b/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml deleted file mode 100644 index 5caa692a..00000000 --- a/app/data/config/watcher-azimuth/watcher-configs/censures-watcher.toml +++ /dev/null @@ -1,66 +0,0 @@ -[server] - host = "0.0.0.0" - port = 3002 - kind = "lazy" - - # Checkpointing state. - checkpointing = true - - # Checkpoint interval in number of blocks. - checkpointInterval = 2000 - - # Enable state creation - # CAUTION: Disable only if state creation is not desired or can be filled subsequently - enableState = true - - # Boolean to filter logs by contract. - filterLogs = false - - # Max block range for which to return events in eventsInRange GQL query. - # Use -1 for skipping check on block range. - maxEventsBlockRange = 1000 - - # GQL cache settings - [server.gqlCache] - enabled = true - - # Max in-memory cache size (in bytes) (default 8 MB) - # maxCacheSize - - # GQL cache-control max-age settings (in seconds) - maxAge = 15 - -[metrics] - host = "127.0.0.1" - port = 9000 - [metrics.gql] - port = 9001 - -[database] - type = "postgres" - host = "watcher-db" - port = 5432 - database = "censures-watcher" - username = "vdbm" - password = "password" - synchronize = true - logging = false - -[upstream] - [upstream.ethServer] - gqlApiEndpoint = "http://host.docker.internal:8083/graphql" - rpcProviderEndpoint = "http://host.docker.internal:8082" - - [upstream.cache] - name = "requests" - enabled = false - deleteOnStart = false - -[jobQueue] - dbConnectionString = "postgres://vdbm:password@watcher-db/censures-watcher-job-queue" - maxCompletionLagInSecs = 300 - jobDelayInMilliSecs = 100 - eventsInBatch = 50 - blockDelayInMilliSecs = 2000 - prefetchBlocksInMem = true - prefetchBlockCount = 10 From 6d08758bc5205e4d75948f9c7aaac638d7713884 Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 4 May 2023 10:39:57 +0530 Subject: [PATCH 4/7] Add all azimuth watchers in stack --- .../docker-compose-watcher-azimuth.yml | 166 +++++++++++++++++- .../watcher-azimuth/gateway-watchers.json | 24 +++ .../config/watcher-azimuth/start-server.sh | 1 - .../cerc-watcher-azimuth/Dockerfile | 3 + 4 files changed, 190 insertions(+), 4 deletions(-) diff --git a/app/data/compose/docker-compose-watcher-azimuth.yml b/app/data/compose/docker-compose-watcher-azimuth.yml index 094eca94..54ee6d52 100644 --- a/app/data/compose/docker-compose-watcher-azimuth.yml +++ b/app/data/compose/docker-compose-watcher-azimuth.yml @@ -7,8 +7,8 @@ services: image: postgres:14-alpine environment: - POSTGRES_USER=vdbm - - POSTGRES_MULTIPLE_DATABASES=azimuth-watcher,azimuth-watcher-job-queue,censures-watcher,censures-watcher-job-queue,claims-watcher,claims-watcher-job-queue,conditional-star-release-watcher,conditional-star-release-watcher-job-queue,delegated-watcher,delegated-watcher-job-queue,ecliptic-watcher,ecliptic-watcher-job-queue,linear-star-release-watcher,linear-star-release-watcher-job-queue,polls-watcher,polls-watcher-job-queue - - POSTGRES_EXTENSION=azimuth-watcher-job-queue:pgcrypto,censures-watcher-job-queue:pgcrypto,claims-watcher-job-queue:pgcrypto,conditional-star-release-watcher-job-queue:pgcrypto,delegated-watcher-job-queue:pgcrypto,ecliptic-watcher-job-queue:pgcrypto,linear-star-release-watcher-job-queue:pgcrypto,polls-watcher-job-queue:pgcrypto, + - POSTGRES_MULTIPLE_DATABASES=azimuth-watcher,azimuth-watcher-job-queue,censures-watcher,censures-watcher-job-queue,claims-watcher,claims-watcher-job-queue,conditional-star-release-watcher,conditional-star-release-watcher-job-queue,delegated-sending-watcher,delegated-sending-watcher-job-queue,ecliptic-watcher,ecliptic-watcher-job-queue,linear-star-release-watcher,linear-star-release-watcher-job-queue,polls-watcher,polls-watcher-job-queue + - POSTGRES_EXTENSION=azimuth-watcher-job-queue:pgcrypto,censures-watcher-job-queue:pgcrypto,claims-watcher-job-queue:pgcrypto,conditional-star-release-watcher-job-queue:pgcrypto,delegated-sending-watcher-job-queue:pgcrypto,ecliptic-watcher-job-queue:pgcrypto,linear-star-release-watcher-job-queue:pgcrypto,polls-watcher-job-queue:pgcrypto, - POSTGRES_PASSWORD=password volumes: - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh @@ -37,6 +37,8 @@ services: - ../config/watcher-azimuth/watcher-config.toml:/app/packages/azimuth-watcher/environments/watcher-config.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/azimuth-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/azimuth-watcher/start-server.sh + ports: + - "3001" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3001"] interval: 20s @@ -46,7 +48,7 @@ services: extra_hosts: - "host.docker.internal:host-gateway" - # Starts the censures-watcher server + # Starts the censures-watcher server censures-watcher-server: image: cerc/watcher-azimuth:local restart: unless-stopped @@ -70,6 +72,150 @@ services: extra_hosts: - "host.docker.internal:host-gateway" + # Starts the claims-watcher server + claims-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/claims-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/claims-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/claims-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/claims-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3003"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the conditional-star-release-watcher server + conditional-star-release-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/conditional-star-release-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/conditional-star-release-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/conditional-star-release-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/conditional-star-release-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3004"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the delegated-sending-watcher server + delegated-sending-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/delegated-sending-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/delegated-sending-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/delegated-sending-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/delegated-sending-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3005"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the ecliptic-watcher server + ecliptic-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/ecliptic-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/ecliptic-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/ecliptic-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/ecliptic-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3006"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the linear-star-release-watcher server + linear-star-release-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/linear-star-release-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/linear-star-release-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/linear-star-release-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/linear-star-release-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3007"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + # Starts the polls-watcher server + polls-watcher-server: + image: cerc/watcher-azimuth:local + restart: unless-stopped + depends_on: + watcher-db: + condition: service_healthy + environment: + CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + working_dir: /app/packages/polls-watcher + command: "./start-server.sh" + volumes: + - ../config/watcher-azimuth/watcher-config.toml:/app/packages/polls-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/merge-toml.js:/app/packages/polls-watcher/merge-toml.js + - ../config/watcher-azimuth/start-server.sh:/app/packages/polls-watcher/start-server.sh + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "3008"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + # Starts the gateway-server for proxying queries gateway-server: image: cerc/watcher-azimuth:local @@ -77,6 +223,20 @@ services: depends_on: azimuth-watcher-server: condition: service_healthy + censures-watcher-server: + condition: service_healthy + claims-watcher-server: + condition: service_healthy + conditional-star-release-watcher-server: + condition: service_healthy + delegated-sending-watcher-server: + condition: service_healthy + ecliptic-watcher-server: + condition: service_healthy + linear-star-release-watcher-server: + condition: service_healthy + polls-watcher-server: + condition: service_healthy environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} working_dir: /app/packages/gateway-server diff --git a/app/data/config/watcher-azimuth/gateway-watchers.json b/app/data/config/watcher-azimuth/gateway-watchers.json index 550da348..40687556 100644 --- a/app/data/config/watcher-azimuth/gateway-watchers.json +++ b/app/data/config/watcher-azimuth/gateway-watchers.json @@ -6,5 +6,29 @@ { "endpoint": "http://censures-watcher-server:3002/graphql", "prefix": "censures" + }, + { + "endpoint": "http://claims-watcher-server:3003/graphql", + "prefix": "claims" + }, + { + "endpoint": "http://conditional-star-release-watcher-server:3004/graphql", + "prefix": "conditionalStarRelease" + }, + { + "endpoint": "http://delegated-sending-watcher-server:3005/graphql", + "prefix": "delegatedSending" + }, + { + "endpoint": "http://ecliptic-watcher-server:3006/graphql", + "prefix": "ecliptic" + }, + { + "endpoint": "http://linear-star-release-watcher-server:3007/graphql", + "prefix": "linearStarRelease" + }, + { + "endpoint": "http://polls-watcher-server:3008/graphql", + "prefix": "polls" } ] diff --git a/app/data/config/watcher-azimuth/start-server.sh b/app/data/config/watcher-azimuth/start-server.sh index 5df6a2d1..c49f2634 100755 --- a/app/data/config/watcher-azimuth/start-server.sh +++ b/app/data/config/watcher-azimuth/start-server.sh @@ -21,7 +21,6 @@ echo "Using IPLD GQL endpoint ${CERC_IPLD_GQL}" # echo "$WATCHER_CONFIG" > environments/watcher-config.toml # Merge SO watcher config with existing config file -yarn add --dev --ignore-scripts toml-js node merge-toml.js diff --git a/app/data/container-build/cerc-watcher-azimuth/Dockerfile b/app/data/container-build/cerc-watcher-azimuth/Dockerfile index 4cd65a0d..8c299257 100644 --- a/app/data/container-build/cerc-watcher-azimuth/Dockerfile +++ b/app/data/container-build/cerc-watcher-azimuth/Dockerfile @@ -8,3 +8,6 @@ COPY . . RUN echo "Building azimuth-watcher-ts" && \ yarn && yarn build + +RUN echo "Install toml-js to update watcher config files" && \ + yarn add --dev toml-js From ddf756c68c7ff05dedd2494d00fdb9bb51a0435d Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 4 May 2023 13:36:29 +0530 Subject: [PATCH 5/7] Fix toml-js install --- app/data/container-build/cerc-watcher-azimuth/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-watcher-azimuth/Dockerfile b/app/data/container-build/cerc-watcher-azimuth/Dockerfile index 8c299257..eaf717aa 100644 --- a/app/data/container-build/cerc-watcher-azimuth/Dockerfile +++ b/app/data/container-build/cerc-watcher-azimuth/Dockerfile @@ -10,4 +10,4 @@ RUN echo "Building azimuth-watcher-ts" && \ yarn && yarn build RUN echo "Install toml-js to update watcher config files" && \ - yarn add --dev toml-js + yarn add --dev --ignore-workspace-root-check toml-js From 3e8b87c3a793e9f9d712c8b9d8d242c345d79b87 Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 4 May 2023 14:54:47 +0530 Subject: [PATCH 6/7] Use env variables for ipld-eth-server endpoints --- .../docker-compose-watcher-azimuth.yml | 62 ++++++++++++++++--- .../config/watcher-azimuth/start-server.sh | 21 +++---- ...nfig.toml => watcher-config-template.toml} | 5 +- .../config/watcher-azimuth/watcher-params.env | 5 ++ app/data/stacks/azimuth/README.md | 22 +++++-- 5 files changed, 90 insertions(+), 25 deletions(-) rename app/data/config/watcher-azimuth/{watcher-config.toml => watcher-config-template.toml} (51%) create mode 100644 app/data/config/watcher-azimuth/watcher-params.env diff --git a/app/data/compose/docker-compose-watcher-azimuth.yml b/app/data/compose/docker-compose-watcher-azimuth.yml index 54ee6d52..327c77fc 100644 --- a/app/data/compose/docker-compose-watcher-azimuth.yml +++ b/app/data/compose/docker-compose-watcher-azimuth.yml @@ -29,12 +29,16 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/azimuth-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/azimuth-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/azimuth-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/azimuth-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/azimuth-watcher/start-server.sh ports: @@ -55,14 +59,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/censures-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/censures-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/censures-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/censures-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/censures-watcher/start-server.sh + ports: + - "3002" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3002"] interval: 20s @@ -79,14 +89,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/claims-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/claims-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/claims-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/claims-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/claims-watcher/start-server.sh + ports: + - "3003" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3003"] interval: 20s @@ -103,14 +119,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/conditional-star-release-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/conditional-star-release-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/conditional-star-release-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/conditional-star-release-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/conditional-star-release-watcher/start-server.sh + ports: + - "3004" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3004"] interval: 20s @@ -127,14 +149,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/delegated-sending-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/delegated-sending-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/delegated-sending-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/delegated-sending-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/delegated-sending-watcher/start-server.sh + ports: + - "3005" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3005"] interval: 20s @@ -151,14 +179,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/ecliptic-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/ecliptic-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/ecliptic-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/ecliptic-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/ecliptic-watcher/start-server.sh + ports: + - "3006" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3006"] interval: 20s @@ -175,14 +209,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/linear-star-release-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/linear-star-release-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/linear-star-release-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/linear-star-release-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/linear-star-release-watcher/start-server.sh + ports: + - "3007" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3007"] interval: 20s @@ -199,14 +239,20 @@ services: depends_on: watcher-db: condition: service_healthy + env_file: + - ../config/watcher-azimuth/watcher-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_IPLD_ETH_RPC: ${CERC_IPLD_ETH_RPC} + CERC_IPLD_ETH_GQL: ${CERC_IPLD_ETH_GQL} working_dir: /app/packages/polls-watcher command: "./start-server.sh" volumes: - - ../config/watcher-azimuth/watcher-config.toml:/app/packages/polls-watcher/environments/watcher-config.toml + - ../config/watcher-azimuth/watcher-config-template.toml:/app/packages/polls-watcher/environments/watcher-config-template.toml - ../config/watcher-azimuth/merge-toml.js:/app/packages/polls-watcher/merge-toml.js - ../config/watcher-azimuth/start-server.sh:/app/packages/polls-watcher/start-server.sh + ports: + - "3008" healthcheck: test: ["CMD", "nc", "-vz", "localhost", "3008"] interval: 20s diff --git a/app/data/config/watcher-azimuth/start-server.sh b/app/data/config/watcher-azimuth/start-server.sh index c49f2634..c84c58d0 100755 --- a/app/data/config/watcher-azimuth/start-server.sh +++ b/app/data/config/watcher-azimuth/start-server.sh @@ -5,24 +5,23 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then fi CERC_IPLD_ETH_RPC="${CERC_IPLD_ETH_RPC:-${DEFAULT_CERC_IPLD_ETH_RPC}}" -CERC_IPLD_GQL="${CERC_IPLD_GQL:-${DEFAULT_CERC_IPLD_GQL}}" +CERC_IPLD_ETH_GQL="${CERC_IPLD_ETH_GQL:-${DEFAULT_CERC_IPLD_ETH_GQL}}" echo "Using IPLD ETH RPC endpoint ${CERC_IPLD_ETH_RPC}" -echo "Using IPLD GQL endpoint ${CERC_IPLD_GQL}" +echo "Using IPLD GQL endpoint ${CERC_IPLD_ETH_GQL}" -# # TODO: Replace env variables in template TOML file -# # Read in the config template TOML file and modify it -# WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) -# WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ -# sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \ -# s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ") +# Replace env variables in template TOML file +# Read in the config template TOML file and modify it +WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) +WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ + sed -E "s|REPLACE_WITH_CERC_IPLD_ETH_RPC|${CERC_IPLD_ETH_RPC}|g; \ + s|REPLACE_WITH_CERC_IPLD_ETH_GQL|${CERC_IPLD_ETH_GQL}| ") -# # Write the modified content to a new file -# echo "$WATCHER_CONFIG" > environments/watcher-config.toml +# Write the modified content to a new file +echo "$WATCHER_CONFIG" > environments/watcher-config.toml # Merge SO watcher config with existing config file node merge-toml.js - echo 'yarn server' yarn server diff --git a/app/data/config/watcher-azimuth/watcher-config.toml b/app/data/config/watcher-azimuth/watcher-config-template.toml similarity index 51% rename from app/data/config/watcher-azimuth/watcher-config.toml rename to app/data/config/watcher-azimuth/watcher-config-template.toml index eb5711f2..1a4616fc 100644 --- a/app/data/config/watcher-azimuth/watcher-config.toml +++ b/app/data/config/watcher-azimuth/watcher-config-template.toml @@ -1,5 +1,6 @@ [server] host = "0.0.0.0" + maxSimultaneousRequests = -1 [database] host = "watcher-db" @@ -9,5 +10,5 @@ [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://host.docker.internal:8083/graphql" - rpcProviderEndpoint = "http://host.docker.internal:8082" + gqlApiEndpoint = "REPLACE_WITH_CERC_IPLD_ETH_GQL" + rpcProviderEndpoint = "REPLACE_WITH_CERC_IPLD_ETH_RPC" diff --git a/app/data/config/watcher-azimuth/watcher-params.env b/app/data/config/watcher-azimuth/watcher-params.env new file mode 100644 index 00000000..8fcdc2d6 --- /dev/null +++ b/app/data/config/watcher-azimuth/watcher-params.env @@ -0,0 +1,5 @@ +# Defaults + +# ipld-eth-server endpoints +DEFAULT_CERC_IPLD_ETH_RPC= +DEFAULT_CERC_IPLD_ETH_GQL= diff --git a/app/data/stacks/azimuth/README.md b/app/data/stacks/azimuth/README.md index ecd2a730..baa5f116 100644 --- a/app/data/stacks/azimuth/README.md +++ b/app/data/stacks/azimuth/README.md @@ -4,13 +4,15 @@ Instructions to setup and deploy Azimuth Watcher stack ## Setup +Prerequisite: ipld-eth-server RPC and GQL endpoints + Clone required repositories: ```bash laconic-so --stack azimuth setup-repositories ``` -NOTE: If the repository already exists and checked out to different versions, `setup-repositories` command will throw an error. +NOTE: If the repository already exists and checked out to a different version, `setup-repositories` command will throw an error. For getting around this, the `azimuth-watcher-ts` repository can be removed and then run the command. Checkout to the required versions and branches in repos @@ -29,12 +31,24 @@ laconic-so --stack azimuth build-containers This should create the required docker images in the local image registry. -Deploy the stack: +### Configuration + +* Create and update an env file to be used in the next step: + + ```bash + # External ipld-eth-server endpoints + CERC_IPLD_ETH_RPC= + CERC_IPLD_ETH_GQL= + ``` + +* NOTE: If ipld-eth-server is running on the host machine, use `host.docker.internal` as the hostname to access host ports + +### Deploy the stack * Deploy the containers: ```bash - laconic-so --stack azimuth deploy-system up + laconic-so --stack azimuth deploy-system --env-file up ``` * List and check the health status of all the containers using `docker ps` and wait for them to be `healthy` @@ -44,7 +58,7 @@ Deploy the stack: Stop all the services running in background run: ```bash -laconic-so --stack azimuth deploy-system down 30 +laconic-so --stack azimuth deploy-system down ``` Clear volumes created by this stack: From dc9be1b260802d78898a2aaabd936ddc7b7a972d Mon Sep 17 00:00:00 2001 From: nabarun Date: Thu, 4 May 2023 15:24:54 +0530 Subject: [PATCH 7/7] Checkout to version tag in azimuth-watcher-ts repo --- app/data/config/watcher-azimuth/merge-toml.js | 2 -- app/data/stacks/azimuth/README.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/data/config/watcher-azimuth/merge-toml.js b/app/data/config/watcher-azimuth/merge-toml.js index 11b91b10..9224baec 100644 --- a/app/data/config/watcher-azimuth/merge-toml.js +++ b/app/data/config/watcher-azimuth/merge-toml.js @@ -25,8 +25,6 @@ const main = () => { updatedConfig.jobQueue.dbConnectionString = parts.join("://"); - updatedConfig.jobQueue.dbConnectionString = parts.join("://"); - fs.writeFileSync('environments/local.toml', tomlJS.dump(updatedConfig), 'utf-8'); } diff --git a/app/data/stacks/azimuth/README.md b/app/data/stacks/azimuth/README.md index baa5f116..d3e377da 100644 --- a/app/data/stacks/azimuth/README.md +++ b/app/data/stacks/azimuth/README.md @@ -20,7 +20,7 @@ Checkout to the required versions and branches in repos ```bash # azimuth-watcher-ts cd ~/cerc/azimuth-watcher-ts -# git checkout v0.1.0 +git checkout v0.1.0 ``` Build the container images: