分享

区块链3.0EOS入门1:EOS介绍及安装编译EOS

本帖最后由 yuwenge 于 2018-6-7 21:55 编辑
问题导读

1.什么是EOS?
2.为什么说EOS交易时间接近支付宝?
3.如何编译安装EOS?





EOS是什么?

Eos是一个区块链操作系统,它提供了数据库,账号许可,调度,认证和互联网应用通信,这极大地提高了智能商业开发的效率,它使用了并行计算使得把区块链拓展到百万用户和每秒百万次交易成为可能。由此产生的技术是一个区块链架构,有可能扩展到每秒数百万次的交易,消除了用户的费用,并允许分布式应用的快速和容易的部署。
EOS项目可以看做是升级版的以太坊,支持每秒数百万笔交易,每3秒出一个区块,以太坊要14秒才出一个区块。为什么说EOS是区块链3.0, 处理速度逼近支付宝。


EOS特点如下

1、EOS 的 DPOS 共识算法和石墨烯底层工具组能够满足每秒上万次,甚至每秒上百万次交易请求的企业级应用需求。这能力彻底吊打之前的区块链应用比如比特币和以太,这也使得在其中心化的副本建立dapp成为可能。

2、EOS 并不是一条公链,它是一个区块链基础架构,开发者可以在 EOS 架构上自由创建自己的公链。

3、在 EOS 上转账交易与运行智能合约并不需要消耗 EOS 系统代币。在 EOS 系统当中,有三大类资源被应用程序消耗:带宽和日志存储(磁盘),计算和计算积压(CPU),以及状态存储器(RAM)。这些资源根据账户持有 EOS 数量来分配,这也是 EOS 系统代币的价值来源。

4、EOS是第一个拥有自己宪法(constitution)的区块链。EOS 建立的约束性合约(被称作 EOS “宪法”)定义了仅依靠代码无法完全执行的用户间义务,还定义了源代码协议的人类可读性意图,当出现系统错误时,人类可读性意图可用于区分此错误是否确实为 bug,并判断社区的修复举措是否得当。而当系统面临一个漏洞时,区块生产者还可以加速变更约束性合约。

5、 EOS 设置的以太虚拟机(EVM),能够支持现有在以太坊运行的智能合约。现存在于以太坊的区块链应用,通过添加少量适配,就能够在 EOS 系统上运行。
如何安装和编译EOS

1.获取代码

1 环境要求

Git Version >= 1.7


2 拉取代码
执行
[mw_shl_code=bash,true]git clone https://github.com/eosio/eos --recursive
[/mw_shl_code]
来拉取源代码,拉取完成后可以看到如下输出

459820-c5b0725bdbbdac91.png


2.编译EOS

1 自动生成脚本

对于Ubuntu 16.06 和MacOS Sierra,项目中有一个自动构建的脚本,它可以安装所有依赖并编译EOS。
当执行编译脚本build.sh时可以给出以下参数
architecture [ubuntu|darwin]
optional mode [full|build]
  • 第一个选项architecture决定了脚本运行在哪个架构下,ubuntu是指Ubuntu,darwin是指MacOS。
  • 第二个选项是指可选的编译模式,可选项有full、build。full是指编译时安装所有依赖并进行EOS编译,build是指只编译EOS。默认不传递此参数时,使用full模式。




[mw_shl_code=bash,true]cd eos
git checkout dawn-2.x
./build.sh ${architecture} ${optional_mode}[/mw_shl_code]

在切换到eos目录然后执行以上命令进行编译,下面分别介绍Ubuntu和MacOS Sierra下如何编译EOS。

Ubuntu 16.10
Full Build
[mw_shl_code=bash,true]
git clone https://github.com/eosio/eos --recursive
cd eos
git checkout dawn-2.x
./build.sh ubuntu full
[/mw_shl_code]

MacOS Sierra

运行脚本之前请确保你的MacOS Sierra系统中安装最新版本的XCode和Brew

若是没有安装请使用如下命令安装Xcode和Brew
[mw_shl_code=bash,true]xcode-select --install (安装Xcode Command Line Tools)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" (安装Brew)[/mw_shl_code]


最后使用如下命令拉取代码并编译
[mw_shl_code=bash,true]git clone https://github.com/eosio/eos --recursive
cd eos
git checkout dawn-2.x
./build.sh darwin full[/mw_shl_code]


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


2 MacOS Sierra

安装相关依赖

[mw_shl_code=bash,true]brew update
brew install git automake libtool boost openssl llvm@4 gmp ninja gettext
brew link gettext --force[/mw_shl_code]

安装secp256k1-zkp
[mw_shl_code=bash,true]git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make
sudo make install[/mw_shl_code]

安装binaryen

[mw_shl_code=bash,true]git clone https://github.com/WebAssembly/binaryen.git
cd binaryen
git checkout tags/1.37.14
cmake . && make[/mw_shl_code]

设置环境变量

[mw_shl_code=bash,true]echo "export BINARYEN_ROOT=~/binaryen" >> ~/.bash_profile
source ~/.bash_profile[/mw_shl_code]

编译LLVM和WASM

[mw_shl_code=bash,true]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
[/mw_shl_code]

设置环境变量

[mw_shl_code=bash,true]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
[/mw_shl_code]


3.Docker


1 安装依赖
Docker version >= 17.05


2 构建EOS镜像
[mw_shl_code=bash,true]git clone https://github.com/EOSIO/eos.git --recursive
cd eos/Docker
docker build . -t eosio/eos[/mw_shl_code]

3 启动EOS容器
[mw_shl_code=bash,true]docker run --name eosd -p 8888:8888 -p 9876:9876 -t eosio/eos start_eosd.sh arg1 arg2[/mw_shl_code]

4 获取链信息
[mw_shl_code=bash,true]curl http://127.0.0.1:8888/v1/chain/get_info
[/mw_shl_code]

5 启动EOSD和WALLETD容器
[mw_shl_code=bash,true]docker-compose up
[/mw_shl_code]

5.1 执行EOSC命令
[mw_shl_code=bash,true]alias eosc='docker-compose exec walletd /opt/eos/bin/eosc -H eosd'
eosc get info
eosc get account inita[/mw_shl_code]

5.2 更改默认配置
我们可以查看Docker Compose的配置文件并根据自身需要来更改配置文件, 比如更改依赖的服务或者挂载的目录,最后通过如下命令重启容器
[mw_shl_code=bash,true]docker-compose down
docker-compose up[/mw_shl_code]


5.3 清除数据挂载点
[mw_shl_code=bash,true]docker volume rm eosd-data-volume[/mw_shl_code]


4. 创建和启动单节点测试网络


在构建EOS成功后,可以在build/programs目录下看到编译生成的二进制文件
编辑config.ini文件并添加以下内容

[mw_shl_code=bash,true]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
[/mw_shl_code]
随后执行eosd来启动节点,启动后将看到如下输出
[mw_shl_code=bash,true]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
[/mw_shl_code]

下一篇区块链3.0EOS入门2:EOS常用概念术语汇总
http://www.aboutyun.com/forum.php?mod=viewthread&tid=24622



作者:韬声依旧在路上
链接:https://www.jianshu.com/p/26b55a665c22

本帖被以下淘专辑推荐:

没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条