GitHub安裝說明
https://github.com/EOSIO/eos/tree/dawn-2.x
macOS 下安裝
- 升級系統到macOS High Sierra。
- 安裝Xcode最新版本。
- 從github克隆代碼,執行安裝腳本。
git clone https://github.com/eosio/eos --recursive
# 本文發布時master不穩定,切換到dawn-2.x分支
git checkout dawn-2.x
cd eos
./build.sh darwin
# 啟動eosd sever進程,首次執行會自動停止,產生data-dir/config.ini文件
./build/eosd/eosd
# 修改config.ini文件,見下方問題區。
# 啟動eosd
./build/eosd/eosd
# 啟動eosc,命令行工具eosc查看eosd的信息
./build/eosc/eosc get info
注意:版本問題。
安裝過程中遇到的問題
說在前面
我最早是從master分支直接安裝的,中間遇到了一些問題,知道最后啟動服務發現沒有產生區塊,才改成穩定的dawn-2.x版本。所以,如果你直接從dawn-2.x版本開始安裝的話,下面的一些問題不一定會遇到。
磁盤空間
磁盤空間要求至少100GB,否則報錯。先修改腳本scripts/eosio/build/darwin.sh,先繞過去限制。
# if [ $DISK_AVAIL -lt 100 ]; then
if [ $DISK_AVAIL -lt 10 ]; then # 修改為10GB
printf "\tYou must have at least 100GB of available storage to install EOSIO.\n"
printf "\tExiting now.\n"
exit 1
fi
autoreconf -i 報錯
Usage: autoreconf [-f] [-h] [--help] [-m dir] [--macrodir=dir]
[-l dir] [--localdir=dir] [--force] [--verbose] [--version]
解決:更新版本autoconf 到2.69, 原本PATH里有指向低版本autoconf 2.10的路徑,刪掉。
libtoolize 報錯
Can't exec "libtoolize": No such file or directory at /usr/local/share/autoconf/Autom4te/FileUtils.pm line 345, <GEN3> line 5.
autoreconf: failed to run libtoolize: No such file or directory
autoreconf: libtoolize is needed because this package uses Libtool
Error running autogen
解決:
要用glibtool,參考
https://stackoverflow.com/questions/15448582/installed-libtool-but-libtoolize-not-found
http://blog.csdn.net/diandianxiyu_geek/article/details/56667415
解法:
#添加PATH /usr/local/Cellar/libtool/2.4.6_1/bin
export PATH=/usr/local/Cellar/libtool/2.4.6_1/bin:$PATH
brew install boost double-conversion gflags glog libevent
sudo ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
openssl問題
在編譯的時候遇到openssl版本問題。報錯如下:
CMake Error at /usr/local/Cellar/cmake/3.7.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR)
原因在于安裝腳本里為Darwin指定了openssl的路徑如下,默認版本為1.1:
if [ $ARCH == "Darwin" ]; then
OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1
OPENSSL_LIBRARIES=/usr/local/opt/openssl@1.1/lib
但是系統里安裝的是1.0.2版本。
eos ansen$ ls -lh /usr/local/opt/openssl@1.0
lrwxr-xr-x 1 ansen admin 24B 2 19 00:47 /usr/local/opt/openssl@1.0 -> ../Cellar/openssl/1.0.2n
用brew安裝openssl@1.1后,編譯還是有問題,說找不到symbol,google搜了一圈,沒找到解決辦法。
Undefined symbols for architecture x86_64:
"_BN_is_negative", referenced from:
fc::bigint::is_negative() const in libfc.a(bigint.cpp.o)
fc::bigint::to_int64() const in libfc.a(bigint.cpp.o)
"_BN_is_zero", referenced from:
fc::bigint::operator bool() const in libfc.a(bigint.cpp.o)
"_ECDSA_SIG_get0", referenced from:
fc::crypto::r1::ECDSA_SIG_recover_key_GFp(ec_key_st*, ECDSA_SIG_st*, unsigned char const*, int, int, int) in libfc.a(elliptic_r1.cpp.o)
fc::crypto::r1::private_key::sign_compact(fc::sha256 const&) const in libfc.a(elliptic_r1.cpp.o)
"_ECDSA_SIG_set0", referenced from:
fc::crypto::r1::public_key::public_key(fc::array<unsigned char, 65ul> const&, fc::sha256 const&, bool) in libfc.a(elliptic_r1.cpp.o)
"_OPENSSL_init_crypto", referenced from:
fc::openssl_scope::openssl_scope() in libfc.a(openssl.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
解決: 修改安裝腳本,使用1.0版本,編譯就成功了。
if [ $ARCH == "Darwin" ]; then
OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.0
OPENSSL_LIBRARIES=/usr/local/opt/openssl@1.0/lib
安裝成功,顯示如下:
[100%] Linking CXX executable eosiod
cd /Users/ansen/eos/eos/build/programs/eosiod && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_link_script CMakeFiles/eosiod.dir/link.txt --verbose=0
[100%] Built target eosiod
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_progress_start /Users/ansen/eos/eos/build/CMakeFiles 0
EOSIO has been successfully installed.
修改config.ini
在自動生成的config.ini的基礎上修改下面這些配置項。 genesis就是eos根目錄的genesis.json。
# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
代碼分支版本問題
最早是從master開始編譯的,解決了上面的問題后,最后運行起來確發現沒有產生區塊。
1046000ms thread-0 producer_plugin.cpp:227 block_production_loo ] Not producing block because it isn't my turn, its eosio 1046500ms thread-0 producer_plugin.cpp:227 block_production_loo ] Not producing block because it isn't my turn, its eosio 1047000ms thread-0 producer_plugin.cpp:227 block_production_loo ] Not producing block because it isn't my turn, its eosio 1047500ms thread-0 producer_plugin.cpp:227 block_production_loo ] Not producing block because it isn't my turn, its eosio
看到有篇文章里寫到,master版本不穩定,建議切換會dawn-2.x版本。
dawn-2.x版本執行build/eosd/eosd。然后會有區塊產生。
2390002ms chain_controller.cpp:208 _push_block ] initl #2614 @2018-02-19T05:39:50 | 0 trx, 0 pending, exectime_ms=1
2390003ms producer_plugin.cpp:246 block_production_loo ] initl generated block #2614 @ 2018-02-19T05:39:50 with 0 trxs 0 pending
2391002ms chain_controller.cpp:208 _push_block ] inits #2615 @2018-02-19T05:39:51 | 0 trx, 0 pending, exectime_ms=0
2391002ms producer_plugin.cpp:246 block_production_loo ] inits generated block #2615 @ 2018-02-19T05:39:51 with 0 trxs 0 pending
eosc執行
查詢當前區塊鏈概況:
eos ansen$ ./build/programs/eosc/eosc get info
{
"server_version": "d051c1b6",
"head_block_num": 2920,
"last_irreversible_block_num": 2905,
"head_block_id": "00000b68623d835911d8d8d67e8fae041ddc522e4412e2f742c7fd52c462fa53",
"head_block_time": "2018-02-19T05:44:56",
"head_block_producer": "initu",
"recent_slots": "1111111111111111111111111111111111111111111111111111111111111111",
"participation_rate": "1.00000000000000000"
}