Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
/ ChainBridge Public archive

🌉 Modular Multi-Directional Blockchain Bridge to interact with Multiple Networks; Ethereum, Ethereum Classic, Substrate, based chains. Stay tuned for ChainBridge Hub!

License

Notifications You must be signed in to change notification settings

ChainSafe/ChainBridge

Repository files navigation

Archiving notice:

This library is no longer in use and maintenance. All further development related to chainbridge will happen in thenewrepo. More detailed information about chainbridge-core you can find in its readme orDiscussions.

If you already running an old ChainBridge version please consider checkingchainbridge-migrationscripts that allow migrating to a newer version of chainbridge.

ChainBridge

discord build status

Contents

Getting Started

Installation

Dependencies

  • Subkey: Used for substrate key management. Only required if connecting to a substrate chain.

Building

make build:Buildschainbridgein./build.

or

make install:Usesgo installto addchainbridgeto your GOBIN.

Docker

The official ChainBridge Docker image can be found here.

To build the Docker image locally run:

docker build -t chainsafe/chainbridge.

To start ChainBridge:

  • docker run -vuses an absolute path rather than a relative one.
docker run -v $(pwd)/config.json:/config.json chainsafe/chainbridge

Configuration

Note: TOML configs have been deprecated in favour of JSON

A chain configurations take this form:

{
"name": "eth", // Human-readable name
"type": "ethereum", // Chain type (eg. "ethereum" or "substrate" )
"id": "0", // Chain ID
"endpoint": "ws://<host>:<port>", // Node endpoint
"from": "0xff93...", // On-chain address of relayer
"opts": {}, // Chain-specific configuration options (see below)
}

Seeconfig.json.examplefor an example configuration.

Ethereum Options

Ethereum chains support the following additional options:

{
"bridge": "0x12345...", // Address of the bridge contract (required)
"erc20Handler": "0x1234...", // Address of erc20 handler (required)
"erc721Handler": "0x1234...", // Address of erc721 handler (required)
"genericHandler": "0x1234...", // Address of generic handler (required)
"maxGasPrice": "0x1234", // Gas price for transactions (default: 20000000000)
"minGasPrice": "0x1234", // Minimum gas price for transactions (default: 0)
"gasLimit": "0x1234", // Gas limit for transactions (default: 6721975)
"gasMultiplier": "1.25", // Multiplies the gas price by the supplied value (default: 1)
"http": "true", // Whether the chain connection is ws or http (default: false)
"startBlock": "1234", // The block to start processing events from (default: 0)
"blockConfirmations": "10" // Number of blocks to wait before processing a block
"useExtendedCall": "true" // Extend extrinsic calls to substrate with ResourceID. Used for backward compatibility with example pallet. *Default: false*
"egsApiKey": "xxx..." // API key for Eth Gas Station (https:// ethgasstation.info/)
"egsSpeed": "fast" // Desired speed for gas price selection, the options are: "average", "fast", "fastest"
}

Substrate Options

Substrate supports the following additonal options:

{
"startBlock": "1234" // The block to start processing events from (default: 0)
}

Blockstore

The blockstore is used to record the last block the relayer processed, so it can pick up where it left off.

If astartBlockoption is provided (seeConfiguration), then the greater ofstartBlockand the latest block in the blockstore is used at startup.

To disable loading from the blockstore specify the--freshflag. A custom path for the blockstore can be provided with--blockstore <path>.For development, the--latestflag can be used to start from the current block and override any other configuration.

Keystore

ChainBridge requires keys to sign and submit transactions, and to identify each bridge node on chain.

To use secure keys, seechainbridge accounts --help.The keystore password can be supplied with theKEYSTORE_PASSWORDenvironment variable.

To import external ethereum keys, such as those generated with geth, usechainbridge accounts import --ethereum /path/to/key.

To import private keys as keystores, usechainbridge accounts import --privateKey key.

For testing purposes, chainbridge provides 5 test keys. The can be used with--testkey <name>,wherenameis one ofAlice,Bob,Charlie,Dave,orEve.

Metrics

Seemetrics.md.

Chain Implementations

  • Ethereum (Solidity):chainbridge-solidity

    The Solidity contracts required for chainbridge. Includes deployment and interaction CLI.

    The bindings for the contracts live inbindings/.To update the bindings modifyscripts/setup-contracts.shand then runmake clean && make setup-contracts

  • Substrate:chainbridge-substrate

    A substrate pallet that can be integrated into a chain, as well as an example pallet to demonstrate chain integration.

Docs

MKdocs will generate static HTML files for Chainsafe markdown files located inChainbridge/docs/

make install-mkdocs:Pull the docker image MkDocs

make mkdocs:Run MkDoc's docker image, building and hosting the html files onlocalhost:8000

Testing

Unit tests require an ethereum node running onlocalhost:8545and a substrate node running onlocalhost:9944.E2E tests require an additional ethereum node onlocalhost:8546.

A docker-compose file is provided to run two Geth nodes and a chainbridge-substrate-chain node in isolated environments:

$ docker-compose -f./docker-compose-e2e.yml up

Seechainbridge-solidityandchainbridge-substrate-chainfor more information on testing facilities.

All Go tests can be run with:

$ make test

Go tests specifically for ethereum, substrate and E2E can be run with

$ make test-eth
$ make test-sub
$ make test-e2e

ChainSafe Security Policy

Reporting a Security Bug

We take all security issues seriously, if you believe you have found a security issue within a ChainSafe project please notify us immediately. If an issue is confirmed, we will take all necessary precautions to ensure a statement and patch release is made in a timely manner.

Please email us a description of the flaw and any related information (e.g. reproduction steps, version) to security at chainsafe dot io.

About

🌉 Modular Multi-Directional Blockchain Bridge to interact with Multiple Networks; Ethereum, Ethereum Classic, Substrate, based chains. Stay tuned for ChainBridge Hub!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages