1

I am working on a private blockchain that consists of 4 nodes running on different ports.

I am trying to get each node to communicate its connections to its peers, so the network would be fully-connected (each Node has each other Node as its peer). However, nodes are not discovering the peers of their peers.

Node 1 is designated as the bootstrap node, and Nodes 2 & 3 connect to it upon starting. However, Node 1 will have Nodes 2 & 3 as its peers while they will each only have Node 1 as its own peer. I want Nodes 2 & 3 to discover each other.

Additionally, when I run admin.addPeer(node4's enode), from Node 1, it is not broadcasted to its peers.

My question: How can I enable a peer-discovery protocol wherein every Node communicates all of its peers to each of its peers?

I understand that there are some hacks to get around this. Per instance, I can simply pass in each of the 3 other nodes' enode address to every node's --bootnodes in Geth. Or I can just use admin.addPeer() on each of its peer's admin.peers. But I think Geth has this automated somehow and I'd like to use their solution.

StartNode Script:

geth --networkid 63261 --mine --minerthreads 1 --datadir . --rpc --rpcport "8547" --port "30305" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password "./node3password.sec" --ipcdisable --bootnodes "node1enode" console 2>> geth.log

[Edit]:

I had already initialized each of my nodes to point at my Private Network's Genesis JSON (./BCNetworkName.json) before running the StartNode script. geth --datadir ./NodeN init BCNetworkName.json

1

Bootnodes is a cheap and effective solution to aid the network self-discovery, but they need to catch up with a proper genesis file to isolate your network.

When you run geth, the genesis block is recreated from scratch and then it begin to sync with peers at block 1.

For you private blockchain, you need to provide this file to all of your nodes so they can talk to each other without having to run addpeers.

You can find more informations about the genesis block here

If you are familiar with docker, you can check this Github repository which play with the geth image in order to run a private network. You can learn a lot about peers self-discovery.

  • Could you explain what you mean by the nodes "catching up with a proper genesis file"? Does it happen automatically with time or do I need to specify something in the nodes' startnode script? How can I "provide the file"? Thanks for your help Edit: I have already run geth --datadir ./NodeN init BCNetworkName.json on each node before running the StartNode script – 3mrsh Oct 29 '18 at 16:45
  • Should normally work. What's the command you used to run your bootnode ? – M. Riggi Oct 30 '18 at 11:29
  • I initialized my bootnode by running bootnode -genkey bootnode.key as was suggested here Then my script to start the bootnode was: geth --networkid 63261 --mine --minerthreads 1 --datadir . --rpc --rpcport "8545" --port "30303" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password "./node1password.sec" --ipcdisable console 2>> geth.log – 3mrsh Oct 30 '18 at 17:51
  • I couldn't find anything in the Geth CLI Options that I would need to add to the script of a node that will be the Bootnode. Did I miss anything? – 3mrsh Oct 30 '18 at 17:54
  • try to start the bootnode with this command --nodekey /opt/bootnode/boot.key – M. Riggi Oct 31 '18 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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