在 MAC 上安装 EOS

2018-02-23  本文已影响0人  ChainBoard链博科技

系统要求:MacOS Sierra 10.12.6 及更高版本

一、系统依赖

  1. Brew
  2. 最新版本的 XCode

二、安装环境

已安装过的步骤可以直接跳过

1.更新 XCode 到最新版本

xcode-select --install

2.安装 homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.安装依赖

brew update
brew install git automake libtool boost openssl llvm@4 gmp ninja gettext
brew link gettext --force

4.安装 secp256k1-zkp (Cryptonomex 分支)

cd ~
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make -j$( sysctl -in machdep.cpu.core_count )
sudo make install

5.安装 binaryen v1.37.14

cd ~
git clone https://github.com/WebAssembly/binaryen.git
cd ~/binaryen
git checkout tags/1.37.14
cmake . && make -j$( sysctl -in machdep.cpu.core_count )

6.将 BINARYEN_ROOT 加入到 .bash_profile中

echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile
source ~/.bash_profile

7.为 WASM 构建 LLVM 和 clang

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 -j$( sysctl -in machdep.cpu.core_count )
make install

8.将 WASM_LLVM_CONFIGLLVM_DIR 加入到 .bash_profile中

echo "export WASM_LLVM_CONFIG=~/wasm-compiler/llvm/bin/llvm-config" >> ~/.bash_profile
echo "export LLVM_DIR=/usr/local/Cellar/llvm@4/4.0.1/lib/cmake/llvm/" >> ~/.bash_profile
source ~/.bash_profile

三、安装EOS

1.获取源代码
要下载所有的代码,需要下载EOS源代码和一个递归或两个子模块。最简单的下载方法是递归复制:

git clone https://github.com/eosio/eos --recursive

如果下载时没有带上 --recursive 参数,可以通过在repo内部运行此命令来检索子模块:

git submodule update --init --recursive

2.编译源代码
WASM_LLVM_CONFIG环境变量用于查找我们最近构建的WASM编译器。这需要在eos/contract文件夹和它们各自的测试中编译示例契约。

cd ~
git clone https://github.com/eosio/eos --recursive
mkdir -p ~/eos/build && cd ~/eos/build
cmake -DBINARYEN_BIN=~/binaryen/bin -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
make -j$( nproc )

也支持非源构建。需要覆盖clang在编译器中的默认选择,将这些参数添加到CMake命令中:

-DCMAKE_CXX_COMPILER=/path/to/c++ -DCMAKE_C_COMPILER=/path/to/cc

调试构建模式,需要添加参数 -DCMAKE_BUILD_TYPE=debug。其他常见的构建类型还有 ReleaseRelWithDebInfo
构建后,需要在 test 文件夹下执行 chain_test 进行测试。
EOS有程序,你可以在~/ EOS /build/programs 中找到。比如:

四、创建和启动一个单节点测试版

在成功构建项目后,eosiod 二进制文件应该存在于目录 build/programs/eosiod 中。
运行 eosiod 命令 -- 它有可能会报错并结束运行,如果没有结束运行,按下 Ctrl-C 结束运行。如果出现错误,eosiod 创建了一个名为 data-dir 包含默认配置(config.ini)和其他一些内部文件的目录。默认的数据存储路径可以通过 eosiod 的参数 --data-dir /path/to/data 覆盖,指令会继续使用默认路径。
编辑 config.ini 文件,在默认设置中添加/更新以下设置:

# 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

现在应该可以运行 eosiod,并会看到它开始产生区块。
如果运行 eosiod 时看见一下日志信息,说明区块产生成功。

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
...

英文原文地址:https://github.com/EOSIO/eos#runanodehttps://github.com/EOSIO/eos#manualdepmacos

上一篇 下一篇

猜你喜欢

热点阅读