Substrate之旅4:基于Substrate私有链的搭建

参考:https://docs.substrate.io/tutorials/v3/private-network/

实现目标

这里我们学习:

  1. 如何基于Substrate来构成一个两节点的链网络。
  2. 如何配置使用Aura的共识机制。
  3. 如何定制账户,并设置其为Aura的Validator。

启动两个节点的链网络

确认环境准备好了

  1. Rust及相关Rust的工具链已安装。
  2. Substrate node template源码已下载好,且编译通过。
  3. Subkey已安装好(它的安装步骤将在“自主生成key”部分详细讲)。

基于Substrate节点模板启动两节点的链网络

这里,我们将基于节点模板里缺省有的两个账户Alice和Bob,来启动两个Substrate节点,并让这个两个节点相互连接,形成一个链网络。因此,经过这部分学习后,我们应掌握基于Substrate构建多节点链网络的基本步骤。

基于Alice启动Substrate节点

  1. 执行以下的命令,清除之前节点启动可能残留的数据
./target/release/node-template purge-chain --base-path /tmp/alice --chain local

该命令会提示,敲入y

Are you sure to remove "/tmp/alice/chains/local_testnet/db/full"? [y/N]

注:如果希望新建的链是纯净的,就应清除之前启动过的链的数据。

  1. 执行以下的命令,用alice这个账户来启动一个substrate节点。
./target/release/node-template \
--base-path /tmp/alice \
--chain local \
--alice \
--port 30333 \
--ws-port 9945 \
--rpc-port 9933 \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator

下面是该命令用到的选项的含义:

:Option :Description
--base-path Specifies the directory for storing all of the data related to this chain.
--chain local Specifies the chain specification to use. Valid predefined chain specifications include local, development, and staging.
--alice Adds the predefined keys for the alice account to the node’s keystore. With this setting, the alice account is used for block production and finalization.
--port 30333 Specifies the port to listen on for peer-to-peer (p2p) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account.
--ws-port 9945 Specifies the port to listen on for incoming WebSocket traffic. The default port is 9944. This tutorial uses a custom web socket port number (9945).
--rpc-port 9933 Specifies the port to listen on for incoming RPC traffic. The default port is 9933.
--node-key <key> Specifies the Ed25519 secret key to use for libp2p networking. You should only use this option for development and testing.
--telemetry-url Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use.
--validator Spec
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DongAoTony

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值