Skip to content

HPB Development Node Construction Guild

Nicemanss edited this page Aug 20, 2019 · 5 revisions

Introduction: The first problem that community developers faces when developing HPB DAPP is gaining access to HPB main network. This article, based on Ubuntu 16.04, introduces the building of development nodes. The development nodes are equivalent to light nodes, which can initiate transactions and synchronize blocks. But they are not entitled to election among candidate nodes or high-performance nodes, nor can they generate blocks. They can be used as access nodes to DAPP applications.

You have two choices when constructing development node:

(1) Method 1: The node is built by source codes, which requires certain knowledge on software programming and understanding of compilation process. This method needs to be equipped with the installation of GO compilation environment first, and then follow the source code building steps and examples;

(2) Method 2: The node is built by the HPB executable file, which is directly performed according to the executable file building steps and examples.

Note:

1. The HPB program must be run with ROOT privileges. 

2.Do not trust other users to operate any password relevant to the account in case of password leakage. 

3.The node startup must be operated by the user to prevent password leakage. 

1. Check network connection

Before setting up nodes, the user needs to check the network connection of the server and enter the following five commands to check whether there is delay or packet loss when connecting the server to the bootnode.

No. Command Node location
1 ping -c 200 47.254.133.46 Germany
2 ping -c 200 47.94.20.30 Beijing
3 ping -c 200 47.88.60.227 Silicon Valley
4 ping -c 200 47.75.213.166 Hong Kong
5 ping -c 200 47.100.250.120 Shanghai

Example: (only the number 1 is used as an example, and the rest of commands are required to be executed by the user)

Input the command: ping 47.254.133.46 and console will output summary information after the command is finished, where "200 packets transmitted" means packets are sent for 200 times, "186 received" means packets are received for 186 times, and "7% packet loss" means the proportion of packet loss during this process is 7%; “time 199386ms” means that the total time of 200 connections is 199836ms, “rtt min/avg/max/mdev = 230.439/248.901/290.203/9.397 ms” means that the shortest time among 200 connections is 234.439 Ms, the average time is 248.901ms, the longest time is 290.203ms and the average variance is 9.397ms.

Hint: If the server location and node location are in the same continent, it only meet the standard when the packet loss is 0% and the delay is less than 100ms ; (For example, if a domestic server connects Beijing or Shanghai nodes, the packet loss should be 0%); When different continents are connected, the packet loss generally exists and the delay generally does not exceed 300ms. But the standard threhold is difficult to define. When the user is uncertain about the proportion of the packet loss and the delay, please consult the HPB community staff to see whether these two parameters meet the standard.

Users who do not meet the standard need to contact the network service provider or data center to solve the network problem. ​

2. Example of executable file construction

(1) Step 1 determines program execution path Enter sudo mkdir /home/ghpb-bin to create program execution path in which /home/ghpb-bin can be changed to specified path

Switch to ROOT user: Enter su root and enter ROOT account password as prompted;

(2) Step 2 Select download path Enter cd /home/ in which /home/ can be changed to specified path;

(3) Step 3 Download HPB main network executable program Enter sudo git clone https://github.com/hpb-project/hpb-release If it says hpb-release already exists, enter the command: rm -rf hpb-release and before downloading hpb-release file.

(4) Step 4 Visit HPB main network executable program Enter cd hpb-release/ to visit the hpb-release directory, enter ls command to visit directory file, and see bin, config and README.md three files.

(5) Step 5 Copy the creation file to execution path Enter cd config/ into the config directory and continue typing sudo cp gensis.json /home/ghpb-bin/, where /hone/gphb-bin/ is set for you Program execution path.

(6) Step 6 Visit download path

Enter cd .. and cd bin/ to visit bin directory, then extract HPB main web program

Enter sudo tar zxvf ghpb-vx.x.x.x.tar.gz command to extract ghpb-vx.x.x.x.tar.gz file, in which x.x.x.x is the latest version number of the HPB software.

(7) Step 7 Modify the file permission:

Enter: sudo chmod +x ghpb-v0.0.0.1 -R

(8) Step 8 Copy the program into execution path

Enter sudo cp ghpb-vX.X.X.X/\ /home/ghpb-bin/, in which /home/ghpb-bin/ is the program execution path set for you;

(9) Step 9 Initialize nodes Enter cd /home/ghpb-bin/ to visit the program execution path; continue to enter sudo ./ghpb --datadir node/data init gensis.json, when "Successfully wrote genesis state database=chaindata" appears, continue the next step; in which /home/ghpb-bin/ is the program execution path set for you;

(10) Step 10 Export account Export your account information file from HPB wallet, create a keystore, enter cd node/data/ and continue to enter mkdir keystore;

​ Enter ls to see the two files ghpb and keystore;

(11) Step 11 Import nodes Visit the path /home/ghpb-bin/node/data/keystore in order, and copy the account information file into the keystore folder.

​ Hint: If you do not have permission to enter this directory, enter the command chmod 777 /home/ghpb-bin -R and re-enter.

(12) Step 12 Create new account Enter ./ghpb --datadir node/data account new, wait a moment to set password for the new account as prompt. Input again and return to the new account address. The user needs to record the address;

(13) Step 13 Startup node

​ Startup 1: Enter cd /home/ghpb-bin/ to visit the ghpb-bin directory;

​ Continue to type

sudo ./ghpb --datadir node/data --networkid 100 --port 3004 --syncmode full --nodetype synnode console;

When the message "Welcome to the GHPB JavaScript console!" appears, the node is successfully started.

Hint: The port number of the test bandwidth between nodes is the local ghpb port number plus 100; the local port (such as 3004) in the development node firewall must be open, the test bandwidth port can be closed. When choosing this startup mode, if the user quits the remote server or turn off the terminal, the node program would stop running.

Startup 2: Enter cd /home/ghpb-bin/ to enter the ghpb-bin directory;

Continue to type

sudo nohup ./ghpb --datadir node/data --networkid 100  --verbosity 3 --syncmode full --rpc --rpcapi hpb,web3,admin,txpool,debug,personal,net,miner,prometheus  --nodetype synnode  &

Then, press Enter twice;

Hint: The port number of the test bandwidth between nodes is the local ghpb port number plus 100; the local port in the development node firewall (the default is 30303) must be open, the test bandwidth port can be closed, wait for 10s and continue to enter the command:

sudo ./ghpb attach http://127.0.0.1:8545

3. Source code building example

(1) Step 1 determine the program execution path

         Enter sudo mkdir /home/ghpb-bin to create the program execution path; among which /home/ghpb-bin can be changed to the specified path;
Switch to ROOT user and enter the ROOT account and password as required;

(2) Step 2 Select the download path

     Enter cd /home/ in which /home/ can be changed to the specified path

(3) Step 3 Download HPB main network executable program Download HPB main network executable

  Enter sudo git clone https://github.com/hpb-project/hpb-release

Hint: If it shows go-hpb already exists, enter the command: rm -rf go-hpb before downloading the go-hpb source.

(4) Step 4 Visit the HPB main network executable program

          Enter cd hpb-release/ to visit hpb-release directory, enter ls command to visit directory file, and bin, config, and README.md three files are available.

(5) Step 5 Copy creation file into the execution path

          Enter cd config/ to visit config directory and continue to enter sudo cp gensis.json /home/ghpb-bin/**; where /hone/gphb-bin/ is program execution path that you set.

(6) Step 6 Enter the download path

           Enter cd /home/ to download the source code to the home directory, where /home/ can be changed to the source download path.

Index: HPB source code

(7) Step 7 compile go-hpb

  Enter cd go-hpb/; continue to enter make all to compile go-hpb;

(8) Step 8 copy the program into the execution path

           Enter sudo cp build/bin/* /home/ghpb-bin/;            in which /home/ghpb-bin/ is the program execution path set for you;

(9) Step 9 Initialize the node

           Enter cd /home/ghpb-bin/ to visit the program execution path; continue to enter sudo ./ghpb --datadir node/data init Gensis.json, when "Successfully wrote genesis state database=chaindata" appears, continue the next step; /home/ghpb-bin/ is the program execution path set for you;

(10) Step 11 Create a new account

            Enter ./ghpb --datadir node/data account new. Wait a moment and set the password for the new account as required. Enter again to come back to the new account address. The user needs to record the address.

(11) Step 12 Startup node Startup one: Enter cd /home/ghpb-bin/ to visit the ghpb-bin directory and continue to enter

Sudo ./ghpb --datadir node/data --networkid 100 --port 3004 --syncmode full --nodetype synnode console;

​ When the message "Welcome to the GHPB JavaScript console!" appears, the node is successfully started.

(12) Hint: The port number of the test bandwidth between nodes is the local ghpb port number plus 100; the local port (such as 3004) in the development node firewall must be open, the test bandwidth port can be closed. When the startup one is selected, if the user exits the remote server or the terminal is turned off, the node program will stop running.

Startup two: Enter cd /home/ghpb-bin/ to visit ghpb-bin directory, continue to enter

Sudo nohup ./ghpb --datadir node/data --networkid 100 --verbosity 3 --syncmode full --rpc --rpcapi hpb,web3,admin,txpool,debug,personal,net,miner,prometheus --nodetype synnode &

Then, press enter twice;

Hint: The port number of the test bandwidth between nodes is local ghpb port number plus 100; the local port in the development node firewall (default is 30303) must be open, the test bandwidth port can be closed, wait for 15s and continue to enter the command:

sudo ./ghpb attach http://127.0.0.1:8545
Clone this wiki locally