Add a stack for mobymask-v2-watcher to run peer tests (#222)

* Add mobymask-v2-watcher stack with peer tests

* Rename stack and container

* Avoid building react-peer container

* Improve step for getting container ID

Former-commit-id: 7831078872
This commit is contained in:
Nabarun Gogoi 2023-03-20 18:25:39 +05:30 committed by GitHub
parent 49092305e4
commit 4d3042bfcc
16 changed files with 274 additions and 0 deletions

View File

@ -0,0 +1,47 @@
version: '3.2'
services:
mobymask-watcher-db:
restart: unless-stopped
image: postgres:14-alpine
environment:
- POSTGRES_USER=vdbm
- POSTGRES_MULTIPLE_DATABASES=mobymask-watcher,mobymask-watcher-job-queue
- POSTGRES_EXTENSION=mobymask-watcher-job-queue:pgcrypto
- POSTGRES_PASSWORD=password
volumes:
- ../config/postgresql/multiple-postgressql-databases.sh:/docker-entrypoint-initdb.d/multiple-postgressql-databases.sh
- mobymask_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
mobymask-watcher-server:
restart: unless-stopped
depends_on:
mobymask-watcher-db:
condition: service_healthy
image: cerc/watcher-mobymask-v2:local
command: ["sh", "-c", "yarn server"]
volumes:
- ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml
- ../config/watcher-mobymask-v2/.env:/app/packages/peer/.env
- ../config/watcher-mobymask-v2/relay-id.json:/app/packages/mobymask-v2-watcher/relay-id.json
ports:
- "0.0.0.0:3001:3001"
- "0.0.0.0:9001:9001"
- "0.0.0.0:9090:9090"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "9090"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
volumes:
mobymask_watcher_db_data:

View File

@ -0,0 +1 @@
RELAY="/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"

View File

@ -0,0 +1,8 @@
{
"relayNodes": [
"/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
],
"peer": {
"enableDebugInfo": true
}
}

View File

@ -0,0 +1,5 @@
{
"id": "12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t",
"privKey": "CAESQGsqG5o4VlWJZM9XlA3MjabyZOXWQ2MLZU5AhBQsjXGt9iSlGtTuNOrHX5xSRgLBxLuMoqWsjGxE/dDB9c46RI8=",
"pubKey": "CAESIPYkpRrU7jTqx1+cUkYCwcS7jKKlrIxsRP3QwfXOOkSP"
}

View File

@ -0,0 +1,70 @@
[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
enableState = true
# Boolean to filter logs by contract.
filterLogs = true
# Max block range for which to return events in eventsInRange GQL query.
# Use -1 for skipping check on block range.
maxEventsBlockRange = -1
[server.p2p]
enableRelay = true
enablePeer = false
[server.p2p.relay]
host = "0.0.0.0"
port = 9090
relayPeers = []
peerIdFile = './relay-id.json'
enableDebugInfo = true
[server.p2p.peer]
relayMultiaddr = '/ip4/mobymask-watcher-server/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t'
pubSubTopic = 'mobymask'
peerIdFile = './peer-id.json'
enableDebugInfo = true
[metrics]
host = "0.0.0.0"
port = 9000
[metrics.gql]
port = 9001
[database]
type = "postgres"
host = "mobymask-watcher-db"
port = 5432
database = "mobymask-watcher"
username = "vdbm"
password = "password"
synchronize = true
logging = false
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
rpcProviderEndpoint = "http://ipld-eth-server:8082"
blockDelayInMilliSecs = 60000
[upstream.cache]
name = "requests"
enabled = false
deleteOnStart = false
[jobQueue]
dbConnectionString = "postgres://vdbm:password@mobymask-watcher-db/mobymask-watcher-job-queue"
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50

View File

@ -0,0 +1,12 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add make git
WORKDIR /app
COPY . .
RUN echo "Building mobymask-ui" && \
npm install
WORKDIR /app

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/mobymask-ui
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/mobymask-ui:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/mobymask-ui

View File

@ -0,0 +1,12 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add make git
WORKDIR /app
COPY . .
RUN echo "Building react-peer" && \
yarn && yarn workspace @cerc-io/react-peer build
WORKDIR /app

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/react-peer
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/react-peer:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/react-peer

View File

@ -0,0 +1,20 @@
FROM ubuntu:22.04
RUN apt-get update \
&& apt-get install -y curl gnupg build-essential \
&& curl --silent --location https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get update \
&& apt-get install -y nodejs git \
&& node -v
RUN corepack enable \
&& yarn --version
WORKDIR /app
COPY . .
RUN echo "Building watcher-ts" && \
yarn && yarn build
WORKDIR /app/packages/mobymask-v2-watcher

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/watcher-mobymask-v2
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/watcher-mobymask-v2:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/watcher-ts

View File

@ -18,6 +18,9 @@ cerc/watcher-erc20
cerc/watcher-erc721 cerc/watcher-erc721
cerc/watcher-uniswap-v3 cerc/watcher-uniswap-v3
cerc/uniswap-v3-info cerc/uniswap-v3-info
cerc/watcher-mobymask-v2
cerc/react-peer
cerc/mobymask-ui
cerc/test-container cerc/test-container
cerc/eth-probe cerc/eth-probe
cerc/builder-js cerc/builder-js

View File

@ -14,6 +14,7 @@ watcher-mobymask
watcher-erc20 watcher-erc20
watcher-erc721 watcher-erc721
watcher-uniswap-v3 watcher-uniswap-v3
watcher-mobymask-v2
test test
eth-probe eth-probe
keycloak keycloak

View File

@ -11,6 +11,8 @@ cerc-io/laconic-sdk
cerc-io/laconic-registry-cli cerc-io/laconic-registry-cli
cerc-io/mobymask-watcher cerc-io/mobymask-watcher
cerc-io/watcher-ts cerc-io/watcher-ts
cerc-io/react-peer
cerc-io/mobymask-ui
vulcanize/uniswap-watcher-ts vulcanize/uniswap-watcher-ts
vulcanize/uniswap-v3-info vulcanize/uniswap-v3-info
vulcanize/assemblyscript vulcanize/assemblyscript

View File

@ -0,0 +1,61 @@
# MobyMask v2 watcher
Instructions to deploy MobyMask v2 watcher stack using [laconic-stack-orchestrator](/README.md#install)
## Setup
Clone required repositories:
```bash
laconic-so --stack mobymask-v2 setup-repositories
```
Build the container images:
```bash
laconic-so --stack mobymask-v2 build-containers
```
This should create the required docker images in the local image registry.
Deploy the stack:
```bash
laconic-so --stack mobymask-v2 deploy-system up
```
## Tests
Find the watcher container's id:
```bash
docker ps | grep "cerc/watcher-mobymask-v2:local"
```
Example output
```
8b38e9a64d7e cerc/watcher-mobymask-v2:local "sh -c 'yarn server'" 35 seconds ago Up 14 seconds (health: starting) 0.0.0.0:3001->3001/tcp, 0.0.0.0:9001->9001/tcp, 0.0.0.0:9090->9090/tcp laconic-aeb84676de2b0a7671ae90d537fc7d26-mobymask-watcher-server-1
```
In above output the container ID is `8b38e9a64d7e`
Export it for later use:
```bash
export CONTAINER_ID=<CONTAINER_ID>
```
Run the peer tests:
```bash
docker exec -w /app/packages/peer $CONTAINER_ID yarn test
```
## Clean up
To stop all the services running in background run:
```bash
laconic-so --stack mobymask-v2 deploy-system down
```

View File

@ -0,0 +1,11 @@
version: "1.0"
name: mobymask-v2
repos:
- cerc-io/watcher-ts
- cerc-io/react-peer
- cerc-io/mobymask-ui
containers:
- cerc/watcher-mobymask-v2
- cerc/mobymask-ui
pods:
- watcher-mobymask-v2