watcher-ts/docs/README.md

86 lines
2.8 KiB
Markdown
Raw Normal View History

2022-12-21 13:07:42 +00:00
# Watcher Documentation
2023-01-09 18:57:40 +00:00
This document is specifically focused on standing up a minimal core version of the Laconic Stack *without* using [Stack Orchestrator]( https://github.com/cerc-io/stack-orchestrator). If this is your first foray into the stack, start with Stack Orchestrator. To understand what is going on under the hood or to make contributions to this repo, this is a good place to start.
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
There are 3 main components to setting up an environment for running watchers:
- core services
- configure postgres
- edit config file
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
After which you should be able to navigate to the `README.md` of any watcher and run through its demo using `yarn`. The common `yarn` CLI commands for watchers are documented [here](../cli.md).
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
## Core services
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
The following core services should be setup and running on localhost:
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
* `cerc-io/go-ethereum` [v1.10.26-statediff-4.2.2-alpha](https://github.com/cerc-io/go-ethereum/releases/tag/v1.10.26-statediff-4.2.2-alpha)
on port 8545
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
* `cerc-io/ipld-eth-server` [v4.2.2-alpha](https://github.com/cerc-io/ipld-eth-server/releases/tag/v4.2.2-alpha) with native GQL API enabled, on port 8082
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
* `cerc-io/ipld-eth-db` [v4.2.2-alpha](https://github.com/cerc-io/ipld-eth-db/releases/tag/v4.2.2-alpha) is the postgres schema required for `ipld-eth-server`
## Setup Postgres
In this example, we use the `erc20-watcher`; for another watcher substitute with its name.
Create a postgres database for the watcher:
```bash
sudo su - postgres
createdb erc20-watcher
```
Create a postgres database for the job queue:
2023-01-04 15:08:58 +00:00
```
sudo su - postgres
createdb erc20-watcher-job-queue
```
2023-01-09 18:57:40 +00:00
Enable the `pgcrypto` [extension](https://github.com/timgit/pg-boss/tree/master/docs#database-install) on the job queue database.
2023-01-04 15:08:58 +00:00
```
postgres@tesla:~$ psql -U postgres -h localhost erc20-watcher-job-queue
Password for user postgres:
psql (12.7 (Ubuntu 12.7-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.
erc20-watcher-job-queue=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
erc20-watcher-job-queue=# exit
```
2023-01-09 18:57:40 +00:00
## Config File
2023-01-04 15:08:58 +00:00
In each watchers' directory is a config file: `<watcher>/environments/local.toml`:
2023-01-04 15:08:58 +00:00
2023-01-09 18:57:40 +00:00
* Update the database connection settings.
* Update the `upstream` config and provide the `ipld-eth-server` GraphQL API endpoint.
* Select "active" vs. "lazy" watcher depending on its kind.
For example:
2023-01-04 15:08:58 +00:00
```toml
2023-01-09 18:57:40 +00:00
[server]
kind = "active"
2023-01-04 15:08:58 +00:00
[database]
type = "postgres"
host = "localhost"
port = 5432
database = "erc20-watcher"
username = "postgres"
password = "postgres"
[jobQueue]
dbConnectionString = "postgres://postgres:postgres@localhost/erc20-watcher-job-queue"
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://127.0.0.1:8082/graphql"
rpcProviderEndpoint = "http://127.0.0.1:8081"
```
2023-01-09 18:57:40 +00:00
Now that your environment is setup, you can test run any watcher!