1. 介紹
EOS - The Most Powerful Infrastructure for Decentralized Applications
2. 獲取代碼
2.1 環(huán)境要求
- Git Version >= 1.7
2.2 拉取代碼
執(zhí)行git clone https://github.com/eosio/eos --recursive
來拉取源代碼仔掸,拉取完成后可以看到如下輸出
3. 編譯EOS
3.1 自動生成腳本
對于Ubuntu 16.06 和MacOS Sierra严就,項目中有一個自動構(gòu)建的腳本,它可以安裝所有依賴并編譯EOS椭员。
當執(zhí)行編譯腳本build.sh
時可以給出以下參數(shù)
architecture [ubuntu|darwin]
optional mode [full|build]
- 第一個選項
architecture
決定了腳本運行在哪個架構(gòu)下,ubuntu
是指Ubuntu,darwin
是指MacOS蔫耽。 - 第二個選項是指可選的編譯模式尝哆,可選項有
full
仰禀、build
。full
是指編譯時安裝所有依賴并進行EOS編譯秦叛,build
是指只編譯EOS。默認不傳遞此參數(shù)時瀑粥,使用full
模式挣跋。
cd eos
git checkout dawn-2.x
./build.sh ${architecture} ${optional_mode}
在切換到eos目錄然后執(zhí)行以上命令進行編譯,下面分別介紹Ubuntu和MacOS Sierra下如何編譯EOS狞换。
3.1.1 Ubuntu 16.10
Full Build
git clone https://github.com/eosio/eos --recursive
cd eos
git checkout dawn-2.x
./build.sh ubuntu full
3.1.2 MacOS Sierra
運行腳本之前請確保你的MacOS Sierra系統(tǒng)中安裝最新版本的XCode和Brew
若是沒有安裝請使用如下命令安裝Xcode和Brew
xcode-select --install (安裝Xcode Command Line Tools)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" (安裝Brew)
最后使用如下命令拉取代碼并編譯
git clone https://github.com/eosio/eos --recursive
cd eos
git checkout dawn-2.x
./build.sh darwin full
3.2 手動生成腳本
3.2.1 依賴軟件
- Clang Version >= 4.0.0
- CMake Version >= 3.5.1
- Boost Version >= 1.64
- OpenSSL Version >= 1.0.21
- LLVM Version >= 4.0
- secp256k1-zkp (Cryptonomex Branch)
- Binaryen
3.2.2 MacOS Sierra
- 安裝相關(guān)依賴
brew update
brew install git automake libtool boost openssl llvm@4 gmp ninja gettext
brew link gettext --force
- 安裝secp256k1-zkp
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make
sudo make install
- 安裝binaryen
git clone https://github.com/WebAssembly/binaryen.git
cd binaryen
git checkout tags/1.37.14
cmake . && make
- 設(shè)置環(huán)境變量
echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile
source ~/.bash_profile
- 編譯LLVM和WASM
mkdir ~/wasm-compiler
cd ~/wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
cd llvm/tools
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd ..
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
make -j4 install
- 設(shè)置環(huán)境變量
echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile
echo "export LLVM_DIR=/usr/local/Cellar/llvm/4.0.1/lib/cmake/llvm" >> ~/.bash_profile
source ~/.bash_profile
4. Docker
4.1 安裝依賴
- Docker version >= 17.05
4.2 構(gòu)建EOS鏡像
- git clone https://github.com/EOSIO/eos.git --recursive
- cd eos/Docker
- docker build . -t eosio/eos
4.3 啟動EOS容器
- docker run --name eosd -p 8888:8888 -p 9876:9876 -t eosio/eos start_eosd.sh arg1 arg2
4.4 獲取鏈信息
4.5 啟動EOSD和WALLETD容器
- docker-compose up
4.5.1 執(zhí)行EOSC命令
- alias eosc='docker-compose exec walletd /opt/eos/bin/eosc -H eosd'
- eosc get info
- eosc get account inita
4.5.2 更改默認配置
我們可以查看Docker Compose的配置文件并根據(jù)自身需要來更改配置文件, 比如更改依賴的服務(wù)或者掛載的目錄避咆,最后通過如下命令重啟容器
docker-compose down
docker-compose up
4.5.3 清除數(shù)據(jù)掛載點
docker volume rm eosd-data-volume
5. 創(chuàng)建和啟動單節(jié)點測試網(wǎng)絡(luò)
在構(gòu)建EOS成功后,可以在build/programs
目錄下看到編譯生成的二進制文件
編輯config.ini
文件并添加以下內(nèi)容
genesis-json = /path/to/eos/source/genesis.json
enable-stale-production = true
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
plugin = eosio::producer_plugin
plugin = eosio::wallet_api_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
隨后執(zhí)行eosd來啟動節(jié)點修噪,啟動后將看到如下輸出
1575001ms thread-0 chain_controller.cpp:235 _push_block ] initm #1 @2017-09-04T04:26:15 | 0 trx, 0 pending, exectime_ms=0
1575001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initm generated block #1 @ 2017-09-04T04:26:15 with 0 trxs 0 pending
1578001ms thread-0 chain_controller.cpp:235 _push_block ] initc #2 @2017-09-04T04:26:18 | 0 trx, 0 pending, exectime_ms=0
1578001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initc generated block #2 @ 2017-09-04T04:26:18 with 0 trxs 0 pending
6. 參考
7. 個人總結(jié)
通過以上步驟完成EOS在本地的安裝后查库,可以大概知道EOS項目具體的子項目是如何關(guān)聯(lián)的,當然要是從源碼解讀的角度來看黄琼,這些都是入門的基礎(chǔ)操作樊销,接下來我會分享一些有關(guān)EOS項目的個人看法,感謝您抽空瀏覽我的文章脏款,要是我的文章對您有所啟發(fā)围苫,那將是我莫大的榮幸。