1

I am attempting to have a second node sync up with an original node.

I had previously synced two nodes from the get-go but am unable to add a peer to an already running blockchain. In other words I want to add a peer to an already running network either for the first time or after a disconnect.

I have instantiated and started the chains with the same commands

geth --datadir test/ --maxpeers 55 --nodiscover init genesis.json

geth --datadir test/ --networkid 1234321 console 2>> myEth.log

And they have the same genesis.json files

{
  "config": {
        "chainId": 1234321,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

What am I doing wrong? Is there some command I must use to make them sync and peer?

I have already tried admin.addPeer()

1

You need to attach themself manually with

admin.addPeer("enode://$ENODEIDOFNODE@$IPOFNODE:30303?discport=0")

You can obtain the enodeid on the other node with admin.nodeInfo.enode

They cannot discover each other automatically as bootstrap nodes are required, however you can either preload a javascript script with all the admin.addPeer you need, or, alternatively you can create a json <datadir>/geth/static-nodes.json with this format

[
  "enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303",
  "enode://pubkey@ip:port"
]
  • Yes, this is what i did to initiate contact but I think when I changed IP addresses or lost connectivity the syncing stopped and the peers were dropped.. – 0TTT0 Jan 23 at 17:06
  • 1
    It dropped because each time the nodes lose connectivity or change IP, it needs to reconnect to the other nodes. Also, if it changes IP, the other node cannot know the new IP, as there's no discovery, so, yeah, don't change IP. to make them reconnect, put the admin.addPeer you need in a preloaded javascript file or create the static-nodes.json file – waytosay Jan 23 at 17:37
  • I had three nodes running and synched, i stopped them from mining and then waited a couple days came back and the blockchain had been reset to block 0... what could have happened? – 0TTT0 Jan 25 at 17:47
  • Did it go to 0 on all three nodes or just one or two? It could be possible, if not all of them, that the ones that went to zero at some point failed to syncronize with the other nodes. It is something that can happen with a very low difficulty and blocktime, in that case you can wipe the datadir of your faulty node and resync it – waytosay Jan 28 at 17:19

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.