Composer files to build oracle and monitor docker images (#299)

This commit is contained in:
Alexander Kolotov 2020-02-21 16:58:05 +03:00 committed by GitHub
parent 8977ed6d3b
commit dbf3d3d90d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 10 deletions

@ -66,11 +66,13 @@ Clone the repository:
git clone https://github.com/poanetwork/tokenbridge
```
Initialize submodules, install dependencies, compile the Smart Contracts:
If there is no need to build docker images for the TokenBridge components (oracle, monitor, UI), initialize submodules, install dependencies, compile the Smart Contracts:
```
yarn initialize
```
Then refer to the corresponding README files to get information about particular TokenBridge component.
## Linting
Running linter for all JS projects:

@ -4,7 +4,12 @@ Tool for checking balances and unprocessed events in bridged networks.
## Overview
Please refer to the [POA TokenBridge](../README.md) overview first of all.
- Deployed version: https://bridge-monitoring.poa.net/
- Deployed version serves several monitor configurations:
* https://bridge-monitoring.poa.net/poa
* https://bridge-monitoring.poa.net/xdai
* https://bridge-monitoring.poa.net/wetc
* https://bridge-monitoring.poa.net/amb-dai
* https://bridge-monitoring.poa.net/amb-poa
This tool allows you to spin up a NODE.JS server to monitor for health of the TokenBridge contracts: check for the balance difference, discover inconsistency in the validators list, catch unhandled transactions.
@ -122,14 +127,19 @@ yarn start
You can run web interface via [pm2](https://www.npmjs.com/package/pm2) or similar supervisor program.
Using Docker:
```
docker-compose up -d
```
* to run it very first time (or after changes related to the monitor code):
```
docker-compose -f docker-compose-build.yml -f docker-compose.yml up -d --build
```
* next time (or in case of usage of an official docker image)
```
docker-compose up -d
```
- The application will run on `http://localhost:MONITOR_PORT/MONITOR_BRIDGE_NAME`, where `MONITOR_PORT` and `MONITOR_BRIDGE_NAME` are specified in your `.env` file.
- To enabled debug logging, set `DEBUG=1` variable in `.env`.
## Check balances of contracts and validators, get unprocessed events
## Preparing statistic about balances of bridge contracts and validators, get unprocessed events
Using Yarn:
```
@ -138,13 +148,32 @@ yarn check-all
Using Docker:
```
docker-compose exec monitor yarn check-all
docker run --rm --env-file .env -v $(pwd)/responses:/mono/monitor/responses \
poanetwork/tokenbridge-monitor:latest /bin/bash -c 'yarn check-all'
```
As soon as the process finishes, use the URL described above to get the statistic.
### Cron
You can create cron job to run workers (see `crontab.example` for reference):
## Ad-hoc monitoring
There is a possibility to get bridge statistics without running the web interface use the commands provided above. In this case the results will be located in the `responses` directory.
## Build the image without running the monitor
To build the image change the directory:
```
cd monitor
```
And run the docker composer:
```
docker-compose -f docker-compose-build.yml build
```
## Linting
Running linter:

@ -2,4 +2,4 @@
*/4 * * * * cd $HOME/tokenbridge/monitor; yarn check-all >>cronWorker.out 2>>cronWorker.err
# Docker:
*/4 * * * * cd $HOME/tokenbridge/monitor; docker-compose exec monitor yarn check-all >>cronWorker.out 2>>cronWorker.err
*/4 * * * * cd $HOME/tokenbridge/monitor; docker run --rm --env-file .env -v $(pwd)/responses:/mono/monitor/responses poanetwork/tokenbridge-monitor:latest /bin/bash -c 'yarn check-all' >>cronWorker.out 2>>cronWorker.err

@ -0,0 +1,6 @@
---
version: '2.4'
services:
monitor:
image: poanetwork/tokenbridge-monitor
build: .

@ -117,8 +117,18 @@ There are two options to run the TokenBridge processes:
### Docker
- While running the bridge containers for the first time use `ORACLE_VALIDATOR_ADDRESS=<validator address> ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up -d --build`
- For further launches use `ORACLE_VALIDATOR_ADDRESS=<validator address> ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up --detach`
- While running the bridge containers for the first time use
```
env ORACLE_VALIDATOR_ADDRESS=<validator address> \
env ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> \
docker-compose -f docker-compose-build.yml -f docker-compose.yml up -d --build
```
- For further launches (or in case of usage an official docker image) use
```
env ORACLE_VALIDATOR_ADDRESS=<validator address> \
env ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> \
docker-compose up --d
```
All [watcher](#watcher) & [sender](#sender) services launch when `docker-compose` is called.
@ -144,6 +154,18 @@ In case you need to reset your bridge or setup a new one (with different configu
See the [UI instructions](../ui/README.md) to configure and use the optional Bridge UI.
### Build the image without running the oracle
To build the image change the directory:
```
cd oracle
```
And run the docker composer:
```
docker-compose -f docker-compose-build.yml build
```
## Rollback the Last Processed Block in Redis
If the bridge does not handle an event properly (i.e. a transaction stalls due to a low gas price), the Redis DB can be rolled back. You must identify which watcher needs to re-run. For example, if the validator signatures were collected but the transaction with signatures was not sent to the Foreign network, the `collected-signatures` watcher must look at the block where the corresponding `CollectedSignatures` event was raised.

@ -0,0 +1,6 @@
---
version: '2.4'
services:
oracle:
image: poanetwork/tokenbridge-oracle
build: .