Skip to content

Commit

Permalink
Add a SushiSwap stack (#482)
Browse files Browse the repository at this point in the history
* Add a sushiswap stack with contract deployments

* Add watcher services

* Add a service for the info app

* Add instructions to run smoke tests

* Use sushi-info-watcher in demo mode

* Turn off block prefetching

* Fix sushiswap demo instructions

* Use release version and add healthcheck in Lotus stack

* Wait for Lotus node to start before sushiswap watchers

---------

Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
  • Loading branch information
prathamesh0 and nikugogoi authored Aug 10, 2023
1 parent bccf711 commit 4c72ace
Show file tree
Hide file tree
Showing 24 changed files with 673 additions and 11 deletions.
12 changes: 12 additions & 0 deletions app/data/compose/docker-compose-fixturenet-lotus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down
187 changes: 187 additions & 0 deletions app/data/compose/docker-compose-watcher-sushiswap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
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
lotus-node-1:
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
- ../config/watcher-sushiswap/sushi-watcher-test.toml:/app/packages/uni-watcher/environments/test.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
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"
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
lotus-node-1:
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
- ../config/watcher-sushiswap/sushi-info-watcher-test.toml:/app/packages/uni-info-watcher/environments/test.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
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"
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3004"]
interval: 20s
timeout: 5s
retries: 15
start_period: 5s
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
env_file:
- ../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/lotus-params.env

volumes:
sushiswap_watcher_db_data:
3 changes: 2 additions & 1 deletion app/data/config/fixturenet-lotus/setup-miner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions app/data/config/watcher-sushiswap/erc20-watcher.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[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

[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/erc20-watcher-job-queue"
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50
blockDelayInMilliSecs = 2000
6 changes: 6 additions & 0 deletions app/data/config/watcher-sushiswap/lotus-params.env
Original file line number Diff line number Diff line change
@@ -0,0 +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"
45 changes: 45 additions & 0 deletions app/data/config/watcher-sushiswap/sushi-info-watcher-test.toml
Original file line number Diff line number Diff line change
@@ -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 = false
prefetchBlockCount = 10
Loading

0 comments on commit 4c72ace

Please sign in to comment.