芯链第1课 如何在Ubuntu64位系统下搭建HPB开发环境

1,摘要

本文详细讲解如何在Ubuntu 64位虚拟机上搭建HPB开发环境,并给出了遇到的各种问题的解决方法。主要包括: (1)下载HPB版本并编译; (2)创建账号和创始区块 (3)获取本地hnode信息并重新编译版本 (4)开启启动节点(bootnode)和高性能节点(挖矿) (5)进入本地开发环境 总体分析来看,HPB由于采用BOE硬件导致存在多类节点,本地环境的编译也比较复杂。环境搭建成功后,就可以享受HPB类以太坊环境但具备高TPS性能的优势了。

2,操作内容

2.1 前置环境搭建

本文有个前置条件,开发者需要已经具备了安装了GO环境的Ubuntu 64位系统或者虚拟机。没有的环境的WINDOWS用户,可参考铂链第1课 如何在WINDOWS操作系统下搭建BOTTOS开发环境完成前置 环境的搭建。也可以在阿里云申请虚拟机或者ECS,选择Ubuntu 64位操作系统。

2.2 下载HPB版本并第一次编译

1) 建立HPB工程工作目录

【成功结果输出】

duncanwang@ubuntu64bit-server:~$ mkdir hpb
duncanwang@ubuntu64bit-server:~$ cd hpb
duncanwang@ubuntu64bit-server:~/hpb$ mkdir ghpb-bin

2)下载go-hpb源码

在芯链GITHUB主页上(https://github.com/hpb-project/go-hpb/releases),可以找到最新的稳定版本,下载适合的版本。例如,辉哥下载的最新稳定版本为"version_1.0.3.1"。

git clone -b version_x.x.x.x https://github.com/hpb-project/go-hpb

【提示】x.x.x.x为主网程序最新版本号

【说明】下载官网的BIN程序,连的的主网。搭私链,要改源码的bootnode信息,所以必须本地编译HPB版本。

【成功输出结果】

duncanwang@ubuntu64bit-server:~/hpb$ git clone -b version_1.0.3.1 https://github.com/hpb-project/go-hpb
Cloning into 'go-hpb'...
remote: Enumerating objects: 217, done.
remote: Counting objects: 100% (217/217), done.
remote: Compressing objects: 100% (134/134), done.
remote: Total 12081 (delta 124), reused 150 (delta 83), pack-reused 11864
Receiving objects: 100% (12081/12081), 14.95 MiB | 1.08 MiB/s, done.
Resolving deltas: 100% (6962/6962), done.
Note: checking out 'a909e019d3d11223649317357155f7dc0075cae9'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

3)安装make编译程序

【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo apt install make 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 97 not upgraded.
Need to get 154 kB of archives.
After this operation, 381 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]
Fetched 154 kB in 1s (113 kB/s)
Selecting previously unselected package make.
(Reading database ... 103020 files and directories currently installed.)
Preparing to unpack .../make_4.1-9.1ubuntu1_amd64.deb ...
Unpacking make (4.1-9.1ubuntu1) ...###########.............................................................................................................................................] 
Setting up make (4.1-9.1ubuntu1) ...##################################################################.....................................................................................] 
Processing triggers for man-db (2.8.3-2) ...##################################################################################################################.............................] 

4)安装常用的开发编译工具包

sudo apt-get install build-essential

【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo apt-get install build-essential
[sudo] password for duncanwang: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
...
Setting up gcc (4:7.3.0-3ubuntu2.1) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.1) ...
Setting up g++ (4:7.3.0-3ubuntu2.1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

5)编译源码

make all

【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ make all
build/env.sh go run build/ci.go install ./cmd/ghpb
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=a909e019d3d11223649317357155f7dc0075cae9 -v ./cmd/ghpb
github.com/hpb-project/go-hpb/common/crypto/secp256k1
github.com/hpb-project/go-hpb/common/crypto
github.com/hpb-project/go-hpb/boe
github.com/hpb-project/go-hpb/network/p2p/discover
github.com/hpb-project/go-hpb/config
github.com/hpb-project/go-hpb/blockchain/types
github.com/hpb-project/go-hpb/event/sub
...
github.com/hpb-project/go-hpb/cmd/ghpb
Done building.
Run "/home/duncanwang/hpb/go-hpb/build/bin/geth" to launch geth.
build/env.sh go run build/ci.go install ./consensus/promfile
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=a909e019d3d11223649317357155f7dc0075cae9 -v ./consensus/promfile
github.com/hpb-project/go-hpb/vendor/github.com/olekukonko/tablewriter
github.com/hpb-project/go-hpb/vendor/golang.org/x/crypto/curve25519
github.com/hpb-project/go-hpb/vendor/golang.org/x/crypto/ed25519/internal/edwards25519
github.com/hpb-project/go-hpb/vendor/golang.org/x/crypto/ed25519
github.com/hpb-project/go-hpb/vendor/golang.org/x/crypto/ssh
github.com/hpb-project/go-hpb/vendor/golang.org/x/crypto/ssh/terminal
github.com/hpb-project/go-hpb/consensus/promfile
Done building.
Run "/home/duncanwang/hpb/go-hpb/build/bin/promfile" to launch promfile.
cp "/home/duncanwang/hpb/go-hpb/network/iperf3/iperf3" "/home/duncanwang/hpb/go-hpb/build/bin/iperf3"
cp "/home/duncanwang/hpb/go-hpb/network/p2p/binding.json" "/home/duncanwang/hpb/go-hpb/build/bin/binding.json"
cp "/home/duncanwang/hpb/go-hpb/network/p2p/config.json" "/home/duncanwang/hpb/go-hpb/build/bin/config.json"
编译常见失败原因及解决方法
1) 【失败结果1】
duncanwang@ubuntu64bit-server:~/hpb$ cd go-hpb
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ make all

Command 'make' not found, but can be installed with:

sudo apt install make      
sudo apt install make-guile (You will have to enable component called 'universe')

【解决方法】 安装make编译程序。

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo apt install make 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 97 not upgraded.
Need to get 154 kB of archives.
After this operation, 381 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]
Fetched 154 kB in 1s (113 kB/s)
Selecting previously unselected package make.
(Reading database ... 103020 files and directories currently installed.)
Preparing to unpack .../make_4.1-9.1ubuntu1_amd64.deb ...
Unpacking make (4.1-9.1ubuntu1) ...###########.............................................................................................................................................] 
Setting up make (4.1-9.1ubuntu1) ...##################################################################.....................................................................................] 
Processing triggers for man-db (2.8.3-2) ...##################################################################################################################.............................] 
2) 【失败结果】-GO环境不存在
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ make all
build/env.sh go run build/ci.go install ./cmd/ghpb
build/env.sh: 30: exec: go: not found
Makefile:29: recipe for target 'all' failed
make: *** [all] Error 127

【解决办法】- 需要安装GO语言包 参考《铂链第1课 如何在WINDOWS操作系统下搭建BOTTOS开发环境》的“6.2 安装GO环境”章节完成环境搭建。 【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/duncanwang/.cache/go-build"
...
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build114243981=/tmp/go-build -gno-record-gcc-switches"
3) 【编译失败2】
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ make all
build/env.sh go run build/ci.go install ./cmd/ghpb
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=a909e019d3d11223649317357155f7dc0075cae9 -v ./cmd/ghpb
github.com/hpb-project/go-hpb/vendor/github.com/maruel/panicparse/stack
github.com/hpb-project/go-hpb/vendor/github.com/mattn/go-runewidth
github.com/hpb-project/go-hpb/vendor/github.com/mitchellh/go-wordwrap
github.com/hpb-project/go-hpb/vendor/github.com/nsf/termbox-go
github.com/hpb-project/go-hpb/vendor/github.com/gizak/termui
github.com/hpb-project/go-hpb/common/crypto/sha3
github.com/hpb-project/go-hpb/common/hexutil
...
github.com/hpb-project/go-hpb/internal/web3ext
github.com/hpb-project/go-hpb/vendor/github.com/peterh/liner
util.go:44: exit status 2
exit status 1
Makefile:29: recipe for target 'all' failed
make: *** [all] Error 1

【解决方案】-缺少ecec执行程序

sudo apt-get install build-essential

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo apt-get install build-essential
[sudo] password for duncanwang: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
...
Setting up gcc (4:7.3.0-3ubuntu2.1) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.1) ...
Setting up g++ (4:7.3.0-3ubuntu2.1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

6) 拷贝程序到执行路径,进入执行路径

命令:

sudo cp -r build/bin/. /home/duncanwang/hpb/ghpb-bin

【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo cp -r /home/duncanwang/hpb/go-hpb/build/bin/. /home/duncanwang/hpb/ghpb-bin
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ cd /home/duncanwang/hpb/ghpb-bin

2.3 创建账号和创始区块

(1)创建新账户

1)创建第一个账户

命令:

./ghpb --datadir node/data account new

根据提示设置账户密码并记录账户地址,根据提示设置账户密码,记录得到的账户地址"0x17b164fab6b429cc54913745e71939c029d6b835"。

【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node/data account new
INFO [12-28|07:19:56]  HPB : Create New HpbConfig object 
INFO [12-28|07:19:56]  HPB : Initialising Hpb node             network=1
INFO [12-28|07:19:56]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|07:19:56]  HPB : Boe init fail. 
INFO [12-28|07:19:56]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|07:19:56]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {17b164fab6b429cc54913745e71939c029d6b835}
2) 创建第二个新账户

输入./ghpb --datadir node1/data account new 创建第二个新账户,根据提示设置账户密码,记录得到的账户地址"0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7"。 【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node1/data account new 
INFO [12-28|07:21:25]  HPB : Create New HpbConfig object 
INFO [12-28|07:21:25]  HPB : Initialising Hpb node             network=1
INFO [12-28|07:21:25]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|07:21:25]  HPB : Boe init fail. 
INFO [12-28|07:21:25]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|07:21:25]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {7fbe17afdd7e1d40f920d53e0d8dd951059a36e7}
3) 创建第三个新账户

输入./ghpb account new 创建第三个新账户,根据提示设置账户密码,记录得到的账户地址"0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704"。 【成功结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node2/data account new
INFO [12-28|07:22:25]  HPB : Create New HpbConfig object 
INFO [12-28|07:22:25]  HPB : Initialising Hpb node             network=1
INFO [12-28|07:22:25]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node2/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|07:22:25]  HPB : Boe init fail. 
INFO [12-28|07:22:25]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|07:22:25]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704}

(2)生成创世区块

命令:

./promfile

根据提示以及示例完成生成步骤。

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./promfile
+-----------------------------------------------------------+
| Welcome to prometh, your HPB private network manager |
|                                                           |
| This tool lets you create a new HPB network down to  |
| the genesis block, bootnodes, miners and ethstats servers |
| without the hassle that it would normally entail.         |
|                                                           |
| Prometh uses SSH to dial in to remote servers, and builds |
| its network components out of Docker containers using the |
| docker-compose toolset.                                   |
+-----------------------------------------------------------+

Please specify a network name to administer (no spaces, please)
> 
1)给测试链命名,可随意命名

【结果】

> HiBlock
Sweet, you can set this via --network=HiBlock next time!

INFO [12-27|07:25:39]  HPB : Administering HPB network         name=HiBlock
WARN [12-27|07:25:39]  HPB : No previous configurations found  path=/home/duncanwang/.prometh/HiBlock
2) 选择1,生成新的创世文件

【结果】

What would you like to do? (default = stats)
 1. Configure new genesis
 2. Manage existing genesis
> 1

Welcome to HPB consensus engine file maker
3)设置生成区块的间隔,如5

【结果】

How many seconds should blocks take? (default = 15)
> 5
4)设置投票周期,如100

【结果】

How many blocks should voting epoch be ? (default = 30000)
> 100
5)设置初始挖矿地址,示例为新建的第一个账户

可继续添加挖矿地址,按回车可进入下一步 【结果】

Which accounts are allowed to seal? (initialise miner addresses)
> 0x17b164fab6b429cc54913745e71939c029d6b835
> 0x
6)设置初始预存钱的地址

示例为新建的第一个账户0x17b164fab6b429cc54913745e71939c029d6b835

Which accounts should be pre-funded? (advisable at least one)
> 0x17b164fab6b429cc54913745e71939c029d6b835
> 0x
7) 设置网络号,可随意设置,后续启动命令中需用到该网络号

硬件初始化直接回车忽略。 【结果】

Please input the initialization hardware random
> 0x

Specify your chain/network ID if you want an explicit one (default = random)
> 66300
8)在创始块埋个彩蛋

例如土星是土豪的拼音

Anything fun to embed into the genesis block? (max 32 bytes)
> tuxingshituhao
9)导出刚设置的创世文件
What would you like to do? (default = stats)
 1. Configure new genesis
 2. Manage existing genesis
> 2
10) 将会打印出json文件,需在最后输入名称"gensis.json"

选择1导出json文件,然后输入名称"gensis.json",并回车

1. Export genesis configuration
> 1
Which file to save the genesis into? (default = HiBlock.json)
{
 "config": {
   "chainId": 66300,
   "prometheus": {
     "period": 5,
     "epoch": 100
   }
 },
 "nonce": "0x0",
 "timestamp": "0x5c25d300",
 "extraData": "0x747578696e67736869747568616f00000000000000000000000000000000000017b164fab6b429cc54913745e71939c029d6b8350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 "gasLimit": "0x5f5e100",
 "difficulty": "0x1",
 "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "coinbase": "0x0000000000000000000000000000000000000000",
 "alloc": {
   "17b164fab6b429cc54913745e71939c029d6b835": {
     "balance": "0x8"
   }
 },
 "number": "0x0",
 "gasUsed": "0x0",
 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "hardwareRandom": "0x0000000000000000000000000000000000000000000000000000000000000000"
}> gensis.json
INFO [12-27|07:43:10]  HPB : Exported existing genesis block 

What would you like to do? (default = stats)
1. Configure new genesis
2. Manage existing genesis
11)查看确认创世文件gensis.json是否生成

按ctrl+c退出,输入ls可看到已导出创世文件gensis.json

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ls
binding.json  config.json  gensis.json  ghpb  iperf3  node  promfile

(3)初始化节点

1)输入./ghpb --datadir node/data init gensis.json初始化第一个节点;

【告警】要启动3个节点吧。因为至少要起1个bootnode 一个挖矿节点。

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node/data init gensis.json
INFO [12-28|07:48:13]  HPB : Create New HpbConfig object 
INFO [12-28|07:48:13]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb/chaindata cache=16 handles=16
INFO [12-28|07:48:13]  HPB : Writing custom genesis block 
INFO [12-28|07:48:13]  HPB : Successfully wrote genesis state  database=chaindata                                              hash=876f60??351d0
2)输入./ghpb --datadir node1/data init gensis.json初始化第二个节点;

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node1/data init gensis.json
INFO [12-28|07:48:37]  HPB : Create New HpbConfig object 
INFO [12-28|07:48:37]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb/chaindata cache=16 handles=16
INFO [12-28|07:48:37]  HPB : Writing custom genesis block 
INFO [12-28|07:48:37]  HPB : Successfully wrote genesis state  database=chaindata                                               hash=876f60??351d0
3)输入./ghpb --datadir node2/data init gensis.json初始化第三个节点;

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node2/data init gensis.json
INFO [12-28|07:49:01]  HPB : Create New HpbConfig object 
INFO [12-28|07:49:01]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node2/data/ghpb/chaindata cache=16 handles=16
INFO [12-28|07:49:01]  HPB : Writing custom genesis block 
INFO [12-28|07:49:01]  HPB : Successfully wrote genesis state  database=chaindata                                               hash=876f60??351d0

(4)加载启动节点(bootnode)

1)配置binding.json

输入vim binding.json将所有账户写入binding.json,

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ sudo vim binding.json

在打开的文件中按下I变为Insert可输入状态,并粘贴以下代码: (用户需将三个coinbase更改为三个新建账户的地址,CID和HID可随意填写,可与示例中的保持一致。)

[
        {"coinbase":"0x17b164fab6b429cc54913745e71939c029d6b835","cid":"2cd504a93518fe0c9b60895602586efc4786cf9da9396d0a6d39403b94710b0a16092dcbd8458bb46cef1e71ba9953db881268ce5d773ce63ffb421a657a00ea","hid":"a3b8e1f3bd9cf3ed0a520744010bf2cc48e781b04af7f462e452f9c96e476aba"},
        {"coinbase":"0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7","cid":"2cd504a93518fe0c9b60895602586efc4786cf9da9396d0a6d39403b94710b0a16092dcbd8458bb46cef1e71ba9953db881268ce5d773ce63ffb421a657a00eb","hid":"a3b8e1f3bd9cf3ed0a520744010bf2cc48e781b04af7f462e452f9c96e476abb"},
        {"coinbase":"0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704","cid":"2cd504a93518fe0c9b60895602586efc4786cf9da9396d0a6d39403b94710b0a16092dcbd8458bb46cef1e71ba9953db881268ce5d773ce63ffb421a657a00ec","hid":"a3b8e1f3bd9cf3ed0a520744010bf2cc48e781b04af7f462e452f9c96e476abc"}
]

按下Esc键并输入:wq即可保存文件并退出。

2)拷贝binding.json

输入cp binding.json node1/data拷贝binding.json到bootnode数据文件里。

cp binding.json node1/data

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ cp binding.json node/data 
3)启动bootnode获得hnode信息

输入./ghpb --datadir node1/data --networkid 66300 --port 3001 --nodetype bootnode console(66300为创建创世区块过程中设置的网络号,3001为端口号,不同节点不同以作区分)

./ghpb --datadir node1/data --networkid 66300 --port 3001 --nodetype bootnode console

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node1/data --networkid 66300 --port 3001 --nodetype bootnode console
INFO [12-28|08:18:40]  HPB : Create New HpbConfig object 
INFO [12-28|08:18:40]  HPB : Initialising Hpb node             network=66300
INFO [12-28|08:18:40]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|08:18:40]  HPB : Boe init fail. 
INFO [12-28|08:18:40]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|08:18:40]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
INFO [12-28|08:18:40]  HPB : --------------StageNumberII---------------- value=260000
INFO [12-28|08:18:40]  HPB : --------------StageNumberIII--------------- value=1200000
INFO [12-28|08:18:40]  HPB : Loaded most recent local header   number=0 hash=876f60??351d0 td=1
INFO [12-28|08:18:40]  HPB : Loaded most recent local full block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:18:40]  HPB : Loaded most recent local fast block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:18:40]  HPB : Set coinbase address by start     address=0x7FBE17afdD7e1D40f920D53e0D8dd951059a36E7 roletype=bootnode
INFO [12-28|08:18:40]  HPB : Change node local type            from=UnknownNode to=BootNode
INFO [12-28|08:18:40]  HPB : Set Init Local Type by p2p        type=BootNode
INFO [12-28|08:18:40]  HPB : Starting P2P networking 
INFO [12-28|08:18:42]  HPB : UDP listener up                   self=hnode://3be2d632c0ff1e143a7e397750da9be03e82d6eed4dd6f23642a6f42d5a18ad735c1dc7358892c538d33143311a8cc42737dd4f62ef1d5a1e88e670539cc705c@0.0.0.0:3001
INFO [12-28|08:18:42]  HPB : Server start with type.           NodeType=BootNode
INFO [12-28|08:18:42]  HPB : Start server of bandwidth test.   port=3101
INFO [12-28|08:18:42]  HPB : Boot node parse binding hardware table. hdtab="[{Adr:0x17b164fab6b429cc54913745e71939c029d6b835 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 234] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 186]} {Adr:0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 235] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 187]} {Adr:0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 236] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 188]}]"
INFO [12-28|08:18:42]  HPB : server need to update hardware table boot=true our=0 there=3 hdtab="[{Adr:0x17b164fab6b429cc54913745e71939c029d6b835 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 234] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 186]} {Adr:0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 235] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 187]} {Adr:0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 236] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 188]}]"
INFO [12-28|08:18:42]  HPB : IPC endpoint opened               url=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb.ipc
Welcome to the GHPB JavaScript console!

instance: 
coinbase: 0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7
at block: 0 (Fri, 28 Dec 2018 07:38:40 UTC)
 datadir: /home/duncanwang/hpb/ghpb-bin/node1/data
 modules: admin:1.0 debug:1.0 hpb:1.0 miner:1.0 net:1.0 personal:1.0 prometheus:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

记录hnode信息,并在端口号前添加公网ip(公网Ip即为bootnode所在服务器的公网ip地址,示例中为10.225.17.8,开发者需改为自己的公网Ip):

hnode://3be2d632c0ff1e143a7e397750da9be03e82d6eed4dd6f23642a6f42d5a18ad735c1dc7358892c538d33143311a8cc42737dd4f62ef1d5a1e88e670539cc705c@10.225.17.8:3001

常见问题和解决方法

** 1)【失败结果】**

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb --datadir node1/data --networkid 66300 --port 3001 --nodetype bootnode console
INFO [12-28|08:04:10]  HPB : Create New HpbConfig object 
INFO [12-28|08:04:10]  HPB : Initialising Hpb node             network=66300
INFO [12-28|08:04:10]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|08:04:10]  HPB : Boe init fail. 
INFO [12-28|08:04:10]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|08:04:10]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
INFO [12-28|08:04:10]  HPB : --------------StageNumberII---------------- value=260000
INFO [12-28|08:04:10]  HPB : --------------StageNumberIII--------------- value=1200000
INFO [12-28|08:04:10]  HPB : Loaded most recent local header   number=0 hash=876f60??351d0 td=1
INFO [12-28|08:04:10]  HPB : Loaded most recent local full block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:04:10]  HPB : Loaded most recent local fast block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:04:10]  HPB : Set coinbase address by start     address=0x7FBE17afdD7e1D40f920D53e0D8dd951059a36E7 roletype=bootnode
INFO [12-28|08:04:10]  HPB : Change node local type            from=UnknownNode to=BootNode
INFO [12-28|08:04:10]  HPB : Set Init Local Type by p2p        type=BootNode
INFO [12-28|08:04:10]  HPB : Starting P2P networking 
ERROR[12-28|08:04:10]  HPB : Hpb protocol                      error="listen udp :3001: bind: address already in use"
ERROR[12-28|08:04:10]  HPB : Start hpbpeermanager error 
Fatal: Error starting protocol stack: start peermanager error ".ipc"

**【解决方法】 **

绑定地址已经被使用。

sudo killall -9 ghpb iperf3 ps aux|grep ghpb

【杀进程未成功】- 因为没有使用sudo

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ killall -9 ghpb iperf3
ghpb: no process found
iperf3: no process found
duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ps aux|grep ghpb
root      2875  0.0  0.4  66552  4440 ?        S    Dec27   0:00 sudo nohup ./ghpb --datadir node/data --networkid 66300 --port 3001 --rpcaddr 0.0.0.0 --rpcport 8541 --verbosity 3 --rpc --rpcapi hpb,web3,admin,txpool,debug,personal,net --nodetype bootnode
root      2878  0.1  3.1 788876 31468 ?        Sl   Dec27   1:25 ./ghpb --datadir node/data --networkid 66300 --port 3001 --rpcaddr 0.0.0.0 --rpcport 8541 --verbosity 3 --rpc --rpcapi hpb,web3,admin,txpool,debug,personal,net --nodetype bootnode
root      2900  0.0  0.0   4624   800 ?        S    Dec27   0:00 /home/duncanwang/hpb/ghpb-bin/iperf3 -s -p 3101
duncanw+  4741  0.0  0.1  13136  1044 pts/1    S+   08:13   0:00 grep --color=auto ghpb

【杀进程成功】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ sudo killall -9 ghpb iperf3
[sudo] password for duncanwang: 
duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ps aux|grep ghpb
duncanw+  4746  0.0  0.1  13136  1056 pts/1    R+   08:16   0:00 grep --color=auto ghpb 

2.4 获取本地hnode信息后,重新编译版本

(1)修改配置文件
1)输入exit退出

【结果】

exit INFO [12-28|08:21:13] HPB : Hpb data sync stopped INFO [12-28|08:21:13] HPB : IPC endpoint closed endpoint=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb.ipc INFO [12-28|08:21:13] HPB : Database closed database=/home/duncanwang/hpb/ghpb-bin/node1/data/ghpb/chaindata

2)继续输入vi /home/go-hpb/config/networkconfig.go打开配置文件;

【结果】

exit INFO [12-27|09:06:04] HPB : Hpb data sync stopped INFO [12-27|09:06:04] HPB : IPC endpoint closed endpoint=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb.ipc INFO [12-27|09:06:04] HPB : Database closed database=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb/chaindata

3)将hnode写入配置文件

在打开的文件中找到var MainnetBootnodes方法,在该方法中输入hnode信息(含公网ip);并在其余hnode信息前都输入//,表示注释掉不需要的hnode信息。

提示:将光标移到方法里的第一行,按下字母o,即自动插入空的一行,此时即可粘贴hnode信息,注意带上双引号和逗号,格式为英文。

var MainnetBootnodes = []string{
        "hnode://3be2d632c0ff1e143a7e397750da9be03e82d6eed4dd6f23642a6f42d5a18ad735c1dc7358892c538d33143311a8cc42737dd4f62ef1d5a1e88e670539cc705c@10.225.17.8:3001",
        //"hnode://73c8ac9dddc8f094d28f42e1ec5c3e8000cad25be152c147fceacc27953d58e64bfe9f555145d93f9f6b995bab984411941751fef3bd460f74c0151eb0432b56@47.94.20.30:30303",
        //"hnode://a6ef92a46adb69f94f2d48ff20f7800fb057d6aba7945e5af062ef27be5598072c5ce083ec5a2c89f80d112401c261b9ba9dacbd53aeb7c8243685d537edadb9@47.254.133.46:30303",
}

【操作方法】

sudo vi /home/go-hpb/config/networkconfig.go

4)保存配置文件

按下Esc,并输入:wq,回车即可保存。 提示:如果想退出不保存文件,则需按下Esc,并输入:q!回车即可;如果无法编辑, 可按下字母i即可。

:wq

(2)再编译程序

输入go-hpb的下载路径

cd /home/duncanwang/hpb/go-hpb

继续输入make all编译。

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ cd /home/duncanwang/hpb/go-hpb
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ make all
build/env.sh go run build/ci.go install ./cmd/ghpb
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=a909e019d3d11223649317357155f7dc0075cae9 -v ./cmd/ghpb
github.com/hpb-project/go-hpb/config
github.com/hpb-project/go-hpb/blockchain/types
github.com/hpb-project/go-hpb/network/rpc
github.com/hpb-project/go-hpb/consensus
github.com/hpb-project/go-hpb/hvm/evm
github.com/hpb-project/go-hpb/node/db
github.com/hpb-project/go-hpb/blockchain
github.com/hpb-project/go-hpb/consensus/snapshots
github.com/hpb-project/go-hpb/network/p2p
github.com/hpb-project/go-hpb/consensus/voting
github.com/hpb-project/go-hpb/consensus/prometheus
github.com/hpb-project/go-hpb/txpool
github.com/hpb-project/go-hpb/synctrl
github.com/hpb-project/go-hpb/internal/hpbapi
github.com/hpb-project/go-hpb/node/gasprice
github.com/hpb-project/go-hpb/worker
github.com/hpb-project/go-hpb/node
github.com/hpb-project/go-hpb/cmd/utils
github.com/hpb-project/go-hpb/cmd/ghpb
Done building.
Run "/home/duncanwang/hpb/go-hpb/build/bin/geth" to launch geth.
build/env.sh go run build/ci.go install ./consensus/promfile
>>> /usr/local/go/bin/go install -ldflags -X main.gitCommit=a909e019d3d11223649317357155f7dc0075cae9 -v ./consensus/promfile
github.com/hpb-project/go-hpb/consensus/promfile
Done building.
Run "/home/duncanwang/hpb/go-hpb/build/bin/promfile" to launch promfile.
cp "/home/duncanwang/hpb/go-hpb/network/iperf3/iperf3" "/home/duncanwang/hpb/go-hpb/build/bin/iperf3"
cp "/home/duncanwang/hpb/go-hpb/network/p2p/binding.json" "/home/duncanwang/hpb/go-hpb/build/bin/binding.json"
cp "/home/duncanwang/hpb/go-hpb/network/p2p/config.json" "/home/duncanwang/hpb/go-hpb/build/bin/config.json"

2.5 开启启动节点(bootnode)和高性能节点(挖矿)

1)拷贝程序到执行路径ghpb-bin,

该操作会覆盖目标目录的同名文件,其中/home/duncanwang/hpb/ghpb-bin/为您设置的程序执行路径;

【结果】

duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ sudo cp -r build/bin/. /home/duncanwang/hpb/ghpb-bin/
duncanwang@ubuntu64bit-server:~/hpb/go-hpb$ cd /home/duncanwang/hpb/ghpb-bin
2)开启启动节点(bootnode)

输入sudo nohup ./ghpb...启动bootnode; 继续输入attach连入节点。 其中示例里为创建的第二个账户,66300为步骤8中设置的网络号。

sudo nohup ./ghpb --datadir node1/data --networkid 66300 --port 3001  --rpcaddr 0.0.0.0 --rpcport 8541  --verbosity  3  --rpc  --rpcapi    hpb,web3,admin,txpool,debug,personal,net --nodetype bootnode > bootnode.log &
sudo ./ghpb attach http://127.0.0.1:8541

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ sudo nohup ./ghpb --datadir node1/data --networkid 66300 --port 3001  --rpcaddr 0.0.0.0 --rpcport 8541  --verbosity  3  --rpc  --rpcapi    hpb,web3,admin,txpool,debug,personal,net --nodetype bootnode > bootnode.log &
[1] 5450
duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ nohup: ignoring input and redirecting stderr to stdout
sudo ./ghpb attach http://127.0.0.1:8541
Welcome to the GHPB JavaScript console!

instance: 
coinbase: 0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7
at block: 0 (Fri, 28 Dec 2018 07:38:40 UTC)
 datadir: /home/duncanwang/hpb/ghpb-bin/node1/data
 modules: admin:1.0 debug:1.0 hpb:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

2)启动第一个挖矿节点

另开一个控制台窗口输入./ghpb根据提示输入账户密码,启动第一个挖矿节点; 继续输入miner.start()开始挖矿。 示例里为创建的第一个账户"0x17b164fab6b429cc54913745e71939c029d6b835";

sudo ./ghpb --datadir node/data  --unlock "0x17b164fab6b429cc54913745e71939c029d6b835" --networkid 66300 --port 3002  --rpcaddr 0.0.0.0 --rpcport 8542  --verbosity  3  --rpc  --rpcapi    hpb,web3,admin,txpool,debug,personal,net console --testmode
miner.start()

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ sudo ./ghpb --datadir node/data  --unlock "0x17b164fab6b429cc54913745e71939c029d6b835" --networkid 66300 --port 3002  --rpcaddr 0.0.0.0 --rpcport 8542  --verbosity  3  --rpc  --rpcapi    hpb,web3,admin,txpool,debug,personal,net console --testmode
INFO [12-28|08:51:14]  HPB : Create New HpbConfig object 
INFO [12-28|08:51:14]  HPB : Initialising Hpb node             network=66300
INFO [12-28|08:51:14]  HPB : Allocated cache and file handles  database=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb/chaindata cache=128 handles=1024
WARN [12-28|08:51:23]  HPB : Boe init fail. 
INFO [12-28|08:51:23]  HPB : GetBindAccount                    ecode:=101
WARN [12-28|08:51:23]  HPB : Get coinbase from boe fail, and set coinbase with account[0] 
Unlocking account 0x17b164fab6b429cc54913745e71939c029d6b835 | Attempt 1/3
Passphrase: 
INFO [12-28|08:51:31]  HPB : Unlocked account                  address=0x17B164FAb6b429cC54913745e71939C029D6b835
INFO [12-28|08:51:31]  HPB : --------------StageNumberII---------------- value=260000
INFO [12-28|08:51:31]  HPB : --------------StageNumberIII--------------- value=1200000
INFO [12-28|08:51:31]  HPB : Loaded most recent local header   number=0 hash=876f60??351d0 td=1
INFO [12-28|08:51:31]  HPB : Loaded most recent local full block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:51:31]  HPB : Loaded most recent local fast block number=0 hash=876f60??351d0 td=1
INFO [12-28|08:51:31]  HPB : Set coinbase address by start     address=0x17B164FAb6b429cC54913745e71939C029D6b835 roletype=
INFO [12-28|08:51:31]  HPB : Change node local type            from=UnknownNode to=PreNode
INFO [12-28|08:51:31]  HPB : Set Init Local Type by p2p        type=PreNode
INFO [12-28|08:51:31]  HPB : Starting P2P networking 
INFO [12-28|08:51:33]  HPB : UDP listener up                   self=hnode://e8eec18f9064a3c3d039ab3d26d6fee468b11aed997c6616ebe3b6993ad5bba5cd002aff60849957b1cb6d439ea5d681b0054a0eb1a9d54a4b53eb90e84656e6@0.0.0.0:3002
WARN [12-28|08:51:33]  HPB : Can't load file /home/duncanwang/hpb/ghpb-bin/synnode.json: open /home/duncanwang/hpb/ghpb-bin/synnode.json: no such file or directory 
INFO [12-28|08:51:33]  HPB : Server start with type.           NodeType=PreNode
INFO [12-28|08:51:33]  HPB : Start server of bandwidth test.   port=3102
INFO [12-28|08:51:33]  HPB : IPC endpoint opened               url=/home/duncanwang/hpb/ghpb-bin/node/data/ghpb.ipc
INFO [12-28|08:51:33]  HPB : HTTP endpoint opened              url=http://0.0.0.0:8542                              cors= vhosts=localhost,localhost
INFO [12-28|08:51:33]  HPB : Mapped network port               proto=udp extport=3002 intport=3002 interface="UPNP IGDv2-IP1"
Welcome to the GHPB JavaScript console!

instance: 
coinbase: 0x17b164fab6b429cc54913745e71939c029d6b835
at block: 0 (Fri, 28 Dec 2018 07:38:40 UTC)
 datadir: /home/duncanwang/hpb/ghpb-bin/node/data
 modules: admin:1.0 debug:1.0 hpb:1.0 miner:1.0 net:1.0 personal:1.0 prometheus:1.0 rpc:1.0 txpool:1.0 web3:1.0

> INFO [12-28|08:51:34]  HPB : boe hwsign failed                  ecode:=101
INFO [12-28|08:51:34]  HPB : Remote node is boot.              id=3be2d632c0ff1e14 addr=10.225.17.8:3001 conn=dyndial id=3be2d632c0ff1e14
INFO [12-28|08:51:34]  HPB : Verify the remote hardware.       id=3be2d632c0ff1e14 addr=10.225.17.8:3001 conn=dyndial id=3be2d632c0ff1e14 result=true
INFO [12-28|08:51:34]  HPB : server need to update hardware table boot=true our=0 there=3 hdtab="[{Adr:0x17b164fab6b429cc54913745e71939c029d6b835 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 234] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 186]} {Adr:0x7fbe17afdd7e1d40f920d53e0d8dd951059a36e7 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 235] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 187]} {Adr:0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704 Cid:[44 213 4 169 53 24 254 12 155 96 137 86 2 88 110 252 71 134 207 157 169 57 109 10 109 57 64 59 148 113 11 10 22 9 45 203 216 69 139 180 108 239 30 113 186 153 83 219 136 18 104 206 93 119 60 230 63 251 66 26 101 122 0 236] Hid:[163 184 225 243 189 156 243 237 10 82 7 68 1 11 242 204 72 231 129 176 74 247 244 98 228 82 249 201 110 71 106 188]}]"
INFO [12-28|08:51:34]  HPB : P2P set init peer remote type bootnode id=3be2d632c0ff1e14 port=3001
INFO [12-28|08:51:34]  HPB : Start hpb message loop.           id=3be2d632c0ff1e14 port=3001
> miner.start()
INFO [12-28|08:53:07]  HPB : miner start : : 
INFO [12-28|08:53:07]  HPB : Transaction pool price threshold updated price=18000000000
null
> INFO [12-28|08:53:07]  HPB : Starting mining operation 
INFO [12-28|08:53:07]  HPB : Change node local type            from=PreNode     to=HpNode
ERROR[12-28|08:53:07]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
######### peers length is: 0
INFO [12-28|08:53:07]  HPB : Commit new mining work            number=1 txs=0 uncles=0 elapsed=9.445ms
INFO [12-28|08:53:07]  HPB : HPB Prometheus Seal is starting 
INFO [12-28|08:53:07]  HPB : Successfully sealed new block     number -> =1 hash -> =352176??9c0a8 difficulty -> =2
INFO [12-28|08:53:07]  HPB : ?. mined potential block           number=1 hash=352176??9c0a8
ERROR[12-28|08:53:07]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
######### peers length is: 0
INFO [12-28|08:53:07]  HPB : Commit new mining work            number=2 txs=0 uncles=0 elapsed=126.416ms
INFO [12-28|08:53:07]  HPB : HPB Prometheus Seal is starting 
INFO [12-28|08:53:13]  HPB : Successfully sealed new block     number -> =2 hash -> =df0a75??11ddd difficulty -> =2
INFO [12-28|08:53:13]  HPB : ?. mined potential block           number=2 hash=df0a75??11ddd
ERROR[12-28|08:53:13]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
######### peers length is: 0
INFO [12-28|08:53:13]  HPB : Commit new mining work            number=3 txs=0 uncles=0 elapsed=5.877ms
INFO [12-28|08:53:13]  HPB : HPB Prometheus Seal is starting 
INFO [12-28|08:53:19]  HPB : Successfully sealed new block     number -> =3 hash -> =9c0c55??5e0aa difficulty -> =2
INFO [12-28|08:53:19]  HPB : ?. mined potential block           number=3 hash=9c0c55??5e0aa
ERROR[12-28|08:53:19]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
3)启动第二个挖矿节点

另开一个控制台窗口输入./ghpb根据提示输入账户密码,启动第一个挖矿节点; 继续输入miner.start()开始挖矿。 示例里为创建的第一个账户"0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704";

sudo ./ghpb --datadir node2/data  --unlock "0x4da3d2c1ecc3d2bbd64e6753dce6c88201a1b704" --networkid 66300 --port 3003  --rpcaddr 0.0.0.0 --rpcport 8543  --verbosity  3  --rpc  --rpcapi    hpb,web3,admin,txpool,debug,personal,net console --testmode

【结果】

...
INFO [12-28|09:29:13]  HPB : Importing propagated block        peer=e8eec18f9064a3c3 number=362 hash=866104??ccb3f difficulty=2
INFO [12-28|09:29:13]  HPB : ----> Write Block and State From Outside number=362 hash=866104??ccb3f difficulty=2
INFO [12-28|09:29:13]  HPB : Inserted new block                number=362 hash=866104??ccb3f
INFO [12-28|09:29:13]  HPB : Imported new chain segment        blocks=1  txs=0 mgas=0.000 elapsed=3.097ms   mgasps=0.000 number=362 hash=866104??ccb3f
ERROR[12-28|09:29:13]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
######### peers length is: 1
INFO [12-28|09:29:19]  HPB : Importing propagated block        peer=e8eec18f9064a3c3 number=363 hash=7132fe??13fac difficulty=2
INFO [12-28|09:29:19]  HPB : ----> Write Block and State From Outside number=363 hash=7132fe??13fac difficulty=2
INFO [12-28|09:29:19]  HPB : Inserted new block                number=363 hash=7132fe??13fac
INFO [12-28|09:29:19]  HPB : Imported new chain segment        blocks=1  txs=0 mgas=0.000 elapsed=10.112ms  mgasps=0.000 number=363 hash=7132fe??13fac
ERROR[12-28|09:29:19]  HPB : GetNodeinfoFromContract err       value="return bootnode info result is nil or length is 0"
######### peers length is: 1

3.运行结果

2.6 进入本地开发环境

进入挖矿节点环境2 新的窗口输入attach可以进入节点环境,便于进行后续操作事宜。 例如,进入第一个挖矿节点

./ghpb attach http://127.0.0.1:8542

【结果】

duncanwang@ubuntu64bit-server:~/hpb/ghpb-bin$ ./ghpb attach http://127.0.0.1:8542
Welcome to the GHPB JavaScript console!

instance: 
coinbase: 0x17b164fab6b429cc54913745e71939c029d6b835
at block: 387 (Fri, 28 Dec 2018 09:31:43 UTC)
 datadir: /home/duncanwang/hpb/ghpb-bin/node/data
 modules: admin:1.0 debug:1.0 hpb:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

3,参考

1) Hpb私链搭建教程 2) 教程系列|如何通过docker快速搭建HPB全节点 3) GITHUB版本


本文编写过程中得到HPB技术专家李庆华的及时支持,深表感谢。

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券