Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

darwinia-network/bridger

Repository files navigation

Darwinia Bridger

CI release doc downloads license

Relayers (aka. Bridgers) in Darwinia Network are offchain worker clients which help relay the headers and messages between source chains and target chains, they work between two chains and require RPC access of two chains.

Darwinia Bridger (this repo) is an implementation of a relayer client written in Rust.

Installation

Download from GitHub releases

Download the binary from latest release .

  • The asset name for macOS is bridger-darwin-x86_64.zip.
  • The asset name for Linux is bridger-linux-x86_64.zip.

Pull the Docker image

The latest version you can find from latest release

docker pull quay.io/darwinia-network/bridger:<VERSION>

Build from source

Please install rust toolchain first

git clone https://github.com/darwinia-network/bridger.git
cd bridger/
./bridger.sh -h
Set registry

You need set registry when you want to compile from source, because default registry download precompile binary from Github release page. So set registry to local

./bridger.sh registry set --type local

Environment Vars

The bridger program will read some environments.

Name Description
BRIDGER_HOME All data of bridger and bridges will be store in this path. If not set this value, the default will be store in $HOME/.bridger.
LOG_ADAPTER Custom log adapter, you can use json value. after do this, all logs will output use json format.
LOG_MAX_LEVEL Max log level, default is trace
RUST_BACKTRACE You can set 1 or 0 to enable or disable error full error trace
RUST_LOG Custom log level for target or crate

Configuration

The currently darwinia-bridger supports muliti bridges. Each bridge has its own configuration file. The configuration filename pattern is bridge-<BRIDGE_NAME>.toml

The default configuration dir is your BRIDGER_HOME env var.

If you use docker to run the bridger. You should put your configuration file to your dir that will be mapped to the container's /root/.bridger. For example: /home/ubuntu/bridger_config_dir/pangolin-pangoro.

Mainnet

TYPE BRIDGE NAME
evm-ethereum darwinia-ethereum Guide
substrate-substrate darwinia-crab Guide

Testnet

TYPE BRIDGE NAME
evm-ethereum pangoro-goerli Guide
substrate-substrate pangolin-pangoro Guide

Goerli is the testnet of Ethereum. Pangolin is the testnet of Crab. Pangoro is the testnet of Darwinia.

Usage

Binary

bridger pangolin-pangoro start

The pangolin-pangoro here is a bridge name listed in the previous Configuration section.

-h will list all commands it supports.

bridger pangolin-pangoro -h
Update

Open your ~/.bridger/bridger.toml and update the version to the new one.

[registry]
path = "https://github.com/darwinia-network/bridger"
type = "Github"
version = "0.8.0"

Run bridger pangolin-pangoro start, It will automatically update the new version bridge.

Docker

docker run -d \
  --name pangolin-pangoro \
  --restart always \
  -v /home/ubuntu/bridger_config_dir/pangolin-pangoro:/root/.bridger \
  quay.io/darwinia-network/bridger:v0.8.0 \
  pangolin-pangoro start

Note: It is recommended that you create a directory specific to a bridge if you use docker to run bridger. Here we have a pangolin-pangoro dir in your local config dir.

Update

First delete your container, then rerun the docker run command with the new version.

docker stop pangolin-pangoro
docker rm pangolin-pangoro
docker run -d \
  --name pangolin-pangoro \
  --restart always \
  -v /home/ubuntu/bridger_config_dir/pangolin-pangoro:/root/.bridger \
  quay.io/darwinia-network/bridger:v0.8.0 \
  pangolin-pangoro start

docker-compose

If you run multiple bridges, you can use docker-compose to simplify the process. What you need to do is create a docker-compose.yml file. Here is an example:

version: '3'
services:
  pangolin-pangoro:
    container_name: pangolin-pangoro
    image: quay.io/darwinia-network/bridger:v0.8.0
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime
      - /home/ubuntu/bridger_config_dir/pangolin-pangoro:/root/.bridger
    command:
      - pangolin-pangoro
      - start

  pangoro-goerli:
    container_name: pangoro-goerli
    image: quay.io/darwinia-network/bridger:v0.8.0
    restart: always
    volumes:
      - /etc/localtime:/etc/localtime
      - /home/ubuntu/bridger_config_dir/pangoro-goerli:/root/.bridger
    command:
      - pangoro-goerli
      - start

Run in the directory where the docker-compose.yml file is located:

docker-compose up -d
Update

Update the bridger version in your docker-compose.yml file, then,

docker-compose down
docker-compose up -d

Advanced

Init bridge

After the blockchain is reset, the bridge needs to be initialized. The user does not need to do this, it is usually done by the developer.

bridger pangolin-pangoro init pangolin-to-pangoro
bridger pangolin-pangoro init pangoro-to-pangolin