substrate学习笔记12:Relay Chain

1 说明

在本节课程中,我们将学习启动一个relay chain, 通过cumus来创建自己的parachain,并且在在本地测试网络中将parachain连接到relaychain。

2 软硬件要求

1、硬件要求
建议编译的最小硬件要求如下:

  • 8G内存;
  • 4核
  • 50G硬盘

如果无法达到最小要求,可以通过加-j标志来编译,同时通过codegen-units来优化,如下:

cargo build --release -j 1
RUSTFLAGS="-C codegen-units=1" cargo build --release

2、软件版本要求
本节测试对应的版本为:

  • Polkadot v0.9.16;
  • Substrate Parachain Template polkadot-v0.9.16;
  • Polkadot-JS Apps v0.103.2-8.

3 编译节点

3.1 编译relay chain节点

# Clone the Polkadot Repository
git clone https://github.com/paritytech/polkadot.git

# Switch into the Polkadot directory
cd polkadot

# Checkout the proper commit
git checkout v0.9.16

# Build the relay chain Node
cargo build --release

# Check if the help page prints to ensure the node is built correctly
./target/release/polkadot --help

3.2 编译parachain模板

我们将使用substrate parachain template来启动平行链然后进行跨链资产转换。在一个新的terminal窗口中,我们进行如下:

git clone https://github.com/substrate-developer-hub/substrate-parachain-template

cd substrate-parachain-template

git checkout polkadot-v0.9.16

cargo build --release

./target/release/parachain-collator --help

4 relay chain 的chain spec

现在我们需要为relaychain准备chain spec。
在本教程中,我们使用官方实验提供的rococo chain spec。

chain spec文件的地址为:

5 启动relay chain

5.1 启动Alice节点

命令如下:

# Start Relay `Alice` node
./target/release/polkadot \
--alice \
--validator \
--base-path /tmp/relay/alice \
--chain <path to spec json> \
--port 30333 \
--ws-port 9944

5.2 启动Bob节点

./target/release/polkadot \
--bob \
--validator \
--base-path /tmp/relay-bob \
--chain <path to spec json> \
--bootnodes /ip4/<Alice IP>/tcp/30333/p2p/<Alice Peer ID> \
--port 30334 \
--ws-port 9945

6 参考文档

docs.substrate.io/tutorials/v3/cum...

7 实验完整源码地址

github.com/anonymousGiga/substrate...

本作品采用《CC 协议》,转载必须注明作者和本文链接
令狐一冲
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
文章
255
粉丝
120
喜欢
308
收藏
128
排名:335
访问:2.8 万
私信
所有博文
社区赞助商