0

I am trying to build a private testnet with two nodes. This is my genesis block:

{
"config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block":0,
    "eip158Block":0
    },
    "difficulty":"0x400",
    "gasLimit": "0x2100000",
    "alloc": {
        "ba1464c6a4afb32f6b3eb6d750248d27e2c9925a":
        { "balance":"0x1337000000000000000000"}
    }
}

I have started by initializing a single node with this command:

./geth --identity "1"  --datadir /home/davide/Documents/Ether/ --networkid 4999 --rpc --rpcport 40901 --rpcapi "db,eth,net,web3" --rpccorsdomain "*"  --port 30303 --nodiscover --ipcpath /home/davide/Documents/Ether/geth.ipc

Then I attached a console to it with the command:

./geth attach /home/davide/Documents/Ether/geth.ipc 

and I made some transactions and mined 630 blocks.

Now I want to add a new node to my private blockchain and make it synchronize with the other nodes. I initialized a new node with this command:

./geth --identity "2"  --datadir /home/davide/Documents/Ether/2nd/ --networkid 4999 --rpc --rpcport 40900 --rpcapi "db,eth,net,web3" --rpccorsdomain "*"  --port 30300 --nodiscover --ipcpath /home/davide/Documents/Ether/2nd/geth.ipc init /home/davide/Documents/Ether/a.json

The a.json is the genesis block which is the same used for the other node as well

Then I launched it with:

./geth --identity "2"  --datadir /home/davide/Documents/Ether/2nd/ --networkid 4999 --rpc --rpcport 40900 --rpcapi "db,eth,net,web3" --rpccorsdomain "*"  --port 30300 --nodiscover --ipcpath /home/davide/Documents/Ether/2nd/geth.ipc

and I attached a console with the command:

./geth attach /home/davide/Documents/Ether/2nd/geth.ipc

So now I have the first node with 600 blocks and the second node with 0 blocks. To connect the two nodes I executed in the second node the command:

admin.addPeer("enode://9968520a028521084cb904b4c19ff9a40277c9f22f83b3bc2d3be944497ed55e5a0a1782c6f3d6e6b879ec3f806eb735670a7184c2026b438250fdff3e98c588@172.17.0.1:30303?discport=0")

where enode is the identity of the first node and 172.17.0.1 is the local IP address. The nodes are running on the same linux virtual machine.

The I get the following output:

INFO [03-27|16:24:27] Maximum peer count                       ETH=25 LES=0 total=25
INFO [03-27|16:24:27] Starting peer-to-peer node               instance=Geth/2/v1.8.2-stable-b8b9f7f4/linux-amd64/go1.9.4
INFO [03-27|16:24:27] Allocated cache and file handles         database=/home/davide/Documents/Ether/2nd/geth/chaindata cache=768 handles=512
WARN [03-27|16:24:27] Upgrading database to use lookup entries 
INFO [03-27|16:24:27] Initialised chain configuration          config="{ChainID: 15 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Constantinople: <nil> Engine: unknown}"
INFO [03-27|16:24:27] Disk storage enabled for ethash caches   dir=/home/davide/Documents/Ether/2nd/geth/ethash count=3
INFO [03-27|16:24:27] Disk storage enabled for ethash DAGs     dir=/home/davide/.ethash                         count=2
INFO [03-27|16:24:27] Initialising Ethereum protocol           versions="[63 62]" network=4999
INFO [03-27|16:24:27] Database deduplication successful        deduped=0
INFO [03-27|16:24:27] Loaded most recent local header          number=0 hash=36a78b…0fbdc8 td=1024
INFO [03-27|16:24:27] Loaded most recent local full block      number=0 hash=36a78b…0fbdc8 td=1024
INFO [03-27|16:24:27] Loaded most recent local fast block      number=0 hash=36a78b…0fbdc8 td=1024
INFO [03-27|16:24:27] Loaded local transaction journal         transactions=0 dropped=0
INFO [03-27|16:24:27] Regenerated local transaction journal    transactions=0 accounts=0
INFO [03-27|16:24:27] Starting P2P networking 
INFO [03-27|16:24:27] RLPx listener up                         self="enode://4ae8ab68997bca30e5c91495d9610ddbe3cd49082447710b0754b3b91880fa2946fa2fa8a24bcbc512356d51343ee38fb490594fa7645395f20d5c35d8144bde@[::]:30300?discport=0"
INFO [03-27|16:24:27] HTTP endpoint opened                     url=http://127.0.0.1:40900 cors=* vhosts=localhost
INFO [03-27|16:24:27] IPC endpoint opened                      url=/home/davide/Documents/Ether/2nd/geth.ipc
INFO [03-27|16:24:31] Etherbase automatically configured       address=0x494a61d7c8C48Bb47C59261e3F7C46f6B5D102d5
INFO [03-27|16:25:37] Block synchronisation started 
INFO [03-27|16:25:37] Imported new state entries               count=426 elapsed=869.471µs processed=426 pending=62 retry=0 duplicate=0 unexpected=0
INFO [03-27|16:25:37] Imported new state entries               count=22  elapsed=137.697µs processed=448 pending=0  retry=0 duplicate=0 unexpected=0
INFO [03-27|16:25:37] Imported new block headers               count=192 elapsed=20.183ms  number=192 hash=15b72f…071529 ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=27  elapsed=3.143ms   number=27  hash=82726c…b0614c size=56.94kB ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=165 elapsed=12.946ms  number=192 hash=15b72f…071529 size=70.97kB ignored=0
INFO [03-27|16:25:37] Imported new block headers               count=192 elapsed=35.971ms  number=384 hash=1dd324…af81c0 ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=2   elapsed=105.541µs number=194 hash=2c4cec…04979f size=8.00B   ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=190 elapsed=22.647ms  number=384 hash=1dd324…af81c0 size=71.95kB ignored=0
INFO [03-27|16:25:37] Imported new block headers               count=192 elapsed=179.280ms number=576 hash=9176d3…d96d9c ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=7   elapsed=1.957ms   number=391 hash=8a915b…59c18f size=28.00B  ignored=0
INFO [03-27|16:25:37] Imported new block receipts              count=174 elapsed=9.873ms   number=565 hash=0dbc2a…886588 size=91.09kB ignored=0
WARN [03-27|16:25:37] Node data write error                    err="state node 9e37b1…5c7c0a failed with all peers (1 tries, 1 peers)"
INFO [03-27|16:25:37] Imported new block headers               count=54  elapsed=67.773ms  number=630 hash=962920…003b4c ignored=0
WARN [03-27|16:25:37] Rolled back headers                      count=630 header=630->0 fast=565->0 block=0->0
WARN [03-27|16:25:37] Synchronisation failed, retrying         err="state node 9e37b1…5c7c0a failed with all peers (1 tries, 1 peers)"
INFO [03-27|16:25:47] Imported new block headers               count=0   elapsed=5.381ms   number=192 hash=15b72f…071529 ignored=192
INFO [03-27|16:25:47] Imported new block headers               count=0   elapsed=5.386ms   number=384 hash=1dd324…af81c0 ignored=192
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=56.831µs  number=27  hash=82726c…b0614c size=0.00B   ignored=27
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=216.716µs number=192 hash=15b72f…071529 size=0.00B   ignored=165
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=27.26µs   number=194 hash=2c4cec…04979f size=0.00B   ignored=2
INFO [03-27|16:25:47] Imported new block headers               count=0   elapsed=5.145ms   number=576 hash=9176d3…d96d9c ignored=192
INFO [03-27|16:25:47] Imported new block headers               count=0   elapsed=2.148ms   number=630 hash=962920…003b4c ignored=54
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=720.4µs   number=384 hash=1dd324…af81c0 size=0.00B   ignored=190
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=107.955µs number=391 hash=8a915b…59c18f size=0.00B   ignored=7
INFO [03-27|16:25:47] Imported new block receipts              count=0   elapsed=608.307µs number=565 hash=0dbc2a…886588 size=0.00B   ignored=174
WARN [03-27|16:25:47] Node data write error                    err="state node 9e37b1…5c7c0a failed with all peers (1 tries, 1 peers)"
WARN [03-27|16:25:47] Synchronisation failed, retrying         err="state node 9e37b1…5c7c0a failed with all peers (1 tries, 1 peers)"

What is the problem in my setup? Why aren't the nodes syncing?

  • is the field Hash from the output of eth.getBlock(0) the same on both nodes? – Nulik Mar 27 '18 at 16:53
  • add the output of admin.peers for both of your nodes to the question – Nulik Mar 27 '18 at 16:54
  • you are using wrong --networkid parameter, it should be 15 in your case – Nulik Mar 27 '18 at 17:04
1

What fixed this exact problem for me was adding node #1's enode to node #2's <datadir>/geth/static-nodes.json file, as described in the documentation. That's a way to persistently add a peer node, and it fixed my sync issue--I'm not completely sure how.

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.