I'm exploring blockchain technology and I want to setup my own private Ethereum network. There are a number of tutorials over the Internet (such as this), but unfortunately I have a problem, when any node starts mining, connection between nodes disappears.
To be concrete, I use 2 Amazon instances (Ubuntu Server 16.04 LTS (HVM), SSD Volume Type, t2.medium (2 vCPUs 2.3 GHz, 4GiB RAM)) and connect to them via ssh from my Windows desktop.
I install geth
on both (as described here) and have version 1.8.8-stable-2688dab4
:
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
Also I create directory for ethereum on both instances: /home/ubuntu/eth-root/datadir
After that I create my own genesis file and save it in /home/ubuntu/eth-root/genesis.json
on first instance and /home/ubuntu/common_init_files/root_init_result/genesis.json
on the second one:
{
"config": {
"chainId": 4970521,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"difficulty" : "0x1000",
"gasLimit" : "0xFFFFFFFFFFFFFFFF"
}
After that I define some properties (on both instances) via:
export GETH_COMMON_PROPERTIES="--datadir=/home/ubuntu/eth-root/datadir --networkid 4970521 --rpc --rpcport 8101 --rpccorsdomain \"*\" --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3 --port 30303"
export GETH="geth ${GETH_COMMON_PROPERTIES}";
Seems that all is OK, so I init first instance with
$GETH init /home/ubuntu/eth-root/genesis.json;
and launch simply with $GETH 2>ethereum.log;
After that I check that shasum
of both genesis.json
files on both instances are same, init second instance via $GETH init /home/ubuntu/common_init_files/root_init_result/genesis.json;
and launch also with $GETH 2>ethereum.log;
I attach to running geth
on both instances via $GETH attach
and add first instance to the second. I execute admin.nodeInfo.enode
on the first, replace [::]
via public IP address which I receive from Amazon and add it with admin.addPeer(..)
to the second instance. Seems that works, because I can see first instance from the second and vice versa with admin.peers
for ~5 minutes.
After that I want to start mining, because I want that my own blockchain actually works. I create account on the first instance with personal.newAccount("0000")
, set it as etherbase via miner.setEtherbase(personal.listAccounts[0])
and start mining with single thread with miner.start(1)
, after that I wait some time (~2 minutes) as first instance generates DAG and after that first instance starts to produce new blocks (as eth.blockNumber
constantly increasing), but when I execute eth.blockNumber
on the second instance I always receive 0! I try to restore connection by adding first instance as a peer for the second one (same command as above admin.addPeer(..)
, but now it doesn't help, when I look at ethereum.log
I can see error: WARN Synchronisation failed, dropping peer peer=48ed8f5fbb9f3f6c err="retrieved hash chain is invalid"
). I attempt to add second instance as a peer for the first one, but it also doesn't help. (I also tried to add peers via --bootnodes
flag on startup, but results were the same).
How can I fix this to setup my own working private Ethereum network?