1. 程式人生 > >EOSIO本地環境搭建

EOSIO本地環境搭建

eos.io的本地環境的搭建主要是參考eos.io在GitHub的Wiki,同時記錄一下搭建過程中遇到的坑。

Getting the Code

首先需要獲得eos.io的source code,通過以下的命令clone到本地:
git clone https://github.com/EOSIO/eos --recursive
命令列的–recursive這個flag確保克隆eos倉庫和它的子模組,如果clone時沒有使用這個flag,則通過下面的命令也可以取得子模組:
git submodule update --init --recursive

Building EOSIO

Automated build script

最簡單的方法是使用eos的自動編譯指令碼,自動編譯指令碼支援以下的系統:

1. Amazon 2017.09 and higher.
2. Centos 7.
3. Fedora 25 and higher (Fedora 27 recommended).
4. Mint 18.
5. Ubuntu 16.04 (Ubuntu 16.10 recommended).
6. MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended).

System Requirements (all platforms)

同時,所有的操作平臺,需要滿足:

1. 8GB的可用記憶體
2. 20GB的可用磁碟

如果記憶體不滿足,指令碼將會給出提示並且終止當前編譯。

Run the build script

cd eos
./eosio_build.sh
指令碼會check系統的環境,如果某些依賴不存在,指令碼會提示進行安裝。
如下是博主在macOS Darwin 10.13.4上執行指令碼後出現的依賴不存在情況:

Checking dependencies.
Checking automake ...        automake NOT found.
Checking Libtool ...
Libtool NOT found. Checking OpenSSL ... OpenSSL NOT found. Checking llvm ... llvm NOT found. Checking wget ... wget NOT found. Checking CMake ... CMake NOT found. Checking GMP ... GMP NOT found. Checking gettext ... gettext NOT found. Checking MongoDB ... MongoDB NOT found. Checking Doxygen ... Doxygen NOT found. Checking Graphviz ... Graphviz NOT found. Checking LCOV ... LCOV NOT found. Checking Python3 ... python3 NOT found. The following dependencies are required to install EOSIO. 1. automake 2. Libtool 3. OpenSSL 4. llvm 5. wget 6. CMake 7. GMP 8. gettext 9. MongoDB 10. Doxygen 11. Graphviz 12. LCOV 13. Python 3 Do you wish to install these packages? 1) Yes 2) No #?

build seccess將會出現以下畫面:

     _______  _______  _______ _________ _______
    (  ____ \(  ___  )(  ____ \\__   __/(  ___  )
    | (    \/| (   ) || (    \/   ) (   | (   ) |
    | (__    | |   | || (_____    | |   | |   | |
    |  __)   | |   | |(_____  )   | |   | |   | |
    | (      | |   | |      ) |   | |   | |   | |
    | (____/\| (___) |/\____) |___) (___| (___) |
    (_______/(_______)\_______)\_______/(_______)

    EOS.IO has been successfully built. 1:6:15

    To verify your installation run the following commands:

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

    For more information:
    EOS.IO website: https://eos.io
    EOS.IO Telegram channel @ https://t.me/EOSProject
    EOS.IO resources: https://eos.io/resources/
    EOS.IO wiki: https://github.com/EOSIO/eos/wiki

Build validation

可以通過一組測試用例,驗證你的編譯。
如果是在Linux平臺:
~/opt/mongodb/bin/mongod -f ~/opt/mongodb/mongod.conf &
如果是在macOS:
/usr/local/bin/mongod -f /usr/local/etc/mongod.conf &
然後執行以下命令,不管在Linux還是macOS:
cd build
make test
最後出現這樣的提示說明測試通過:

100% tests passed, 0 tests failed out of 33

Total Test time (real) = 806.70 sec

Install the executables

通過安裝可執行檔案,可以在系統中方便操作eos,相當於把cmd寫到PATH變數中,但是其實是把內容安裝到/usr/local:
cd build
sudo make install

Creating and Launching a Single Node Testnet

執行下面的命令,將啟動一個簡單的節點:
cd build/programs/nodeos
./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin
這個時候,預設的config路徑,在macOS上是$HOME/Library/Application Support/eosio/nodeos/config,裡面包含config.inigenesis.json兩個檔案。當然,你也可以在啟動nodeos時通過–config-dir指定config路徑,並且需要建立ini和json兩個檔案。

總結

博主build時用的是macOS,同時系統配置滿足要求,使用自動編譯指令碼的時候沒遇到什麼坑,順利build通過。Source code是master branch,commit id是19227c9b0a095683c1df3668c110cef2d91cbb15

參考

原文出自我的個人部落格