手把手教你厘清EOS开发环境搭建来龙去脉

区块链技术巴比特2018-04-17 21:02:38  阅读 -评论 1  阅读原文
目前来讲,任何学习EOS相关技术的资料都来自https://github.com/EOSIO/eos,可能大家在搭建EOS开发环境的过程中,会很迷茫,网上资料都很乱,自己也理不清头绪,不知如何下手。在这里,春哥将一步步为你揭开层层面纱。 1. 硬件软件环境

因为EOS的版本太多,所以你需要先知道如何查看EOS对应版本的相关资料。

打开EOS Github官网https://github.com/EOSIO/eos,如下图所示,点击master,然后点击tag,你将会看到不同的版本及其对应的文档。

手把手教你厘清EOS开发环境搭建来龙去脉

我在我电脑安装过各种各样的版本,踩过各种各样的莫名其妙的坑,这篇文章我将以如下配置为大家分享。

操作系统

手把手教你厘清EOS开发环境搭建来龙去脉

EOS 版本

手把手教你厘清EOS开发环境搭建来龙去脉

2. 编译设置开发环境 2.1 获取EOS源码及其所有子模块

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

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

$ git submodule update --init --recursive

2.2 编译源码生成可执行文件

切换到上面的项目根目录下面,执行如下命令。

liyuechun:eos yuechunli$ ./eosio_build.sh darwin full

liyuechun:eos yuechunli$ ls CMakeLists.txt debian ring.dot CMakeModules docs ring.png Docker eos-logo.png scripts Doxyfile eos.doxygen.in star.dot HEADER eosio_build.sh star.png Jenkinsfile externals testnet-diagrams.sh LICENSE.txt libraries testnet.md README.md mesh.dot testnet.template build mesh.png tests circle.yml plugins tools contracts programs liyuechun:eos yuechunli$ ./eosio_build.sh darwin full Beginning build version: 1.2 2018年 4月12日 星期四 07时44分06秒 UTC git head id: 96ee0325cc925ff3e90f865ebc72b01341196e08 Current branch: * master ARCHITECTURE: Darwin OS name: Darwin OS Version: 10.13.3 CPU speed: 250.00Ghz CPU cores: 4 Physical Memory: 16 Gbytes Disk space total: 465G Disk space available: 133G ..... 漫长等待,半小时左右,网络不好的话,40 - 50分钟。 [100%] Linking CXX executable chain_test ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in ___gmpn_divexact_1 from /usr/local/lib/libgmp.a(dive_1.o). To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie [100%] Built target chain_test _______ _______ _______ _________ _______ ( ____ \( ___ )( ____ \\__ __/( ___ ) | ( \/| ( ) || ( \/ ) ( | ( ) | | (__ | | | || (_____ | | | | | | | __) | | | |(_____ ) | | | | | | | ( | | | | ) | | | | | | | | (____/\| (___) |/\____) |___) (___| (___) | (_______/(_______)\_______)\_______/(_______) EOS.IO has been successfully built. 0:11:48 To verify your installation run the following commands: /usr/local/bin/mongod -f /usr/local/etc/mongod.conf & cd /Users/liyuechun/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

EOS附带的可执行程序:

liyuechun:programs yuechunli$ pwd /Users/liyuechun/Desktop/0402/eos/build/programs liyuechun:programs yuechunli$ ls CMakeFiles cmake_install.cmake keosd CTestTestfile.cmake eosio-abigen nodeos Makefile eosio-applesedemo cleos eosio-launcher liyuechun:programs yuechunli$

nodeos: 区块链服务器节点生成组建 cleos: 和区块链交互的接口命令 keosd: EOS 钱包 eosio-launcher:节点网络组成和部署的应用

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

2.3 建立区块链节点

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

./nodeos命令可附带 --data-dir 节点文件夹名字 参数,默认文件夹为nodeos。

liyuechun:nodeos yuechunli$ ./nodeos

如下图所示,执行完./nodeos程序后会抱错,并且有如下两个提示。

手把手教你厘清EOS开发环境搭建来龙去脉

generating default genesis file /Users/liyuechun/Library/Application Support/eosio/nodeos/config/genesis.json表示创建了一个nodeos节点文件夹。

No producers configured! Please add producer IDs and private keys to configuration.表示

liyuechun:nodeos yuechunli$ cd /Users/liyuechun/Library/Application\ Support/eosio/ liyuechun:eosio yuechunli$ ls nodeos liyuechun:eosio yuechunli$ cd nodeos/ liyuechun:nodeos yuechunli$ ls config data liyuechun:nodeos yuechunli$ cd config/ liyuechun:config yuechunli$ ls config.ini genesis.json liyuechun:config yuechunli$ cd .. liyuechun:nodeos yuechunli$ ls config data liyuechun:nodeos yuechunli$ cd data/ liyuechun:data yuechunli$ ls blocks default.wallet shared_mem liyuechun:data yuechunli$

config是区块链配置文件,data是区块链交易数据、钱包数据存储文件。我们需要修改config.ini文件里面的相关配置。

我的文件的内容如下:

# Track only transactions whose scopes involve the listed accounts. Default is to track all transactions. (eosio::account_history_plugin) # filter_on_accounts = # Limits the maximum time (in milliseconds) processing a single get_transactions call. (eosio::account_history_plugin) get-transactions-time-limit = 3 # File to read Genesis State from (eosio::chain_plugin) genesis-json = "/Users/liyuechun/Library/Application Support/eosio/nodeos/config/genesis.json" # override the initial timestamp in the Genesis State file (eosio::chain_plugin) # genesis-timestamp = # the location of the block log (absolute path or relative to application data dir) (eosio::chain_plugin) block-log-dir = "blocks" # Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin) # checkpoint = # Limits the maximum time (in milliseconds) that a reversible block is allowed to run before being considered invalid (eosio::chain_plugin) max-reversible-block-time = -1 # Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::chain_plugin) max-pending-transaction-time = -1 # Limits the maximum time (in milliseconds) that is allowed a to push deferred transactions at the start of a block (eosio::chain_plugin) max-deferred-transaction-time = 20 # Override default WASM runtime (eosio::chain_plugin) # wasm-runtime = # Time to wait, in milliseconds, between creating next faucet created account. (eosio::faucet_testnet_plugin) faucet-create-interval-ms = 1000 # Name to use as creator for faucet created accounts. (eosio::faucet_testnet_plugin) faucet-name = faucet # [public key, WIF private key] for signing for faucet creator account (eosio::faucet_testnet_plugin) faucet-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"] # The local IP and port to listen for incoming http connections. (eosio::http_plugin) http-server-address = 127.0.0.1:8888 # Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin) # access-control-allow-origin = # Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin) # access-control-allow-headers = # Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin) access-control-allow-credentials = false # The queue size between nodeos and MongoDB plugin thread. (eosio::mongo_db_plugin) mongodb-queue-size = 256 # MongoDB URI connection string, see: https://docs.mongodb.com/master/reference/connection-string/. If not specified then plugin is disabled. Default database 'EOS' is used if not specified in URI. (eosio::mongo_db_plugin) # mongodb-uri = # The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin) p2p-listen-endpoint = 0.0.0.0:9876 # An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin) # p2p-server-address = # The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin) # p2p-peer-address = # The name supplied to identify this node amongst the peers. (eosio::net_plugin) agent-name = "EOS Test Agent" # Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin) allowed-connection = any # Optional public key of peer allowed to connect. May be used multiple times. (eosio::net_plugin) # peer-key = # Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin) # peer-private-key = # Log level: one of 'all', 'debug', 'info', 'warn', 'error', or 'off' (eosio::net_plugin) log-level-net-plugin = info # Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin) max-clients = 25 # number of seconds to wait before cleaning up dead connections (eosio::net_plugin) connection-cleanup-period = 30 # True to require exact match of peer network version. (eosio::net_plugin) network-version-match = 0 # number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin) sync-fetch-span = 100 # Enable block production, even if the chain is stale. (eosio::producer_plugin) enable-stale-production = true # Percent of producers (0-100) that must be participating in order to produce blocks (eosio::producer_plugin) required-participation = 33 # ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin) producer-name = eosio # Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin) private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"] # The path of the wallet files (absolute path or relative to application data dir) (eosio::wallet_plugin) wallet-dir = "." # Timeout for unlocked wallet in seconds. Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin) # unlock-timeout = # eosio key that will be imported automatically when a wallet is created. (eosio::wallet_plugin) # eosio-key = # Plugin(s) to enable, may be specified multiple times # 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

你需要做如下设置:

genesis-json = "/Users/liyuechun/Library/Application Support/eosio/nodeos/config/genesis.json" enable-stale-production = true producer-name = eosio plugin = eosio::producer_plugin plugin = eosio::wallet_api_plugin plugin = eosio::chain_api_plugin plugin = eosio::http_plugin

接下来再次启动./nodeos程序,每0.5秒会产生一个区块。

liyuechun:nodeos yuechunli$ ./nodeos 2212313ms thread-0 chain_plugin.cpp:99 plugin_initialize ] initializing chain plugin 2212313ms thread-0 wallet_plugin.cpp:41 plugin_initialize ] initializing wallet plugin 2212313ms thread-0 http_plugin.cpp:141 plugin_initialize ] host: 127.0.0.1 port: 8888 2212313ms thread-0 http_plugin.cpp:144 plugin_initialize ] configured http to listen on 127.0.0.1:8888 2212313ms thread-0 net_plugin.cpp:2628 plugin_initialize ] Initialize net plugin 2212313ms thread-0 net_plugin.cpp:2644 plugin_initialize ] Setting net_plugin logging level to info 2212313ms thread-0 net_plugin.cpp:2669 plugin_initialize ] host: 0.0.0.0 port: 9876 2212313ms thread-0 net_plugin.cpp:2745 plugin_initialize ] my node_id is e03436889c70950da2180e6bc3b215d4283d078a54723ca32cd28c816aa4621b 2212313ms thread-0 main.cpp:90 main ] nodeos version 96ee0325 2212313ms thread-0 main.cpp:91 main ] eosio root is /Users/liyuechun/Library/Application Support 2212329ms thread-0 chain_plugin.cpp:208 plugin_startup ] starting chain in read/write mode 2212329ms thread-0 chain_plugin.cpp:213 plugin_startup ] Blockchain started; head block is #0, genesis timestamp is 2018-03-01T12:00:00.000 2212329ms thread-0 producer_plugin.cpp:161 plugin_startup ] producer plugin: plugin_startup() begin 2212329ms thread-0 producer_plugin.cpp:166 plugin_startup ] Launching block production for 1 producers. ******************************* * * * ------ NEW CHAIN ------ * * - Welcome to EOSIO! - * * ----------------------- * * * ******************************* Your genesis seems to have an old timestamp Please consider using the --genesis-timestamp option to give your genesis a recent timestamp 2212330ms thread-0 producer_plugin.cpp:176 plugin_startup ] producer plugin: plugin_startup() end 2212330ms thread-0 http_plugin.cpp:213 plugin_startup ] start listening for http requests 2212330ms thread-0 wallet_api_plugin.cpp:70 plugin_startup ] starting wallet_api_plugin 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/create 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/get_public_keys 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/import_key 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/list_keys 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/list_wallets 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/lock 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/lock_all 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/open 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/set_timeout 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/sign_transaction 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/wallet/unlock 2212330ms thread-0 chain_api_plugin.cpp:62 plugin_startup ] starting chain_api_plugin 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/abi_bin_to_json 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/abi_json_to_bin 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_account 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_block 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_code 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_currency_balance 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_currency_stats 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_info 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_required_keys 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/get_table_rows 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/push_block 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/push_transaction 2212330ms thread-0 http_plugin.cpp:242 add_handler ] add api url: /v1/chain/push_transactions 2212330ms thread-0 net_plugin.cpp:2757 plugin_startup ] starting listener, max clients is 25 eosio generated block b8001d13... #1 @ 2018-04-12T08:36:52.500 with 0 trxs, lib: 0 eosio generated block 96eab818... #2 @ 2018-04-12T08:36:53.000 with 0 trxs, lib: 1 eosio generated block 635d105b... #3 @ 2018-04-12T08:36:53.500 with 0 trxs, lib: 2 eosio generated block 29ef0516... #4 @ 2018-04-12T08:36:54.000 with 0 trxs, lib: 3 eosio generated block 1fc1ac75... #5 @ 2018-04-12T08:36:54.500 with 0 trxs, lib: 4 eosio generated block 041d331f... #6 @ 2018-04-12T08:36:55.000 with 0 trxs, lib: 5 eosio generated block ebee3c7d... #7 @ 2018-04-12T08:36:55.500 with 0 trxs, lib: 6 eosio generated block eecd62a0... #8 @ 2018-04-12T08:36:56.000 with 0 trxs, lib: 7 eosio generated block c2b27ea5... #9 @ 2018-04-12T08:36:56.500 with 0 trxs, lib: 8 eosio generated block 6c66dc13... #10 @ 2018-04-12T08:36:57.000 with 0 trxs, lib: 9 eosio generated block 2534614c... #11 @ 2018-04-12T08:36:57.500 with 0 trxs, lib: 10 eosio generated block cce2934b... #12 @ 2018-04-12T08:36:58.000 with 0 trxs, lib: 11 eosio generated block 0165d88b... #13 @ 2018-04-12T08:36:58.500 with 0 trxs, lib: 12 eosio generated block fa240aa7... #14 @ 2018-04-12T08:36:59.000 with 0 trxs, lib: 13 eosio generated block 2965e8d4... #15 @ 2018-04-12T08:36:59.500 with 0 trxs, lib: 14

3. 查看区块信息

重新打开一个终端,切换到如下路径。

liyuechun:cleos yuechunli$ ./cleos -p 8888 get info { "server_version": "96ee0325", "head_block_num": 342, "last_irreversible_block_num": 341, "head_block_id": "0000015609ca5ec4f237bbe49e8eb3aa36dbe8ecec86133340567dad5caf01ba", "head_block_time": "2018-04-12T08:39:43", "head_block_producer": "eosio" } liyuechun:cleos yuechunli$ ./cleos -p 8888 get info { "server_version": "96ee0325", "head_block_num": 359, "last_irreversible_block_num": 358, "head_block_id": "00000167a933b393bc3562ca2998080748a1ed24f79014848e7b0b34f2c0c429", "head_block_time": "2018-04-12T08:39:51", "head_block_producer": "eosio" }

声明:链世界登载此文仅出于分享区块链知识,并不意味着赞同其观点或证实其描述。文章内容仅供参考,不构成投资建议。投资者据此操作,风险自担。此文如侵犯到您的合法权益,请联系我们100@7234.cn

    参与讨论 (1 人参与讨论)

    相关推荐

    区块链投资趋势报告:巨头入场布局行业趋于成熟

    区块链投资趋势报告:巨头入场布局行业趋于成熟

    来自:https://mp.weixin.qq.com/s?__biz=MzI4NzIxOTY1NA==&mid=2650632639&idx=1&sn=e6d1c29731d992a80410aaee82ec3ea6&chksm=f3d8db16c4af520097e4a64a71b1d4743ac326b9f027

    重新发明货币

    重新发明货币

    一、货币的演化过程 先简单回顾一下人类货币的演化过程,大概有以下阶段: a. 1.0版本:自然货币(贝壳、牲口、金银……) 这个阶段,货币基于一般等价物的稀有性或者实用性,货币不可能出现人为操纵的超发。 b. 2.0版本:早期纸币、银票到本位纸币 当贸易量越来越大,实物货币太不方便了,而且大家发现其实并不在意货币本身有什么价值,在意的只是这么多的货币能不能交换到足够的物品,于是纸币这种信用货

    从比特币交易看欧洲央行虚拟货币分类

    从比特币交易看欧洲央行虚拟货币分类

      互联网对传统社会的颠覆从未停止,在其完成对信息流、商流、物流、资金流的初步改造之后,或将以虚拟货币的形式打破现有货币体系   4月18日,在中国极客张沈鹏创办的比特币交易平台(42BTC.com)上,比特币对人民币的平均交易价为576元。当天,该平台完成了100个比特币的交易量。仅仅过去一周,4月25日上午,比特币对人民币的平均交易价已达到906元。据42BTC网站统计:在过去的32个月

    欧洲央行-比特币报告

    3.1 比特币 3.1.1 基本特征          比特币可能是最成功的,也可能是最有争议的虚拟货币方案,由日本程序员中本聪(译者注:事实上,中本聪是不是日本人,甚至是不是单个人无从考证)在2009年设计并实现。该计划基于一个类似于BitTorrent的P2P网络。BitTorrent是互联网上著名的共享文件协议,应用在电影,游戏和音乐领域。比特币在全球层面上运作,可用于各类货币交易(虚

    彻底玩转比特币地址和私匙

    彻底玩转比特币地址和私匙

    比特币地址和私匙是所有比特币初学者面对的一大难题,再加上那一串超长的字符串,让人更是摸不到头脑。 现在编者以问答的形式,带你一步步的揭开比特币地址和私匙的面纱。 还不知道什么是比特币地址和私匙的同学请点这里 问题一、比特币钱包由什么组成? 答 我们知道,比特币地址和私匙组成了比特币钱包,而私匙则决定了比特币地址上比特币的归属。 地址和私匙 问题二、如果只记得私匙我们还能还原比特币地址么? 答

    用GO语言实现比特币算法

    用GO语言实现比特币算法

    本节的这个例子展示一点点高精度数学包math/big、一点点散列包hash、一点点加密包crypto,还有一点点测试包testing的知识。这里不介绍bitcoin协议和算法——尽管它们很有趣,而是试图指出,Go对多种操作系统的支持,是实现这种跨平台应用的理想语言。 位钱(bitcoin)是一种使用加密手段制作的分布式电子货币。它最初于1998年由Wei Dai提出,并由中本聪(Satoshi

    详解比特币的找零机制

    详解比特币的找零机制

    比特币的找零机制一直让人有些迷惑,明明只向一个地址发送了比特币为什么 blockchain 上面的显示的有时是1个地址对多个地址,有时是多个地址对1个地址,有时又显示多个地址对多个地址? 为什么比特币资深用户要提醒大家当比特币钱包交易100次以上时再次交易后要重新备份钱包,恢复以前的钱包备份有可能会遭遇损失? 是的,这一切都是因为比特币的找零(Change)机制。本文参考 Bitcoin的维

    玩转比特币客户端之一:C盘转移和加速下载

    玩转比特币客户端之一:C盘转移和加速下载

    C盘空间不足?交易数据下载速度太慢?别着急,乐享比特币教你轻松玩转比特币官方客户端。 所有新人开始接触比特币时做的第一件事情大多数是安装比特币的官方客户端。 安全起见大家最好直接访问官方发布渠道sourceforge的地址进行下载:http://sourceforge.net/projects/bitcoin/files/Bitcoin/ 该网页列出了各版本的官方比特币客户端,目前

    麦妖榜
    更新日期 2019-06-18
    排名用户贡献值
    1BitettFan23992
    2等待的宿命23809
    3六叶树20309
    4区块大康18727
    5牛市来了16520
    6天下无双16192
    7linjm122716021
    8lizhen00215101
    9让时间淡忘14475
    10冷风大q11188
    返回顶部 ↑