23dda62 Rococo <> Wococo messages relay (#1030) bcde21d Update the wasm builder to substrate master (#1029) a8318ce Make target signer optional when sending message. (#1018) f8602e1 Fix insufficient balance when send message. (#1020) d95c0a7 greedy relayer don't need message dispatch to be prepaid if dispatch is supposed to be paid at the target chain (#1016) ad5876f Update types. (#1027) 116cbbc CI: fix starting the pipeline (#1022) 7e0fadd Add temporary `canary` job (#1019) 6787091 Update types to contain dispatch_fee_payment (#1017) 03f79ad Allow Root to assume SourceAccount. (#1011) 372d019 Return dispatch_fee_payment from message details RPC (#1014) 604eb1c Relay basic single-bit message dispatch results back to the source chain (#935) bf52fff Use plain source_queue view when selecting nonces for delivery (#1010) fc5cf7d pay dispatch fee at target chain (#911) 1e35477 Bump Substrate to `286d7ce` (#1006) 7ad07b3 Add --only-mandatory-headers mode (#1004) 5351dc9 Messages relayer operating mode (#995) 9bc29a7 Rococo <> Wococo relayer balance guard (#998) bc17341 rename messages_dispatch_weight -> message_details (#996) 95be244 Bump Rococo and Wococo spec versions (#999) c35567b Move ChainWithBalances::NativeBalance -> Chain::Balance (#990) 1bfece1 Fix some nits (#988) 334ea0f Increase pause before starting relays again (#989) 7fb8248 Fix clippy in test code (#993) d60ae50 fix clippy issues (#991) 75ca813 Make sure GRANDPA shares state with RPC. (#987) da2a38a Bump Substrate (#986) 5a9862f Update submit finality proof weight formula (#981) 69df513 Flag for rejecting all outbound messages (#982) 14d0506 Add script to setup bench machine. (#984) e74e8ab Move CI from GitHub Actions to GitLab (#814) c5ca5dd Custom justification verification (#979) 643f10d Always run on-demand headers relay in complex relay (#975) a35b0ef Add JSON type definitions for Rococo<>Wococo bridge (#977) 0eb83f2 Update cargo.deny (#980) e1d1f4c Bump Rococo/Wococo spec_version (#976) deac90d increase pause before starting relays (#974) 68d6d79 Revert to use InspectCmd, bump substrate `6bef4f4` (#966) 66e1508 Avoid hashing headers twice in verify_justification (#973) a31844f Bump `environmental` dependency (#972) 2a4c29a in auto-relays keep trying to connect to nodes until connection is established (#971) 0e767b3 removed stray file (#969) b9545dc Serve multiple lanes with single complex relay instance (#964) 73419f4 Correct type error (#968) bac256f Start finality relay spec-version guards for Rococo <> Wococo finality relays (#965) bfd7037 pass source and target chain ids to account_ownership_proof (#963) 8436073 Upstream changes from Polkadot repo (#961) e58d851 Increase account endowment amount (#960) git-subtree-dir: bridges git-subtree-split: 23dda6248236b27f20d76cbedc30e189cc6f736c
8.3 KiB
Parity Bridges Common
This is a collection of components for building bridges.
These components include Substrate pallets for syncing headers, passing arbitrary messages, as well as libraries for building relayers to provide cross-chain communication capabilities.
Three bridge nodes are also available. The nodes can be used to run test networks which bridge other Substrate chains or Ethereum Proof-of-Authority chains.
🚧 The bridges are currently under construction - a hardhat is recommended beyond this point 🚧
Contents
- Installation
- High-Level Architecture
- Project Layout
- Running the Bridge
- How to send a message
- Community
Installation
To get up and running you need both stable and nightly Rust. Rust nightly is used to build the Web Assembly (WASM) runtime for the node. You can configure the WASM support as so:
rustup install nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
Once this is configured you can build and test the repo as follows:
git clone https://github.com/paritytech/parity-bridges-common.git
cd parity-bridges-common
cargo build --all
cargo test --all
If you need more information about setting up your development environment Substrate's Getting Started page is a good resource.
High-Level Architecture
This repo has support for bridging foreign chains together using a combination of Substrate pallets and external processes called relayers. A bridge chain is one that is able to follow the consensus of a foreign chain independently. For example, consider the case below where we want to bridge two Substrate based chains.
+---------------+ +---------------+
| | | |
| Rialto | | Millau |
| | | |
+-------+-------+ +-------+-------+
^ ^
| +---------------+ |
| | | |
+-----> | Bridge Relay | <-------+
| |
+---------------+
The Millau chain must be able to accept Rialto headers and verify their integrity. It does this by using a runtime module designed to track GRANDPA finality. Since two blockchains can't interact directly they need an external service, called a relayer, to communicate. The relayer will subscribe to new Rialto headers via RPC and submit them to the Millau chain for verification.
Take a look at Bridge High Level Documentation for more in-depth description of the bridge interaction.
Project Layout
Here's an overview of how the project is laid out. The main bits are the node, which is the actual
"blockchain", the modules which are used to build the blockchain's logic (a.k.a the runtime) and
the relays which are used to pass messages between chains.
├── bin // Node and Runtime for the various Substrate chains
│ └── ...
├── deployments // Useful tools for deploying test networks
│ └── ...
├── diagrams // Pretty pictures of the project architecture
│ └── ...
├── modules // Substrate Runtime Modules (a.k.a Pallets)
│ ├── ethereum // Ethereum PoA Header Sync Module
│ ├── grandpa // On-Chain GRANDPA Light Client
│ ├── messages // Cross Chain Message Passing
│ ├── dispatch // Target Chain Message Execution
│ └── ...
├── primitives // Code shared between modules, runtimes, and relays
│ └── ...
├── relays // Application for sending headers and messages between chains
│ └── ...
└── scripts // Useful development and maintenance scripts
Running the Bridge
To run the Bridge you need to be able to connect the bridge relay node to the RPC interface of nodes on each side of the bridge (source and target chain).
There are 3 ways to run the bridge, described below:
- building & running from source,
- building or using Docker images for each individual component,
- running a Docker Compose setup (recommended).
Using the Source
First you'll need to build the bridge nodes and relay. This can be done as follows:
# In `parity-bridges-common` folder
cargo build -p rialto-bridge-node
cargo build -p millau-bridge-node
cargo build -p substrate-relay
Running
To run a simple dev network you'll can use the scripts located in
the deployments/local-scripts folder. Since the relayer connects to
both Substrate chains it must be run last.
# In `parity-bridges-common` folder
./deployments/local-scripts/run-rialto-node.sh
./deployments/local-scripts/run-millau-node.sh
./deployments/local-scripts/relay-millau-to-rialto.sh
At this point you should see the relayer submitting headers from the Millau Substrate chain to the Rialto Substrate chain.
Local Docker Setup
To get up and running quickly you can use published Docker images for the bridge nodes and relayer. The images are published on Docker Hub.
To run the dev network we first run the two bridge nodes:
docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \
-it paritytech/rialto-bridge-node --dev --tmp \
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
docker run -p 30334:30333 -p 9934:9933 -p 9945:9944 \
-it paritytech/millau-bridge-node --dev --tmp \
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
Notice that the docker run command will accept all the normal Substrate flags. For local
development you should at minimum run with the --dev flag or else no blocks will be produced.
Then we need to initialize and run the relayer:
docker run --network=host -it \
paritytech/substrate-relay init-bridge RialtoToMillau \
--target-host localhost \
--target-port 9945 \
--source-host localhost \
--source-port 9944 \
--target-signer //Alice
docker run --network=host -it \
paritytech/substrate-relay relay-headers RialtoToMillau \
--target-host localhost \
--target-port 9945 \
--source-host localhost \
--source-port 9944 \
--target-signer //Bob \
You should now see the relayer submitting headers from the Millau chain to the Rialto chain.
If you don't want to use the published Docker images you can build images yourself. You can do this by running the following commands at the top level of the repository.
# In `parity-bridges-common` folder
docker build . -t local/rialto-bridge-node --build-arg PROJECT=rialto-bridge-node
docker build . -t local/millau-bridge-node --build-arg PROJECT=millau-bridge-node
docker build . -t local/substrate-relay --build-arg PROJECT=substrate-relay
Note: Building the node images will take a long time, so make sure you have some coffee handy.
Once you have the images built you can use them in the previous commands by replacing
paritytech/<component_name> with local/<component_name> everywhere.
Full Network Docker Compose Setup
For a more sophisticated deployment which includes bidirectional header sync, message passing, monitoring dashboards, etc. see the Deployments README.
How to send a message
A straightforward way to interact with and test the bridge is sending messages. This is explained in the send message document.
Community
Main hangout for the community is Element (formerly Riot). Element is a chat server like, for example, Discord. Most discussions around Polkadot and Substrate happen in various Element "rooms" (channels). So, joining Element might be a good idea, anyway.
If you are interested in information exchange and development of Polkadot related bridges please feel free to join the Polkadot Bridges Element channel.
The Substrate Technical Element channel is most suited for discussions regarding Substrate itself.