0

I want to write a script that runs node01, node02, node03 in relay chain network setup.

How do I get local node identity generated from running node 01? Also I am confused on how the first validator node decides the order to use keys from chain-spec. Chain is either substrate/polkadot/rococo-local

./target/release/polkadot \
--base-path /data/node01 \
--chain ./customSpecRaw.json \
--port 30333 \
--ws-port 9944 \
--rpc-port 9933 \
--no-telemetry \
--validator \
--rpc-methods Unsafe \  

var local_id = ??
echo "Run node02"

./target/release/polkadot  --base-path /data/node02   --chain ./customSpecRaw.json   --port 30334   --ws-external --ws-port 9945   --rpc-external --rpc-port 9934 --rpc-cors all  --no-telemetry --validator   --rpc-methods Unsafe --name MyNode02   --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/$local_id

Please help me in writing a script that uses node1's peerID to run other validator nodes

1 Answer 1

1

You can boot your node with:

--node-key 0000000000000000000000000000000000000000000000000000000000000000

Then copy the id from your terminal and paste/hardcode it into your script. Because you specify a node key, it won't change.


If you don't want to use 00.. as your node key. You can generate yours from subkey. And use it while booting your node.

subkey generate-node-key --file node-key

Or you could specify the --node-key-file xxx. If xxx doesn't exist, then the node will create it for you. And use the curl http://127.0.0.1:9933 -X POST -H "Content-Type:application/json" -d '{"jsonrpc":"2.0","method":"system_localPeerId","params":[],"id":1}' to get the peer id, then use it.

3
  • does the node-key override or conflict with generated custom keys we put in chainspec for validator? Can you explain the difference between node-key and keys we put in chain for validators? How is peerID derived for a node? Commented Jan 12, 2023 at 8:08
  • my purpose is not to copy/paste the local node identity from screen when node is run. My purpose is to have command that does it for me and then uses this ID to run 2nd node in another terminal tab. Any different ideas are welcomed. Commented Jan 12, 2023 at 8:15
  • That is one-time job. After that you don't need to do it. If you don't want that, just write some script to generate a node key from the subkey, then use it.
    – aurexav
    Commented Jan 12, 2023 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.