1

On my desktop and my laptop, I downloaded geth&tools 1.8.2. On the desktop I created a local node using:

geth --datadir "D:\EthereumLocalNode" init "D:\EthereumLocalNode\genesis.json"

In the genesis.json file:

{
   "config": {
      "chainId": 1114,
      "homesteadBlock": 0,
      "eip155Block": 0,
      "eip158Block": 0
   },
   "difficulty": "400",
   "gasLimit": "2100000",
   "alloc": {
      "1f8b3201b54d73daac3c9437289102c7f11f9ff0": { 
          "balance": "100000000000000000000000" 
      },
      "968859556c516ccf00269a69795d08b5e899e2d2": { 
          "balance": "120000000000000000000000" 
      }
   }
}

Then using bootnode tool , I have created nodekey in order to be used later for bootnodes command as such:

bootnode -genkey boot.key

Then I start my first node using the following flags:

geth --datadir  "D:\EthereumLocalNode" --networkid 1114 console 2>>  "D:\EthereumLocalNode\myLog.log" --rpc --rpccorsdomain "*" --nodiscover --nodekey boot.key

Flags as my intention are for :

--networkid 1114    // random id (same as chainId in genesis.json, I'm not sure if this equivalance is required, please comment if not)
--rpc
--rpccorsdomain "*" // To be able to reach this local node using remix and deploy contracts through there
--nodiscover        // To manually add the nodes I want, no other random nodes allowed.
--nodekey boot.key  // To use same constant key I created previously in the boot.key file  

When I run

admin.nodeInfo.enode

I get :

"enode://1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@[::]:30303?discport=0"

Please note the ?discport=0 part at the end (due to --nodiscover option)

My desktop ip is assigned as 192.168.1.20 for my local wifi network.

Then I created an empty folder in my laptop as "E:\EthereumLocalNode2" which I later will use to create a node that will be connected to the node in my desktop.

I intentionally leave it empty now and not use geth init for that node, since I want my network to have a single blockchain that will originate from the node in my desktop. If I run geth init in this node, genesis nodes and therefore blockchains would differ. (Please warn me, if this assumption is wrong)

I run the following command in the laptop as :

geth --datadir "E:\EthereumLocalNode2" console 2>> "E:\EthereumLocalNode2\myLog2.log" --bootnodes "enode://1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@192.168.1.20:30303" --nodiscover

Note that enode address is the same as boot.key I previously created. What happens next is, some default blockchain is generated, admin.peers returns empty for both nodes.

I have tried using the following geth calls also , with each difference:

No "enode://" string:

geth --datadir "E:\EthereumLocalNode2" console 2>> E:\EthereumLocalNode2\myLog2.log" --bootnodes "1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@192.168.1.20:30303" --nodiscover

No quotation marks around enode address:

geth --datadir "E:\EthereumLocalNode2" console 2>> E:\EthereumLocalNode2\myLog2.log" --bootnodes 1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@192.168.1.20:30303 --nodiscover

With bracelets around ip address

geth --datadir "E:\EthereumLocalNode2" console 2>> "E:\EthereumLocalNode2\myLog2.log" --bootnodes "1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@[192.168.1.20]:30303" --nodiscover

All of which fail to successfully connect to node on my desktop.

I also tried using admin.addPeer with no sucess.

Then I was suspicous about whether firewall was getting in the way, so in my desktop I started another cmd instance and create another node in an again empty folder pointing to my first node using --bootnodes but this time with

--ipcdisable // To be able to connect from the same computer.
--port 30304 // Not to have conflicting ports

Full command is :

geth --datadir "D:\EthereumLocalNode2" console 2>> "D:\EthereumLocalNode2\myLog2.log" --bootnodes 1998f24ae4cb9f685633e679286d613a3752ed03d460308c21e3c5efc28d080c608f351c379bdc4f77f4f036e3ce86e1786ec7256c8e467c1dee8c99aafc0629@127.0.0.1:30303 --port 30304 --networkid 1114 --ipcdisable --nodiscover

Again neither this nor admin.addPeer work. I'm not able to connect to my first node either through my local home wifi network or through the same computer.

Please help, I've already lost 2 nights hopeless to find a solution. Probably something is wrong with the way I'm using flags.

Sorry for the long explanation.

  • is the Hash field of the output eth.getBlock(0) the same on both nodes? – Nulik Mar 16 '18 at 1:06
  • what is the output of the node's console if you set verbosity to 6? – Nulik Mar 16 '18 at 1:07
  • @nulik hash fields were not equal.My assumption was not to init the second node so that it gets whole blockchain from the master one when it is run with bootnodes flag.But here is what happens, since it doesnt start connected to my first node, it initializes (geth init) automatically with some initial settings of difficulty and other init params and when I try to call addPeer nothing happened because they have different genesis. But when I called geth init for the second node with init.json same as the first one,they didnt connect to each other from the start, but later calling addPeer worked! – Mehmet Katircioglu Mar 16 '18 at 7:05
1

I'm assuming the geth instances on your private testnet are run from the same machine? (As opposed to separate machines with their own VLAN)

Adding --nodiscover flag prevents your nodes peering unless done manually, so what was your command for admin.addPeer? It needs to be followed by enode address, ip, and port like so:

admin.addPeer("enode://insertenodeaddresshere@insert Node 1 IP here:insertportnumber")

An alternative to bootnode is creating a static-nodes.json file and place it in you datadir. This file will contain a list of the enode addresses that you want to connect to automatically when you launch your geth instance. No need for a flag. Here's an example of one for reference.

  • thank you for your reply, bootnodes flag did not work probably because of nodiscover flag as you said. I'll give it a try with static nodes json file soon and tell you the results. But like I said in the reply for nulik, I was wrong in thinking that : a node connecting to another node with bootnodes flag on, would get even the genesis block and the rest of the blockchain. If blockchain folder left empty and called geth, I think that geth init is called with default params automatically then looks for other nodes. When genesises dont match, they fail to connect. – Mehmet Katircioglu Mar 16 '18 at 7:10
  • static-nodes.json did work well, I dont need to search for another optıon right now, thanks. – Mehmet Katircioglu Mar 17 '18 at 14:32
  • Great! Glad I could help you out! – zakcole Mar 17 '18 at 22:06

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.