bifrost-relayer.py (Legacy)

What is bifrost-relayer.py?

bifrost-relayer.py is the Python implementation of the Bifrost network's relayer and represents the initial implementation of the CCCP-Relayer. Recently, we have introduced a Rust implementation of the CCCP-Relayer. However, this doesn't imply the end of the legacy relayer, which will continue to be maintained and supported.

Install Requirements

First, you need to get the code to prepare for the relayer execution.

git clone https://github.com/bifrost-platform/bifrost-relayer.py

The common configurations for the bifrost-relayer is provided through the configs/entity.relayer.json file, but the individual settings for each relayer must be set through the configs/entity.relayer.private.json file. (For testnet relayers, use the configs-testnet directory)

Using Systemd

Python version 3.10 is required to run the relayer as a system daemon.

apt install python3.10 python3.10-venv

The required Python packages must be priorly installed. It is recommended to use a virtual environment, and this manual assumes the use of a virtual environment.

cd bifrost-relayer.py

# Install virtualenv package & create virtual environment
python3.10 -m venv ./venv

# activate virtual environment & install dependencies
source venv/bin/activate
pip install -r requirements.txt

# deactivate the virtual environment
deactivate

Next, you need to create a Systemd configuration file. Create the file in the following directory.

sudo vi /etc/systemd/system/bifrost-relayer.service
  • <DIRECTORY_WHERE_BIFROST_RELAYER_LOCATES> : The absolute path to the directory where the installed bifrost-relayer locates.

  • <PATH_TO_BIFROST_RELAYER> : The absolute path to the installed bifrost-relayer.

[Unit]
Description=Bifrost relayer Daemon
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
SyslogIdentifier=bifrost-relayer
SyslogFacility=local7
WorkingDirectory=<DIRECTORY_WHERE_BIFROST_RELAYER_LOCATES>
ExecStart=<PATH_TO_BIFROST_RELAYER>/venv/bin/python relayer-launcher.py --slow-relayer --prometheus
KillSignal=SIGHUP

[Install]
WantedBy=multi-user.target
Example
[Unit]
Description=Bifrost relayer Daemon
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
SyslogIdentifier=bifrost-relayer
SyslogFacility=local7
WorkingDirectory=/home/ubuntu/example/bifrost-relayer
ExecStart=/home/ubuntu/example/bifrost-relayer/venv/bin/python relayer-launcher.py --slow-relayer --prometheus
KillSignal=SIGHUP

[Install]
WantedBy=multi-user.target

Now, with the two lines of the command below, the relayer will be executed in the background.

systemctl enable bifrost-relayer.service
systemctl start bifrost-relayer.service

To check your running bifrost-relayer service logs, execute the command below.

journalctl -f -u bifrost-relayer

Using Docker

Move to the project root path and build the Docker image.

cd bifrost-relayer.py
docker build -t bifrost-relayer .

Run the built image.

docker run --restart always -d \
    --mount type=bind,source="$(pwd)"/configs,target=/app/configs \
    --name relayer \
    --network host \
    bifrost-relayer

To check your running bifrost-relayer container logs, execute the command below.

docker logs -f bifrost-relayer

Last updated