I created a private ethereuem network using geth, and now I want other machine to join my network, I try this command :

geth --datadir node1/ --syncmode 'full' --port 30304 --rpc --rpcaddr 'localhost' --rpcport 8504 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://20c47b4a7bd6d8383f87c1c988e601c7aa27ba7177b25d57e00794d1917c0c992dc37b93dfdf54741633179fd9a96a34fc2687d606ad48e2015ef2d958f3f0fb@10.2.1.124:30310' --networkid 1515 -unlock '0x6747efc15a7209763e840c8bbf381b721aeababd' --password node1/password.txt 

But it doesn't sync with others nodes, and when I copy the genesis.json from connected machine and run:

geth --datadir node1/ init genesis.json

than I repeated the first command line it works!

so I want to know why I must have the genesis.json of a network to join it?

up vote 1 down vote accepted

The genesis file, in effect, describes the state of the network prior to the first block being mined. When a new node wishes to connect to a network, the genesis file helps it determined if the blocks it is being provided with follow from the initial state of the network.

When you run geth without initializing a genesis file first, it assumes that the network is the ethereum mainnet, and generates the chainstate based on the genesis for that (which is built into geth).

Thus, when you try to connect to your existing private network peers, your new node appears to be on a different chain to them, and they will not sync with it.

  • so every time I want to add a new node I have to copy the genesis.json ? – maroodb Aug 10 at 10:53
  • 1
    Yes, that's correct. – Raghav Sood Aug 10 at 11:11

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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