Substrate Tutorials:Start a Private Network (multi-node)

https://substrate.dev/docs/en/tutorials/start-a-private-network/

Substrate Start a Private Network

搭建本地私有区块链网络(即搭建本地测试区块链网络)

实践时的系统是:Linux Mint

一、Start a Private Network 简介

在本教程中,我们将学习和实践如何使用您选择的 验证程序/授权 集合来启动一个Substrate区块链网络。

Install the Node Template

您应该在 Create Your First Substrate Chain Tutorial 教程中已经完成了在计算机上编译v3.0.0版本的Substrate节点模板。如果您没有,请先完成该教程。

有经验的开发人员确实喜欢跳过该教程,您可以直接根据readme文件中的说明进行安装节点模板。

What you will be doing

在我们开始之前,让我们先说明一下本教程中要做的事情。我们将:

  1. 基于模板项目启动一个Substrate区块链网络。(Launch a Substrate blockchain network based on a template project.)
  2. 生成用于网络授权的ed25519和sr25519密钥对。(Generate ed25519 and sr25519 key-pairs for use as a network authority.)
  3. 创建和编辑一个chainspec的json文件。(Create and edit a chainspec json file.)

听起来挺合理? 好,那我们开始吧!

二、Alice and Bob Start Blockchain

在我们生成自己的密钥并开始一个真正独特的Substrate网络之前,让我们先从一个名为local的预定义网络规范开始学习基础知识,这个网络规范有两个预定义的(当然不是私有的!)被称为爱丽丝和鲍勃的钥匙。

本教程的这一部分应该在单个工作站上运行,该工作站具有一个二进制Substrate。如果您已经按照教程进行到了这里,您就有了正确的设置。

Alice Starts First

Alice(或是扮演她的人)应该从node-template的存储库的根目录运行这些命令。

这里我们已经显式地展示了purge-chain命令。在将来,我们将省略这一点,任何时候您试图开始一个新的网络时您应该清除旧的链数据。

# Purge any chain data from previous runs
# You will be prompted to type `y`
./target/release/node-template purge-chain --base-path /tmp/alice --chain local
# Start Alice's node
./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

Let’s look at those flags in detail:
在这里插入图片描述
When the node starts you should see output similar to this.

2021-03-10 17:34:27  Substrate Node    
2021-03-10 17:34:27  ✌️  version 3.0.0-1c5b984-x86_64-linux-gnu    
2021-03-10 17:34:27  ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021    
2021-03-10 17:34:27  📋 Chain specification: Local Testnet    
2021-03-10 17:34:27  🏷 Node name: Alice    
2021-03-10 17:34:27  👤 Role: AUTHORITY    
2021-03-10 17:34:27  💾 Database: RocksDb at /tmp/alice/chains/local_testnet/db    
2021-03-10 17:34:27Native runtime: node-template-100 (node-template-1.tx1.au1)    
2021-03-10 17:34:27  🔨 Initializing Genesis block/state (state: 0xea479ba8, header-hash: 0x9d077cce)    
2021-03-10 17:34:27  👴 Loading GRANDPA authority set from genesis on what appears to be first startup.    
2021-03-10 17:34:27Loaded block-time = 6000 milliseconds from genesis on first-launch    
2021-03-10 17:34:27  Using default protocol ID "sup" because none is configured in the chain specs    
2021-03-10 17:34:27  🏷 Local node identity is: 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp    
2021-03-10 17:34:27  📦 Highest known block at #0    
2021-03-10 17:34:27  〽️ Prometheus server started at 127.0.0.1:9615    
2021-03-10 17:34:27  Listening for new connections on 127.0.0.1:9945.    
2021-03-10 17:34:32  💤 Idle (0 peers), best: #0 (0x9d077cce), finalized #0 (0x9d077cce),00    
2021-03-10 17:34:37  💤 Idle (0 peers), best: #0 (0x9d077cce), finalized #0 (0x9d077cce),00

...

Notes
🔨 Initializing Genesis block/state (state: 0xea47…9ba8, header-hash: 0x9d07…7cce)
告诉节点正在使用哪个genesis区块。当你启动下一个节点时,请验证这些值是否相等。

🏷 Local node identity is: 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
显示当Bob从Alice的节点启动时需要的 Peer ID 。这个值是由用来启动Alice节点的 --node-key 参数决定的。

您将注意到目前尚未生成任何块。一旦有另一个节点加入网络,就会开始生成区块。

关于所有这些标志和我没有提到的其他标志的更多细节可以通过运行./target/release/node-template --help 进行查看。

Role: AUTHORITY 表示当前节点是authority的身份,Substrate中的节点有两种身份:validator和authority,validator是验证节点

Attach a UI

通过观察节点在终端中产生的输出,你可以了解很多关于节点的信息。还有一个很好的图形用户界面,叫做 Polkadot-JS Apps,或者简称“Apps”。

在你的web浏览器中,导航到 https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9945#/explorer

一些广告拦截器(例如Brave browser中内置的防护罩、pihole、browser Extensions等)会阻止与本地节点的连接。如果您的浏览器中有任何广告拦截器,当您在连接到本地节点时遇到问题时,请确保检查并且根据需要关闭它们。还有一些浏览器,特别是Firefox,不会从https网站连接到本地节点。一个简单的解决方法是尝试另外的浏览器,比如Chromium。或者,您可以在本地托管此接口

上面提供的链接包含 rpc URL参数,该参数指示 Apps UI 连接到其值提供的URL(在本例中是您的本地节点)。要手动配置Apps UI连接到另一个节点,请执行以下操作:

  • Click on the top left network icon
    在这里插入图片描述
  • A popup dialog appears. Expand DEVELOPMENT and ensure the custom endpoint is set to ws://127.0.0.1:9945.
    在这里插入图片描述
  • To connect to a custom node and port, you just need to specify the endpoint by choosing custom endpoint and type in your own endpoint. In this way you can use a single instance of Apps UI to connect to various nodes. Click Switch icon to actually switch to the new endpoint when necessary.
    在这里插入图片描述

现在,您应该在Network和Explorer页面中看到类似下面示例的内容:
在这里插入图片描述

Notes
如果不想在连接到远程部署的Substrate节点时运行托管版本的Polkadot-JS Apps UI,你可以配置ssh local port forwarding,将本地请求转发到远程主机监听的ws port。相关说明见参考资料

Bob Joins

现在Alice的节点已经启动并运行,Bob可以通过从她的节点进行启动来加入网络。他的命令和之前的(即启动Alice节点的命令)看起来很像。

./target/release/node-template purge-chain --base-path /tmp/bob --chain local
./target/release/node-template \
  --base-path /tmp/bob \
  --chain local \
  --bob \
  --port 30334 \
  --ws-port 9946 \
  --rpc-port 9934 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp

上面已经解释了其中的大多数选项,但是有几点值得一提。

  • Because these two nodes are running on the same physical machine, Bob must specify different --base-path, --port, --ws-port, and --rpc-port values.
  • Bob has added the --bootnodes flag and specified a single boot node, namely Alice’s. He must correctly specify these three pieces of information which Alice can supply for him.
    Alice’s IP Address, probably 127.0.0.1
    Alice’s Port, she specified 30333
    Alice’s Peer ID, copied from her log output.

如果一切顺利,几秒钟后,节点之间应该建立了对等连接,并开始生成区块。在启动Alice节点的控制台中,你应该会看到类似下面的几行代码:

...
2021-03-10 17:47:32  🔍 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp    
2021-03-10 17:47:32  🔍 Discovered new external address for our node: /ip4/<your computer's LAN IP>/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp    
2021-03-10 17:47:33  💤 Idle (1 peers), best: #0 (0x9d077cce), finalized #0 (0x9d077cce),1.0kiB/s ⬆ 1.0kiB/s    
2021-03-10 17:47:36  🙌 Starting consensus session on top of parent 0x9d07d1757a9ca248e58141ce52a11fca37f71007dec16650b87a853f0d4c7cce    
2021-03-10 17:47:36  🎁 Prepared block for proposing at 1 [hash: 0x727826a5e6fba9a13af11422d4677b5f0743cc733c382232328e69fd307d1d2f; parent_hash: 0x9d077cce; extrinsics (1): [0x768a…a9e2]]    
2021-03-10 17:47:36  🔖 Pre-sealed block for proposal at 1. Hash now 0x4841d8b2e62483fa4702b3ddcd1b603803842374dcdc1e9533ad407708b33dd8, previously 0x727826a5e6fba9a13af11422d4677b5f0743cc733c382232328e69fd307d1d2f.    
2021-03-10 17:47:36Imported #1 (0x48413dd8)    
2021-03-10 17:47:36Imported #1 (0xb2412ae8)    
2021-03-10 17:47:38  💤 Idle (1 peers), best: #1 (0x48413dd8), finalized #0 (0x9d077cce),0.8kiB/s ⬆ 0.8kiB/s    
2021-03-10 17:47:42  ♻️  Reorg on #1,0x48413dd8 to #2,0x8b6a…dce6, common ancestor #0,0x9d077cce    
2021-03-10 17:47:42Imported #2 (0x8b6a…dce6)    
2021-03-10 17:47:43  💤 Idle (1 peers), best: #2 (0x8b6a…dce6), finalized #0 (0x9d077cce),0.8kiB/s ⬆ 0.7kiB/s    
2021-03-10 17:47:48  🙌 Starting consensus session on top of parent 0x8b6a3ab2fe9891b1af008ea0d92dae9bc84cfa5578231e81066d47928822dce6    
2021-03-10 17:47:48  🎁 Prepared block for proposing at 3 [hash: 0xb887aef2097eff5869e38ccec0302bce372ad05ac2cdf9cc4725c38ec071fb7a; parent_hash: 0x8b6a…dce6; extrinsics (1): [0x82ac2f20]]    
2021-03-10 17:47:48  🔖 Pre-sealed block for proposal at 3. Hash now 0x34d608dd8be6b82bef4a7aaae1ec80930a5c4b8cf9bdc99013410e91544f3a2a, previously 0xb887aef2097eff5869e38ccec0302bce372ad05ac2cdf9cc4725c38ec071fb7a.    
2021-03-10 17:47:48Imported #3 (0x34d63a2a)    
2021-03-10 17:47:48  💤 Idle (1 peers), best: #3 (0x34d63a2a), finalized #0 (0x9d077cce),0.7kiB/s ⬆ 0.8kiB/s    
2021-03-10 17:47:53  💤 Idle (1 peers), best: #3 (0x34d63a2a), finalized #1 (0xb2412ae8),0.6kiB/s ⬆ 0.7kiB/s    
2021-03-10 17:47:54Imported #4 (0x2b8a…fdc4)    
2021-03-10 17:47:58  💤 Idle (1 peers), best: #4 (0x2b8a…fdc4), finalized #2 (0x8b6a…dce6),0.7kiB/s ⬆ 0.6kiB/s
...

这些输出行表示Bob已与Alice(1 peers)建立了对等连接,它们已经生成了一些区块(best: #4 (0x2b8a…fdc4)),并且区块正在被最终确定(finalized #2 (0x8b6a…dce6))。

查看启动Bob节点的控制台,你应该会看到类似的内容。

一旦你确认两个节点都按预期正在运行,就应该关闭它们。虽然这不是严格要求,只要您没有冲突的端口和相同的chainspec。本教程的下一节将包括必要时重新启动新节点的命令。

References

Configure ssh local port forwarding

三、Generate Your Own Keys

既然我们已经了解了基础知识和命令行选项,现在是时候生成我们自己的keys了,而不是使用众所周知的Alice和Bob的keys。每个想要参与区块链的人都应该生成自己的密钥(keys)。本页解释了生成密钥的几个选项,每个参与者只需要选择其中一个选项。无论您选择哪个选项,请务必记录本节的所有输出,因为你稍后将需要它。

Option 1: Subkey

Subkey是一种工具,它用于生成专门为Substrate设计的Keys。

从编译和安装工具开始(这里有说明和更多的信息),这大约需要15分钟左右。

我们需要从每个类型生成至少2个keys。每个节点都需要有自己的密钥。

生成一个助记词,并查看与之相关的sr25519密钥和地址。此密钥将被Aura用来制作区块。

# subkey command
subkey generate --scheme sr25519
# subkey output
Secret phrase `infant salmon buzz patrol maple subject turtle cute legend song vital leisure` is account:
  Secret seed:      0xa2b0200f9666b743402289ca4f7e79c9a4a52ce129365578521b0b75396bd242
  Public key (hex): 0x0a11c9bcc81f8bd314e80bc51cbfacf30eaeb57e863196a79cccdc8bf4750d21
  Account ID:       0x0a11c9bcc81f8bd314e80bc51cbfacf30eaeb57e863196a79cccdc8bf4750d21
  SS58 Address:     5CHucvTwrPg8L2tjneVoemApqXcUaEdUDsCEPyE7aDwrtR8D

接下来查看与同一助记词关联的ed25519密钥和地址。此密钥将由GRANDPA用于区块确认。

# subkey command
subkey inspect --scheme ed25519 "infant salmon buzz patrol maple subject turtle cute legend song vital leisure"
# subkey output
Secret phrase `infant salmon buzz patrol maple subject turtle cute legend song vital leisure` is account:
  Secret seed:      0xa2b0200f9666b743402289ca4f7e79c9a4a52ce129365578521b0b75396bd242
  Public key (hex): 0x1a0e2bf1e0195a1f5396c5fd209a620a48fe90f6f336d89c89405a0183a857a3
  Account ID:       0x1a0e2bf1e0195a1f5396c5fd209a620a48fe90f6f336d89c89405a0183a857a3
  SS58 Address:     5CesK3uTmn4NGfD3oyGBd1jrp4EfRyYdtqL3ERe9SXv8jUHb

Option 2: Polkadot-JS Apps

我们用来查看正在生成的区块的同一个UI也可以用来查看生成密钥。如果不想安装Subkey,则此选项很方便。它可以用于生产密钥,但在生成此类密钥时,系统不应连接到internet。

无论您选择何种方法,生成生产密钥的系统都不应连接到internet。这里特别提到这一点,是因为在使用类似Polkadot JS Apps的webapp时,通常需要互联网连接。
A system that generates production keys should not be connected to the internet regardless of what method you choose. It is mentioned here specifically because having an internet connection is generally desired when using a webapp like Polkadot JS Apps.

在“帐户”选项卡上,单击“添加帐户”。你不需要提供名称,但如果您希望保存此帐户以提交交易以及验证,则可以提供名称。

生成一个sr25519密钥,该密钥将由Aura用于区块生产。仔细记下助记词短语和SS58地址(单击左上角的标识图标可以复制SS58地址)。

然后生成一个ed25519密钥,供GRANDPA用于区块确认。同样,记下助记词短语和ss58地址。

Option 3: Use Pre-Generated Keys(使用预生成的密钥)

如果您只想继续学习教程,可以使用下面其中一个预生成的密钥对。但要意识到,这些密钥绝对不能用于生产,而只能用于学习目的。

在这里插入图片描述

四、Create a Custom Chain Spec

既然每个参与者都生成了自己的密钥,现在你可以创建自定义的链规范了(create a custom chain specification)。我们将使用这个自定义的链规范(custom chain spec),而不是我们以前使用的内置的本地规范(local spec)。

在本例中,我们将创建一个由两个节点组成的网络,但该过程将以直接的方式推广到更多节点。

Create a Chain Specification

上次,我们使用了--chain local,它是预定义的“链规范”(“chain spec”),它将Alice和Bob指定为验证器,同时还有许多其他有用的默认值。

与其从头开始编写链规范,我们不如只需对以前使用的链规范进行一些修改。首先,我们需要将链规范导出到名为customSpec.json的文件。请记住,所有这些命令的更多详细信息可以通过运行node-template --help获得。

# Export the local chain spec to json
./target/release/node-template build-spec --disable-default-bootnode --chain local > customSpec.json

我们刚刚创建的文件包含几个字段,您可以通过探索这些字段学到很多东西。到目前为止,最大的字段是一个二进制blob,它是我们运行时的Wasm二进制。它是您之前运行cargo build--release命令时构建的内容的一部分。

文件中我们感兴趣的部分是用于创建区块的Aura权限,由下面的“aura”字段表示,以及用于区块确认的GRANDPA权限,由“grandpa”字段表示。该部分与使用 two provided demo 密钥类似:

{
 //-- snip --
 "genesis": {
    "runtime": {
      "frameSystem": {
        //-- snip --
      },
      "palletAura": {
        "authorities": [
          "5FfBQ3kwXrbdyoqLPvcXRp7ikWydXawpNs2Ceu3WwFdhZ8W4",
          "5EhrCtDaQRYjVbLi7BafbGpFqcMhjZJdu8eW8gy6VRXh6HDp"
        ]
      },
      "palletGrandpa": {
        "authorities": [
          ["5G9NWJ5P9uk7am24yCKeLZJqXWW6hjuMyRJDmw4ofqxG8Js2", 1],
          ["5CRZoFgJs4zLzCCAGoCUUs2MRmuD5BKAh17pWtb62LMoCi9h", 1]
        ]
      },
    //-- snip --
    }
 }
}

这些说明是为节点模板编写的。它们将与其他基于Substrate的节点一起工作,只需很少的修改。在Substrate中,包含会话托盘的节点应该将Aura和Grandpa的配置留空,并且将此信息插入到会话配置中。所有这些都在从所需节点导出的链规范中进行了演示。

grandpa数据的格式更复杂,因为grandpa协议支持加权投票( supports weighted votes )。在本例中,我们给每个验证器的权重都是1。

我们所需要做的就是将列出的授权地址(当前为Alice和Bob)更改为我们在上一步中生成的自己的地址。sr25519地址放在aura部分,ed25519地址放在grandpa部分。您可以添加任意数量的验证器。有关其他上下文,请阅读 keys in Substrate

验证器不应该共享相同的密钥,即使是出于学习的目的。如果两个验证器有相同的密钥,它们将产生冲突的区块。

准备好链规范后,将其转换为“原始”链规范。原始链规范包含所有相同的信息,但它包含编码过的存储密钥(encoded storage keys),节点将用这个存储密钥引用其本地存储中的数据。分发原始链规范可以确保每个节点将数据存储在适当的存储密钥中。

./target/release/node-template build-spec --chain=customSpec.json --raw --disable-default-bootnode > customSpecRaw.json

最后,与你网络中的所有其他验证器共享customSpecRaw.json

关键提示:应该由单个人创建链规范,并与其他后续的验证器共享customSpecRaw.json结果文件。

因为 Rust->Wasm 优化的构建不是“可再生的”,每个人都会得到一个稍微不同的Wasm blob,因此如果每个参与者都自己生成文件,将打破共识。对于好奇的人,可以在这篇博文中了解更多关于这个问题的信息。

五、Creating Your Private Network

当创建好自定义的链规范并将其分发给所有参与者之后,就可以启动自己的自定义链了。在本节中,不再需要使用单个物理机或单个二进制文件。

First Participant Starts a Bootnode

创建自定义链规范并将其分发给所有参与者之后,就可以启动自己的自定义链了。在本节中,不再需要使用单个物理机或单个二进制文件。

你已经完成了所有必要的前置准备工作,现在可以启动你的链了。这个过程非常类似于之前启动Alice和Bob那个链的时候。从一个干净的基本路径开始是很重要的,因此如果您计划使用以前使用过的相同路径,请删除该目录中的所有内容。

第一个参与者可以通过以下方式启动节点:

# purge chain (only required for new/modified dev chain spec)
./target/release/node-template purge-chain --base-path /tmp/node01 --chain local -y
# start node01
./target/release/node-template \
  --base-path /tmp/node01 \
  --chain ./customSpecRaw.json \
  --port 30333 \
  --ws-port 9945 \
  --rpc-port 9933 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --rpc-methods Unsafe \
  --name MyNode01

这里与之前启动Alice那个区块链有一些不同:

  • 我省略了 --alice 参数。相反,我们将很快通过RPC将自己的自定义密钥插入到密钥库。
  • --chain 参数已更改为使用我们的自定义链规范。
  • 我添加了可选的--name参数。您可以使用它在遥测UI中为节点提供一个人类可读的名称。
  • 已添加可选的--rpc-methods Unsafe标志。顾名思义,在生产环境中使用这个标志是不安全的,但是它允许本教程集中精力于手头的主题。

您应该在控制台看到如下输出:

2021-03-10 18:32:15  Substrate Node
2021-03-10 18:32:15  ✌️  version 3.0.0-1c5b984-x86_64-linux-gnu
2021-03-10 18:32:15  ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021
2021-03-10 18:32:15  📋 Chain specification: Local Testnet
2021-03-10 18:32:15  🏷 Node name: MyNode01
2021-03-10 18:32:15  👤 Role: AUTHORITY
2021-03-10 18:32:15  💾 Database: RocksDb at /tmp/node01/chains/local_testnet/db
2021-03-10 18:32:15Native runtime: node-template-100 (node-template-1.tx1.au1)
2021-03-10 18:32:16  🔨 Initializing Genesis block/state (state: 0xea47…9ba8, header-hash: 0x9d07…7cce)
2021-03-10 18:32:16  👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2021-03-10 18:32:16  ⏱  Loaded block-time = 6000 milliseconds from genesis on first-launch
2021-03-10 18:32:16  Using default protocol ID "sup" because none is configured in the chain specs
2021-03-10 18:32:16  🏷 Local node identity is: 12D3KooWJvVUoAa7R8gjCSQ45x69Ahh3HcdVSH1dvpcA52vKawHL
2021-03-10 18:32:16  📦 Highest known block at #0
2021-03-10 18:32:16  〽️ Prometheus server started at 127.0.0.1:9615
2021-03-10 18:32:16  Listening for new connections on 127.0.0.1:9944.
2021-03-10 18:32:21  💤 Idle (0 peers), best: #0 (0x9d07…7cce), finalized #0 (0x9d07…7cce),00
2021-03-10 18:32:26  💤 Idle (0 peers), best: #0 (0x9d07…7cce), finalized #0 (0x9d07…7cce),00

这里您必须注意节点标识(node identity):
12D3KooWJvVUoAa7R8gjCSQ45x69Ahh3HcdVSH1dvpcA52vKawHLIP地址127.0.0.1,以及p2p port --port 30333。这些值是用于这个特定的示例,但是对于你的节点,它们将是不同的,并且需要其它节点直接连接到它(chain spec中没有bootnode,因为我们已经在前面的flags中删除了它)

Add Keys to Keystore

当节点运行后,你将再次注意到并没有任何区块生成。此时,你需要将你的密钥添加到密钥库中。请记住,你需要为网络中的每个节点完成这些步骤。你将为每个节点添加两种类型的密钥:Aura密钥和GRANDPA密钥。Aura密钥是生成区块所必需的;GRANDPA密钥对于区块确认是必需的。

Option 1: Use the Polkadot-JS Apps UI

你可以使用Apps UI将密钥插入到密钥库。导航到“Developer --> RPC Call”。选择“author”和“insertKey”。字段可以这样填写:
在这里插入图片描述

keytype: aura
suri: <your mnemonic phrase> (eg. clip organ olive upper oak void inject side suit toilet stick narrow)
publicKey: <your raw sr25519 key> (eg. 0x9effc1668ca381c242885516ec9fa2b19c67b6684c02a8a3237b6862e5c8cd7e)

如果你使用Apps UI生成密钥,则你不会知道原始的公钥。在这种情况下,你可以使用SS58地址(5FfBQ3kwXrbdyoqLPvcXRp7ikWydXawpNs2Ceu3WwFdhZ8W4)。

现在你以及成功插入 Aura 密钥。您可以通过重复这些步骤插入 GRANDPA 密钥(ed25519 密钥)
在这里插入图片描述

keytype: gran
suri: <your mnemonic phrase> (eg. clip organ olive upper oak void inject side suit toilet stick narrow)
publicKey: <your raw ed25519 key> (eg. 0xb48004c6e1625282313b07d1c9950935e86894a2e4f21fb1ffee9854d180c781)

如果你使用Apps UI生成密钥,则你不会知道原始的公钥。在这种情况下,你可以使用SS58地址(5G9NWJ5P9uk7am24yCKeLZJqXWW6hjuMyRJDmw4ofqxG8Js2)。

如果你要对网络中的第二个节点执行这些步骤,则必须在插入密钥之前将UI连接到第二个节点。

Option 2: Use curl

你也可以在命令行中的使用curl将密钥插入到密钥库中。这种方法在生产环境中可能更合适,因为您可能正在使用基于云的虚拟专用服务器。

因为安全是生产环境中最重要的问题,所以采取一切可能的预防措施是很重要的。在这个例子中,这意味着要注意不要留下任何密钥的痕迹,比如在终端的历史记录中。创建一个文件,用于定义curl请求的body:

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"author_insertKey",
  "params": [
    "<aura/gran>",
    "<mnemonic phrase>",
    "<public key>"
  ]
}
# Submit a new key via RPC, connect to where your `rpc-port` is listening
curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d "@/path/to/file"

如果您正确地输入了命令和参数,节点将返回一个如下所示的JSON响应:

{ "jsonrpc": "2.0", "result": null, "id": 1 }

完成后,请确保删除包含密钥的文件。

Option 3: Use the key command

或者,可以使用key命令将密钥插入保存到本地文件中:

# Insert the key from /path/to/key/file into the keystore
./target/release/node-template key insert --base-path /tmp/node01 --chain local --key-type <aura/gran> --suri /path/to/key/file

Verify Keys in the Keystore (Optional)

可选的,如果您想检查您的密钥是否已加载成功,您可以查看node01的现在应该存在的密钥库文件。它们位于以下(默认示例)位置:

# The path stems from `--base-path` and ID from `chain_spec.rs` ID field.
# Keys are then in `chains/<chain ID>/keystore :
ls /tmp/node01/chains/local_testnet/keystore
## list of keystore files:
617572619effc1668ca381c242885516ec9fa2b19c67b6684c02a8a3237b6862e5c8cd7e
6772616eb48004c6e1625282313b07d1c9950935e86894a2e4f21fb1ffee9854d180c781

# read a keystore file (our demo seed 1 was used)
cat /tmp/node01/chains/local_testnet/keystore/617572619effc1668ca381c242885516ec9fa2b19c67b6684c02a8a3237b6862e5c8cd7e
"clip organ olive upper oak void inject side suit toilet stick narrow"

请注意,这里有两个密钥库,正如预期的那样我们在节点中添加了两个密钥。这个例子使用了来自这里的已知种子的pair 1,我们的下一个节点将使用pair 2,具体操作时你的密钥可能不同。

Subsequent Participants Join

随后的验证节点现在可以加入网络。这可以通过像Bob之前那样指定--bootnodes参数来实现。

# purge chain (only required for new/modified dev chain spec)
./target/release/node-template purge-chain --base-path /tmp/node02 --chain local -y

# start node02
./target/release/node-template \
  --base-path /tmp/node02 \
  --chain ./customSpecRaw.json \
  --port 30334 \
  --ws-port 9946 \
  --rpc-port 9934 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --rpc-methods Unsafe \
  --name MyNode02 \
  --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWAvdwXzjmRpkHpz8PzUTaX1o23SdpgAWVyTGMSQ68QXK6
  # you MUST fill the correct info in the line above:
  # --bootnodes /ip4/<IP Address>/tcp/<p2p Port>/p2p/<Peer ID>

如果您没有设置从另一个具有相同链规范的运行中节点收集的正确节点ID,而是仅设置了正确的IP,你将会收到以下形式的错误:💔 The bootnode you want to connect to at ... provided a different peer ID than the one you expect: ...

和前面一样,我们指定另一个base-path,给它另一个名称,并且也将此节点指定为验证节点(validator)。

区块生产(Block production):现在您还必须也在这个节点中设置authoring keys,就像我们对第一个节点所操作的那样。请注意,您需要在节点的正确的ws-port端口上进行通信(因此,设置app UI 并将curl提交到正确的端口是至关重要的),如果节点没有添加Aura密钥,它将无法生成区块!
区块确认(Block finalization):只有超过三分之二的验证节点将它们的GRANDPA密钥添加到密钥库中时,这种情况才会发生。由于此网络配置了两个验证节点(在chain spec中),因此在第二个节点添加了它的密钥之后(即50%<66%<100%),区块确认可以发生。

注意::
所有验证节点必须使用相同的链规范才能进行对等。你应该看到相同的genesis区块和状态根哈希。
Reminder:
All validators must be using identical chain specifications in order to peer. You should see the same genesis block and state root hashes.

一旦第二个节点正在运行,并且具有 authoring key,你应该会看到两个节点都在报告区块编写:

2021-03-18 16:43:10  Substrate Node
2021-03-18 16:43:10  ✌️  version 3.0.0-c528fd2-x86_64-linux-gnu
2021-03-18 16:43:10  ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021
2021-03-18 16:43:10  📋 Chain specification: Local Testnet
2021-03-18 16:43:10  🏷 Node name: MyNode02
2021-03-18 16:43:10  👤 Role: AUTHORITY
2021-03-18 16:43:10  💾 Database: RocksDb at /tmp/node02/chains/local_testnet/db
2021-03-18 16:43:10Native runtime: node-template-100 (node-template-1.tx1.au1)
2021-03-18 16:43:10  Using default protocol ID "sup" because none is configured in the chain specs
2021-03-18 16:43:10  🏷 Local node identity is: 12D3KooWDfpXmPtsvLCFTh4mKybYi6MvDMDiUrnRDcGZiSTR2GHp
2021-03-18 16:43:10  📦 Highest known block at #1
2021-03-18 16:43:10  Listening for new connections on 127.0.0.1:9946.
2021-03-18 16:43:11  🔍 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWDfpXmPtsvLCFTh4mKybYi6MvDMDiUrnRDcGZiSTR2GHp
2021-03-18 16:43:12  🙌 Starting consensus session on top of parent 0x700fda8b9c7574553eccc8acc72e2dec59e40711e743223d67c3e5b57e1f76ef
2021-03-18 16:43:12  ♻️  Reorg on #1,0x700f76ef to #2,0xe111…c084, common ancestor #0,0x27768ba7
2021-03-18 16:43:12Imported #2 (0xe111…c084)
2021-03-18 16:43:12  Timeout fired waiting for transaction pool at block #1. Proceeding with production.
2021-03-18 16:43:12  🎁 Prepared block for proposing at 2 [hash: 0xc590a846ff17871ffdcdd670914321f667cd6ad0b898bfb6d25f7dd68fff478b; parent_hash: 0x700f76ef; extrinsics (1): [0x34d6…ed56]]
2021-03-18 16:43:12  🔖 Pre-sealed block for proposal at 2. Hash now 0x38b29b343d8f6ef56286a2f3aad20c82ae75d5bb0698569dd06fca654dae6fa6, previously 0xc590a846ff17871ffdcdd670914321f667cd6ad0b898bfb6d25f7dd68fff478b.
2021-03-18 16:43:12Imported #2 (0x38b26fa6)
2021-03-18 16:43:15  💤 Idle (1 peers), best: #2 (0xe111…c084), finalized #0 (0x27768ba7),1.4kiB/s ⬆ 1.4kiB/s

最后一行显示您的节点已与另一个节点(1 peers)进行了对等,并且它们生成了一个区块(best: #2 (0xe111…c084))!

但是请注意,即使你为第二个节点添加了GRANDPA密钥,也没有发生区块确认(finalized #0 (0x2776…8ba7))。Substrate节点需要在插入GRANDPA密钥后重新启动。杀掉你的节点并用你以前使用的相同命令重新启动它们。现在区块应该可以被确认了!

...
2021-03-18 16:47:47  💤 Idle (1 peers), best: #46 (0xfaf102f8), finalized #44 (0x9b0809ea),1.3kiB/s ⬆ 1.3kiB/s
2021-03-18 16:47:48Imported #47 (0x7375…aa51)
2021-03-18 16:47:52  💤 Idle (1 peers), best: #47 (0x7375…aa51), finalized #45 (0x7c137575),0.8kiB/s ⬆ 0.6kiB/s
2021-03-18 16:47:54  🙌 Starting consensus session on top of parent 0x73757e1773e6d86a9ef4a3ec9c3a55eef04345705c0a51f04445af657184aa51
2021-03-18 16:47:54  🎁 Prepared block for proposing at 48 [hash: 0xd9ef428ccd38426a47a9eca181b508630e327b35ef4c468103ce59fa861e60f6; parent_hash: 0x7375…aa51; extrinsics (1): [0x16f0…dbe6]]
2021-03-18 16:47:54  🔖 Pre-sealed block for proposal at 48. Hash now 0x23a93d8e6bbbcf9f36e61264cc3a48a426a7f1112ff48df76f0d55b52c181156, previously 0xd9ef428ccd38426a47a9eca181b508630e327b35ef4c468103ce59fa861e60f6.

You’re Finished

祝贺你!你已经启动了你自己的区块链!

在本教程中,你学习了如何生成自己的密钥对、使用这些密钥对创建自定义链规范,以及基于你的自定义链规范启动一个私有网络。

Solutions and Helpers

如果您想获得正确的JSON keystore curl文件(带有可以正常工作的chainspec)的示例,请参阅解决方案,你可以在已经克隆和编译好的节点中使用额外的文件,无需从头开始。

If you would like examples of correct JSON keystore curl files with a known working chainspec, see the solution, you can use the extra files with your already cloned and compiled node, no need to start from scratch.

Learn More

我们在链规范中遇到的那个大Wasm blob是实现无分叉升级所必需的。点击了解有关executor如何使用链上的Wasm的更多信息。

六、总结

相关的生成密钥以及启动节点的命令:

node1.
subkey generate --scheme sr25519
Secret phrase `expose cable thank nasty cruise lamp select lottery jeans pretty primary chest` is account:
  Secret seed:      0xf10449e18a8dbf72e74401dee7d8bf06abdb08b4e2223402ff3e3ad266ec8fce
  Public key (hex): 0x803758e8fed636e248b26890978c2adc40681ce994328d294b7c3ebb7c648b10
  Account ID:       0x803758e8fed636e248b26890978c2adc40681ce994328d294b7c3ebb7c648b10
  SS58 Address:     5ExpRmzxe841ZVu84fPpcmVeGHsjYm3h1BWB1H9tU36uN7Hk


subkey inspect --scheme ed25519 "expose cable thank nasty cruise lamp select lottery jeans pretty primary chest"
Secret phrase `expose cable thank nasty cruise lamp select lottery jeans pretty primary chest` is account:
  Secret seed:      0xf10449e18a8dbf72e74401dee7d8bf06abdb08b4e2223402ff3e3ad266ec8fce
  Public key (hex): 0x4c62075832ea21d22cb64246e2d7a77dca10921bee8caa8245ab9378d9e7fead
  Account ID:       0x4c62075832ea21d22cb64246e2d7a77dca10921bee8caa8245ab9378d9e7fead
  SS58 Address:     5Dnrcjr2gEtzWjqyLDagZvZ6PZA4XTATgytVtwMRqZgRDV1D



node2.
subkey generate --scheme sr25519
Secret phrase `list venture escape intact cinnamon what dice post split gather ice trim` is account:
  Secret seed:      0x8475016a0409a887ed9af8aa430e0c86790cdacdff336d1cf55d70c22d739cc9
  Public key (hex): 0x9ec394c7383667193d3d67c47a9d740429ca62604140fed8981616066e2ec244
  Account ID:       0x9ec394c7383667193d3d67c47a9d740429ca62604140fed8981616066e2ec244
  SS58 Address:     5FesXGZrQX2RdLY9HmbExxtCY1L333hLXQvqCfiPdk1w1dYG


subkey inspect --scheme ed25519 "list venture escape intact cinnamon what dice post split gather ice trim"
Secret phrase `list venture escape intact cinnamon what dice post split gather ice trim` is account:
  Secret seed:      0x8475016a0409a887ed9af8aa430e0c86790cdacdff336d1cf55d70c22d739cc9
  Public key (hex): 0xa52188f0e4a57041af8c54b19dbb950779dbe450870fadbb8d1da746a1c0c6c8
  Account ID:       0xa52188f0e4a57041af8c54b19dbb950779dbe450870fadbb8d1da746a1c0c6c8
  SS58 Address:     5FoDiidwP18xUaGg8J1RYiomzfdKa1gimaJzZi4tkceftUJJ





启动node1

# start node01
./target/release/node-template \
  --base-path /tmp/node01 \
  --chain ./customSpecRaw.json \
  --port 30333 \
  --ws-port 9945 \
  --rpc-port 9933 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --rpc-methods Unsafe \
  --name MyNode01


#记下nodeid: 12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq



启动node2

./target/release/node-template \
  --base-path /tmp/node02 \
  --chain ./customSpecRaw.json \
  --port 30334 \
  --ws-port 9946 \
  --rpc-port 9934 \
  --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
  --validator \
  --rpc-methods Unsafe \
  --name MyNode02 \
  --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq

#记下nodeid: 12D3KooWPzcciQZWw1vBEJSn9LxnPo8fhrvwDEkeyu5dUNTtouQP

实践时的log:

不添加GRANDPA密钥时节点不会得到确认,设置了GRANDPA密钥后重启节点:
重启node1:

~/SubstratePrivateNetwork/substrate-node-template$ ./target/release/node-template \
>   --base-path /tmp/node01 \
>   --chain ./customSpecRaw.json \
>   --port 30333 \
>   --ws-port 9945 \
>   --rpc-port 9933 \
>   --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
>   --validator \
>   --rpc-methods Unsafe \
>   --name MyNode01
2021-07-05 15:29:39 Substrate Node    
2021-07-05 15:29:39 ✌️  version 3.0.0-12d56a7-x86_64-linux-gnu    
2021-07-05 15:29:39 ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021    
2021-07-05 15:29:39 📋 Chain specification: Local Testnet    
2021-07-05 15:29:39 🏷 Node name: MyNode01    
2021-07-05 15:29:39 👤 Role: AUTHORITY    
2021-07-05 15:29:39 💾 Database: RocksDb at /tmp/node01/chains/local_testnet/db    
2021-07-05 15:29:39Native runtime: node-template-100 (node-template-1.tx1.au1)    
2021-07-05 15:29:39 Using default protocol ID "sup" because none is configured in the chain specs    
2021-07-05 15:29:39 🏷 Local node identity is: 12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq    
2021-07-05 15:29:39 📦 Highest known block at #141    
2021-07-05 15:29:39 〽️ Prometheus server started at 127.0.0.1:9615    
2021-07-05 15:29:39 Listening for new connections on 127.0.0.1:9945.    
2021-07-05 15:29:44 💤 Idle (0 peers), best: #141 (0x3a95…f352), finalized #0 (0xd10e…f468),00    
2021-07-05 15:29:49 💤 Idle (0 peers), best: #141 (0x3a95…f352), finalized #0 (0xd10e…f468),00    
2021-07-05 15:29:54 💤 Idle (0 peers), best: #141 (0x3a95…f352), finalized #0 (0xd10e…f468),00    
2021-07-05 15:29:57 🔍 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq    
2021-07-05 15:29:57 🔍 Discovered new external address for our node: /ip4/192.168.1.190/tcp/30333/p2p/12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq    
2021-07-05 15:29:59 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #47 (0x1b178bf5),1.2kiB/s ⬆ 1.1kiB/s    
2021-07-05 15:30:00 🙌 Starting consensus session on top of parent 0x3a95d8b09495db3c1f1b865cc71635b87e1537a36e7b9c96ad2aab42df81f352    
2021-07-05 15:30:04 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),1.0kiB/s ⬆ 0.8kiB/s    
2021-07-05 15:30:09 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:14 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:30:19 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:24 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:29 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:34 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:39 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:44 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:49 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:54 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:59 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:02Imported #142 (0x465d…ce9f)    
2021-07-05 15:31:02 🎁 Prepared block for proposing at 142 [hash: 0x2209431d10bb71bfedea3a937cda79b471ca9022a5eac93faa4b7fc997c3c85f; parent_hash: 0x3a95…f352; extrinsics (1): [0x86bb33a1]]    
2021-07-05 15:31:02 🔖 Pre-sealed block for proposal at 142. Hash now 0x364320721d9190c3f02b815522196edb86b0eb56002a43d62d33d2f66d98839b, previously 0x2209431d10bb71bfedea3a937cda79b471ca9022a5eac93faa4b7fc997c3c85f.    
2021-07-05 15:31:02Imported #142 (0x3643839b)    
2021-07-05 15:31:02 🙌 Starting consensus session on top of parent 0x465d6ec8a028a8be34d1bade0410d44ee13860a07b426a3db9c69cb4f9cece9f    
2021-07-05 15:31:02 🎁 Prepared block for proposing at 143 [hash: 0x5946fb9f646095258f54f987ce8e2a838ed1f8c5e3f21d7d3da8fa149065af7e; parent_hash: 0x465d…ce9f; extrinsics (1): [0x6a22012e]]    
2021-07-05 15:31:02 🔖 Pre-sealed block for proposal at 143. Hash now 0xe5c6dee052c48d5085a00c2a7d48cc84cf20fc1095afbd2efc241b00a57b057c, previously 0x5946fb9f646095258f54f987ce8e2a838ed1f8c5e3f21d7d3da8fa149065af7e.    
2021-07-05 15:31:02Imported #143 (0xe5c6057c)    
2021-07-05 15:31:04 💤 Idle (1 peers), best: #143 (0xe5c6057c), finalized #141 (0x3a95…f352),0.9kiB/s ⬆ 0.9kiB/s    
2021-07-05 15:31:06Imported #144 (0x65704b9d)    
2021-07-05 15:31:09 💤 Idle (1 peers), best: #144 (0x65704b9d), finalized #142 (0x465d…ce9f),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:12 🙌 Starting consensus session on top of parent 0x65702a5534f22eaeeee7e04b76534e34d62c17c06b2097f3c2d0558a5bcb4b9d    
2021-07-05 15:31:12 🎁 Prepared block for proposing at 145 [hash: 0x0e701baedfd50813a52902288ea792c5b694728184270ee2e16c69801ca3db74; parent_hash: 0x65704b9d; extrinsics (1): [0x8e81…f236]]    
2021-07-05 15:31:12 🔖 Pre-sealed block for proposal at 145. Hash now 0x998c50e03775dd19aa127dfb528df4d8affa2c902f2ff91b372e34c6be11f43c, previously 0x0e701baedfd50813a52902288ea792c5b694728184270ee2e16c69801ca3db74.    
2021-07-05 15:31:12Imported #145 (0x998c…f43c)    
2021-07-05 15:31:14 💤 Idle (1 peers), best: #145 (0x998c…f43c), finalized #143 (0xe5c6057c),0.6kiB/s ⬆ 0.8kiB/s    
2021-07-05 15:31:18Imported #146 (0x9a2f…e55f)    
2021-07-05 15:31:19 💤 Idle (1 peers), best: #146 (0x9a2f…e55f), finalized #144 (0x65704b9d),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:24 🙌 Starting consensus session on top of parent 0x9a2fc9460f312c38ae176b2bd3306920afc888d0631fb123dcd2af1ff3a6e55f    
2021-07-05 15:31:24 🎁 Prepared block for proposing at 147 [hash: 0x8f683b70c9fb6b71861f5a51d4bbf24b21831cb33d6d87061102fb5edb415f9f; parent_hash: 0x9a2f…e55f; extrinsics (1): [0x8a87…beaa]]    
2021-07-05 15:31:24 🔖 Pre-sealed block for proposal at 147. Hash now 0x8531165b0597367812ccbae2b141235bcdeda2e4a0ac2333e6c20799b5877209, previously 0x8f683b70c9fb6b71861f5a51d4bbf24b21831cb33d6d87061102fb5edb415f9f.    
2021-07-05 15:31:24Imported #147 (0x85317209)    
2021-07-05 15:31:24 💤 Idle (1 peers), best: #147 (0x85317209), finalized #144 (0x65704b9d),0.6kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:29 💤 Idle (1 peers), best: #147 (0x85317209), finalized #145 (0x998c…f43c),0.7kiB/s ⬆ 0.7kiB/s    

...

重启node2:

~/SubstratePrivateNetwork/substrate-node-template$ ./target/release/node-template \
>   --base-path /tmp/node02 \
>   --chain ./customSpecRaw.json \
>   --port 30334 \
>   --ws-port 9946 \
>   --rpc-port 9934 \
>   --telemetry-url 'wss://telemetry.polkadot.io/submit/ 0' \
>   --validator \
>   --rpc-methods Unsafe \
>   --name MyNode02 \
>   --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWK2Fis9edEDbaCn3yktHsopFyVxvuirm6pV6FwUkJ25pq
2021-07-05 15:29:57 Substrate Node    
2021-07-05 15:29:57 ✌️  version 3.0.0-12d56a7-x86_64-linux-gnu    
2021-07-05 15:29:57 ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021    
2021-07-05 15:29:57 📋 Chain specification: Local Testnet    
2021-07-05 15:29:57 🏷 Node name: MyNode02    
2021-07-05 15:29:57 👤 Role: AUTHORITY    
2021-07-05 15:29:57 💾 Database: RocksDb at /tmp/node02/chains/local_testnet/db    
2021-07-05 15:29:57Native runtime: node-template-100 (node-template-1.tx1.au1)    
2021-07-05 15:29:57 Using default protocol ID "sup" because none is configured in the chain specs    
2021-07-05 15:29:57 🏷 Local node identity is: 12D3KooWPzcciQZWw1vBEJSn9LxnPo8fhrvwDEkeyu5dUNTtouQP    
2021-07-05 15:29:57 📦 Highest known block at #141    
2021-07-05 15:29:57 Listening for new connections on 127.0.0.1:9946.    
2021-07-05 15:29:57 🔍 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWPzcciQZWw1vBEJSn9LxnPo8fhrvwDEkeyu5dUNTtouQP    
2021-07-05 15:29:57 🔍 Discovered new external address for our node: /ip4/192.168.1.190/tcp/30334/p2p/12D3KooWPzcciQZWw1vBEJSn9LxnPo8fhrvwDEkeyu5dUNTtouQP    
2021-07-05 15:30:00 🙌 Starting consensus session on top of parent 0x3a95d8b09495db3c1f1b865cc71635b87e1537a36e7b9c96ad2aab42df81f352    
2021-07-05 15:30:02 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #135 (0x313d6485),1.5kiB/s ⬆ 1.8kiB/s    
2021-07-05 15:30:03 Accepted a new tcp connection from 127.0.0.1:52540.    
2021-07-05 15:30:07 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:12 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:17 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:22 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:27 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:32 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:30:37 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:30:42 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:47 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:52 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:30:57 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.5kiB/s ⬆ 0.5kiB/s    
2021-07-05 15:31:02 💤 Idle (1 peers), best: #141 (0x3a95…f352), finalized #139 (0xf80f…d79e),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:02 Timeout fired waiting for transaction pool at block #141. Proceeding with production.    
2021-07-05 15:31:02 🎁 Prepared block for proposing at 142 [hash: 0x706c4e86cf34aad4ea7fc928287119a1704bb5029ed097c24871170c3a76498b; parent_hash: 0x3a95…f352; extrinsics (1): [0x7922…a97e]]    
2021-07-05 15:31:02 🔖 Pre-sealed block for proposal at 142. Hash now 0x465d6ec8a028a8be34d1bade0410d44ee13860a07b426a3db9c69cb4f9cece9f, previously 0x706c4e86cf34aad4ea7fc928287119a1704bb5029ed097c24871170c3a76498b.    
2021-07-05 15:31:02Imported #142 (0x465d…ce9f)    
2021-07-05 15:31:02Imported #142 (0x3643839b)    
2021-07-05 15:31:02Imported #143 (0xe5c6057c)    
2021-07-05 15:31:06 🙌 Starting consensus session on top of parent 0xe5c6dee052c48d5085a00c2a7d48cc84cf20fc1095afbd2efc241b00a57b057c    
2021-07-05 15:31:06 🎁 Prepared block for proposing at 144 [hash: 0x2b20f1f93aee9848f375d73db498cc096fdf27aa2aeb331a5a4db03c0c0a8f9d; parent_hash: 0xe5c6057c; extrinsics (1): [0x1b053396]]    
2021-07-05 15:31:06 🔖 Pre-sealed block for proposal at 144. Hash now 0x65702a5534f22eaeeee7e04b76534e34d62c17c06b2097f3c2d0558a5bcb4b9d, previously 0x2b20f1f93aee9848f375d73db498cc096fdf27aa2aeb331a5a4db03c0c0a8f9d.    
2021-07-05 15:31:06Imported #144 (0x65704b9d)    
2021-07-05 15:31:07 💤 Idle (1 peers), best: #144 (0x65704b9d), finalized #142 (0x465d…ce9f),1.0kiB/s ⬆ 1.0kiB/s    
2021-07-05 15:31:12Imported #145 (0x998c…f43c)    
2021-07-05 15:31:12 💤 Idle (1 peers), best: #145 (0x998c…f43c), finalized #142 (0x465d…ce9f),0.7kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:31:17 💤 Idle (1 peers), best: #145 (0x998c…f43c), finalized #143 (0xe5c6057c),0.6kiB/s ⬆ 0.6kiB/s    
2021-07-05 15:31:18 🙌 Starting consensus session on top of parent 0x998c50e03775dd19aa127dfb528df4d8affa2c902f2ff91b372e34c6be11f43c    
2021-07-05 15:31:18 🎁 Prepared block for proposing at 146 [hash: 0x7e90ab90f4adef65f4e2dc9c08791564677ca812ac4d43c58b4bd73e06aca928; parent_hash: 0x998c…f43c; extrinsics (1): [0x736f…cb10]]    
2021-07-05 15:31:18 🔖 Pre-sealed block for proposal at 146. Hash now 0x9a2fc9460f312c38ae176b2bd3306920afc888d0631fb123dcd2af1ff3a6e55f, previously 0x7e90ab90f4adef65f4e2dc9c08791564677ca812ac4d43c58b4bd73e06aca928.    
2021-07-05 15:31:18Imported #146 (0x9a2f…e55f)    
2021-07-05 15:31:22 💤 Idle (1 peers), best: #146 (0x9a2f…e55f), finalized #144 (0x65704b9d),0.7kiB/s ⬆ 0.7kiB/s    
2021-07-05 15:31:24Imported #147 (0x85317209)    
2021-07-05 15:31:27 💤 Idle (1 peers), best: #147 (0x85317209), finalized #145 (0x998c…f43c),0.7kiB/s ⬆ 0.6kiB/s    

...

可以看到区块已经得到确认!

更多相关:
实践Substrate私有网络搭建
如何用 Substrate 创建一条私有链(上)
使用Substrate搭建你的第一条区块链
技术 | Substrate 2.0 搭建私有区块链网络
【Substrate开发教程】08 - 搭建Substrate本地测试区块链网
substrate 学习记录(一):Substrate 安装 + 创建测试链 + 启动私有网络
【Substrate开发教程】09 - 搭建自定义Substrate区块链网络
Substrate 入门 - 运行与调试 -(二)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值