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):
常見問題和解決方法
** 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
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技術專家李慶華的及時支持,深表感謝。