Search code examples
substrate

How to make a joined well-known full node into an authority node in Substrate, automatically became an validator node?


I use node-template to practise the tutorials.

I have finished the start a private network and Permissioned Network. At the end, I can see Charlie joined the network as a full node. I want to go further, I try to make Charlie to be an authority node, I want to make Charlie's role the same as Alice's and Bob's.

I want to let a node automatically joined and became an validator to generate blocks and finalize blocks.

Previously, Charlie runs as :

./node-template \
--chain=local \
--base-path /tmp/validator3 \
--name charlie  \
--node-key=3a9d5b35b9fb4c42aafadeca046f6bf56107bd2579687f069b42646684b94d9e \
--port 30335 \
--ws-port=9946 \
--offchain-worker always

Now Charlie can act as a full node.

I try to modify and make Charlie run as an authority role.

What I do :

  1. clear the db of Charlie.

    ./node-template purge-chain --chain=local --base-path /tmp/validator3 -y

  2. run Charlie as an validator,

remove --offchain-worker always , add --validator --pruning archive

./node-template \
    --chain=local \
    --base-path /tmp/validator3 \
    --name charlie \
    --node-key=3a9d5b35b9fb4c42aafadeca046f6bf56107bd2579687f069b42646684b94d9e \
    --port 30335 \
    --ws-port 9946 \
    --rpc-port 9935 \
    --validator \
    --pruning archive \
    --rpc-methods=unsafe \
    --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWFzXtYJhUkMsWTXQodYaXhs6ah52xVExicuFPvmUQoZrE    # connecto to Alice, if not specified, could not find peer.
  1. submit auro grandpa keys:

input the auro key:

curl http://127.0.0.1:9935 -H "Content-Type:application/json;charset=utf-8" -d \
       '{
                     "jsonrpc":"2.0",
                     "id":1,
                     "method":"author_insertKey",
                     "params": [
                       "aura",
          "scheme sure language chef bacon second club wild suggest advice awful room",
          "0x7a96031a623cb0057299dfe51e9421fde3cc80cf7e534bd7c1fbd84b0d520547"
        ]
    }'

then input the grandpa key:

curl http://127.0.0.1:9935 -H "Content-Type:application/json;charset=utf-8" -d \
               '{
                 "jsonrpc":"2.0",
                 "id":1,
                 "method":"author_insertKey",
                 "params": [
                   "gran",
      "scheme sure language chef bacon second club wild suggest advice awful room",
      "0x85935cef010757764ec07fd2ea8665a123283b7d81d2a063211b3d52d8cc215e"
    ]
}'

Doing this is to insert the SessionKeys for Charlie.

  1. restart Charlie.

5). I stop Alice(or Bob, kill either Alice or Bob), leave Bob and Charlie running. The Best block# is continuing, the finalized# is hanged there, not growing.

I have tried many times and search for a day. Does it need a session pallet to support this? Where am I wrong? what I didn't do?


Solution

  • I got an answer substrate-validator-set. If you want to dynamically add validator on a PoA network, you need to add a session pallet, and let session to manage the auro key and grandpa key.