-
Notifications
You must be signed in to change notification settings - Fork 1
How to test and run dCollab
Whisper is currently an experimental feature of Ethereum and is disabled by default in almost every Ethereum client (at least until June 2020). Without the support of Whisper in other Ethereum nodes, it is usually impractical to test a Whisper-based dApp in the Ethereum mainnet. Therefore, it is necessary to establish a private Ethereum chain in order to test the Whisper API and build more features based on it. This article introduces how to test this dApp on two different machines in a private Ethereum chain.
I have installed Ubuntu Server 18.04 on Hyper-V and planned to run this dApp on the VM and the host OS (Windows 10 20H1). This article is a very good tutorial on how to deploy a local private Ethereum chain. However, some points in that article is outdated. Below are the points which require attention:
-
In Step 2 (Configure the Genesis block), the
genesis.json
provided in the article is not working. Below is an example ofgenesis.json
which works smoothly withgeth v1.9.14
.{ "config": { "chainId": 982, "homesteadBlock": 0, "eip150Block": 0, "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "eip155Block": 0, "eip158Block": 0 }, "difficulty": "0x400", "gasLimit": "0x8000000", "alloc": {} }
You may change the
chainId
as you like. -
In Step 3 (Create local nodes), two nodes are enough for testing.
-
In Step 5 (Initialize and start the nodes), there is a command to initialize the data folders with the genesis block configuration:
geth --datadir "/PATH_TO_NODE/" init /PATH_TO/genesis.json
After running this command, you need to move one of the data folders to another machine. You will need to connect to the private Ethereum chain using this data folder later.
-
In Step 5, there is an important command given in the article to start the Ethereum node on the private chain:
geth --identity "name_of_your_node" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "/PATH_TO_NODE/" --port "30303" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any"
This command does not meet the requirement of Whisper. We would like to revise it as below:
geth --identity "name_of_your_node" --shh --ws --ws.origins "*" --datadir "/PATH_TO_NODE/" --port 30303 --nodiscover --ws.api "eth,net,web3,personal,miner,admin,shh" --networkid 982 --nat "any" --nousb --syncmode full
This command will enable the Whisper feature and enable the WS-RPC server of the Ethereum node instead of the HTTP-RPC server used in the article.
Also, the value of
networkid
should be the same as the value ofchainId
in yourgenesis.json
. -
In Step 6 (Connect to each node from the command line), we are going to connect to the WS-RPC server instead of the HTTP-RPC server. So you should enter the following command to attach to the Ethereum node:
geth attach ws://127.0.0.1:8546
-
In Step 7 (Interconnect the nodes), you need to replace the loopback IP addresses (
127.0.0.1
or[::]
) given in the enode URI (e.g.enode://26f7...692e@[::]:30303?discport=0
) with your actual IP address in your internal network. If you are using Hyper-V, you may want to useipconfig
to find out the IP address of the host OS under the virtual network adapter generated by Hyper-V. -
At the end of Step 7, if your
net.peerCount
is more than0
, it means you have connected the two Ethereum nodes in a private Ethereum chain successfully. If not, you may check your firewall settings on your host OS (Windows 10) and read the tutorial again to see if anything is wrong. -
You don't need to follow Step 8-11 in that article. Step 1-7 are enough to test this dApp.
If you want to install a web browser on Ubuntu Server, you can read this tutorial.
After the installation, you can use npm run dev
to start this dApp
and access it from the two machines which are connected to the private
Ethereum network. If you are not following the tutorial above, it's worth
noting that the geth
client must enable:
- WS-RPC server on the default port (8546), and
- Whisper feature
in order to support this dApp. Otherwise, you will meet the connection
failure when this dApp is trying to communicate with geth
.