不使用默认密钥的 Substrate 节点模板专用网络

luc*_*its 0 blockchain substrate

我正在尝试构建一个 5 节点网络(所有验证者以及 Aura 和 GRANPA 的成员),我的目标是使用自定义密钥,而不是预定义的 Alice 等。因此在自定义规范 JSON 中添加了 SR 和 ED 授权密钥文件。节点模板版本是来自 Github 的未更改的 V3。

\n

我按照教程(https://substrate.dev/docs/en/tutorials/start-a-private-network/customchain)进行操作,但出现此错误:

\n
\n2021-07-26 09:17:35 Substrate Node\n2021-07-26 09:17:35 \xe2\x9c\x8c\xef\xb8\x8f version 3.0.0-unknown-x86_64-linux-gnu\n2021-07-26 09:17:35 \xe2\x9d\xa4\xef\xb8\x8f by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021\n2021-07-26 09:17:35  Chain specification: The Batman Chain\n2021-07-26 09:17:35  Node name: Node1\n2021-07-26 09:17:35  Role: AUTHORITY\n2021-07-26 09:17:35  Database: RocksDb at /peer-data-1/chains/TBC_testnet/db\n2021-07-26 09:17:35 \xe2\x9b\x93 Native runtime: node-template-100 (node-template-1.tx1.au1)\n2021-07-26 09:17:36  Initializing Genesis block/state (state: 0x531c\xe2\x80\xa6653b, header-hash: 0x4c1f\xe2\x80\xa6570d)\n2021-07-26 09:17:36  Loading GRANDPA authority set from genesis on what appears to be first startup.\n2021-07-26 09:17:36 \xe2\x8f\xb1 Loaded block-time = 6000 milliseconds from genesis on first-launch\n2021-07-26 09:17:36 Using default protocol ID "sup" because none is configured in the chain specs\n2021-07-26 09:17:36  Local node identity is: 12D3KooWRzP2WuCbHENdXkf5ZvBStmgYn2N8mkwPofQparf58tkF\n2021-07-26 09:17:36  Highest known block at #0\n2021-07-26 09:17:36 \xe3\x80\xbd\xef\xb8\x8f Prometheus server started at 0.0.0.0:9615\n2021-07-26 09:17:36 Listening for new connections on 0.0.0.0:9944.\n2021-07-26 09:17:37  Discovered new external address for our node: /ip4/10.42.0.82/tcp/30333/p2p/12D3KooWRzP2WuCbHENdXkf5ZvBStmgYn2N8mkwPofQparf58tkF\n2021-07-26 09:17:37 GRANDPA voter error: Signing("Failed to sign GRANDPA vote for round 1 targetting 0x4c1f6404ff3236cbd58fa62dffe9b8e2b2ac670f06516541a641158c0a0a570d")\n2021-07-26 09:17:37 Essential task `grandpa-voter` failed. Shutting down service.\nError: Service(Other("Essential task failed."))\n
Run Code Online (Sandbox Code Playgroud)\n

要启动节点,我使用以下命令:

\n
\n2021-07-26 09:17:35 Substrate Node\n2021-07-26 09:17:35 \xe2\x9c\x8c\xef\xb8\x8f version 3.0.0-unknown-x86_64-linux-gnu\n2021-07-26 09:17:35 \xe2\x9d\xa4\xef\xb8\x8f by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021\n2021-07-26 09:17:35  Chain specification: The Batman Chain\n2021-07-26 09:17:35  Node name: Node1\n2021-07-26 09:17:35  Role: AUTHORITY\n2021-07-26 09:17:35  Database: RocksDb at /peer-data-1/chains/TBC_testnet/db\n2021-07-26 09:17:35 \xe2\x9b\x93 Native runtime: node-template-100 (node-template-1.tx1.au1)\n2021-07-26 09:17:36  Initializing Genesis block/state (state: 0x531c\xe2\x80\xa6653b, header-hash: 0x4c1f\xe2\x80\xa6570d)\n2021-07-26 09:17:36  Loading GRANDPA authority set from genesis on what appears to be first startup.\n2021-07-26 09:17:36 \xe2\x8f\xb1 Loaded block-time = 6000 milliseconds from genesis on first-launch\n2021-07-26 09:17:36 Using default protocol ID "sup" because none is configured in the chain specs\n2021-07-26 09:17:36  Local node identity is: 12D3KooWRzP2WuCbHENdXkf5ZvBStmgYn2N8mkwPofQparf58tkF\n2021-07-26 09:17:36  Highest known block at #0\n2021-07-26 09:17:36 \xe3\x80\xbd\xef\xb8\x8f Prometheus server started at 0.0.0.0:9615\n2021-07-26 09:17:36 Listening for new connections on 0.0.0.0:9944.\n2021-07-26 09:17:37  Discovered new external address for our node: /ip4/10.42.0.82/tcp/30333/p2p/12D3KooWRzP2WuCbHENdXkf5ZvBStmgYn2N8mkwPofQparf58tkF\n2021-07-26 09:17:37 GRANDPA voter error: Signing("Failed to sign GRANDPA vote for round 1 targetting 0x4c1f6404ff3236cbd58fa62dffe9b8e2b2ac670f06516541a641158c0a0a570d")\n2021-07-26 09:17:37 Essential task `grandpa-voter` failed. Shutting down service.\nError: Service(Other("Essential task failed."))\n
Run Code Online (Sandbox Code Playgroud)\n

自定义规范 JSON 文件是:

\n
node-template key insert \\\n    --base-path /peer-data-1 \\\n    --chain local \\\n    --key-type aura \\\n    --suri "0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37";\n\nnode-template key insert \\\n    --base-path /peer-data-1 \\\n    --chain local \\\n    --key-type gran \\\n    --suri "0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37";\nls -l /peer-data-1/chains/local_testnet/keystore;\n\nRUST_LOG=runtime=debug\nnode-template \\\n    --base-path /peer-data-1 \\\n    --name Node1 \\\n    --node-key 0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37 \\\n    --chain /genesis/customSpecRaw.json \\\n    --keystore-path /peer-data-1/chains/local_testnet/keystore/ \\\n    --port 30333 \\\n    --ws-port 9944 \\\n    --rpc-port 9933 \\\n    --unsafe-ws-external \\\n    --unsafe-rpc-external \\\n    --rpc-cors=all \\\n    --prometheus-external \\\n    --log info \\\n    --wasm-execution Compiled \\\n    --ws-max-connections 1000 \\\n    --pool-limit 10000 \\\n    --pool-kbytes 20480 \\\n    --max-runtime-instances 100 \\\n    --validator \\\n    --bootnodes /ip4/$SUBSTRATE_0_SERVICE_HOST/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp\n
Run Code Online (Sandbox Code Playgroud)\n

luc*_*its 5

我自己找到了答案。

  • 我把光环和爷爷的权限ID颠倒了。确保AURA 使用 Sr25519 ss58 Addresses并且grandpa 使用 Ed25519 ss58 Addresses
  • 启动节点的代码是错误的,我添加了--scheme Ed25519/Sr25519以确保在密钥库中添加的密钥正确。
node-template key insert \
    --base-path /peer-data-1 \
    --chain local \
    --key-type aura \
    --scheme Sr25519 \
    --suri "0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37";
node-template key insert \
    --base-path /peer-data-1 \
    --chain local \
    --key-type gran \
    --scheme Ed25519 \
    --suri "0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37";
ls -l /peer-data-1/chains/local_testnet/keystore;
RUST_LOG=runtime=debug
node-template \
    --base-path /peer-data-1 \
    --name Node1 \
    --chain /genesis/customSpecRaw.json \
    --keystore-path /peer-data-1/chains/local_testnet/keystore/ \
    --node-key 0x0e32f2687f1234deb25e20a50c39db5cdf0a2f2ccb84995189522fc9f20beb37 \
    --port 30333 \
    --ws-port 9944 \
    --rpc-port 9933 \
    --unsafe-ws-external \
    --unsafe-rpc-external \
    --rpc-cors=all \
    --prometheus-external \
    --log info \
    --wasm-execution Compiled \
    --ws-max-connections 1000 \
    --pool-limit 10000 \
    --pool-kbytes 20480 \
    --max-runtime-instances 100 \
    --validator \
    --bootnodes /ip4/$SUBSTRATE_0_SERVICE_HOST/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
Run Code Online (Sandbox Code Playgroud)