Skip to content

Commit

Permalink
Add watchdog quick configuration guide (#752)
Browse files Browse the repository at this point in the history
Сo-authored-by: Karim <[email protected]>
  • Loading branch information
sept-en authored Jun 10, 2022
1 parent 54bde2d commit 81d589d
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Note, you can use environment variables to pass sensitive data which will not le

## Security

* [Guide](near2eth/watchdog/README.md) on how to quickly configure the watchdog for Mainnet

Bridge is secure as long as majority (1/2) of Etherem mining power is honest and supermajority (2/3) of NEAR stake is honest.
There are no additional security requirements, except that Ethereum should be able to accept 1 transaction within 4 hour period even in the worst congestion scenario.

Expand Down
113 changes: 113 additions & 0 deletions near2eth/watchdog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Watchdog configuration for Mainnet

### Prerequisites

* NodeJS (v14+)
* npm/yarn

### Initial setup

Clone `rainbow-bridge` GitHub repo:
```
$ git clone https://github.com/aurora-is-near/rainbow-bridge/
```

Prepare an environment:
```
$ cd rainbow-bridge
$ yarn
$ mkdir -p ~/.rainbow
```

Build contracts:
```
$ cd contracts/eth/nearbridge
$ yarn
$ yarn build
$ cd -
```

### Rainbow Bridge config

Create and fill `~/.rainbow/config.json` file. The content of the config file for running watchdog should be the following:

```json=
{
"ethNodeUrl": "",
"ethClientAddress": "0x3be7Df8dB39996a837041bb8Ee0dAdf60F767038",
"ethMasterSk": "",
"watchdogDelay": 600
}
```

Please fill `ethNodeUrl` (any web3 node, e.g. [Infura](https://infura.io), [Alchemy](https://www.alchemy.com), etc) and `ethMasterSk` (private key for the expected watchdog EOA)

### Start the watchdog

```
$ cli/index.js start bridge-watchdog
```

### Check whether the watchdog is running

Ensure the watchdog is in the list of processes in `pm2` and running:
```
$ pm2 list
```

Check `pm2` logs for the watchdog
```
$ pm2 logs bridge-watchdog
```


## Troubleshooting

If you have any trouble running the watchdog, one of the issues might be because you don't have `pm2` installed.

So to fix this:
* either install a `pm2` following the [instruction](#Installing-pm2) and try again (recommended)
* or run the watchdog without daemon mode (not-recommended):
```$ cli/index.js start bridge-watchdog --daemon false```

### Additional info

To get more info on each of the parameters, run:

```
$ cli/index.js start bridge-watchdog --help
```

And get as a response an output similar to this:
```
Usage: index start bridge-watchdog [options]
Options:
--eth-node-url <eth_node_url> The URL of the Ethereum node. (default: "")
--eth-master-sk <eth_master_sk> The secret key of the master account on Ethereum blockchain. (default: "")
--eth-client-artifact-path <eth_client_artifact_path> Path to the artifact file defining Ethereum Client contract. (default: "/home/username/src/rainbow-bridge/contracts/eth/nearbridge/artifacts/contracts/NearBridge.sol/NearBridge.json")
--eth-client-address <eth_client_address> ETH address of the EthClient contract. (default: "0x3be7Df8dB39996a837041bb8Ee0dAdf60F767038")
--watchdog-delay <watchdog_delay> Number of seconds to wait after validating all signatures. (default: 600)
--watchdog-error-delay <watchdog_error_delay> Number of seconds to wait before retrying if there is an error. (default: "1")
--daemon <daemon> Whether the process should be launched as a daemon. (default: "true")
--metrics-port <metrics_port> On which port to expose metrics for corresponding relayer, if not provided no metrics exposed
```

### Installing `pm2`

With `yarn`:
```
$ yarn global add pm2
```

With `npm`:

```
$ npm install pm2 -g
```

With _debian_, use the install script:

```
$ apt update && apt install sudo curl && curl -sL https://raw.githubusercontent.com/Unitech/pm2/master/packager/setup.deb.sh | sudo -E bash -
```

0 comments on commit 81d589d

Please sign in to comment.