tokenbridge/monitor
2021-10-11 12:14:55 +03:00
..
cache Add allowance/block lists support to monitor (#477) 2020-10-29 11:25:43 +03:00
configs Support multiple bridges in one monitor (#262) 2020-01-10 15:55:34 +03:00
responses Update bridge monitor (#38) 2019-05-14 09:17:03 +02:00
scripts Cache fetched events in monitor (#482) 2020-11-04 14:24:42 +03:00
test Support alternative receiver feature in Monitor (#223) 2019-10-29 22:22:02 +03:00
utils Fix handling of Compound related Transfer events (#595) 2021-08-24 11:31:15 +03:00
.env.example Add env variables for selective validator balance checks (#507) 2021-01-10 20:18:06 -06:00
.eslintrc Support alternative receiver feature in Monitor (#223) 2019-10-29 22:22:02 +03:00
alerts.js Fix monitor metrics (#533) 2021-04-02 03:59:49 -06:00
checkWorker2.js Fix monitor metrics (#533) 2021-04-02 03:59:49 -06:00
checkWorker3.js Update the contract's submodule to the release 6.0.0-rc0 (#562) 2021-05-08 09:50:46 -06:00
checkWorker.js Update the contract's submodule to the release 6.0.0-rc0 (#562) 2021-05-08 09:50:46 -06:00
crontab.example Composer files to build oracle and monitor docker images (#299) 2020-02-21 16:58:05 +03:00
detectFailures.js Include stats about failed and pending messages in mediators monitor endpoint (#544) 2021-04-13 07:59:49 -06:00
detectMediators.js Add statistics about used AMB information requests (#577) 2021-05-26 08:58:20 -06:00
docker-compose-build.yml Add a possibility to fetch gas price from multiple sources (#420) 2020-08-23 22:56:59 +03:00
docker-compose.yml Add allowance/block lists support to monitor (#477) 2020-10-29 11:25:43 +03:00
Dockerfile Update the contract's submodule to the release 6.0.0-rc0 (#562) 2021-05-08 09:50:46 -06:00
eventsStats.js Fix monitor metrics (#533) 2021-04-02 03:59:49 -06:00
getBalances.js Include cDAI balance in balanceDiff (#613) 2021-10-11 12:14:55 +03:00
getShortEventStats.js Add statistics about used AMB information requests (#577) 2021-05-26 08:58:20 -06:00
index.js Fix monitor metrics (#533) 2021-04-02 03:59:49 -06:00
logger.js Extend line width to 120 (#174) 2019-08-01 15:10:22 +02:00
metricsWorker.js Fix monitor metrics (#533) 2021-04-02 03:59:49 -06:00
package.json Update the contract's submodule to the release 6.0.0-rc0 (#562) 2021-05-08 09:50:46 -06:00
prometheusMetrics.js Update the contract's submodule to the release 6.0.0-rc0 (#562) 2021-05-08 09:50:46 -06:00
README.md Composer files to build oracle and monitor docker images (#299) 2020-02-21 16:58:05 +03:00
test-srv.js Consistent variable naming (#198) 2019-09-13 09:11:38 +02:00
validators.js Fix logging in gas price service (#583) 2021-07-05 13:50:18 +03:00

POA TokenBridge / Monitor

Tool for checking balances and unprocessed events in bridged networks.

Overview

Please refer to the POA TokenBridge overview first of all.

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.

Examples

Example of an API

  • GET / - check contract balances & tx numbers

{
    "home": {
        "balance": "3710077.6896438415780044",
        "deposits": 481,
        "withdrawals": 221
    },
    "foreign": {
        "totalSupply": "3710077.6896438415780044",
        "deposits": 481,
        "withdrawals": 221
    },
    "balanceDiff": 0,
    "lastChecked": 1529511982,
    "depositsDiff": 0,
    "withdrawalDiff": 0
}
  • GET /validators - check validators balances
{
    "home": {
        "validators": {
            "0x35DC13c72A9C09C8AEEBD0490C7228C43Ccc38Cd": {
                "balance": "19.994900374",
                "leftTx": 66649667913333,
                "gasPrice": 1
            },
            "0x5D44BC8642947685F45004c936245B969F9709a6": {
                "balance": "19.993736069",
                "leftTx": 66645786896666,
                "gasPrice": 1
            },
            "0x284877074B986A78F01D7Eb1f34B6043b1719002": {
                "balance": "19.995139875",
                "leftTx": 66650466250000,
                "gasPrice": 1
            }
        },
        "requiredSignatures": 2
    },
    "foreign": {
        "validators": {
            "0x35DC13c72A9C09C8AEEBD0490C7228C43Ccc38Cd": {
                "balance": "19.084023268196",
                "leftTx": 28915,
                "gasPrice": 2.2
            },
            "0x5D44BC8642947685F45004c936245B969F9709a6": {
                "balance": "19.086724777075",
                "leftTx": 28919,
                "gasPrice": 2.2
            },
            "0x284877074B986A78F01D7Eb1f34B6043b1719002": {
                "balance": "19.050074813935",
                "leftTx": 28863,
                "gasPrice": 2.2
            }
        },
        "requiredSignatures": 2
    },
    "requiredSignaturesMatch": true,
    "validatorsMatch": true,
    "lastChecked": 1529512164
}
  • GET /eventsStats - check unprocessed events
{
    "onlyInHomeDeposits": [],
    "onlyInForeignDeposits": [],
    "onlyInHomeWithdrawals": [],
    "onlyInForeignWithdrawals": [],
    "lastChecked": 1529512436
}

How to run

Setup

  1. Initialize the monorepository.

  2. Go to the monitor sub-repository:

cd monitor
  1. Create .env file:
cp .env.example .env

Please refer to Configuration for details on configuration parameters.

Run web interface

Using Yarn:

yarn start

You can run web interface via pm2 or similar supervisor program.

Using Docker:

  • 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.

Preparing statistic about balances of bridge contracts and validators, get unprocessed events

Using Yarn:

yarn check-all

Using Docker:

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:

yarn lint

Contributing

See the CONTRIBUTING document for contribution, testing and pull request protocol.

License

License: LGPL v3.0

This project is licensed under the GNU Lesser General Public License v3.0. See the LICENSE file for details.