eos.io环境搭建

GitHub安装说明

https://github.com/EOSIO/eos/tree/dawn-2.x

macOS 下安装

  1. 升级系统到macOS High Sierra。
  2. 安装Xcode最新版本。
  3. 从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

注意:版本问题。


eos-build1.png

config.ini修改

安装过程中遇到的问题

说在前面

我最早是从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"
}

参考文献

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,015评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,262评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,727评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,986评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,363评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,610评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,871评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,582评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,297评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,551评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,053评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,385评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,035评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,079评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,841评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,648评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,550评论 2 270

推荐阅读更多精彩内容