Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Latest commit

 

History

History
262 lines (216 loc) · 10.2 KB

README.md

File metadata and controls

262 lines (216 loc) · 10.2 KB

Bridge-hub Parachains

Implementation of BridgeHub, a blockchain to support message passing between Substrate based chains like Polkadot and Kusama networks.

BridgeHub allows users to:

  • Passing arbitrary messages between different Substrate chains (Polkadot <-> Kusama).

BridgeHub is meant to be system parachain with main responsibilities:

  • sync finality proofs between relay chains
  • sync finality proofs between BridgeHub parachains
  • pass (XCM) messages between different BridgeHub parachains

How to test locally Rococo <-> Wococo

Prepare/Build/Deploy

# Prepare empty directory for testing
mkdir -p ~/local_bridge_testing/bin
mkdir -p ~/local_bridge_testing/logs

# 1. Install zombienet
Go to: https://github.com/paritytech/zombienet/releases
Copy the apropriate binary (zombienet-linux) from the latest release to ~/local_bridge_testing/bin

# 2. Build polkadot binary
git clone https://github.com/paritytech/polkadot.git
cd polkadot
cargo build --release
cp target/release/polkadot ~/local_bridge_testing/bin/polkadot

# 3. Build cumulus polkadot-parachain binary
cd <cumulus-git-repo-dir>
git checkout -b bridge-hub-rococo-wococo --track origin/bridge-hub-rococo-wococo
cargo build --release --locked -p polkadot-parachain-bin
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-mint

# 4. Build substrate-relay binary
git clone https://github.com/paritytech/parity-bridges-common.git
cd parity-bridges-common
cargo build --release -p substrate-relay
cp target/release/substrate-relay ~/local_bridge_testing/bin/substrate-relay

# (Optional) 5. Build polkadot-parachain-mint binary with statemine/westmint for moving assets
cd <cumulus-git-repo-dir>
git checkout -b bko-transfer-asset-via-bridge --track origin/bko-transfer-asset-via-bridge
cargo build --release --locked -p polkadot-parachain-bin
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-mint

Run chains (Rococo + BridgeHub, Wococo + BridgeHub) with zombienet

# Rococo + BridgeHubRococo + Rockmine (mirroring Kusama)
POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \
POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \
POLKADOT_PARACHAIN_BINARY_PATH_FOR_ROCKMINE=~/local_bridge_testing/bin/polkadot-parachain-mint \
	~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml
# Wococo + BridgeHubWococo + Wockmint (mirroring Polkadot)
POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \
POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \
POLKADOT_PARACHAIN_BINARY_PATH_FOR_WOCKMINT=~/local_bridge_testing/bin/polkadot-parachain-mint \
	~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml

Run relayers (Rococo, Wococo)

Accounts of BridgeHub parachains:

  • Bob is pallet owner of all bridge pallets

Run with script (alternative 1)

cd <cumulus-git-repo-dir>
./scripts/bridges_rococo_wococo.sh run-relay

Run with binary (alternative 2)

Need to wait for parachain activation (start producing blocks), then run:

# 1. Init bridges:

# Rococo -> Wococo
RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
	~/local_bridge_testing/bin/substrate-relay init-bridge rococo-to-bridge-hub-wococo \
	--source-host localhost \
	--source-port 9942 \
	--source-version-mode Auto \
	--target-host localhost \
	--target-port 8945 \
	--target-version-mode Auto \
	--target-signer //Bob

# Wococo -> Rococo
RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
	~/local_bridge_testing/bin/substrate-relay init-bridge wococo-to-bridge-hub-rococo \
	--source-host localhost \
	--source-port 9945 \
	--source-version-mode Auto \
	--target-host localhost \
	--target-port 8943 \
	--target-version-mode Auto \
	--target-signer //Bob

# 2. Relay relay-chain headers, parachain headers and messages**
RUST_LOG=runtime=trace,rpc=trace,bridge=trace \
    ~/local_bridge_testing/bin/substrate-relay relay-headers-and-messages bridge-hub-rococo-bridge-hub-wococo \
    --rococo-host localhost \
    --rococo-port 9942 \
    --rococo-version-mode Auto \
    --bridge-hub-rococo-host localhost \
    --bridge-hub-rococo-port 8943 \
    --bridge-hub-rococo-version-mode Auto \
    --bridge-hub-rococo-signer //Charlie \
    --wococo-headers-to-bridge-hub-rococo-signer //Bob \
    --wococo-parachains-to-bridge-hub-rococo-signer //Bob \
    --bridge-hub-rococo-transactions-mortality 4 \
    --wococo-host localhost \
    --wococo-port 9945 \
    --wococo-version-mode Auto \
    --bridge-hub-wococo-host localhost \
    --bridge-hub-wococo-port 8945 \
    --bridge-hub-wococo-version-mode Auto \
    --bridge-hub-wococo-signer //Charlie \
    --rococo-headers-to-bridge-hub-wococo-signer //Bob \
    --rococo-parachains-to-bridge-hub-wococo-signer //Bob \
    --bridge-hub-wococo-transactions-mortality 4 \
    --lane 00000001

Check relay-chain headers relaying:

Check parachain headers relaying:

Send messages (Rococo, Wococo)

Local Rococo:Statemine -> Wococo:Westmint

Live Rococo:Rockmine2 -> Wococo:Wockmint

  • uses account seed on Live Rococo:Rockmine2
    cd <cumulus-git-repo-dir>
    
    ./scripts/bridges_rococo_wococo.sh send-remark-rococo
    or
    ./scripts/bridges_rococo_wococo.sh send-trap-rococo
    
  • open explorers: (see paritytech/parity-bridges-common#1671)
    • Rockmine2 (see polkadotXcm.Sent)
    • BridgeHubRococo (see bridgeWococoMessages.MessageAccepted)
    • BridgeHubWococo (see bridgeRococoMessages.MessagesReceived)
    • Wockmint (see xcmpQueue.Success for remark and xcmpQueue.Fail for trap)
    • BridgeHubRococo (see bridgeWococoMessages.MessagesDelivered)

How to test local BridgeHubKusama

cd <base-cumulus-repo-directory>
cargo build --release -p polkadot-parachain-bin

# script expect to have pre-built polkadot binary on the path: ../polkadot/target/release/polkadot
# if using `kusama-local` / `polkadot-local`, build polkadot with `--features fast-runtime`

# BridgeHubKusama
zombienet-linux --provider native spawn ./zombienet/examples/bridge_hub_kusama_local_network.toml

or

# BridgeHubPolkadot
zombienet-linux --provider native spawn ./zombienet/examples/bridge_hub_polkadot_local_network.toml

How to test local BridgeHubPolkadot

TODO: from master


Git subtree ./bridges

Add Bridges repo as a local remote and synchronize it with latest master from bridges repo:

How to update bridges subtree

cd <cumulus-git-repo-dir>

# this will update new git branches from bridges repo
# there could be unresolved conflicts, but dont worry,
# lots of them are caused because of removed unneeded files with patch step :)
# so before solving conflicts just run patch
./scripts/bridges_update_subtree.sh fetch

# this will remove unneeded files and checks if subtree modules compiles
./scripts/bridges_update_subtree.sh patch

# if there are conflicts, this could help, removes locally deleted files at least
# (but you can also do this manually)
./scripts/bridges_update_subtree.sh merge

# when conflicts resolved, you can check build again - should pass
# also important: this updates global Cargo.lock
./scripts/bridges_update_subtree.sh patch

We use --squash to avoid adding individual commits and rather squashing them all into one. Now we use master branch, but in future, it could change to some release branch/tag.

How was first time initialized (dont need anymore)

cd <cumulus-git-repo-dir>
git remote add -f bridges git@github.com:paritytech/parity-bridges-common.git
# (ran just only first time, when subtree was initialized)
git subtree add --prefix=bridges bridges master --squash