Add a stack for erc721 watcher

This commit is contained in:
Prathamesh Musale 2022-12-22 09:57:41 +05:30
parent a7221ddc24
commit f5b004a811
8 changed files with 171 additions and 0 deletions

View File

@ -14,6 +14,7 @@ cerc/fixturenet-eth-geth
cerc/fixturenet-eth-lighthouse
cerc/watcher-mobymask
cerc/watcher-erc20
cerc/watcher-erc721
cerc/test-container
cerc/eth-probe
cerc/builder-js

View File

@ -12,6 +12,7 @@ fixturenet-laconicd
fixturenet-eth
watcher-mobymask
watcher-erc20
watcher-erc721
test
eth-probe
keycloak

View File

@ -0,0 +1,49 @@
version: '3.2'
services:
watcher-db:
restart: unless-stopped
image: postgres:14-alpine
environment:
- POSTGRES_USER=vdbm
- POSTGRES_MULTIPLE_DATABASES=erc721-watcher,erc721-watcher-job-queue
- POSTGRES_EXTENSION=erc721-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
erc721-watcher:
restart: unless-stopped
depends_on:
ipld-eth-server:
condition: service_healthy
watcher-db:
condition: service_healthy
image: cerc/watcher-erc721:local
environment:
- ETH_RPC_URL=http://go-ethereum:8545
command: ["sh", "-c", "yarn server"]
volumes:
- ../config/watcher-erc721/erc721-watcher.toml:/app/packages/erc721-watcher/environments/local.toml
ports:
- "0.0.0.0:3009:3009"
- "0.0.0.0:9001:9001"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3009"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
volumes:
watcher_db_data:

View File

@ -0,0 +1,56 @@
[server]
host = "0.0.0.0"
port = 3009
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 = false
# Max block range for which to return events in eventsInRange GQL query.
# Use -1 for skipping check on block range.
maxEventsBlockRange = 1000
[metrics]
host = "127.0.0.1"
port = 9000
[metrics.gql]
port = 9001
[database]
type = "postgres"
host = "watcher-db"
port = 5432
database = "erc721-watcher"
username = "vdbm"
password = "password"
synchronize = true
logging = false
maxQueryExecutionTime = 100
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
rpcProviderEndpoint = "http://ipld-eth-server:8081"
[upstream.cache]
name = "requests"
enabled = false
deleteOnStart = false
[jobQueue]
dbConnectionString = "postgres://vdbm:password@watcher-db:5432/erc721-watcher-job-queue"
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50
blockDelayInMilliSecs = 2000
prefetchBlocksInMem = true
prefetchBlockCount = 10

View File

@ -0,0 +1,13 @@
FROM node:16.17.1-alpine3.16
RUN apk --update --no-cache add git python3 alpine-sdk
WORKDIR /app
COPY . .
RUN echo "Building watcher-ts" && \
git checkout v0.2.19 && \
yarn && yarn build
WORKDIR /app/packages/erc721-watcher

View File

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

26
stacks/erc721/README.md Normal file
View File

@ -0,0 +1,26 @@
# ERC721 Watcher
Instructions to deploy a local ERC721 watcher stack (core + watcher) for demonstration and testing purposes using [laconic-stack-orchestrator](../../README.md#setup)
## Setup
* Clone / pull required repositories:
```bash
$ laconic-so setup-repositories --include cerc-io/go-ethereum,cerc-io/ipld-eth-db,cerc-io/ipld-eth-server,cerc-io/watcher-ts --pull
```
* Build the core and watcher container images:
```bash
$ laconic-so build-containers --include cerc/go-ethereum,cerc/go-ethereum-foundry,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/watcher-erc721
```
This should create the required docker images in the local image registry.
* Deploy the stack:
```bash
$ laconic-so deploy-system --include db,go-ethereum-foundry,ipld-eth-server,watcher-erc721 up
```

18
stacks/erc721/stack.yml Normal file
View File

@ -0,0 +1,18 @@
version: "1.0"
name: erc721-watcher
repos:
- cerc-io/go-ethereum
- cerc-io/ipld-eth-db
- cerc-io/ipld-eth-server
- cerc-io/watcher-ts
containers:
- cerc/go-ethereum
- cerc/go-ethereum-foundry
- cerc/ipld-eth-db
- cerc/ipld-eth-server
- cerc/watcher-erc721
pods:
- go-ethereum-foundry
- db
- ipld-eth-server
- watcher-erc721