Skip to content

Local TestNet (between eth cli & AlethZero).

Simon de la Rouviere edited this page Feb 26, 2015 · 2 revisions

Local TestNet

(NOTE 26 Feb 2015: This is not required anymore. AlethZero now uses the same data as eth-cli. Not sure when the move was implemented, but at least from cb2a1aa869e0cdf5eb8c475bf5a62901a9a66a0b onwards).

This is a simple guide on how to run a local testnet, between 2 nodes on your own computer (between AlethZero & eth-cli). AlethZero & eth-cli store blockchain data in different directories.

The trick is to make sure that neither node listens to the "outside". The most important part is to use a port anyone else uses. Turning UPNP off means your node isn't trying to find other nodes. In the scenario that 2 local testnets use the same, having UPNP on means they can potentially discover each other. So it's best just to turn it off (and use a relatively unique port number).

  1. On AlethZero in the network pane, set the listening port to your desired port nr. Also turn off past peers.
  2. Turn UPNP off.
  3. Turn on eth-cli with the following command. "eth -j --upnp off --listen <port_nr> -t 1". "-j" turns on the JSON-RPC & "-t" specifies the amount of miners to use for the cli. There was a problem where when the timestamp is similar, it doesn't accept new blocks (https://github.com/ethereum/cpp-ethereum/issues/994). Not sure if it is still a problem (should do testing again without limiting the mining thread on eth-cli).
  4. Grab the network (not localhost) in the eth-cli output.
  5. Add network peer in AlethZero (with correct address & peer).

If everything goes well, the 2 nodes should start talking to each other. You can thus run Browser-based dapps from Chrome and use AlethZero for network monitoring.

In the event that it connects to other peers, chances are your local chains will start fetching blocks from these peers and connect to them. In this case, turn off eth-cli first. In AlethZero, disable the network & kill the blockchain. Change the port number to something new (so it doesn't happen again). In eth-cli's case, you must delete the peer & chain data folder (depends on OS where it resides). In OS X, it is ~/Library/Application\ Support/Ethereum/. Then start with a new eth-cli port similar to AlethZero.