From 7972e5f88d712a618a53a0ec03c8650b2e8dab5e Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Mon, 7 Aug 2023 19:09:42 +0530 Subject: [PATCH 1/9] Add a sushiswap stack with contract deployments --- .../docker-compose-watcher-sushiswap.yml | 14 +++++++++++ .../watcher-sushiswap/contract-deployment.env | 3 +++ .../cerc-sushiswap-v3-core/Dockerfile | 14 +++++++++++ .../cerc-sushiswap-v3-core/build.sh | 7 ++++++ .../cerc-sushiswap-v3-periphery/Dockerfile | 13 ++++++++++ .../cerc-sushiswap-v3-periphery/build.sh | 7 ++++++ app/data/container-image-list.txt | 2 ++ app/data/pod-list.txt | 1 + app/data/repository-list.txt | 2 ++ app/data/stacks/sushiswap/README.md | 25 +++++++++++++++++++ app/data/stacks/sushiswap/stack.yml | 18 +++++++++++++ 11 files changed, 106 insertions(+) create mode 100644 app/data/compose/docker-compose-watcher-sushiswap.yml create mode 100644 app/data/config/watcher-sushiswap/contract-deployment.env create mode 100644 app/data/container-build/cerc-sushiswap-v3-core/Dockerfile create mode 100755 app/data/container-build/cerc-sushiswap-v3-core/build.sh create mode 100644 app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile create mode 100755 app/data/container-build/cerc-sushiswap-v3-periphery/build.sh create mode 100644 app/data/stacks/sushiswap/README.md create mode 100644 app/data/stacks/sushiswap/stack.yml diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml new file mode 100644 index 00000000..946ba6da --- /dev/null +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -0,0 +1,14 @@ +version: '3.2' + +services: + # Deploys the core (UniswapV3Factory) contract + sushiswap-v3-core: + image: cerc/sushiswap-v3-core:local + env_file: + - ../config/watcher-sushiswap/contract-deployment.env + + # Deploys the periphery (NFPM, token, etc.) contracts + sushiswap-v3-periphery: + image: cerc/sushiswap-v3-periphery:local + env_file: + - ../config/watcher-sushiswap/contract-deployment.env diff --git a/app/data/config/watcher-sushiswap/contract-deployment.env b/app/data/config/watcher-sushiswap/contract-deployment.env new file mode 100644 index 00000000..8cd749dc --- /dev/null +++ b/app/data/config/watcher-sushiswap/contract-deployment.env @@ -0,0 +1,3 @@ +ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" +CHAIN_ID=31415926 +ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" diff --git a/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile b/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile new file mode 100644 index 00000000..993897d4 --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-v3-core/Dockerfile @@ -0,0 +1,14 @@ +FROM node:18.15.0-alpine3.16 + +RUN apk --update --no-cache add git python3 alpine-sdk bash +RUN curl -L https://unpkg.com/@pnpm/self-installer | node + +WORKDIR /app + +COPY . . + +RUN echo "Installing dependencies..." && \ + pnpm install + +# Keep container running for commands to be executed +CMD ["tail", "-f"] diff --git a/app/data/container-build/cerc-sushiswap-v3-core/build.sh b/app/data/container-build/cerc-sushiswap-v3-core/build.sh new file mode 100755 index 00000000..74533781 --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-v3-core/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Build cerc/sushiswap-v3-core +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/sushiswap-v3-core:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/sushiswap-v3-core diff --git a/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile b/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile new file mode 100644 index 00000000..4fcf712c --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-v3-periphery/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18.15.0-alpine3.16 + +RUN apk --update --no-cache add git python3 alpine-sdk bash + +WORKDIR /app + +COPY . . + +RUN echo "Installing dependencies..." && \ + yarn install + +# Keep container running for commands to be executed +CMD ["tail", "-f"] diff --git a/app/data/container-build/cerc-sushiswap-v3-periphery/build.sh b/app/data/container-build/cerc-sushiswap-v3-periphery/build.sh new file mode 100755 index 00000000..d7157025 --- /dev/null +++ b/app/data/container-build/cerc-sushiswap-v3-periphery/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Build cerc/sushiswap-v3-periphery +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/sushiswap-v3-periphery:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/sushiswap-v3-periphery diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 43781f8a..4f6534c8 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -44,3 +44,5 @@ cerc/lotus cerc/go-opera cerc/lasso cerc/reth +cerc/sushiswap-v3-core +cerc/sushiswap-v3-periphery diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index 97a7f369..5355c90e 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -30,3 +30,4 @@ fixturenet-lotus mainnet-go-opera lasso reth +watcher-sushiswap diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index e2cd263b..a3509035 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -39,3 +39,5 @@ github.com/cerc-io/lasso github.com/paradigmxyz/reth git.vdb.to/cerc-io/plugeth git.vdb.to/cerc-io/plugeth-statediff +github.com/cerc-io/sushiswap-v3-core +github.com/cerc-io/sushiswap-v3-periphery diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md new file mode 100644 index 00000000..42cde33d --- /dev/null +++ b/app/data/stacks/sushiswap/README.md @@ -0,0 +1,25 @@ +# SushiSwap + +## Setup + +Clone required repositories: + +```bash +laconic-so --stack sushiswap setup-repositories + +# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the conflicting repositories and re-run the command +``` + +Build the container images: + +```bash +laconic-so --stack sushiswap build-containers +``` + +## Deploy + +Deploy the stack: + +```bash +laconic-so --stack sushiswap deploy --cluster lotus up +``` diff --git a/app/data/stacks/sushiswap/stack.yml b/app/data/stacks/sushiswap/stack.yml new file mode 100644 index 00000000..b4506cbf --- /dev/null +++ b/app/data/stacks/sushiswap/stack.yml @@ -0,0 +1,18 @@ +version: "1.0" +name: sushiswap +description: "End-to-end SushiSwap watcher stack" +repos: + ## fixturenet-lotus repo + - github.com/filecoin-project/lotus + ## sushiswap repos + - github.com/cerc-io/sushiswap-v3-core + - github.com/cerc-io/sushiswap-v3-periphery +containers: + ## fixturenet-lotus image + - cerc/lotus + ## sushiswap images + - cerc/sushiswap-v3-core + - cerc/sushiswap-v3-periphery +pods: + - fixturenet-lotus + - watcher-sushiswap From d1d06e9aed1b3d73c85b10b5123b83dc04bfd632 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Tue, 8 Aug 2023 10:40:33 +0530 Subject: [PATCH 2/9] Add watcher services --- .../docker-compose-watcher-sushiswap.yml | 153 ++++++++++++++++++ .../watcher-sushiswap/erc20-watcher.toml | 40 +++++ .../watcher-sushiswap/sushi-info-watcher.toml | 91 +++++++++++ .../watcher-sushiswap/sushi-watcher.toml | 42 +++++ .../cerc-watcher-sushiswap/Dockerfile | 11 ++ .../cerc-watcher-sushiswap/build.sh | 9 ++ app/data/container-image-list.txt | 1 + app/data/stacks/sushiswap/stack.yml | 1 + 8 files changed, 348 insertions(+) create mode 100644 app/data/config/watcher-sushiswap/erc20-watcher.toml create mode 100644 app/data/config/watcher-sushiswap/sushi-info-watcher.toml create mode 100644 app/data/config/watcher-sushiswap/sushi-watcher.toml create mode 100644 app/data/container-build/cerc-watcher-sushiswap/Dockerfile create mode 100755 app/data/container-build/cerc-watcher-sushiswap/build.sh diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index 946ba6da..285dcaf7 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -1,6 +1,156 @@ version: '3.2' services: + sushiswap-watcher-db: + restart: unless-stopped + image: postgres:14-alpine + environment: + - POSTGRES_USER=vdbm + - POSTGRES_MULTIPLE_DATABASES=erc20-watcher,sushi-watcher,sushi-info-watcher,erc20-watcher-job-queue,sushi-watcher-job-queue,sushi-info-watcher-job-queue + - POSTGRES_EXTENSION=erc20-watcher-job-queue:pgcrypto,sushi-watcher-job-queue:pgcrypto,sushi-info-watcher-job-queue:pgcrypto + - POSTGRES_PASSWORD=password + command: ["postgres", "-c", "shared_preload_libraries=pg_stat_statements", "-c", "pg_stat_statements.track=all", "-c", "work_mem=2GB"] + volumes: + - ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh + - ../config/postgresql/create-pg-stat-statements.sql:/docker-entrypoint-initdb.d/create-pg-stat-statements.sql + - sushiswap_watcher_db_data:/var/lib/postgresql/data + ports: + - "0.0.0.0:15435:5432" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + shm_size: '8GB' + + erc20-watcher-server: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + image: cerc/watcher-sushiswap:local + working_dir: /app/packages/erc20-watcher + environment: + - DEBUG=vulcanize:* + command: ["node", "--enable-source-maps", "dist/server.js"] + volumes: + - ../config/watcher-sushiswap/erc20-watcher.toml:/app/packages/erc20-watcher/environments/local.toml + ports: + - "0.0.0.0:3005:3001" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3001"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + sushi-watcher-job-runner: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + image: cerc/watcher-sushiswap:local + working_dir: /app/packages/uni-watcher + environment: + - DEBUG=vulcanize:* + command: ["node", "--enable-source-maps", "dist/job-runner.js"] + volumes: + - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + ports: + - "0.0.0.0:9004:9000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "9000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + sushi-watcher-server: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + sushi-watcher-job-runner: + condition: service_healthy + image: cerc/watcher-sushiswap:local + environment: + - DEBUG=vulcanize:* + working_dir: /app/packages/uni-watcher + command: ["node", "--enable-source-maps", "dist/server.js"] + volumes: + - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + ports: + - "0.0.0.0:3003:3003" + - "0.0.0.0:9005:9001" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3003"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + sushi-info-watcher-job-runner: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + erc20-watcher-server: + condition: service_healthy + sushi-watcher-server: + condition: service_healthy + image: cerc/watcher-sushiswap:local + working_dir: /app/packages/uni-info-watcher + environment: + - DEBUG=vulcanize:* + command: ["node", "--enable-source-maps", "dist/job-runner.js"] + volumes: + - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + ports: + - "0.0.0.0:9006:9002" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "9002"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + + sushi-info-watcher-server: + restart: unless-stopped + depends_on: + sushiswap-watcher-db: + condition: service_healthy + erc20-watcher-server: + condition: service_healthy + sushi-watcher-server: + condition: service_healthy + sushi-info-watcher-job-runner: + condition: service_healthy + image: cerc/watcher-sushiswap:local + working_dir: /app/packages/uni-info-watcher + command: ["node", "--enable-source-maps", "dist/server.js"] + volumes: + - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + ports: + - "0.0.0.0:3004:3004" + - "0.0.0.0:9007:9003" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3004"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 5s + extra_hosts: + - "host.docker.internal:host-gateway" + # Deploys the core (UniswapV3Factory) contract sushiswap-v3-core: image: cerc/sushiswap-v3-core:local @@ -12,3 +162,6 @@ services: image: cerc/sushiswap-v3-periphery:local env_file: - ../config/watcher-sushiswap/contract-deployment.env + +volumes: + uniswap_watcher_db_data: diff --git a/app/data/config/watcher-sushiswap/erc20-watcher.toml b/app/data/config/watcher-sushiswap/erc20-watcher.toml new file mode 100644 index 00000000..f8882829 --- /dev/null +++ b/app/data/config/watcher-sushiswap/erc20-watcher.toml @@ -0,0 +1,40 @@ +[server] + host = "0.0.0.0" + port = 3001 + mode = "eth_call" + kind = "lazy" + +[metrics] + host = "127.0.0.1" + port = 9000 + [metrics.gql] + port = 9001 + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "erc20-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +# TODO: Update to use rpc-eth-client +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" + rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/erc20-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 100 + eventsInBatch = 50 + blockDelayInMilliSecs = 2000 diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml new file mode 100644 index 00000000..3bf3e288 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml @@ -0,0 +1,91 @@ +[server] + host = "0.0.0.0" + port = 3004 + mode = "prod" + kind = "active" + + # Checkpointing state. + checkpointing = true + + # Checkpoint interval in number of blocks. + checkpointInterval = 50000 + + # Enable state creation + enableState = false + + # Max block range for which to return events in eventsInRange GQL query. + # Use -1 for skipping check on block range. + maxEventsBlockRange = 1000 + + # Interval in number of blocks at which to clear entities cache. + clearEntitiesCacheInterval = 1000 + + # Boolean to skip updating entity fields required in state creation and not required in the frontend. + skipStateFieldsUpdate = false + + # Boolean to load GQL query nested entity relations sequentially. + loadRelationsSequential = false + + # Max GQL API requests to process simultaneously (defaults to 1). + maxSimultaneousRequests = 1 + + # 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 + timeTravelMaxAge = 86400 # 1 day + +[metrics] + host = "0.0.0.0" + port = 9002 + [metrics.gql] + port = 9003 + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-info-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + + [database.extra] + # maximum number of clients the pool should contain + max = 20 + +# TODO: Update to use rpc-eth-client +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" + rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + + [upstream.uniWatcher] + gqlEndpoint = "http://sushi-watcher-server:3003/graphql" + gqlSubscriptionEndpoint = "ws://sushi-watcher-server:3003/graphql" + + [upstream.tokenWatcher] + gqlEndpoint = "http://erc20-watcher-server:3001/graphql" + gqlSubscriptionEndpoint = "ws://erc20-watcher-server:3001/graphql" + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-info-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 1000 + eventsInBatch = 50 + subgraphEventsOrder = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-watcher.toml b/app/data/config/watcher-sushiswap/sushi-watcher.toml new file mode 100644 index 00000000..d386f5b6 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-watcher.toml @@ -0,0 +1,42 @@ +[server] + host = "0.0.0.0" + port = 3003 + kind = "active" + +[metrics] + host = "0.0.0.0" + port = 9000 + [metrics.gql] + port = 9001 + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +# TODO: Update to use rpc-eth-client +[upstream] + [upstream.ethServer] + gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" + rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 0 + eventsInBatch = 50 + lazyUpdateBlockProgress = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/container-build/cerc-watcher-sushiswap/Dockerfile b/app/data/container-build/cerc-watcher-sushiswap/Dockerfile new file mode 100644 index 00000000..4c2eb15f --- /dev/null +++ b/app/data/container-build/cerc-watcher-sushiswap/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18.15.0-alpine3.16 + +RUN apk --update --no-cache add git python3 alpine-sdk bash + +WORKDIR /app + +COPY . . + +RUN echo "Building uniswap-watcher-ts" && \ + git checkout sushiswap && \ + yarn && yarn build && yarn build:contracts diff --git a/app/data/container-build/cerc-watcher-sushiswap/build.sh b/app/data/container-build/cerc-watcher-sushiswap/build.sh new file mode 100755 index 00000000..1a3762f2 --- /dev/null +++ b/app/data/container-build/cerc-watcher-sushiswap/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Build cerc/watcher-sushiswap + +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-sushiswap:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/uniswap-watcher-ts diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 4f6534c8..444ee995 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -46,3 +46,4 @@ cerc/lasso cerc/reth cerc/sushiswap-v3-core cerc/sushiswap-v3-periphery +cerc/watcher-sushiswap diff --git a/app/data/stacks/sushiswap/stack.yml b/app/data/stacks/sushiswap/stack.yml index b4506cbf..65e685ca 100644 --- a/app/data/stacks/sushiswap/stack.yml +++ b/app/data/stacks/sushiswap/stack.yml @@ -13,6 +13,7 @@ containers: ## sushiswap images - cerc/sushiswap-v3-core - cerc/sushiswap-v3-periphery + - cerc/watcher-sushiswap pods: - fixturenet-lotus - watcher-sushiswap From 78d482c7a0919ba4bbd3063c713a3a007735a6d4 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Tue, 8 Aug 2023 10:49:40 +0530 Subject: [PATCH 3/9] Add a service for the info app --- app/data/compose/docker-compose-watcher-sushiswap.yml | 8 ++++++++ app/data/stacks/sushiswap/stack.yml | 3 +++ 2 files changed, 11 insertions(+) diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index 285dcaf7..915f39cd 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -151,6 +151,14 @@ services: extra_hosts: - "host.docker.internal:host-gateway" + sushiswap-v3-info: + depends_on: + sushi-info-watcher-server: + condition: service_healthy + image: cerc/uniswap-v3-info:local + ports: + - "0.0.0.0:3006:3000" + # Deploys the core (UniswapV3Factory) contract sushiswap-v3-core: image: cerc/sushiswap-v3-core:local diff --git a/app/data/stacks/sushiswap/stack.yml b/app/data/stacks/sushiswap/stack.yml index 65e685ca..44969e3a 100644 --- a/app/data/stacks/sushiswap/stack.yml +++ b/app/data/stacks/sushiswap/stack.yml @@ -7,6 +7,8 @@ repos: ## sushiswap repos - github.com/cerc-io/sushiswap-v3-core - github.com/cerc-io/sushiswap-v3-periphery + - github.com/vulcanize/uniswap-watcher-ts + - github.com/vulcanize/uniswap-v3-info containers: ## fixturenet-lotus image - cerc/lotus @@ -14,6 +16,7 @@ containers: - cerc/sushiswap-v3-core - cerc/sushiswap-v3-periphery - cerc/watcher-sushiswap + - cerc/uniswap-v3-info pods: - fixturenet-lotus - watcher-sushiswap From 4992554c9a562956c1d2b851a35706b6aedfde04 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Tue, 8 Aug 2023 16:52:51 +0530 Subject: [PATCH 4/9] Add instructions to run smoke tests --- .../docker-compose-watcher-sushiswap.yml | 12 ++- .../watcher-sushiswap/erc20-watcher.toml | 5 +- ...ntract-deployment.env => lotus-params.env} | 3 + .../sushi-info-watcher-test.toml | 45 +++++++++++ .../watcher-sushiswap/sushi-info-watcher.toml | 5 +- .../watcher-sushiswap/sushi-watcher-test.toml | 34 ++++++++ .../watcher-sushiswap/sushi-watcher.toml | 5 +- app/data/stacks/sushiswap/README.md | 24 +++++- app/data/stacks/sushiswap/smoke-tests.md | 77 +++++++++++++++++++ 9 files changed, 198 insertions(+), 12 deletions(-) rename app/data/config/watcher-sushiswap/{contract-deployment.env => lotus-params.env} (67%) create mode 100644 app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml create mode 100644 app/data/config/watcher-sushiswap/sushi-watcher-test.toml create mode 100644 app/data/stacks/sushiswap/smoke-tests.md diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index 915f39cd..f5c5c0b9 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -59,6 +59,7 @@ services: command: ["node", "--enable-source-maps", "dist/job-runner.js"] volumes: - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-watcher-test.toml:/app/packages/uni-watcher/environments/test.toml ports: - "0.0.0.0:9004:9000" healthcheck: @@ -78,12 +79,15 @@ services: sushi-watcher-job-runner: condition: service_healthy image: cerc/watcher-sushiswap:local + env_file: + - ../config/watcher-sushiswap/lotus-params.env environment: - DEBUG=vulcanize:* working_dir: /app/packages/uni-watcher command: ["node", "--enable-source-maps", "dist/server.js"] volumes: - ../config/watcher-sushiswap/sushi-watcher.toml:/app/packages/uni-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-watcher-test.toml:/app/packages/uni-watcher/environments/test.toml ports: - "0.0.0.0:3003:3003" - "0.0.0.0:9005:9001" @@ -112,6 +116,7 @@ services: command: ["node", "--enable-source-maps", "dist/job-runner.js"] volumes: - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-info-watcher-test.toml:/app/packages/uni-info-watcher/environments/test.toml ports: - "0.0.0.0:9006:9002" healthcheck: @@ -135,10 +140,13 @@ services: sushi-info-watcher-job-runner: condition: service_healthy image: cerc/watcher-sushiswap:local + env_file: + - ../config/watcher-sushiswap/lotus-params.env working_dir: /app/packages/uni-info-watcher command: ["node", "--enable-source-maps", "dist/server.js"] volumes: - ../config/watcher-sushiswap/sushi-info-watcher.toml:/app/packages/uni-info-watcher/environments/local.toml + - ../config/watcher-sushiswap/sushi-info-watcher-test.toml:/app/packages/uni-info-watcher/environments/test.toml ports: - "0.0.0.0:3004:3004" - "0.0.0.0:9007:9003" @@ -163,13 +171,13 @@ services: sushiswap-v3-core: image: cerc/sushiswap-v3-core:local env_file: - - ../config/watcher-sushiswap/contract-deployment.env + - ../config/watcher-sushiswap/lotus-params.env # Deploys the periphery (NFPM, token, etc.) contracts sushiswap-v3-periphery: image: cerc/sushiswap-v3-periphery:local env_file: - - ../config/watcher-sushiswap/contract-deployment.env + - ../config/watcher-sushiswap/lotus-params.env volumes: uniswap_watcher_db_data: diff --git a/app/data/config/watcher-sushiswap/erc20-watcher.toml b/app/data/config/watcher-sushiswap/erc20-watcher.toml index f8882829..65dc1a2f 100644 --- a/app/data/config/watcher-sushiswap/erc20-watcher.toml +++ b/app/data/config/watcher-sushiswap/erc20-watcher.toml @@ -21,11 +21,10 @@ logging = false maxQueryExecutionTime = 100 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/config/watcher-sushiswap/contract-deployment.env b/app/data/config/watcher-sushiswap/lotus-params.env similarity index 67% rename from app/data/config/watcher-sushiswap/contract-deployment.env rename to app/data/config/watcher-sushiswap/lotus-params.env index 8cd749dc..dc132361 100644 --- a/app/data/config/watcher-sushiswap/contract-deployment.env +++ b/app/data/config/watcher-sushiswap/lotus-params.env @@ -1,3 +1,6 @@ +# Lotus node config ETH_RPC_ENDPOINT="http://lotus-node-1:1234/rpc/v1" CHAIN_ID=31415926 + +# From app/data/config/fixturenet-lotus/fund-account.sh ACCOUNT_PRIVATE_KEY="0xc05fd3613bcd62a4f25e5eba1f464d0b76d74c3f771a7c2f13e26ad6439444b3" diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml new file mode 100644 index 00000000..e8f2d935 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml @@ -0,0 +1,45 @@ +[server] + host = "0.0.0.0" + port = 3004 + # Use mode demo when running watcher locally. + # Mode demo whitelists all tokens so that entity values get updated. + mode = "demo" + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-info-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +[upstream] + [upstream.ethServer] + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + + [upstream.uniWatcher] + gqlEndpoint = "http://sushi-watcher-server:3003/graphql" + gqlSubscriptionEndpoint = "ws://sushi-watcher-server:3003/graphql" + + [upstream.tokenWatcher] + gqlEndpoint = "http://erc20-watcher-server:3001/graphql" + gqlSubscriptionEndpoint = "ws://erc20-watcher-server:3001/graphql" + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-info-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 1000 + eventsInBatch = 50 + subgraphEventsOrder = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = true + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml index 3bf3e288..2a300831 100644 --- a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml @@ -61,11 +61,10 @@ # maximum number of clients the pool should contain max = 20 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/config/watcher-sushiswap/sushi-watcher-test.toml b/app/data/config/watcher-sushiswap/sushi-watcher-test.toml new file mode 100644 index 00000000..0420cf75 --- /dev/null +++ b/app/data/config/watcher-sushiswap/sushi-watcher-test.toml @@ -0,0 +1,34 @@ +[server] + host = "0.0.0.0" + port = 3003 + +[database] + type = "postgres" + host = "sushiswap-watcher-db" + port = 5432 + database = "sushi-watcher" + username = "vdbm" + password = "password" + synchronize = true + logging = false + maxQueryExecutionTime = 100 + +[upstream] + [upstream.ethServer] + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true + + [upstream.cache] + name = "requests" + enabled = false + deleteOnStart = false + +[jobQueue] + dbConnectionString = "postgres://vdbm:password@sushiswap-watcher-db:5432/sushi-watcher-job-queue" + maxCompletionLagInSecs = 300 + jobDelayInMilliSecs = 0 + eventsInBatch = 50 + lazyUpdateBlockProgress = true + blockDelayInMilliSecs = 2000 + prefetchBlocksInMem = false + prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-watcher.toml b/app/data/config/watcher-sushiswap/sushi-watcher.toml index d386f5b6..d8dfa594 100644 --- a/app/data/config/watcher-sushiswap/sushi-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-watcher.toml @@ -20,11 +20,10 @@ logging = false maxQueryExecutionTime = 100 -# TODO: Update to use rpc-eth-client [upstream] [upstream.ethServer] - gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082" + rpcProviderEndpoint = "http://lotus-node-1:1234/rpc/v1" + rpcClient = true [upstream.cache] name = "requests" diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index 42cde33d..1a636135 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -21,5 +21,27 @@ laconic-so --stack sushiswap build-containers Deploy the stack: ```bash -laconic-so --stack sushiswap deploy --cluster lotus up +laconic-so --stack sushiswap deploy --cluster sushiswap up +``` + +## Tests + +Follow [smoke-tests.md](./smoke-tests.md) to run smoke tests + +## Clean up + +Stop all the services running in background run: + +```bash +laconic-so --stack sushiswap deploy --cluster sushiswap down +``` + +Clear volumes created by this stack: + +```bash +# List all relevant volumes +docker volume ls -q --filter "name=sushiswap" + +# Remove all the listed volumes +docker volume rm $(docker volume ls -q --filter "name=sushiswap") ``` diff --git a/app/data/stacks/sushiswap/smoke-tests.md b/app/data/stacks/sushiswap/smoke-tests.md new file mode 100644 index 00000000..713f8373 --- /dev/null +++ b/app/data/stacks/sushiswap/smoke-tests.md @@ -0,0 +1,77 @@ +# SushiSwap Watcher Smoke Tests + +## sushi-watcher + +Deploy required contracts and set the addresses to variables: + +```bash +# Deploy UniswapV3Factory +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags UniswapV3Factory + +# Set the returned address to a variable +export FACTORY_ADDRESS= + +# Deploy TestUniswapV3Callee +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags TestUniswapV3Callee + +# Set the returned address to a variable +export UNISWAP_CALLEE_ADDRESS= + +# Deploy NFPM contract +docker exec -it sushiswap-sushiswap-v3-periphery-1 bash -c "export FACTORY_ADDRESS=$FACTORY_ADDRESS && yarn hardhat --network docker deploy --tags NonfungiblePositionManager" + +# Set the returned address to a variable +export POSITION_MANAGER_ADDRESS= + +# Deploy two test tokens +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 + +# Set the returned addresses to variables +export TOKEN0_ADDRESS= +export TOKEN1_ADDRESS= +``` + +Watch the contracts: + +```bash +# Watch factory contract +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" + +# Watch NFPM contract +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +``` + +Run the smoke test: + +```bash +docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +``` + +## sushi-info-watcher + +Deploy required contracts and set the addresses to variables: + +```bash +# Deploy TestUniswapV3Callee +docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags TestUniswapV3Callee + +# Set the returned address to a variable +export UNISWAP_CALLEE_ADDRESS= + +# Deploy two test tokens +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 +docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 + +# Set the returned addresses to variables +export TOKEN0_ADDRESS= +export TOKEN1_ADDRESS= +``` + +Run the smoke test: + +```bash +docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +``` From 58bdd92000466d416380ca98e3b23f935d968071 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Wed, 9 Aug 2023 10:38:32 +0530 Subject: [PATCH 5/9] Use sushi-info-watcher in demo mode --- app/data/config/watcher-sushiswap/sushi-info-watcher.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml index 2a300831..2772a872 100644 --- a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml @@ -1,7 +1,7 @@ [server] host = "0.0.0.0" port = 3004 - mode = "prod" + mode = "demo" kind = "active" # Checkpointing state. From eda5bbbf1e30d2f06fbd5a53f2e125747580a241 Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Wed, 9 Aug 2023 14:08:45 +0530 Subject: [PATCH 6/9] Turn off block prefetching --- .../config/watcher-sushiswap/sushi-info-watcher-test.toml | 2 +- app/data/config/watcher-sushiswap/sushi-info-watcher.toml | 2 +- app/data/config/watcher-sushiswap/sushi-watcher.toml | 2 +- app/data/container-build/cerc-watcher-sushiswap/Dockerfile | 3 +-- app/data/stacks/sushiswap/README.md | 4 +--- app/data/stacks/sushiswap/stack.yml | 6 +++--- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml index e8f2d935..e7a60881 100644 --- a/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml @@ -41,5 +41,5 @@ eventsInBatch = 50 subgraphEventsOrder = true blockDelayInMilliSecs = 2000 - prefetchBlocksInMem = true + prefetchBlocksInMem = false prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml index 2772a872..b7dfd933 100644 --- a/app/data/config/watcher-sushiswap/sushi-info-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-info-watcher.toml @@ -86,5 +86,5 @@ eventsInBatch = 50 subgraphEventsOrder = true blockDelayInMilliSecs = 2000 - prefetchBlocksInMem = true + prefetchBlocksInMem = false prefetchBlockCount = 10 diff --git a/app/data/config/watcher-sushiswap/sushi-watcher.toml b/app/data/config/watcher-sushiswap/sushi-watcher.toml index d8dfa594..6e02ba62 100644 --- a/app/data/config/watcher-sushiswap/sushi-watcher.toml +++ b/app/data/config/watcher-sushiswap/sushi-watcher.toml @@ -37,5 +37,5 @@ eventsInBatch = 50 lazyUpdateBlockProgress = true blockDelayInMilliSecs = 2000 - prefetchBlocksInMem = true + prefetchBlocksInMem = false prefetchBlockCount = 10 diff --git a/app/data/container-build/cerc-watcher-sushiswap/Dockerfile b/app/data/container-build/cerc-watcher-sushiswap/Dockerfile index 4c2eb15f..5b890437 100644 --- a/app/data/container-build/cerc-watcher-sushiswap/Dockerfile +++ b/app/data/container-build/cerc-watcher-sushiswap/Dockerfile @@ -7,5 +7,4 @@ WORKDIR /app COPY . . RUN echo "Building uniswap-watcher-ts" && \ - git checkout sushiswap && \ - yarn && yarn build && yarn build:contracts + yarn && yarn build && yarn build:contracts diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index 1a636135..50450613 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -5,9 +5,7 @@ Clone required repositories: ```bash -laconic-so --stack sushiswap setup-repositories - -# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the conflicting repositories and re-run the command +laconic-so --stack sushiswap setup-repositories --git-ssh ``` Build the container images: diff --git a/app/data/stacks/sushiswap/stack.yml b/app/data/stacks/sushiswap/stack.yml index 44969e3a..78c6a07e 100644 --- a/app/data/stacks/sushiswap/stack.yml +++ b/app/data/stacks/sushiswap/stack.yml @@ -5,9 +5,9 @@ repos: ## fixturenet-lotus repo - github.com/filecoin-project/lotus ## sushiswap repos - - github.com/cerc-io/sushiswap-v3-core - - github.com/cerc-io/sushiswap-v3-periphery - - github.com/vulcanize/uniswap-watcher-ts + - github.com/cerc-io/sushiswap-v3-core@watcher-ts + - github.com/cerc-io/sushiswap-v3-periphery@watcher-ts + - github.com/vulcanize/uniswap-watcher-ts@sushiswap - github.com/vulcanize/uniswap-v3-info containers: ## fixturenet-lotus image From 83afd6627500aa3f2203e49308084d8b634d2b02 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 10 Aug 2023 09:57:54 +0530 Subject: [PATCH 7/9] Fix sushiswap demo instructions --- .../compose/docker-compose-watcher-sushiswap.yml | 2 +- app/data/stacks/fixturenet-lotus/README.md | 12 ++++++------ app/data/stacks/sushiswap/README.md | 4 +++- app/data/stacks/sushiswap/smoke-tests.md | 12 ++++++------ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index f5c5c0b9..bd845e6c 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -180,4 +180,4 @@ services: - ../config/watcher-sushiswap/lotus-params.env volumes: - uniswap_watcher_db_data: + sushiswap_watcher_db_data: diff --git a/app/data/stacks/fixturenet-lotus/README.md b/app/data/stacks/fixturenet-lotus/README.md index fd2a020e..2e87e1b9 100644 --- a/app/data/stacks/fixturenet-lotus/README.md +++ b/app/data/stacks/fixturenet-lotus/README.md @@ -16,13 +16,13 @@ $ laconic-so --stack fixturenet-lotus deploy --cluster lotus up ``` Correct operation should be verified by checking the container logs with: ``` -$ laconic-so --stack fixturenet-lotus deploy logs lotus-miner -$ laconic-so --stack fixturenet-lotus deploy logs lotus-node-1 -$ laconic-so --stack fixturenet-lotus deploy logs lotus-node-2 +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-miner +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-node-1 +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-node-2 ``` or by checking the chain status on each node: ``` -$ laconic-so --stack fixturenet-lotus deploy exec lotus-miner "lotus status" -$ laconic-so --stack fixturenet-lotus deploy exec lotus-node-1 "lotus status" -$ laconic-so --stack fixturenet-lotus deploy exec lotus-node-2 "lotus status" +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-miner "lotus status" +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-1 "lotus status" +$ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-2 "lotus status" ``` diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index 50450613..ad0428c8 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -18,8 +18,10 @@ laconic-so --stack sushiswap build-containers Deploy the stack: + ```bash -laconic-so --stack sushiswap deploy --cluster sushiswap up +laconic-so --stack sushiswap deploy --include fixturenet-lotus --cluster sushiswap up +laconic-so --stack sushiswap deploy --include watcher-sushiswap --cluster sushiswap up ``` ## Tests diff --git a/app/data/stacks/sushiswap/smoke-tests.md b/app/data/stacks/sushiswap/smoke-tests.md index 713f8373..f620534f 100644 --- a/app/data/stacks/sushiswap/smoke-tests.md +++ b/app/data/stacks/sushiswap/smoke-tests.md @@ -36,18 +36,18 @@ Watch the contracts: ```bash # Watch factory contract -docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" -docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushi-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushi-info-watcher-server-1 bash -c "yarn watch:contract --address $FACTORY_ADDRESS --kind factory --startingBlock 100 --checkpoint false" # Watch NFPM contract -docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" -docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushi-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" +docker exec -it sushiswap-sushi-info-watcher-server-1 bash -c "yarn watch:contract --address $POSITION_MANAGER_ADDRESS --kind nfpm --startingBlock 100 --checkpoint false" ``` Run the smoke test: ```bash -docker exec -it sushiswap-sushiswap-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +docker exec -it sushiswap-sushi-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" ``` ## sushi-info-watcher @@ -73,5 +73,5 @@ export TOKEN1_ADDRESS= Run the smoke test: ```bash -docker exec -it sushiswap-sushiswap-info-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" +docker exec -it sushiswap-sushi-info-watcher-server-1 bash -c "export TOKEN0_ADDRESS=$TOKEN0_ADDRESS && export TOKEN1_ADDRESS=$TOKEN1_ADDRESS && export UNISWAP_CALLEE_ADDRESS=$UNISWAP_CALLEE_ADDRESS && yarn smoke-test" ``` From 61499004022acf09313592ebcb84df9edddad8f9 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 10 Aug 2023 13:38:15 +0530 Subject: [PATCH 8/9] Use release version and add healthcheck in Lotus stack --- app/data/compose/docker-compose-fixturenet-lotus.yml | 12 ++++++++++++ app/data/config/fixturenet-lotus/setup-miner.sh | 3 ++- app/data/container-build/cerc-lotus/Dockerfile | 7 +++++-- app/data/container-build/cerc-lotus/build.sh | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/data/compose/docker-compose-fixturenet-lotus.yml b/app/data/compose/docker-compose-fixturenet-lotus.yml index 43578682..a1d2d290 100644 --- a/app/data/compose/docker-compose-fixturenet-lotus.yml +++ b/app/data/compose/docker-compose-fixturenet-lotus.yml @@ -30,6 +30,12 @@ services: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - lotus_node_1_params:/var/tmp/filecoin-proof-parameters - lotus-shared:/root/.lotus-shared + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "1234"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s depends_on: - lotus-miner entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] @@ -51,6 +57,12 @@ services: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - lotus_node_2_params:/var/tmp/filecoin-proof-parameters - lotus-shared:/root/.lotus-shared + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "1234"] + interval: 30s + timeout: 10s + retries: 10 + start_period: 3s depends_on: - lotus-miner entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] diff --git a/app/data/config/fixturenet-lotus/setup-miner.sh b/app/data/config/fixturenet-lotus/setup-miner.sh index 68dd5f57..6c065b52 100644 --- a/app/data/config/fixturenet-lotus/setup-miner.sh +++ b/app/data/config/fixturenet-lotus/setup-miner.sh @@ -33,7 +33,8 @@ echo "Daemon started." cp /devgen.car /root/.lotus-shared # publish bootnode peer info to shared volume -lotus net listen | awk 'NR==2{print}' > /root/.lotus-shared/miner.addr +# TODO: Improve exporting public address to shared volume +lotus net listen | awk 'NR==4{print}' > /root/.lotus-shared/miner.addr # if miner not already initialized if [ ! -d $LOTUS_MINER_PATH ]; then diff --git a/app/data/container-build/cerc-lotus/Dockerfile b/app/data/container-build/cerc-lotus/Dockerfile index 963de704..0d43077a 100644 --- a/app/data/container-build/cerc-lotus/Dockerfile +++ b/app/data/container-build/cerc-lotus/Dockerfile @@ -1,5 +1,5 @@ ##################################### -FROM golang:1.19.7-buster AS lotus-builder +FROM golang:1.19.12-bullseye AS lotus-builder MAINTAINER Lotus Development Team RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev @@ -59,7 +59,7 @@ COPY --from=lotus-builder /lib/*/libgcc_s.so.1 /lib/ COPY --from=lotus-builder /lib/*/libutil.so.1 /lib/ COPY --from=lotus-builder /usr/lib/*/libltdl.so.7 /lib/ COPY --from=lotus-builder /usr/lib/*/libnuma.so.1 /lib/ -COPY --from=lotus-builder /usr/lib/*/libhwloc.so.5 /lib/ +COPY --from=lotus-builder /usr/lib/*/libhwloc.so.* /lib/ COPY --from=lotus-builder /usr/lib/*/libOpenCL.so.1 /lib/ RUN useradd -r -u 532 -U fc \ @@ -98,6 +98,9 @@ CMD ["-help"] ##################################### FROM lotus-base AS lotus-all-in-one +# Install netcat for healthcheck +RUN apt-get update && apt-get install -y netcat + ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters ENV LOTUS_MINER_PATH /var/lib/lotus-miner ENV LOTUS_PATH /var/lib/lotus diff --git a/app/data/container-build/cerc-lotus/build.sh b/app/data/container-build/cerc-lotus/build.sh index 10bbf42c..b9520699 100755 --- a/app/data/container-build/cerc-lotus/build.sh +++ b/app/data/container-build/cerc-lotus/build.sh @@ -3,8 +3,8 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -# Per lotus docs, 'releases' branch always contains latest stable release -git -C ${CERC_REPO_BASE_DIR}/lotus checkout releases +# Use a release version tag to match the modified Dockerfile replaced in next step +git -C ${CERC_REPO_BASE_DIR}/lotus checkout v1.23.3 # Replace repo's Dockerfile with modified one cp ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/lotus/Dockerfile From d5c596306375389602dc04f70e54c5834df3df87 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 10 Aug 2023 13:39:31 +0530 Subject: [PATCH 9/9] Wait for Lotus node to start before sushiswap watchers --- app/data/compose/docker-compose-watcher-sushiswap.yml | 4 ++++ app/data/stacks/sushiswap/README.md | 4 +--- app/data/stacks/sushiswap/smoke-tests.md | 6 ------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/data/compose/docker-compose-watcher-sushiswap.yml b/app/data/compose/docker-compose-watcher-sushiswap.yml index bd845e6c..a92e17cb 100644 --- a/app/data/compose/docker-compose-watcher-sushiswap.yml +++ b/app/data/compose/docker-compose-watcher-sushiswap.yml @@ -52,6 +52,8 @@ services: depends_on: sushiswap-watcher-db: condition: service_healthy + lotus-node-1: + condition: service_healthy image: cerc/watcher-sushiswap:local working_dir: /app/packages/uni-watcher environment: @@ -107,6 +109,8 @@ services: condition: service_healthy erc20-watcher-server: condition: service_healthy + lotus-node-1: + condition: service_healthy sushi-watcher-server: condition: service_healthy image: cerc/watcher-sushiswap:local diff --git a/app/data/stacks/sushiswap/README.md b/app/data/stacks/sushiswap/README.md index ad0428c8..50450613 100644 --- a/app/data/stacks/sushiswap/README.md +++ b/app/data/stacks/sushiswap/README.md @@ -18,10 +18,8 @@ laconic-so --stack sushiswap build-containers Deploy the stack: - ```bash -laconic-so --stack sushiswap deploy --include fixturenet-lotus --cluster sushiswap up -laconic-so --stack sushiswap deploy --include watcher-sushiswap --cluster sushiswap up +laconic-so --stack sushiswap deploy --cluster sushiswap up ``` ## Tests diff --git a/app/data/stacks/sushiswap/smoke-tests.md b/app/data/stacks/sushiswap/smoke-tests.md index f620534f..00a066a3 100644 --- a/app/data/stacks/sushiswap/smoke-tests.md +++ b/app/data/stacks/sushiswap/smoke-tests.md @@ -55,12 +55,6 @@ docker exec -it sushiswap-sushi-watcher-server-1 bash -c "export TOKEN0_ADDRESS= Deploy required contracts and set the addresses to variables: ```bash -# Deploy TestUniswapV3Callee -docker exec -it sushiswap-sushiswap-v3-core-1 pnpm hardhat --network docker deploy --tags TestUniswapV3Callee - -# Set the returned address to a variable -export UNISWAP_CALLEE_ADDRESS= - # Deploy two test tokens docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20 docker exec -it sushiswap-sushiswap-v3-periphery-1 yarn hardhat --network docker deploy --tags TestERC20