Skip to content

Commit 209cba3

Browse files
svyatonikacatangiu
andauthored
Update project level docs (#1734)
* updated project level document * updated high level overview document * GRANDPA finality relay sequence diagram * Parachains Finality Relay Sequence Diagram * Messages Relay Sequence Diagram * Complex Relayer Sequence Diagram * small fix * Polkadot <> Kusama bridge flowchart * remove obsolete files * started polkadot-kusama-bridge-overview.md * continue polkadot-kusama-bridge-overview.md * couple more sections in polkadot-kusama-bridge-overview.md * continue polkadot-kusama-bridge-overview.md * renew deployments readme * fixed review suggestions * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * removed obsolete section * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * typo * Update docs/polkadot-kusama-bridge-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/high-level-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/polkadot-kusama-bridge-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/polkadot-kusama-bridge-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/polkadot-kusama-bridge-overview.md Co-authored-by: Adrian Catangiu <[email protected]> * Update docs/polkadot-kusama-bridge-overview.md Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]>
1 parent b05cef5 commit 209cba3

16 files changed

+675
-686
lines changed

README.md

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ Substrate chains.
1010

1111
🚧 The bridges are currently under construction - a hardhat is recommended beyond this point 🚧
1212

13-
**IMPORTANT**: this documentation is outdated and it is mostly related to the previous version of our
14-
bridge. Right there's an ongoing work to make our bridge work with XCM messages. Old bridge is still
15-
available at [encoded-calls-messaging](https://github.com/paritytech/parity-bridges-common/releases/tag/encoded-calls-messaging)
16-
tag.
17-
1813
## Contents
1914

2015
- [Installation](#installation)
@@ -97,7 +92,7 @@ description of the bridge interaction.
9792

9893
## Project Layout
9994

100-
Here's an overview of how the project is laid out. The main bits are the `node`, which is the actual
95+
Here's an overview of how the project is laid out. The main bits are the `bin`, which is the actual
10196
"blockchain", the `modules` which are used to build the blockchain's logic (a.k.a the runtime) and
10297
the `relays` which are used to pass messages between chains.
10398

@@ -106,16 +101,16 @@ the `relays` which are used to pass messages between chains.
106101
│ └── ...
107102
├── deployments // Useful tools for deploying test networks
108103
│ └── ...
109-
├── diagrams // Pretty pictures of the project architecture
110-
│ └── ...
111104
├── modules // Substrate Runtime Modules (a.k.a Pallets)
105+
│ ├── beefy // On-Chain BEEFY Light Client (in progress)
112106
│ ├── grandpa // On-Chain GRANDPA Light Client
113107
│ ├── messages // Cross Chain Message Passing
114-
│ ├── dispatch // Target Chain Message Execution
108+
│ ├── parachains // On-Chain Parachains Light Client
109+
│ ├── relayers // Relayer rewards registry
115110
│ └── ...
116111
├── primitives // Code shared between modules, runtimes, and relays
117112
│ └── ...
118-
├── relays // Application for sending headers and messages between chains
113+
├── relays // Application for sending finality proofs and messages between chains
119114
│ └── ...
120115
└── scripts // Useful development and maintenance scripts
121116
```
@@ -127,8 +122,11 @@ on each side of the bridge (source and target chain).
127122

128123
There are 2 ways to run the bridge, described below:
129124

130-
- building & running from source
131-
- running a Docker Compose setup (recommended).
125+
- building & running from source: with this option, you'll be able to run the bridge between two standalone
126+
chains that are running GRANDPA finality gadget to achieve finality;
127+
128+
- running a Docker Compose setup: this is a recommended option, where you'll see bridges with parachains,
129+
complex relays and more.
132130

133131
### Using the Source
134132

@@ -204,7 +202,33 @@ You will also see the message lane relayers listening for new messages.
204202

205203
To send a message see the ["How to send a message" section](#how-to-send-a-message).
206204

207-
### Full Network Docker Compose Setup
205+
### How to send a message
206+
207+
In this section we'll show you how to quickly send a bridge message. The message is just an encoded XCM
208+
`Trap(43)` message.
209+
210+
```bash
211+
# In `parity-bridges-common` folder
212+
./scripts/send-message-from-millau-rialto.sh
213+
```
214+
215+
After sending a message you will see the following logs showing a message was successfully sent:
216+
217+
```
218+
INFO bridge Sending message to Rialto. Size: 5.
219+
TRACE bridge Sent transaction to Millau node: 0x5e68...
220+
```
221+
222+
And at the Rialto node logs you'll something like this:
223+
224+
```
225+
... runtime::bridge-dispatch: Going to execute message ([0, 0, 0, 0], 1) (...), Trap(43)])
226+
... runtime::bridge-dispatch: Incoming message ([0, 0, 0, 0], 1) dispatched with result: Incomplete(2000000000, Trap(43))
227+
```
228+
229+
It means that the message has been delivered and successfully dispatched.
230+
231+
## Full Network Docker Compose Setup
208232

209233
For a more sophisticated deployment which includes bidirectional header sync, message passing,
210234
monitoring dashboards, etc. see the [Deployments README](./deployments/README.md).
@@ -220,24 +244,6 @@ docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \
220244
--rpc-cors=all --unsafe-rpc-external --unsafe-ws-external
221245
```
222246

223-
### How to send a message
224-
225-
In this section we'll show you how to quickly send a bridge message, if you want to
226-
interact with and test the bridge see more details in [send message](./docs/send-message.md)
227-
228-
```bash
229-
# In `parity-bridges-common` folder
230-
./scripts/send-message-from-millau-rialto.sh remark
231-
```
232-
233-
After sending a message you will see the following logs showing a message was successfully sent:
234-
235-
```
236-
INFO bridge Sending message to Rialto. Size: 286. Dispatch weight: 1038000. Fee: 275,002,568
237-
INFO bridge Signed Millau Call: 0x7904...
238-
TRACE bridge Sent transaction to Millau node: 0x5e68...
239-
```
240-
241247
## Community
242248

243249
Main hangout for the community is [Element](https://element.io/) (formerly Riot). Element is a chat

deployments/README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Bridge Deployments
22

33
## Requirements
4+
45
Make sure to install `docker` and `docker-compose` to be able to run and test bridge deployments. If
56
for whatever reason you can't or don't want to use Docker, you can find some scripts for running the
6-
bridge [here](https://github.com/svyatonik/parity-bridges-common.test).
7+
bridge [here](./local-scripts/).
78

89
## Networks
10+
911
One of the building blocks we use for our deployments are _networks_. A network is a collection of
1012
homogenous blockchain nodes. We have Docker Compose files for each network that we want to bridge.
1113
Each of the compose files found in the `./networks` folder is able to independently spin up a
@@ -18,6 +20,7 @@ docker-compose -f ./networks/rialto.yml up
1820
After running this command we would have a network of several nodes producing blocks.
1921

2022
## Bridges
23+
2124
A _bridge_ is a way for several _networks_ to connect to one another. Bridge deployments have their
2225
own Docker Compose files which can be found in the `./bridges` folder. These Compose files typically
2326
contain bridge relayers, which are services external to blockchain nodes, and other components such
@@ -43,10 +46,11 @@ and Grafana. We cover these in more details in the [Monitoring](#monitoring) sec
4346
the monitoring Compose file is _not_ optional, and must be included for bridge deployments.
4447

4548
### Running and Updating Deployments
49+
4650
We currently support three bridge deployments
4751
1. Rialto Substrate to Millau Substrate
4852
2. Rialto Parachain Substrate to Millau Substrate
49-
2. Westend Substrate to Millau Substrate
53+
2. Westend Substrate to Millau Substrate (only finality bridge)
5054

5155
These bridges can be deployed using our [`./run.sh`](./run.sh) script.
5256

@@ -71,11 +75,12 @@ You can also bring down a deployment using the script with the `stop` argument.
7175
```
7276

7377
### Adding Deployments
78+
7479
We need two main things when adding a new deployment. First, the new network which we want to
7580
bridge. A compose file for the network should be added in the `/networks/` folder. Secondly we'll
7681
need a new bridge Compose file in `./bridges/`. This should configure the bridge relayer nodes
7782
correctly for the two networks, and add any additional components needed for the deployment. If you
78-
want you can also add support in the `./run` script for the new deployment. While recommended it's
83+
want you can also add support in the `./run.sh` script for the new deployment. While recommended it's
7984
not strictly required.
8085

8186
## General Notes
@@ -111,8 +116,8 @@ is not recommended, because this may lead to nonces conflict.
111116

112117
Following accounts are used when `rialto-millau` bridge is running:
113118

114-
- Millau's `Rialto.HeadersAndMessagesRelay` signs complex headers+messages relay transactions on Millau chain;
115-
- Rialto's `Millau.HeadersAndMessagesRelay` signs complex headers+messages relay transactions on Rialto chain;
119+
- Millau's `Rialto.HeadersAndMessagesRelay1` signs complex headers+messages relay transactions on Millau chain;
120+
- Rialto's `Millau.HeadersAndMessagesRelay1` signs complex headers+messages relay transactions on Rialto chain;
116121
- Millau's `Rialto.MessagesSender` signs Millau transactions which contain messages for Rialto;
117122
- Rialto's `Millau.MessagesSender` signs Rialto transactions which contain messages for Millau;
118123
- Millau's `Rialto.OutboundMessagesRelay.Lane00000001` signs relay transactions with message delivery confirmations (lane 00000001) from Rialto to Millau;
@@ -136,18 +141,22 @@ Following accounts are used when `rialto-parachain-millau` bridge is running:
136141
- RialtoParachain's `Millau.HeadersAndMessagesRelay` signs complex headers+messages relay transactions on RialtoParachain chain.
137142

138143
### Docker Usage
144+
139145
When the network is running you can query logs from individual nodes using:
140146

141147
```bash
142148
docker logs rialto_millau-node-charlie_1 -f
143149
```
144150

151+
You may use the [dump-logs.sh](../scripts/dump-logs.sh) to dump logs of most of running containers.
152+
145153
To kill all leftover containers and start the network from scratch next time:
146154
```bash
147155
docker ps -a --format "{{.ID}}" | xargs docker rm # This removes all containers!
148156
```
149157

150158
### Docker Compose Usage
159+
151160
If you're not familiar with how to use `docker-compose` here are some useful commands you'll need
152161
when interacting with the bridge deployments:
153162

@@ -172,10 +181,12 @@ docker-compose -f docker-compose.yml -f docker-compose.override.yml config > doc
172181
```
173182

174183
## Docker and Git Deployment
184+
175185
It is also possible to avoid using images from the Docker Hub and instead build
176186
containers from Git. There are two ways to build the images this way.
177187

178188
### Git Repo
189+
179190
If you have cloned the bridges repo you can build local Docker images by running the following
180191
command at the top level of the repo:
181192

@@ -189,16 +200,17 @@ This will build a local image of a particular component with a tag of
189200
You can configure the build using Docker
190201
[build arguments](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg).
191202
Here are the arguments currently supported:
192-
- `BRIDGE_REPO`: Git repository of the bridge node and relay code
193-
- `BRIDGE_HASH`: Commit hash within that repo (can also be a branch or tag)
194-
- `ETHEREUM_REPO`: Git repository of the OpenEthereum client
195-
- `ETHEREUM_HASH`: Commit hash within that repo (can also be a branch or tag)
196203
- `PROJECT`: Project to build withing bridges repo. Can be one of:
197204
- `rialto-bridge-node`
198205
- `millau-bridge-node`
206+
- `rialto-parachain-collator`
199207
- `substrate-relay`
200208
209+
You may use the [build-containers.sh](../scripts/build-containers.sh) script to build all available
210+
containers.
211+
201212
### GitHub Actions
213+
202214
We have a nightly job which runs and publishes Docker images for the different nodes and relayers to
203215
the [ParityTech Docker Hub](https://hub.docker.com/u/paritytech) organization. These images are used
204216
for our ephemeral (temporary) test networks. Additionally, any time a tag in the form of `v*` is
@@ -209,6 +221,7 @@ With images built using either method, all you have to do to use them in a deplo
209221
`image` field in the existing Docker Compose files to point to the tag of the image you want to use.
210222
211223
### Monitoring
224+
212225
[Prometheus](https://prometheus.io/) is used by the bridge relay to monitor information such as system
213226
resource use, and block data (e.g the best blocks it knows about). In order to visualize this data
214227
a [Grafana](https://grafana.com/) dashboard can be used.
@@ -223,6 +236,7 @@ dashboard can be accessed at `http://localhost:9090`. The Grafana dashboard can
223236
`http://localhost:3000`. Note that the default log-in credentials for Grafana are `admin:admin`.
224237
225238
### Environment Variables
239+
226240
Here is an example `.env` file which is used for production deployments and network updates. For
227241
security reasons it is not kept as part of version control. When deploying a network this
228242
file should be correctly populated and kept in the appropriate [`bridges`](`./bridges`) deployment
@@ -247,13 +261,8 @@ UI_EXPECTED_ETHEREUM_NETWORK_ID=105
247261
248262
### UI
249263
250-
Use [wss://rialto.bridges.test-installations.parity.io/](https://polkadot.js.org/apps/)
251-
as a custom endpoint for [https://polkadot.js.org/apps/](https://polkadot.js.org/apps/).
252-
253-
### Polkadot.js UI
254-
255-
To teach the UI decode our custom types used in the pallet, go to: `Settings -> Developer`
256-
and import the [`./types.json`](./types.json)
264+
Use [wss://wss.rialto.brucke.link](https://polkadot.js.org/apps/) as a custom endpoint for
265+
[https://polkadot.js.org/apps/](https://polkadot.js.org/apps/).
257266
258267
## Scripts
259268

docs/complex-relay.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width">
6+
<title>Complex Relay</title>
7+
</head>
8+
<body>
9+
<h1>Complex Relay</h1>
10+
<p>
11+
Both Source Chain and Target Chains have Bridge Messages pallets deployed. They also have required
12+
finality pallets deployed - we don't care about finality type here - they can be either Bridge GRANDPA,
13+
or Bridge Parachains finality pallets, or any combination of those.<br/>
14+
</p>
15+
<p>
16+
There are 4-6 relayer subprocesses inside the Complex Relayer. They include two message relayers,
17+
serving the lane in both directions and 2-4 Complex Relayers (depending on the finality type of Source
18+
and Target Chains).<br/>
19+
</p>
20+
<p>
21+
The following diagram shows the way the complex relayer serves the lane in single direction. Everything
22+
below may be applied to the opposite direction if you'll swap the Source and Target Chains.
23+
</p>
24+
<div class="mermaid">
25+
sequenceDiagram
26+
participant Source Chain
27+
participant Complex Relayer
28+
participant Target Chain
29+
30+
Note right of Source Chain: Finalized: 480, Target Finalized: 50, Sent Messages: 42, Confirmed Messages: 42
31+
Note left of Target Chain: Finalized: 60, Source Finalized: 420, Received Messages: 42
32+
33+
Source Chain ->> Source Chain: someone Sends Message 43
34+
Source Chain ->> Source Chain: Import and Finalize Block 481
35+
36+
Source Chain ->> Complex Relayer: notes new outbound message 43 at Source Chain Block 481
37+
Note right of Complex Relayer: can't deliver message 43, Source Chain Block 481 is not relayed
38+
Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Source Chain Block 481
39+
40+
Source Chain ->> Complex Relayer: Read Finality Proof of Block 481
41+
Complex Relayer ->> Target Chain: Submit Finality Proof of Block 481
42+
Target Chain ->> Target Chain: Import and Finalize Block 61
43+
Note left of Target Chain: Finalized: 61, Source Finalized: 481, Received Messages: 42
44+
45+
Source Chain ->> Complex Relayer: Read Proof of Message 43 at Block 481
46+
Complex Relayer ->> Target Chain: Submit Proof of Message 43 at Block 481
47+
Target Chain ->> Target Chain: Import and Finalize Block 62
48+
Note left of Target Chain: Finalized: 62, Source Finalized: 481, Received Messages: { rewarded: 42, messages-relayer-account: [43] }
49+
50+
Target Chain ->> Complex Relayer: notes new unrewarded relayer at Target Chain Block 62
51+
Note right of Complex Relayer: can't relay delivery confirmations because Target Chain Block 62 is not relayed
52+
Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Target Chain Block 62
53+
54+
Target Chain ->> Complex Relayer: Read Finality Proof of Block 62
55+
Complex Relayer ->> Source Chain: Submit Finality Proof of Block 62
56+
Source Chain ->> Source Chain: Import and Finalize Block 482
57+
Note right of Source Chain: Finalized: 482, Target Finalized: 62, Confirmed Messages: 42
58+
59+
Target Chain ->> Complex Relayer: Read Proof of Message 43 Delivery at Block 62
60+
Complex Relayer ->> Source Chain: Submit Proof of Message 43 Delivery at Block 612
61+
Source Chain ->> Source Chain: rewards messages-relayer-account for delivering message [43]
62+
Source Chain ->> Source Chain: prune delivered message 43 from runtime storage
63+
Note right of Source Chain: Finalized: 482, Target Finalized: 61, Confirmed Messages: 43
64+
65+
Source Chain ->> Source Chain: someone Sends Message 44
66+
Source Chain ->> Source Chain: Import and Finalize Block 483
67+
68+
Source Chain ->> Complex Relayer: notes new outbound message 44 at Source Chain Block 483 and new confirmed message 43
69+
Note right of Complex Relayer: can't deliver message 44, Source Chain Block 483 is not relayed
70+
Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Source Chain Block 483
71+
72+
Source Chain ->> Complex Relayer: Read Finality Proof of Block 483
73+
Complex Relayer ->> Target Chain: Submit Finality Proof of Block 483
74+
Target Chain ->> Target Chain: Import and Finalize Block 63
75+
Note left of Target Chain: Finalized: 63, Source Finalized: 483, Received Messages: { rewarded: 42, messages-relayer-account: [43] }
76+
77+
Source Chain ->> Complex Relayer: Read Proof of Message 44 and Proof of Message 43 reward at Block 483
78+
Complex Relayer ->> Target Chain: Submit Proof of Message 44 and Proof of Message 43 reward at Block 483
79+
Target Chain ->> Target Chain: Import and Finalize Block 64
80+
Note left of Target Chain: Finalized: 64, Source Finalized: 483, Received Messages: { rewarded: 43, messages-relayer-account: [44] }-->
81+
</div>
82+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
83+
<script>mermaid.initialize({startOnLoad: true})</script>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)