tokenbridge/monitor
Przemyslaw Rzad c66923827b
Common getTokenType used on UI, monitor and Oracle (#165)
* Stopped silently swallowing errors

* getTokenType in commons

* Oracle using getTokenType from commons

* Moved the getTokenType tests from ui to commons

* Using getTokenType in ui and oracle

* Revert "Stopped silently swallowing errors"

fc92c0af9dc7cb4e59a7f1779afc8da8d9c33ecf

* using common getTokenType in monitor.

* Lint.
2019-07-26 14:26:14 +02:00
..
responses Update bridge monitor (#38) 2019-05-14 09:17:03 +02:00
utils Common getTokenType used on UI, monitor and Oracle (#165) 2019-07-26 14:26:14 +02:00
.env.example Add support for oracle gas price values not expressed in gwei (#142) 2019-07-12 19:10:17 +03:00
.eslintrc Oracle & Monitor - Compiled ABI's (#71) 2019-05-27 09:22:08 +02:00
alerts.js Fix error handling on monitor workers 2019-05-30 15:05:36 -03:00
checkWorker2.js Fix error handling on monitor workers 2019-05-30 15:05:36 -03:00
checkWorker3.js Add support v1 legacy contracts on monitor 2019-05-31 15:35:50 -03:00
checkWorker.js Monitor using commons (#143) 2019-07-12 14:49:46 +02:00
crontab.example Monitor in docker (#109) 2019-06-17 09:22:53 +02:00
docker-compose.yml Yaml and Ansible linting in Molecule (#141) 2019-07-11 10:17:02 +02:00
Dockerfile Monitor using commons (#143) 2019-07-12 14:49:46 +02:00
eventsStats.js Fix error handling on monitor workers 2019-05-30 15:05:36 -03:00
getBalances.js Monitor using commons (#143) 2019-07-12 14:49:46 +02:00
getShortEventStats.js Add support v1 legacy contracts on monitor 2019-05-31 15:35:50 -03:00
index.js Expose stuckTransfer endpoint only if v1 bridge 2019-06-03 09:47:12 -03:00
logger.js Update bridge monitor (#38) 2019-05-14 09:17:03 +02:00
package.json Monitor deployment playbook (#133) 2019-07-09 19:26:40 +02:00
README.md Cosistent TokenBridge naming (#159) 2019-07-19 09:18:51 +02:00
stuckTransfers.js UI using abis from commons (#164) 2019-07-26 10:30:35 +02:00
test-srv.js Update bridge monitor (#38) 2019-05-14 09:17:03 +02:00
validators.js Add support for oracle gas price values not expressed in gwei (#142) 2019-07-12 19:10:17 +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

Run web interface

Using Yarn:

yarn start

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

Using Docker:

docker-compose up -d
  • The application will run on http://localhost:PORT, where PORT is specified in your .env file.
  • To enabled debug logging, set DEBUG=1 variable in .env.

Check balances of contracts and validators, get unprocessed events

Using Yarn:

yarn check-all

Using Docker:

docker-compose exec monitor yarn check-all

Cron

You can create cron job to run workers (see crontab.example for reference):

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.