EOS开发(一)环境搭建(非Docker)

EOS相关文档

Git地址:
https://github.com/EOSIO/eos

Docs:https://developers.eos.io/eosio-nodeos/docs/overview-1

最简单快速的方式是使用Docker,但是官方建议开发者从源码进行搭建

获取代码

yuyangdeMacBook-Pro: yuyang$ git clone https://github.com/eosio/eos --recursive

如果克隆代码时未带--recursive参数,那么可切换到项目路径下面执行如下命令,下载子模块。

$ git submodule update --init --recursive

编译代码

yuyangdeMacBook-Pro:EOS yuyang$ cd /Users/yuyang/eos 
yuyangdeMacBook-Pro:eos yuyang$ ./eosio_build.sh
_______  _______  _______ _________ _______
   (  ____ \(  ___  )(  ____ \\__   __/(  ___  )
   | (    \/| (   ) || (    \/   ) (   | (   ) |
   | (__    | |   | || (_____    | |   | |   | |
   |  __)   | |   | |(_____  )   | |   | |   | |
   | (      | |   | |      ) |   | |   | |   | |
   | (____/\| (___) |/\____) |___) (___| (___) |
   (_______/(_______)\_______)\_______/(_______)

   EOSIO has been successfully built. 00:14:06

   To verify your installation run the following commands:

   /usr/local/bin/mongod -f /usr/local/etc/mongod.conf &
   cd /Users/yuyang/eos/build; make test

   For more information:
   EOSIO website: https://eos.io
   EOSIO Telegram channel @ https://t.me/EOSProject
   EOSIO resources: https://eos.io/resources/
   EOSIO Stack Exchange: https://eosio.stackexchange.com
   EOSIO wiki: https://github.com/EOSIO/eos/wiki

如果编译失败,可以看看这篇文章Mac上安装EOS Dawn 3.0的一些坑。

后面换了电脑又遇到新的两个问题:

CMake Error at /usr/local/Cellar/cmake/3.9.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find GMP (missing: GMP_LIBRARIES GMP_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.9.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)

解决办法,参考文章:http://me.tryblockchain.org/eos-howtobuild.html:

brew install gmp
Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)

解决办法,参考文章:http://www.softwareace.cn/?p=1763

brew unlink gettext && brew link --force gettext
find /usr -name libintl* -print 2>/dev/null

安装EOSIO

yuyangdeMacBook-Pro:eos yuyang$ ./eosio_install.sh

失败

[ 96%] Built target deferred_test
[ 98%] Built target unit_test
[100%] Built target plugin_test
[100%] Built target print_floats
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/eosio/etc/eosio
CMake Error at cmake_install.cmake:44 (file):
  file INSTALL cannot set permissions on "/usr/local/eosio/etc/eosio"


make: *** [install] Error 1

    >>>>>>>>>>>>>>>>>>>> MAKE installing EOSIO has exited with the above error.

加入sudo权限

yuyangdeMacBook-Pro:eos yuyang$ sudo ./eosio_install.sh
Password:
    Installing EOSIO Binary Symlinks



     _______  _______  _______ _________ _______
    (  ____ \(  ___  )(  ____ \\__   __/(  ___  )
    | (    \/| (   ) || (    \/   ) (   | (   ) |
    | (__    | |   | || (_____    | |   | |   | |
    |  __)   | |   | |(_____  )   | |   | |   | |
    | (      | |   | |      ) |   | |   | |   | |
    | (____/\| (___) |/\____) |___) (___| (___) |
    (_______/(_______)\_______)\_______/(_______)
    For more information:
    EOSIO website: https://eos.io
    EOSIO Telegram channel @ https://t.me/EOSProject
    EOSIO resources: https://eos.io/resources/
    EOSIO Stack Exchange: https://eosio.stackexchange.com
    EOSIO wiki: https://github.com/EOSIO/eos/wiki

EOS附带的可执行程序:

yuyangdeMacBook-Pro:eos yuyang$ cd /Users/yuyang/eos/build/programs 
yuyangdeMacBook-Pro:programs yuyang$ ls
CMakeFiles      cmake_install.cmake keosd
CTestTestfile.cmake eosio-abigen        nodeos
Makefile        eosio-applesedemo
cleos           eosio-launcher
  • nodeos: 区块链服务器节点生成组件
  • cleos: 和区块链交互的接口命令
  • keosd: EOS 钱包
  • eosio-launcher:节点网络组成和部署的应用

所有这些程序/eos/build/programs都存在于这个文件夹。

安装可执行文件

yuyangdeMacBook-Pro:eos yuyang$ cd  build
yuyangdeMacBook-Pro:build yuyang$ sudo make install

建立单个测试节点

切换到目录eos/build/programs/nodeos下面,然后执行如下命令。

yuyangdeMacBook-Pro:programs yuyang$ cd /Users/yuyang/eos/build/programs/nodeos 
yuyangdeMacBook-Pro:nodeos yuyang$ ./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin

报错

2018-08-21T05:53:54.005 thread-0   chain_plugin.cpp:271          plugin_initialize    ] initializing chain plugin
2018-08-21T05:53:54.012 thread-0   chain_plugin.cpp:580          plugin_initialize    ] 13 St13runtime_error: database dirty flag set
rethrow database dirty flag set: 
    {"what":"database dirty flag set"}
    thread-0  chain_plugin.cpp:580 plugin_initialize
2018-08-21T05:53:54.013 thread-0   main.cpp:118                  main                 ] database dirty flag set (likely due to unclean shutdown): replay required

尝试加上–replay-blockchain –hard-replay-blockchain参数

yuyangdeMacBook-Pro:nodeos yuyang$ ./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin –replay-blockchain –hard-replay-blockchain

还是失败

索性删除data文件夹
文件夹位于/Users/yuyang/Library/Application Support

结果

yuyangdeMacBook-Pro:nodeos yuyang$ ./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
2018-08-21T06:36:51.238 thread-0   chain_plugin.cpp:271          plugin_initialize    ] initializing chain plugin
2018-08-21T06:36:51.238 thread-0   chain_plugin.cpp:508          plugin_initialize    ] Starting up fresh blockchain with default genesis state.
2018-08-21T06:36:52.000 thread-0   http_plugin.cpp:344           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
2018-08-21T06:36:52.000 thread-0   net_plugin.cpp:2905           plugin_initialize    ] Initialize net plugin
2018-08-21T06:36:52.000 thread-0   net_plugin.cpp:2930           plugin_initialize    ] host: 0.0.0.0 port: 9876 
2018-08-21T06:36:52.000 thread-0   net_plugin.cpp:3000           plugin_initialize    ] my node_id is 1a38820d4a44dea82c797340ae46b048edc6c53e7f8332640ed22dcefd58239f
2018-08-21T06:36:52.000 thread-0   main.cpp:105                  main                 ] nodeos version 4f4e5c22
2018-08-21T06:36:52.000 thread-0   main.cpp:106                  main                 ] eosio root is /Users/yuyang/Library/Application Support
2018-08-21T06:36:52.001 thread-0   controller.cpp:1301           startup              ] No head block in fork db, perhaps we need to replay
2018-08-21T06:36:52.001 thread-0   controller.cpp:319            initialize_fork_db   ]  Initializing new blockchain with genesis state                  
2018-08-21T06:36:52.026 thread-0   chain_plugin.cpp:596          plugin_startup       ] starting chain in read/write mode
2018-08-21T06:36:52.026 thread-0   chain_plugin.cpp:600          plugin_startup       ] Blockchain started; head block is #1, genesis timestamp is 2018-06-01T12:00:00.000
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:401           plugin_startup       ] start listening for http requests
2018-08-21T06:36:52.026 thread-0   chain_api_plugin.cpp:75       plugin_startup       ] starting chain_api_plugin
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/abi_bin_to_json
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/abi_json_to_bin
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_abi
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_account
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_block
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_block_header_state
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_code
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_currency_balance
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_currency_stats
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_info
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_producer_schedule
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_producers
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_raw_code_and_abi
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_required_keys
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_scheduled_transactions
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/get_table_rows
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/push_block
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/push_transaction
2018-08-21T06:36:52.026 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/chain/push_transactions
2018-08-21T06:36:52.026 thread-0   history_api_plugin.cpp:38     plugin_startup       ] starting history_api_plugin
2018-08-21T06:36:52.027 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/history/get_actions
2018-08-21T06:36:52.027 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/history/get_controlled_accounts
2018-08-21T06:36:52.027 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/history/get_key_accounts
2018-08-21T06:36:52.027 thread-0   http_plugin.cpp:447           add_handler          ] add api url: /v1/history/get_transaction
2018-08-21T06:36:52.027 thread-0   net_plugin.cpp:3013           plugin_startup       ] starting listener, max clients is 25
2018-08-21T06:36:52.027 thread-0   producer_plugin.cpp:647       plugin_startup       ] producer plugin:  plugin_startup() begin
2018-08-21T06:36:52.027 thread-0   producer_plugin.cpp:665       plugin_startup       ] Launching block production for 1 producers at 2018-08-21T06:36:52.027.
2018-08-21T06:36:52.029 thread-0   producer_plugin.cpp:677       plugin_startup       ] producer plugin:  plugin_startup() end
2018-08-21T06:36:52.502 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 000000029795f452... #2 @ 2018-08-21T06:36:52.500 signed by eosio [trxs: 0, lib: 0, confirmed: 0]
2018-08-21T06:36:53.003 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 00000003895b7073... #3 @ 2018-08-21T06:36:53.000 signed by eosio [trxs: 0, lib: 2, confirmed: 0]
2018-08-21T06:36:53.502 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 00000004691e1021... #4 @ 2018-08-21T06:36:53.500 signed by eosio [trxs: 0, lib: 3, confirmed: 0]
2018-08-21T06:36:54.005 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 000000059a84d840... #5 @ 2018-08-21T06:36:54.000 signed by eosio [trxs: 0, lib: 4, confirmed: 0]
2018-08-21T06:36:54.505 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 000000067cc65718... #6 @ 2018-08-21T06:36:54.500 signed by eosio [trxs: 0, lib: 5, confirmed: 0]
2018-08-21T06:36:55.002 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 00000007e89ca483... #7 @ 2018-08-21T06:36:55.000 signed by eosio [trxs: 0, lib: 6, confirmed: 0]
2018-08-21T06:36:55.500 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 0000000882e5aef6... #8 @ 2018-08-21T06:36:55.500 signed by eosio [trxs: 0, lib: 7, confirmed: 0]
2018-08-21T06:36:56.003 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 000000098ce5a814... #9 @ 2018-08-21T06:36:56.000 signed by eosio [trxs: 0, lib: 8, confirmed: 0]
2018-08-21T06:36:56.501 thread-0   producer_plugin.cpp:1234      produce_block        ] Produced block 0000000a0bbdd045... #10 @ 2018-08-21T06:36:56.500 signed by eosio [trxs: 0, lib: 9, confirmed: 0]

开始正常出块,环境搭建完成。

你可能感兴趣的:(EOS开发(一)环境搭建(非Docker))