内容简介:本文参考:本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。
实践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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:04:20 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:04:20 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:04:20 Node name: jsrzx-BootNode01 2020-07-22 22:04:20 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:04:20 :floppy_disk: 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 :hammer: Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:04:20 :older_man: 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 :package: 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 :part_alternation_mark: Prometheus server started at 127.0.0.1:9615 2020-07-22 22:04:25 :zzz: Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:30 :zzz: Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:35 :zzz: 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
方式二:使用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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:05:24 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:05:24 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:05:24 Node name: jsrzx-Validator01 2020-07-22 22:05:24 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:05:24 :floppy_disk: 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 :hammer: Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:05:25 :older_man: 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 :package: 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 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:05:30 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.6kiB/s ⬆ 0.6kiB/s 2020-07-22 22:05:35 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 27 B/s ⬆ 32 B/s 2020-07-22 22:05:36 :sparkles: Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.1kiB/s ⬆ 77 B/s 2020-07-22 22:05:45 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 91 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:48 :sparkles: Imported #2 (0x8c10…083e)
- 此时Bootnode节点输出
2020-07-22 22:05:25 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:05:30 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:35 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 32 B/s ⬆ 27 B/s 2020-07-22 22:05:36 :raised_hands: Starting consensus session on top of parent 0x864739e39231bfe4eb360a45b24a79256dedd261525028f45c112dc48ea3f715 2020-07-22 22:05:36 :gift: Prepared block for proposing at 1 [hash: 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3; parent_hash: 0x8647…f715; extrinsics (1): [0xc222…88fc]] 2020-07-22 22:05:36 :bookmark: Pre-sealed block for proposal at 1. Hash now 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11, previously 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3. 2020-07-22 22:05:36 :sparkles: Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:45 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:05:48 :raised_hands: Starting consensus session on top of parent 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11 2020-07-22 22:05:48 :gift: Prepared block for proposing at 2 [hash: 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed; parent_hash: 0x2a04…4c11; extrinsics (1): [0xbc14…f03d]] 2020-07-22 22:05:48 :bookmark: Pre-sealed block for proposal at 2. Hash now 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e, previously 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed. 2020-07-22 22:05:48 :sparkles: Imported #2 (0x8c10…083e) 2020-07-22 22:05:50 :zzz: Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 77 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:55 :zzz: Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 51 B/s ⬆ 51 B/s 2020-07-22 22:06:00 :raised_hands: Starting consensus session on top of parent 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e 2020-07-22 22:06:00 :gift: Prepared block for proposing at 3 [hash: 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0; parent_hash: 0x8c10…083e; extrinsics (1): [0x99e8…ddee]] 2020-07-22 22:06:00 :bookmark: Pre-sealed block for proposal at 3. Hash now 0xfa3e8f79aef17e48f0fd5338b9c754cbc3e349ace3246edbc5995a7d2f91ea7c, previously 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0. 2020-07-22 22:06:00 :sparkles: Imported #3 (0xfa3e…ea7c)
我们可以看到连接已经建立,不断有 best
区块产生,但是没有 finalized
区块产生,这时需要我们在验证人节点也添加keys,并且重启节点。
2.4.2.2 添加 keys
到 keystore
方式一:使用 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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:31 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:31 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:10:31 Node name: jsrzx-BootNode01 2020-07-22 22:10:31 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:10:31 :floppy_disk: 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 :package: 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 :part_alternation_mark: Prometheus server started at 127.0.0.1:9615 2020-07-22 22:10:33 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:10:36 :raised_hands: 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 :gift: Prepared block for proposing at 36 [hash: 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557; parent_hash: 0x8053…9477; extrinsics (1): [0xa745…4d58]] 2020-07-22 22:10:36 :bookmark: Pre-sealed block for proposal at 36. Hash now 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802, previously 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557. 2020-07-22 22:10:36 :sparkles: Imported #36 (0xcd71…0802) 2020-07-22 22:10:36 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.4kiB/s ⬆ 1.5kiB/s 2020-07-22 22:10:41 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #34 (0x8720…c226), ⬇ 0.9kiB/s ⬆ 0.9kiB/s 2020-07-22 22:10:42 :sparkles: 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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:32 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:32 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:10:32 Node name: jsrzx-Validator01 2020-07-22 22:10:32 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:10:32 :floppy_disk: 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 :package: 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 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:10:36 :sparkles: Imported #36 (0xcd71…0802) 2020-07-22 22:10:37 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.6kiB/s ⬆ 1.6kiB/s 2020-07-22 22:10:42 :raised_hands: Starting consensus session on top of parent 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802 2020-07-22 22:10:42 :gift: Prepared block for proposing at 37 [hash: 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73; parent_hash: 0xcd71…0802; extrinsics (1): [0xe180…6b2b]] 2020-07-22 22:10:42 :bookmark: Pre-sealed block for proposal at 37. Hash now 0xc532950ea2ee70a35b1d6e9f346b5c8f1ac3881770946f282f1942bcbe1e2af4, previously 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73. 2020-07-22 22:10:42 :sparkles: 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
实践Substrate私有网络搭建
jasonruan 2020.07.22
1 前言
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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:04:20 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:04:20 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:04:20 Node name: jsrzx-BootNode01 2020-07-22 22:04:20 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:04:20 :floppy_disk: 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 :hammer: Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:04:20 :older_man: 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 :package: 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 :part_alternation_mark: Prometheus server started at 127.0.0.1:9615 2020-07-22 22:04:25 :zzz: Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:30 :zzz: Idle (0 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:04:35 :zzz: 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
方式二:使用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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:05:24 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:05:24 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:05:24 Node name: jsrzx-Validator01 2020-07-22 22:05:24 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:05:24 :floppy_disk: 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 :hammer: Initializing Genesis block/state (state: 0xd10f…a688, header-hash: 0x8647…f715) 2020-07-22 22:05:25 :older_man: 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 :package: 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 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:05:30 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.6kiB/s ⬆ 0.6kiB/s 2020-07-22 22:05:35 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 27 B/s ⬆ 32 B/s 2020-07-22 22:05:36 :sparkles: Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.1kiB/s ⬆ 77 B/s 2020-07-22 22:05:45 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 91 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:48 :sparkles: Imported #2 (0x8c10…083e)
- 此时Bootnode节点输出
2020-07-22 22:05:25 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:05:30 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:35 :zzz: Idle (1 peers), best: #0 (0x8647…f715), finalized #0 (0x8647…f715), ⬇ 32 B/s ⬆ 27 B/s 2020-07-22 22:05:36 :raised_hands: Starting consensus session on top of parent 0x864739e39231bfe4eb360a45b24a79256dedd261525028f45c112dc48ea3f715 2020-07-22 22:05:36 :gift: Prepared block for proposing at 1 [hash: 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3; parent_hash: 0x8647…f715; extrinsics (1): [0xc222…88fc]] 2020-07-22 22:05:36 :bookmark: Pre-sealed block for proposal at 1. Hash now 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11, previously 0xfc7a3b7f071bad7bb008f981ffc755d8c52bd28fd4b7a6066f8e0d3e9fb9cee3. 2020-07-22 22:05:36 :sparkles: Imported #1 (0x2a04…4c11) 2020-07-22 22:05:40 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0.2kiB/s ⬆ 0.2kiB/s 2020-07-22 22:05:45 :zzz: Idle (1 peers), best: #1 (0x2a04…4c11), finalized #0 (0x8647…f715), ⬇ 0 ⬆ 0 2020-07-22 22:05:48 :raised_hands: Starting consensus session on top of parent 0x2a04174f2ebb9e13e12f7eb936d6bf00452f5077399f724a99501b8c78124c11 2020-07-22 22:05:48 :gift: Prepared block for proposing at 2 [hash: 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed; parent_hash: 0x2a04…4c11; extrinsics (1): [0xbc14…f03d]] 2020-07-22 22:05:48 :bookmark: Pre-sealed block for proposal at 2. Hash now 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e, previously 0x340e597ba2794bf039d42ffd66013391555e78525166e2cd8e2c60ec93f446ed. 2020-07-22 22:05:48 :sparkles: Imported #2 (0x8c10…083e) 2020-07-22 22:05:50 :zzz: Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 77 B/s ⬆ 0.1kiB/s 2020-07-22 22:05:55 :zzz: Idle (1 peers), best: #2 (0x8c10…083e), finalized #0 (0x8647…f715), ⬇ 51 B/s ⬆ 51 B/s 2020-07-22 22:06:00 :raised_hands: Starting consensus session on top of parent 0x8c10584f605a4cd3d93a70d047fb2e1ea80067f87776ab56ce132d9d405d083e 2020-07-22 22:06:00 :gift: Prepared block for proposing at 3 [hash: 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0; parent_hash: 0x8c10…083e; extrinsics (1): [0x99e8…ddee]] 2020-07-22 22:06:00 :bookmark: Pre-sealed block for proposal at 3. Hash now 0xfa3e8f79aef17e48f0fd5338b9c754cbc3e349ace3246edbc5995a7d2f91ea7c, previously 0x1aaf8b572a750e24ad1b0ee0d0b1e5aa6832f6873526e6efe59126130e88bca0. 2020-07-22 22:06:00 :sparkles: Imported #3 (0xfa3e…ea7c)
我们可以看到连接已经建立,不断有 best
区块产生,但是没有 finalized
区块产生,这时需要我们在验证人节点也添加keys,并且重启节点。
2.4.2.2 添加 keys
到 keystore
方式一:使用 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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:31 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:31 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:10:31 Node name: jsrzx-BootNode01 2020-07-22 22:10:31 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:10:31 :floppy_disk: 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 :package: 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 :part_alternation_mark: Prometheus server started at 127.0.0.1:9615 2020-07-22 22:10:33 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWC2mv6TUKbQbgujE57BWXtPdZM45E1tXtr8ekpUFwZoMX 2020-07-22 22:10:36 :raised_hands: 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 :gift: Prepared block for proposing at 36 [hash: 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557; parent_hash: 0x8053…9477; extrinsics (1): [0xa745…4d58]] 2020-07-22 22:10:36 :bookmark: Pre-sealed block for proposal at 36. Hash now 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802, previously 0x93a11511d172c3e01ea7d161fa050befc8b5ab5524335647e27a7f4701662557. 2020-07-22 22:10:36 :sparkles: Imported #36 (0xcd71…0802) 2020-07-22 22:10:36 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.4kiB/s ⬆ 1.5kiB/s 2020-07-22 22:10:41 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #34 (0x8720…c226), ⬇ 0.9kiB/s ⬆ 0.9kiB/s 2020-07-22 22:10:42 :sparkles: 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 :v: version 2.0.0-rc4-54c58a2-x86_64-linux-gnu 2020-07-22 22:10:32 :heart: by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2020 2020-07-22 22:10:32 :clipboard: Chain specification: jsrzx Testnet 2020-07-22 22:10:32 Node name: jsrzx-Validator01 2020-07-22 22:10:32 :bust_in_silhouette: Role: AUTHORITY 2020-07-22 22:10:32 :floppy_disk: 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 :package: 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 :mag: Discovered new external address for our node: /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWD4fjwTCEtoHczV3bH1bzyouWtAS1VXtM5q49m9zWmrXu 2020-07-22 22:10:36 :sparkles: Imported #36 (0xcd71…0802) 2020-07-22 22:10:37 :zzz: Idle (1 peers), best: #36 (0xcd71…0802), finalized #33 (0x6dfb…9bb2), ⬇ 1.6kiB/s ⬆ 1.6kiB/s 2020-07-22 22:10:42 :raised_hands: Starting consensus session on top of parent 0xcd7199364b6caaf77d4f691f9db0dbdceddfbe5dbadec77b537e744420ed0802 2020-07-22 22:10:42 :gift: Prepared block for proposing at 37 [hash: 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73; parent_hash: 0xcd71…0802; extrinsics (1): [0xe180…6b2b]] 2020-07-22 22:10:42 :bookmark: Pre-sealed block for proposal at 37. Hash now 0xc532950ea2ee70a35b1d6e9f346b5c8f1ac3881770946f282f1942bcbe1e2af4, previously 0xa891f9f76b326856e5fc564a567372315e1924bf06ba69db6c7be13466a6ff73. 2020-07-22 22:10:42 :sparkles: 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
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。
- 发表于 25分钟前
- 阅读 ( 7 )
- 学分 ( 0 )
- 分类:Polkadot
以上所述就是小编给大家介绍的《实践Substrate私有网络搭建》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
C#图解教程
索利斯 (Daniel M.Solis) / 姚琪琳、苏林、朱晔 / 人民邮电出版社 / 2013-7-1 / CNY 89.00
本书是广受赞誉的C# 图解教程的最新版本。作者在本书中创造了一种全新的可视化叙述方式,以图文并茂的形式、朴实简洁的文字,并辅以大量表格和代码示例,全面、直观地阐述了C# 语言的各种特性。新版本除了精心修订旧版内容外,还全面涵盖了C# 5.0 的新增特性,比如异步编程、调用者信息、case 表达式、带参数的泛型构造函数、支持null 类型运算等。通过本书,读者能够快速、深入理解C#,为自己的编程生涯......一起来看看 《C#图解教程》 这本书的介绍吧!