How to Run a Watcher
By the end of this guide, you should know how to run a Watcher on your local machine, on VPS, or a bare-metal server. The guide is useful for enterprise clients who want to integrate with the OMG Network.
Goals
You should use this guide if you need to accomplish one of the following goals:
Rely on a personal Watcher to verify transactions and receive network's events
Host a redundant Watcher node to secure the network
Be an active participant of the network
Prerequisites
Basic knowledge of Linux and blockchain technology
A laptop/PC, a Linux-based VPS, or a bare-metal server
A fully synced Ethereum client
Ethereum client is required to synchronize transactions on the OMG Network with the Ethereum Network. The easiest way to have a full ETH client is to use one of the Ethereum infrastructure providers. Our team has tried Infura and Geth but other providers may work too.
Supported Platforms
The Watcher has been tested on the following environments:
Ubuntu 16.04
Ubuntu 18.04
Alpine 3.11
macOS 11.0.0 (local usage only)
Note, it might be possible to run a Watcher on other environments. Above are provided the systems that have been tested.
Minimum Hardware Requirements
The following hardware is required to run a Watcher:
Storage: 8GB SSD
CPU: 1 CPU Core with at least 2.2 GHz
RAM: 4GB
Bandwidth: 20 Mbps
The requirements are based on the network's load in Q3 2020. It is recommended to use hardware with higher performance to avoid a potential increase in transaction volume.
Costs
The costs of running a Watcher include the following components:
A full Ethereum node (local or ETH provider)
VPS, bare-metal server, or local machine that matches the minimum hardware requirements
DevOps setup and maintenance fee
Setup
Before installing Watcher service on a server or your local machine, you should have a few things setup:
1. Log in to Your Server
If you're planning to install a Watcher on a remote server (VPS or bare-metal), make sure to have an active session open before proceeding with the guide.
The configuration process takes a significant amount of time and may require help from your DevOps team. This step is fully covered in the Manage VPS guide.
You can log in using the following command from your terminal or command prompt:
$USER
- the name of the user with root privileges used to log into the remote server. Default: root.
$REMOTE_SERVER
- an IP address of your remote server.
$PORT
- a port used to connect to the server. Default: 22.
2. Check TCP ports
Make sure you have don't have any of the services running on one of the following ports: 7434, 7534, 5432. The ports are used as follows:
7434:
watcher
, a light-weight Watcher to ensure the security of funds deposited into the childchain7534:
watcher_info
, a convenient and performant API to the child chain data5432:
postgres
, a PostgreSQL database that stores transactions and contains data needed for challenges and exits
You can use lsof
, netstat
or other alternatives to check occupied ports:
If you found one of the ports is already in use, kill the process the port is occupied with as follows:
$PORT
- a port to clear from other processes
$PID
- process ID listening on a defined port
If you're already using Docker, verify these ports are free too:
3. Update Packages
If you're using a Linux-based system, make sure to update your packages:
Install
Running a Watcher locally is recommended for testing purposes only. For production, you should use VPS or a bare-metal server. This allows increasing uptime, reducing latency, and configuring advanced security measures for your instance.
Bare-metal (Ubuntu)
Docker Compose (Ubuntu)
Docker Compose (macOS)
This method shows how to install and run a Watcher from a bare-metal release of the elixir-omg
repository. It is a recommended approach for production use. You can run it on VPS, dedicated, or bare-metal server on one of the supported environments.
1. Install Dependencies
1.1 Install Erlang and Elixir
The current implementation is built with Erlang and Elixir and uses asdf
to manage multiple runtime versions. Asdf relies on several libraries that you may need to install first:
If you've used these libraries before, you may proceed to asdf
installation as follows:
1.2 Install PostgreSQL
PostgreSQL is required to store Watcher's data, such as deposits, transactions, exits, and byzantine events.
2. Compile the Watcher
2.1 Clone elixir-omg
Repository
elixir-omg
Repository2.2 Setup the Project
This step may take up to 30 minutes.
2.3 Build the Watcher
3. Configure the Watcher
3.1 Configure an Environment File
There are several environmental variables the Watcher uses to run its service. To configure them, run the following command in your terminal:
$ETHEREUM_RPC_URL
- a full Ethereum node URL
Above are provided the values for OMG NETWORK MAINNET BETA V1
. If you want to work with another environment, please refer to environments
.
3.2 Apply Environment Variables
For the environment variables to take effect, run the command as follows:
Note, these values live within your current shell's context. So you need to run this command again on system restart, exiting the shell, etc. To permanently set these values, check the following thread.
If you want to set up additional configurations, refer to deployment configuration document.
4. Install the Watcher
4.1 Create a Directory for Geth
4.2 Initialize Database
Example output:
4.3 Migrate Database Tables
Example output:
4.4 Run Ethereum Tasks
Example output:
5. Run the Watcher
You can start a Watcher as follows:
But it's recommended to run this service in the background:
Example output:
6. Update the Watcher
Frequently there will be updates that you need to apply to your Watcher. First, pull the changes from the repo as follows:
Then, repeat the steps starting from here.
This method shows how to set up and run a Watcher via Docker Compose tooling. You can run it on your local machine, VPS, dedicated, or bare-metal server on one of the supported environments.
1. Install Dependencies
1.1 Install Docker
$USER
- the name of the user with root privileges used on a remote server.
1.2 Install Docker Compose
Make sure to install the latest version of Docker Compose from the official repository.
You will have to log out from a server for installed dependencies to take affect.
1.3 Verify
To verify the installed dependencies, use the following commands:
Example output:
2. Set Up Configuration Files
The Watcher consists of watcher
and watcher_info
services. You can run watcher
separately, however, watcher_info
relies on the PostgreSQL database where it stores the network's data. All releases and corresponding Docker images (starting from 1.0.1
) can be found in our official repository
.
2.1 Configure docker-compose-watcher.yml File
Docker Compose allows defining and running multi-container Docker applications. To launch a Watcher with Compose, first, create a YAML file that will contain configurations for our services with nano
or vim
text editor:
Then, copy and paste the required configs, save the changes with ctrl+o
(Linux/Windows) or control+o
(macOS) and Enter
to confirm the changes respectively. Then exit the file with ctrl+x
or control+x
.
2.2 Configure an Environment File
The YAML file has several values that have to be configured in .env
file as follows::
$ETHEREUM_RPC_URL
- a full Ethereum node URL
$WATCHER_IMAGE
- the latest stablewatcher
image (e.g.omisego/watcher:1.0.3
)
$WATCHER_INFO_IMAGE
- the latest stablewatcher_info
image (e.g.omisego/watcher_info:1.0.3
)
Above are provided the values for OMG NETWORK MAINNET BETA V1
. If you want to work with another environment, please refer to environments
.
3. Run a Watcher Instance
To run a Watcher instance, you need to start the required Docker containers. The parameter -d
allows running containers in the background.
Example output:
To see logs, use the following command:
Example output:
Depending on the server's hardware and internet connection, the entire process can take up to an hour.
If you want to exit the logs without stopping containers, use ctrl+c
or control+c
.
This method shows how to set up and run a Watcher via Docker Compose tooling, and should be used only on your local macOS machine.
1. Install Dependencies
1.1 Install Brew
1.2 Install Docker and Docker-Machine
Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively on macOS. You'll have to install docker-machine in order to create VM and attach it to.
1.3 Install Docker-Machine Dependencies
Docker-machine relies on VirtualBox, so you have to install it as well:
If the installation fails, you'll see the Security & Privacy
window opened. Unlock the settings and enable an extension by Oracle as follows:
1.4 Create a Default Docker-Machine
Next, you'll have to create a default machine, specify the name of the machine that Docker will use to execute commands, and connect your shell to the new machine.
You can verify that your machine was created as follows:
Example output:
1.5 Install Docker Compose
The current guide will demonstrate how to set up and manage a Watcher via Docker Compose tooling due to the simplicity of running this on your laptop/PC.
To verify the installed Docker and Compose, use the following commands:
Example output:
2. Configure and Run the Watcher Instance
The rest of the steps are the same as described in the Docker Compose guide for Linux-based systems. Proceed to 2. Set Up Configuration Files
of the Docker Compose
tab to finish the installation.
Verify
To verify that you're fully synced, check the status of Watcher and Watcher Info:
Watcher Info
$REMOTE_SERVER
- an IP address of your remote server. If you run the Watcher on your local machine, replace the value with thelocalhost
.
Example output:
Notice, the server may not respond until the following line appears in the watcher_info
logs:
Watcher
$REMOTE_SERVER
- an IP address of your remote server. If you run the Watcher on your local machine, replace the value with thelocalhost
.
Example output:
Test
There are two ways to test that your Watcher is working properly:
Use
http://$REMOTE_SERVER:7534
as aWATCHER_URL
value in your configs to make a transfer in your own or one of the OMG Network projects, such as omg-js samples.Make a transaction or another operation using Watcher Info API.
$REMOTE_SERVER
- an IP address of your remote server. If you run the Watcher on your local machine, replace the value with thelocalhost
.
Last updated