实践Substrate私有网络搭建

本文参考:https://substrate.dev/docs/en/tutorials/start-a-private-network/,搭建Substrate私有网络,并将其托管到telemetry.polkadot.io上。

# 实践Substrate私有网络搭建 *jasonruan 2020.07.22* # 1 前言 本文参考:https://substrate.dev/docs/en/tutorials/start-a-private-network/,搭建`Substrate`私有网络,并将其托管到`telemetry.polkadot.io`上。 # 2 搭建步骤 ## 2.1 安装 [Substrate Node Template](https://github.com/substrate-developer-hub/substrate-node-template) ```bash # 安装依赖工具 $ curl https://getsubstrate.io -sSf | bash -s -- --fast # clone最新分支版本的Substrate Node Template源码 $ git clone -b v2.0.0-rc4 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template $ cd substrate-node-template/ $ git checkout -b v2.0.0-rc4 # 初始化WebAssembly编译环境 source ~/.cargo/env rustup update nightly rustup update stable rustup target add wasm32-unknown-unknown --toolchain nightly # 编译 $ cargo build --release ``` ## 2.2 创建Keys > 使用`Subkey`命令,它是`Substrate`专用秘钥生成工具。安装方法: > > ```bash > $ cargo install --force subkey --git https://github.com/paritytech/substrate --tag v2.0.0-rc4 > ``` ### 2.2.1 创建助记词 ```bash $ ./subkey --sr25519 generate Secret phrase `text bubble owner rebuild damage today steel inflict mom book absent fiscal` is account: Network ID/version: substrate Secret seed: 0x29a4b095bb4ef2924cbc09f2c366cde44186de89348e8044b708527c35ae38dd Public key (hex): 0xec3ecd2ffebf75556c56e6cd183275a4017d70178d06c13d462a2245a902053a Account ID: 0xec3ecd2ffebf75556c56e6cd183275a4017d70178d06c13d462a2245a902053a SS58 Address: 5HQTpACjQHAE1o9niQctiFAzDLe4nKzMjjaW82ENTnS7DbGH ``` ### 2.2.2 创建Key Pair 1 > 注:用于区块生成的`Aura`账号需要使用`sr25519`,用于区块确认(`finalization`)的`GRANDPA`账号需要使用`ed25519`。 ```bash $ ./subkey --sr25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura" Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura` is account: Network ID/version: substrate Secret seed: 0xa63f8465e6b3d9380a2ffc4ca84256032d438d32eb4e42217a2176f255d35287 Public key (hex): 0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61 Account ID: 0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61 SS58 Address: 5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC $ ./subkey --ed25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa" Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa` is account: Network ID/version: substrate Secret seed: 0xae72aa8342e70e624d2bb583616c2c15bbedf8b00f337886ee6abbad1e99d169 Public key (hex): 0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866 Account ID: 0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866 SS58 Address: 5E9NB65gRVDMqNundHMFC3Umd4tdxocuWEcvAx31vj7hQPRW ``` ### 2.2.3 创建Key Pair 2 ```bash $ ./subkey --sr25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura" Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura` is account: Network ID/version: substrate Secret seed: 0x06e30e1b0e598d61c4a38feb80ea1d75a958fd8a2dd3bd01ac6dcf0d8ef255a8 Public key (hex): 0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71 Account ID: 0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71 SS58 Address: 5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX $ ./subkey --ed25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa" Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa` is account: Network ID/version: substrate Secret seed: 0x11a7c60cc1e1934e549da88512ea4b9dbb53bed6845af90d3e12f67a39b4ae48 Public key (hex): 0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec Account ID: 0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec SS58 Address: 5FcgXQtGzM7SrrAEZjyA9KQzBmpWTyfP8tWBgAFyYC2m1foX ``` ## 2.3 创建用户自定义chain spec文件 ### 2.3.1 创建chain spec文件 ```bash $ ./target/release/node-template build-spec --disable-default-bootnode --chain local > customSpec.json 2020-07-22 20:17:44 Building chain spec ``` ### 2.3.2 修改chain spec文件 > 将`customSpec.json`文件中相关配置,改成前面创建的地址 ```json "name": "jsrzx Testnet", "id": "jsrzx_testnet", "aura": { "authorities": [ "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC", "5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX" ] }, "grandpa": { "authorities": [ [ "5E9NB65gRVDMqNundHMFC3Umd4tdxocuWEcvAx31vj7hQPRW", 1 ], [ "5FcgXQtGzM7SrrAEZjyA9KQzBmpWTyfP8tWBgAFyYC2m1foX", 1 ] ] }, "balances": { "balances": [ [ "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC", 1152921504606846976 ], [ "5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX", 1152921504606846976 ], ] }, "sudo": { "key": "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC" } ``` ### 2.3.3 创建chain spec raw文件 ```bash $ ./target/release/node-template build-spec --chain=customSpec.json --raw --disable-default-bootnode > customSpecRaw.json 2020-07-22 20:23:48 Building chain spec ``` ## 2.4 创建私有网络 ### 2.4.1 启动`Bootnode`节点 #### 2.4.1.1 执行启动命令 ```bash $ ./target/release/node-template --ws-external --rpc-external --rpc-cors=all --base-path /tmp/jsrzx-bootnode01 --chain=./customSpecRaw.json --port 30333 --ws-port 9944 --rpc-port 9933 --telemetry-url 'ws://telemetry.polkadot.io:1024 0' --validator --rpc-methods=Unsafe --name jsrzx-BootNode01 2020-07-22 22:04:20 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods. 2020-07-22 22:04:20 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods. 2020-07-22 22:04:20 Substrate Node 2020-07-22 22:04:20 ️ version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:04:20 ️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:04:20 Chain specification: jsrzx Testnet 2020-07-22 22:04:20 Node name: jsrzx-BootNode01 2020-07-22 22:04:20 Role: AUTHORITY 2020-07-22 22:04:20 Database: RocksDb at /tmp/jsrzx-bootnode01/chains/jsrzx_testnet/db 2020-07-22 22:04:20 Native runtime: node-template-1 (node-template-1.tx1.au1) 2020-07-22 22:04:20 Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:04:20 Loading GRANDPA authority set from genesis on what appears to be first startup. 2020-07-22 22:04:20 ⏱ Loaded block-time = 6000 milliseconds from genesis on first-launch 2020-07-22 22:04:20 Highest known block at #0 2020-07-22 22:04:20 Using default protocol ID "sup" because none is configured in the chain specs 2020-07-22 22:04:20 Local node identity is: 12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX (legacy representation: QmYNUMrY5ow2Ev9zm5fZ2VdE3mQQcmfbzrSsyXaRAppMXc) 2020-07-22 22:04:20 〽️ Prometheus server started at 127.0.0.1:9615 2020-07-22 22:04:25 Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:30 Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:35 Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 ``` 启动后,我们并未看到有区块产生,还需要执行下面的操作。 接下来我们需要把我们创建的`keys`添加到该节点的`keystore`里面,这步操作在后续每个网络节点部署时都必不可少。 #### 2.4.1.2 添加`keys`到`keystore` ##### 方式一:使用`Polkadot-JS Apps UI` ![image.png](https://img.learnblockchain.cn/attachments/2020/07/YiCkMm2j5f1a4038e0043.png) ##### 方式二:使用curl命令 - 添加aura1 ```json curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d "@aura1.json" {"jsonrpc":"2.0","result":null,"id":1} { "jsonrpc":"2.0", "id":1, "method":"author_insertKey", "params": [ "aura", "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura", "0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61" ] } ``` - 添加grandpa1 ```json curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d "@gran1.json" {"jsonrpc":"2.0","result":null,"id":1} { "jsonrpc":"2.0", "id":1, "method":"author_insertKey", "params": [ "gran", "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa", "0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866" ] } ``` ### 2.4.2 添加验证人节点 #### 2.4.2.1 执行启动命令 ```bash $ ./target/release/node-template --base-path /tmp/jsrzx-validator01 --chain ./customSpecRaw.json --port 30334 --ws-port 9945 --rpc-port 9934 --telemetry-url 'ws://telemetry.polkadot.io:1024 0' --validator --rpc-methods=Unsafe --name jsrzx-Validator01 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:05:24 Substrate Node 2020-07-22 22:05:24 ️ version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:05:24 ️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:05:24 Chain specification: jsrzx Testnet 2020-07-22 22:05:24 Node name: jsrzx-Validator01 2020-07-22 22:05:24 Role: AUTHORITY 2020-07-22 22:05:24 Database: RocksDb at /tmp/jsrzx-validator01/chains/jsrzx_testnet/db 2020-07-22 22:05:24 Native runtime: node-template-1 (node-template-1.tx1.au1) 2020-07-22 22:05:25 Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:05:25 Loading GRANDPA authority set from genesis on what appears to be first startup. 2020-07-22 22:05:25 ⏱ Loaded block-time = 6000 milliseconds from genesis on first-launch 2020-07-22 22:05:25 Highest known block at #0 2020-07-22 22:05:25 Using default protocol ID "sup" because none is configured in the chain specs 2020-07-22 22:05:25 Local node identity is: 12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu (legacy representation: QmUQMXzgnMwxzb47xHLxgHzfSuD1sUseDjtZ8CqUW1isJw) 2020-07-22 22:05:25 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:05:30 Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.6kiB/s ⬆ 0.6kiB/s 2020-07-22 22:05:35 Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 27 B/s ⬆ 32 B/s 2020-07-22 22:05:36 Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.1kiB/s ⬆ 77 B/s 2020-07-22 22:05:45 Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 91 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:48 Imported #2 (0x8c10…083e) ``` - 此时Bootnode节点输出 ```bash 2020-07-22 22:05:25 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:05:30 Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:35 Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 32 B/s ⬆ 27 B/s 2020-07-22 22:05:36 Starting consensus session on top of parent 0x864739e39231bfe4eb360a45b24a79256dedd261525028f45c112dc48ea3f715 2020-07-22 22:05:36 Prepared block for proposing at 1 [hash: 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3; parent_hash: 0x8647…f715; extrinsics (1): [0xc222…88fc]] 2020-07-22 22:05:36 Pre-sealed block for proposal at 1. Hash now 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11, previously 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3. 2020-07-22 22:05:36 Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:45 Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:05:48 Starting consensus session on top of parent 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11 2020-07-22 22:05:48 Prepared block for proposing at 2 [hash: 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed; parent_hash: 0x2a04…4c11; extrinsics (1): [0xbc14…f03d]] 2020-07-22 22:05:48 Pre-sealed block for proposal at 2. Hash now 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e, previously 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed. 2020-07-22 22:05:48 Imported #2 (0x8c10…083e) 2020-07-22 22:05:50 Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 77 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:55 Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 51 B/s ⬆ 51 B/s 2020-07-22 22:06:00 Starting consensus session on top of parent 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e 2020-07-22 22:06:00 Prepared block for proposing at 3 [hash: 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0; parent_hash: 0x8c10…083e; extrinsics (1): [0x99e8…ddee]] 2020-07-22 22:06:00 Pre-sealed block for proposal at 3. Hash now 0xfa3e8f79aef17e48f0fd5338b9c754cbc3e349ace3246edbc5995a7d2f91ea7c, previously 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0. 2020-07-22 22:06:00 Imported #3 (0xfa3e…ea7c) ``` 我们可以看到连接已经建立,不断有`best`区块产生,但是没有`finalized`区块产生,这时需要我们在验证人节点也添加keys,并且重启节点。 #### 2.4.2.2 添加`keys`到`keystore` ##### 方式一:使用`Polkadot-JS Apps UI` ![image.png](https://img.learnblockchain.cn/attachments/2020/07/4Exau7Gb5f1a406623817.png) ##### 方式二:使用curl命令 - 添加aura2 ```json curl http://localhost:9934 -H "Content-Type:application/json;charset=utf-8" -d "@aura2.json" {"jsonrpc":"2.0","result":null,"id":1} { "jsonrpc":"2.0", "id":1, "method":"author_insertKey", "params": [ "aura", "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura", "0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71" ] } ``` - 添加grandpa2 ```json curl http://localhost:9934 -H "Content-Type:application/json;charset=utf-8" -d "@gran2.json" {"jsonrpc":"2.0","result":null,"id":1} { "jsonrpc":"2.0", "id":1, "method":"author_insertKey", "params": [ "gran", "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa", "0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec" ] } ``` ### 2.4.3 重启节点 之所以没有**`finalized`**区块产生,是因`Substrate`节点在导入`grandpa key`后,需要进行重启。 重启之后看到成功产生finalized区块。 - **Bootnode节点日志** ```bash $ ./target/release/node-template --ws-external --rpc-external --rpc-cors=all --base-path /tmp/jsrzx-bootnode01 --chain=./customSpecRaw.json --port 30333 --ws-port 9944 --rpc-port 9933 --telemetry-url 'ws://telemetry.polkadot.io:1024 0' --validator --rpc-methods=Unsafe --name jsrzx-BootNode01 2020-07-22 22:10:31 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods. 2020-07-22 22:10:31 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods. 2020-07-22 22:10:31 Substrate Node 2020-07-22 22:10:31 ️ version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:31 ️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:31 Chain specification: jsrzx Testnet 2020-07-22 22:10:31 Node name: jsrzx-BootNode01 2020-07-22 22:10:31 Role: AUTHORITY 2020-07-22 22:10:31 Database: RocksDb at /tmp/jsrzx-bootnode01/chains/jsrzx_testnet/db 2020-07-22 22:10:31 Native runtime: node-template-1 (node-template-1.tx1.au1) 2020-07-22 22:10:31 Highest known block at #35 2020-07-22 22:10:31 Using default protocol ID "sup" because none is configured in the chain specs 2020-07-22 22:10:31 Local node identity is: 12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX (legacy representation: QmYNUMrY5ow2Ev9zm5fZ2VdE3mQQcmfbzrSsyXaRAppMXc) 2020-07-22 22:10:31 〽️ Prometheus server started at 127.0.0.1:9615 2020-07-22 22:10:33 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:10:36 Starting consensus session on top of parent 0x805367935836c821252e2377a2b40f9299c656a0110a282573ce9b68898b9477 2020-07-22 22:10:36 Timeout fired waiting for transaction pool at block #35. Proceeding with production. 2020-07-22 22:10:36 Prepared block for proposing at 36 [hash: 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557; parent_hash: 0x8053…9477; extrinsics (1): [0xa745…4d58]] 2020-07-22 22:10:36 Pre-sealed block for proposal at 36. Hash now 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802, previously 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557. 2020-07-22 22:10:36 Imported #36 (0xcd71…0802) 2020-07-22 22:10:36 Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.4kiB/s ⬆ 1.5kiB/s 2020-07-22 22:10:41 Idle (1 peers), best: #36 (0xcd71…0802), finalized #34 (0x8720…c226), ⬇ 0.9kiB/s ⬆ 0.9kiB/s 2020-07-22 22:10:42 Imported #37 (0xc532…2af4) ``` - **验证人节点日志** ```bash $ ./target/release/node-template --base-path /tmp/jsrzx-validator01 --chain ./customSpecRaw.json --port 30334 --ws-port 9945 --rpc-port 9934 --telemetry-url 'ws://telemetry.polkadot.io:1024 0' --validator --rpc-methods=Unsafe --name jsrzx-Validator01 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:10:32 Substrate Node 2020-07-22 22:10:32 ️ version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:32 ️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:32 Chain specification: jsrzx Testnet 2020-07-22 22:10:32 Node name: jsrzx-Validator01 2020-07-22 22:10:32 Role: AUTHORITY 2020-07-22 22:10:32 Database: RocksDb at /tmp/jsrzx-validator01/chains/jsrzx_testnet/db 2020-07-22 22:10:32 Native runtime: node-template-1 (node-template-1.tx1.au1) 2020-07-22 22:10:32 Highest known block at #35 2020-07-22 22:10:32 Using default protocol ID "sup" because none is configured in the chain specs 2020-07-22 22:10:32 Local node identity is: 12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu (legacy representation: QmUQMXzgnMwxzb47xHLxgHzfSuD1sUseDjtZ8CqUW1isJw) 2020-07-22 22:10:33 Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:10:36 Imported #36 (0xcd71…0802) 2020-07-22 22:10:37 Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.6kiB/s ⬆ 1.6kiB/s 2020-07-22 22:10:42 Starting consensus session on top of parent 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802 2020-07-22 22:10:42 Prepared block for proposing at 37 [hash: 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73; parent_hash: 0xcd71…0802; extrinsics (1): [0xe180…6b2b]] 2020-07-22 22:10:42 Pre-sealed block for proposal at 37. Hash now 0xc532950ea2ee70a35b1d6e9f346b5c8f1ac3881770946f282f1942bcbe1e2af4, previously 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73. 2020-07-22 22:10:42 Imported #37 (0xc532…2af4) ``` ## 2.5 托管网络节点 节点启动成功后,我们便可以在`telemetry.polkadot.io`上查看创建的网络节点: ![image.png](https://img.learnblockchain.cn/attachments/2020/07/9Mfbb3TF5f1a4087e7164.png) # 3 参考资料 https://substrate.dev/docs/en/tutorials/start-a-private-network/ https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup

实践Substrate私有网络搭建

jasonruan 2020.07.22

1 前言

本文参考:https://substrate.dev/docs/en/tutorials/start-a-private-network/,搭建`Substrate`私有网络,并将其托管到`telemetry.polkadot.io`上。

2 搭建步骤

2.1 安装 Substrate Node Template

# 安装依赖工具
$ curl https://getsubstrate.io -sSf | bash -s -- --fast

# clone最新分支版本的Substrate Node Template源码
$ git clone -b v2.0.0-rc4 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template
$ cd substrate-node-template/
$ git checkout -b v2.0.0-rc4

# 初始化WebAssembly编译环境
source ~/.cargo/env
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly

# 编译
$ cargo build --release

2.2 创建Keys

使用Subkey命令,它是Substrate专用秘钥生成工具。安装方法:

$ cargo install --force subkey --git https://github.com/paritytech/substrate --tag v2.0.0-rc4

2.2.1 创建助记词

$ ./subkey --sr25519 generate
Secret phrase `text bubble owner rebuild damage today steel inflict mom book absent fiscal` is account:
  Network ID/version: substrate
  Secret seed:        0x29a4b095bb4ef2924cbc09f2c366cde44186de89348e8044b708527c35ae38dd
  Public key (hex):   0xec3ecd2ffebf75556c56e6cd183275a4017d70178d06c13d462a2245a902053a
  Account ID:         0xec3ecd2ffebf75556c56e6cd183275a4017d70178d06c13d462a2245a902053a
  SS58 Address:       5HQTpACjQHAE1o9niQctiFAzDLe4nKzMjjaW82ENTnS7DbGH

2.2.2 创建Key Pair 1

注:用于区块生成的Aura账号需要使用sr25519,用于区块确认(finalization)的GRANDPA账号需要使用ed25519

$ ./subkey --sr25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura"
Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura` is account:
  Network ID/version: substrate
  Secret seed:        0xa63f8465e6b3d9380a2ffc4ca84256032d438d32eb4e42217a2176f255d35287
  Public key (hex):   0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61
  Account ID:         0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61
  SS58 Address:       5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC

 $ ./subkey --ed25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa"
Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa` is account:
  Network ID/version: substrate
  Secret seed:        0xae72aa8342e70e624d2bb583616c2c15bbedf8b00f337886ee6abbad1e99d169
  Public key (hex):   0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866
  Account ID:         0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866
  SS58 Address:       5E9NB65gRVDMqNundHMFC3Umd4tdxocuWEcvAx31vj7hQPRW

2.2.3 创建Key Pair 2

$ ./subkey --sr25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura"
Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura` is account:
  Network ID/version: substrate
  Secret seed:        0x06e30e1b0e598d61c4a38feb80ea1d75a958fd8a2dd3bd01ac6dcf0d8ef255a8
  Public key (hex):   0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71
  Account ID:         0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71
  SS58 Address:       5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX

$ ./subkey --ed25519 inspect "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa"
Secret Key URI `text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa` is account:
  Network ID/version: substrate
  Secret seed:        0x11a7c60cc1e1934e549da88512ea4b9dbb53bed6845af90d3e12f67a39b4ae48
  Public key (hex):   0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec
  Account ID:         0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec
  SS58 Address:       5FcgXQtGzM7SrrAEZjyA9KQzBmpWTyfP8tWBgAFyYC2m1foX

2.3 创建用户自定义chain spec文件

2.3.1 创建chain spec文件

$ ./target/release/node-template build-spec --disable-default-bootnode --chain local > customSpec.json
2020-07-22 20:17:44 Building chain spec

2.3.2 修改chain spec文件

customSpec.json文件中相关配置,改成前面创建的地址

  "name": "jsrzx Testnet",                                                                                                                                                        
  "id": "jsrzx_testnet",

      "aura": {
        "authorities": [
          "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC",
          "5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX"
        ]   
      },
      "grandpa": {
        "authorities": [
          [ 
            "5E9NB65gRVDMqNundHMFC3Umd4tdxocuWEcvAx31vj7hQPRW",
            1   
          ],
          [ 
            "5FcgXQtGzM7SrrAEZjyA9KQzBmpWTyfP8tWBgAFyYC2m1foX",
            1   
          ] 
        ]   
      },
      "balances": {
        "balances": [
          [ 
            "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC",
            1152921504606846976
          ],
          [ 
            "5FbZJF6Afe2xsM2QnsRSGW7nDkXwBMNKUmFdUp6jEL9QTEjX",
            1152921504606846976
          ],
        ]   
      },
      "sudo": {
        "key": "5GTz3X4NeranDE5ZUj6EzK2PiR6xFokevbKyNQ4REc57DREC"
      }

2.3.3 创建chain spec raw文件

$ ./target/release/node-template build-spec --chain=customSpec.json --raw --disable-default-bootnode > customSpecRaw.json
2020-07-22 20:23:48 Building chain spec

2.4 创建私有网络

2.4.1 启动Bootnode节点

2.4.1.1 执行启动命令

$ ./target/release/node-template   --ws-external --rpc-external --rpc-cors=all   --base-path /tmp/jsrzx-bootnode01   --chain=./customSpecRaw.json   --port 30333   --ws-port 9944   --rpc-port 9933   --telemetry-url 'ws://telemetry.polkadot.io:1024 0'   --validator   --rpc-methods=Unsafe   --name jsrzx-BootNode01
2020-07-22 22:04:20 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods.
2020-07-22 22:04:20 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods.
2020-07-22 22:04:20 Substrate Node
2020-07-22 22:04:20 ️  version 2.0.0-rc4-54c58a2-x86_64-linux-gnu
2020-07-22 22:04:20 ️  by Substrate DevHub &lt;https://github.com/substrate-developer-hub>, 2017-2020
2020-07-22 22:04:20  Chain specification: jsrzx Testnet
2020-07-22 22:04:20   Node name: jsrzx-BootNode01
2020-07-22 22:04:20  Role: AUTHORITY
2020-07-22 22:04:20  Database: RocksDb at /tmp/jsrzx-bootnode01/chains/jsrzx_testnet/db
2020-07-22 22:04:20   Native runtime: node-template-1 (node-template-1.tx1.au1)
2020-07-22 22:04:20  Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715)
2020-07-22 22:04:20  Loading GRANDPA authority set from genesis on what appears to be first startup.
2020-07-22 22:04:20 ⏱  Loaded block-time = 6000 milliseconds from genesis on first-launch
2020-07-22 22:04:20  Highest known block at #0
2020-07-22 22:04:20 Using default protocol ID "sup" because none is configured in the chain specs
2020-07-22 22:04:20   Local node identity is: 12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX (legacy representation: QmYNUMrY5ow2Ev9zm5fZ2VdE3mQQcmfbzrSsyXaRAppMXc)
2020-07-22 22:04:20 〽️ Prometheus server started at 127.0.0.1:9615
2020-07-22 22:04:25  Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0
2020-07-22 22:04:30  Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0
2020-07-22 22:04:35  Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0

启动后,我们并未看到有区块产生,还需要执行下面的操作。

接下来我们需要把我们创建的keys添加到该节点的keystore里面,这步操作在后续每个网络节点部署时都必不可少。

2.4.1.2 添加keyskeystore

方式一:使用Polkadot-JS Apps UI

方式二:使用curl命令
  • 添加aura1
curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d "@aura1.json"
{"jsonrpc":"2.0","result":null,"id":1}

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"author_insertKey",
  "params": [
    "aura",
    "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//aura",
    "0xc2b21193cf6669c82421036e382a945b45db9b0c24dff201cd341346bbe80d61"
  ]
}
  • 添加grandpa1
curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d "@gran1.json"
{"jsonrpc":"2.0","result":null,"id":1}

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"author_insertKey",
  "params": [
    "gran",
    "text bubble owner rebuild damage today steel inflict mom book absent fiscal//jasonruan//grandpa",
    "0x5c066fdf0bfc266fdef4153371c07673108b4681005bfddb02b86612ee362866"
  ]
}

2.4.2 添加验证人节点

2.4.2.1 执行启动命令

$   ./target/release/node-template   --base-path /tmp/jsrzx-validator01  --chain ./customSpecRaw.json   --port 30334   --ws-port 9945   --rpc-port 9934   --telemetry-url 'ws://telemetry.polkadot.io:1024 0'   --validator   --rpc-methods=Unsafe   --name jsrzx-Validator01   --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX
2020-07-22 22:05:24 Substrate Node
2020-07-22 22:05:24 ️  version 2.0.0-rc4-54c58a2-x86_64-linux-gnu
2020-07-22 22:05:24 ️  by Substrate DevHub &lt;https://github.com/substrate-developer-hub>, 2017-2020
2020-07-22 22:05:24  Chain specification: jsrzx Testnet
2020-07-22 22:05:24   Node name: jsrzx-Validator01
2020-07-22 22:05:24  Role: AUTHORITY
2020-07-22 22:05:24  Database: RocksDb at /tmp/jsrzx-validator01/chains/jsrzx_testnet/db
2020-07-22 22:05:24   Native runtime: node-template-1 (node-template-1.tx1.au1)
2020-07-22 22:05:25  Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715)
2020-07-22 22:05:25  Loading GRANDPA authority set from genesis on what appears to be first startup.
2020-07-22 22:05:25 ⏱  Loaded block-time = 6000 milliseconds from genesis on first-launch
2020-07-22 22:05:25  Highest known block at #0
2020-07-22 22:05:25 Using default protocol ID "sup" because none is configured in the chain specs
2020-07-22 22:05:25   Local node identity is: 12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu (legacy representation: QmUQMXzgnMwxzb47xHLxgHzfSuD1sUseDjtZ8CqUW1isJw)
2020-07-22 22:05:25  Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu
2020-07-22 22:05:30  Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.6kiB/s ⬆ 0.6kiB/s
2020-07-22 22:05:35  Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 27 B/s ⬆ 32 B/s
2020-07-22 22:05:36  Imported #1 (0x2a04…4c11)
2020-07-22 22:05:40  Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.1kiB/s ⬆ 77 B/s
2020-07-22 22:05:45  Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 91 B/s ⬆ 0.1kiB/s
2020-07-22 22:05:48  Imported #2 (0x8c10…083e)
  • 此时Bootnode节点输出
2020-07-22 22:05:25  Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX
2020-07-22 22:05:30  Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s
2020-07-22 22:05:35  Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 32 B/s ⬆ 27 B/s
2020-07-22 22:05:36  Starting consensus session on top of parent 0x864739e39231bfe4eb360a45b24a79256dedd261525028f45c112dc48ea3f715
2020-07-22 22:05:36  Prepared block for proposing at 1 [hash: 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3; parent_hash: 0x8647…f715; extrinsics (1): [0xc222…88fc]]
2020-07-22 22:05:36  Pre-sealed block for proposal at 1. Hash now 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11, previously 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3.
2020-07-22 22:05:36  Imported #1 (0x2a04…4c11)
2020-07-22 22:05:40  Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s
2020-07-22 22:05:45  Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0
2020-07-22 22:05:48  Starting consensus session on top of parent 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11
2020-07-22 22:05:48  Prepared block for proposing at 2 [hash: 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed; parent_hash: 0x2a04…4c11; extrinsics (1): [0xbc14…f03d]]
2020-07-22 22:05:48  Pre-sealed block for proposal at 2. Hash now 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e, previously 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed.
2020-07-22 22:05:48  Imported #2 (0x8c10…083e)
2020-07-22 22:05:50  Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 77 B/s ⬆ 0.1kiB/s
2020-07-22 22:05:55  Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 51 B/s ⬆ 51 B/s
2020-07-22 22:06:00  Starting consensus session on top of parent 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e
2020-07-22 22:06:00  Prepared block for proposing at 3 [hash: 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0; parent_hash: 0x8c10…083e; extrinsics (1): [0x99e8…ddee]]
2020-07-22 22:06:00  Pre-sealed block for proposal at 3. Hash now 0xfa3e8f79aef17e48f0fd5338b9c754cbc3e349ace3246edbc5995a7d2f91ea7c, previously 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0.
2020-07-22 22:06:00  Imported #3 (0xfa3e…ea7c)

我们可以看到连接已经建立,不断有best区块产生,但是没有finalized区块产生,这时需要我们在验证人节点也添加keys,并且重启节点。

2.4.2.2 添加keyskeystore

方式一:使用Polkadot-JS Apps UI

方式二:使用curl命令
  • 添加aura2
curl http://localhost:9934 -H "Content-Type:application/json;charset=utf-8" -d "@aura2.json"
{"jsonrpc":"2.0","result":null,"id":1}

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"author_insertKey",
  "params": [
    "aura",
    "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//aura",
    "0x9c3c7edccb0c653c6a867ed9b51cf8a21265a6099109f8bbc03517df65ad7c71"
  ]
}
  • 添加grandpa2
curl http://localhost:9934 -H "Content-Type:application/json;charset=utf-8" -d "@gran2.json"
{"jsonrpc":"2.0","result":null,"id":1}

{
  "jsonrpc":"2.0",
  "id":1,
  "method":"author_insertKey",
  "params": [
    "gran",
    "text bubble owner rebuild damage today steel inflict mom book absent fiscal//rzexin//grandpa",
    "0x9d1811c2cc677a55b04eac77a4390b64a1760e93cfe5577500c89cc921372aec"
  ]
}

2.4.3 重启节点

之所以没有finalized区块产生,是因Substrate节点在导入grandpa key后,需要进行重启。

重启之后看到成功产生finalized区块。

  • Bootnode节点日志
$ ./target/release/node-template   --ws-external --rpc-external --rpc-cors=all   --base-path /tmp/jsrzx-bootnode01   --chain=./customSpecRaw.json   --port 30333   --ws-port 9944   --rpc-port 9933   --telemetry-url 'ws://telemetry.polkadot.io:1024 0'   --validator   --rpc-methods=Unsafe   --name jsrzx-BootNode01

2020-07-22 22:10:31 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods.
2020-07-22 22:10:31 It isn't safe to expose RPC publicly without a proxy server that filters available set of RPC methods.
2020-07-22 22:10:31 Substrate Node
2020-07-22 22:10:31 ️  version 2.0.0-rc4-54c58a2-x86_64-linux-gnu
2020-07-22 22:10:31 ️  by Substrate DevHub &lt;https://github.com/substrate-developer-hub>, 2017-2020
2020-07-22 22:10:31  Chain specification: jsrzx Testnet
2020-07-22 22:10:31   Node name: jsrzx-BootNode01
2020-07-22 22:10:31  Role: AUTHORITY
2020-07-22 22:10:31  Database: RocksDb at /tmp/jsrzx-bootnode01/chains/jsrzx_testnet/db
2020-07-22 22:10:31   Native runtime: node-template-1 (node-template-1.tx1.au1)
2020-07-22 22:10:31  Highest known block at #35
2020-07-22 22:10:31 Using default protocol ID "sup" because none is configured in the chain specs
2020-07-22 22:10:31   Local node identity is: 12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX (legacy representation: QmYNUMrY5ow2Ev9zm5fZ2VdE3mQQcmfbzrSsyXaRAppMXc)
2020-07-22 22:10:31 〽️ Prometheus server started at 127.0.0.1:9615
2020-07-22 22:10:33  Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX
2020-07-22 22:10:36  Starting consensus session on top of parent 0x805367935836c821252e2377a2b40f9299c656a0110a282573ce9b68898b9477
2020-07-22 22:10:36 Timeout fired waiting for transaction pool at block #35. Proceeding with production.
2020-07-22 22:10:36  Prepared block for proposing at 36 [hash: 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557; parent_hash: 0x8053…9477; extrinsics (1): [0xa745…4d58]]
2020-07-22 22:10:36  Pre-sealed block for proposal at 36. Hash now 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802, previously 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557.
2020-07-22 22:10:36  Imported #36 (0xcd71…0802)
2020-07-22 22:10:36  Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.4kiB/s ⬆ 1.5kiB/s
2020-07-22 22:10:41  Idle (1 peers), best: #36 (0xcd71…0802), finalized #34 (0x8720…c226), ⬇ 0.9kiB/s ⬆ 0.9kiB/s
2020-07-22 22:10:42  Imported #37 (0xc532…2af4)
  • 验证人节点日志
$   ./target/release/node-template   --base-path /tmp/jsrzx-validator01  --chain ./customSpecRaw.json   --port 30334   --ws-port 9945   --rpc-port 9934   --telemetry-url 'ws://telemetry.polkadot.io:1024 0'   --validator   --rpc-methods=Unsafe   --name jsrzx-Validator01   --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX

2020-07-22 22:10:32 Substrate Node
2020-07-22 22:10:32 ️  version 2.0.0-rc4-54c58a2-x86_64-linux-gnu
2020-07-22 22:10:32 ️  by Substrate DevHub &lt;https://github.com/substrate-developer-hub>, 2017-2020
2020-07-22 22:10:32  Chain specification: jsrzx Testnet
2020-07-22 22:10:32   Node name: jsrzx-Validator01
2020-07-22 22:10:32  Role: AUTHORITY
2020-07-22 22:10:32  Database: RocksDb at /tmp/jsrzx-validator01/chains/jsrzx_testnet/db
2020-07-22 22:10:32   Native runtime: node-template-1 (node-template-1.tx1.au1)
2020-07-22 22:10:32  Highest known block at #35
2020-07-22 22:10:32 Using default protocol ID "sup" because none is configured in the chain specs
2020-07-22 22:10:32   Local node identity is: 12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu (legacy representation: QmUQMXzgnMwxzb47xHLxgHzfSuD1sUseDjtZ8CqUW1isJw)
2020-07-22 22:10:33  Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu
2020-07-22 22:10:36  Imported #36 (0xcd71…0802)
2020-07-22 22:10:37  Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.6kiB/s ⬆ 1.6kiB/s
2020-07-22 22:10:42  Starting consensus session on top of parent 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802
2020-07-22 22:10:42  Prepared block for proposing at 37 [hash: 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73; parent_hash: 0xcd71…0802; extrinsics (1): [0xe180…6b2b]]
2020-07-22 22:10:42  Pre-sealed block for proposal at 37. Hash now 0xc532950ea2ee70a35b1d6e9f346b5c8f1ac3881770946f282f1942bcbe1e2af4, previously 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73.
2020-07-22 22:10:42  Imported #37 (0xc532…2af4)

2.5 托管网络节点

节点启动成功后,我们便可以在telemetry.polkadot.io上查看创建的网络节点:

3 参考资料

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

https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup

区块链技术网。

  • 发表于 2020-07-24 10:01
  • 阅读 ( 1318 )
  • 学分 ( 87 )
  • 分类:Polkadot

评论