1.入门文档
https://developers.eos.io/eosio-home/docs
Linux / Mac OS体验
EOSIO软件支持以下环境:
Amazon 2017.09 and higher
Centos 7
Fedora 25 and higher (Fedora 27 recommended)
Mint 18
Ubuntu 16.04 (Ubuntu 16.10 recommended)
Ubuntu 18.04
MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended)
安装二进制文件
本教程将使用预构建的二进制文件。为了让您尽快开始,这是最好的选择。从源代码构建是一个选项,但会让您回到一个小时或更长时间,并且可能会遇到构建错误。
以下命令将下载各个操作系统的二进制文件。
如果您以前安装了EOSIO,请eosio_uninstall在下载和使用二进制版本之前运行脚本(它位于您克隆EOSIO的目录中)。
Mac OS X Brew安装
$ brew tap eosio / eosio
$ brew install eosio
Mac OS X Brew卸载
$ brew删除eosio
Ubuntu 18.04 Debian软件包安装
$ wget https://github.com/eosio/eos/releases/download/v1.5.2/eosio_1.5.2-1-ubuntu-18.04_amd64.deb
$ sudo apt install ./eosio_1.5.2-1-ubuntu-18.04_amd64.deb
Ubuntu 16.04 Debian软件包安装
$ wget https://github.com/eosio/eos/releases/download/v1.5.2/eosio_1.5.2-1-ubuntu-16.04_amd64.deb
$ sudo apt install ./eosio_1.5.2-1-ubuntu-16.04_amd64.deb
Debian软件包卸载
$ sudo apt删除eosio
Centos RPM软件包安装
$ wget https://github.com/eosio/eos/releases/download/v1.5.2/eosio-1.5.2-1.el7.x86_64.rpm
$ sudo yum install ./eosio-1.5.2-1.el7.x86_64.rpm
Centos RPM软件包卸载
$ sudo yum删除eosio.cdt
Fedora RPM软件包安装
$ wget https://github.com/eosio/eos/releases/download/v1.5.2/eosio-1.5.2-1.fc27.x86_64.rpm
$ sudo yum install ./eosio-1.5.2-1.fc27.x86_64.rpm
Fedora RPM软件包卸载
$ sudo yum删除eosio.cdt
开发调试环境搭建
nodeos:管理区块链节点的组件。
keosd:管理钱包的组件。
cleos:控制区块链和钱包CLI工具。
第一步:用Git克隆,下载EOS的源代码
git clonehttps://github.com/EOSIO/eos --recursive
要安装xcode和homebrew代码。如果还没有安装的情况,先设置xcode和homebrew。
homebrew : https://brew.sh
更换为中科大的镜像源
cd /usr/local/Homebrew
git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git
cd ~ mkdir tmp cd tmp git clone http://mirrors.ustc.edu.cn/homebrew.git
sudo mv /usr/local/.git /usr/local.git_old
sudo mv /usr/local/Library /usr/local/Library_old
sudo cp -R homebrew/.git /usr/local/
sudo cp -R homebrew/Library /usr/local/
源代码包含构建脚本及构建实现。
cd eos
./eosio_build.sh
[图片上传失败...(image-88fe66-1547814603412)]
可能遇到的报错:
GMP包找不到
CMake Error at /usr/local/Cellar/cmake/3.9.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find GMP (missing: GMP_LIBRARIES GMP_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.9.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
解决办法:
brew install gmp
可能遇到ssl相关的错
CMake error: Could not find openSSL or GCrypt
但明明已经安装,原因是由于新版mac已经移除了openssl,所以我们需要手动配置环境变量,可以在cmake的命令行中通过-D的方式传入OPENSSL_ROOT_DIR和OPENSSL_LIBRARIES两个环境变量:
cmake -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2l -DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl/1.0.2l/lib ..
最后的联接时失败Link failed
第一种,使用brew install llvm后会遇到下面的报错:
- Configuring ChainBase on OS X
CMake Error at libraries/wasm-jit/Source/Runtime/CMakeLists.txt:26 (find_package):
Could not find a package configuration file provided by "LLVM" (requested
version 4.0) with any of the following names:
LLVMConfig.cmake
llvm-config.cmake
Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
"LLVM_DIR" to a directory containing one of the above files. If "LLVM"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
解决办法,配置环境变量:
export LLVM_DIR=/usr/local/Cellar/llvm/4.0.1/lib/cmake/llvm
另一种可能,是手动安装llvm遇到下面的报错:
typeinfo for LLVMJIT::UnitMemoryManager in libRuntime.a(LLVMJIT.cpp.o)
"typeinfo for llvm::CmpInst", referenced from:
typeinfo for llvm::FCmpInst in libRuntime.a(LLVMEmitIR.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libraries/wasm-jit/Source/Programs/wavm] Error 1
make[1]: *** [libraries/wasm-jit/Source/Programs/CMakeFiles/wavm.dir/all] Error 2
初步怀疑这种是因为在第2节中,使用的是默认的llvm编译了,但却后续又使用手动安装的llvm进行后续操作导致的。故统一使用brew管理的llvm。
完整的解决过程,参考这里:https://github.com/EOSIO/eos/issues/99
完整的cmake脚本供参考
## 引入支持合约运行的编译器WASM
export WASM_LLVM_CONFIG=~/develop/eos/environment/wasm-compiler/llvm/bin/llvm-config
## 引入LLVM
export LLVM_DIR=/usr/local/Cellar/llvm/4.0.1/lib/cmake/llvm
## 新版mac移除了openssl的环境变量配置,手动设置并cmake
cmake -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2l -DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl/1.0.2l/lib ..
ERROR: Linking /usr/local/Cellar/python/3.6.5... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks
需要执行以下命令
sudo mkdir /usr/local/Frameworks
sudo chown $(whoami):admin /usr/local/Frameworks
LLVM找不到
ERROR: Could not find a package configuration file provided by "LLVM" (requested version 4.0) with any of the following names
需要执行以下命令(检查一下你有没有这个目录,没有的话搜索一下)
export LLVM_DIR=/usr/local/Cellar/llvm@4/4.0.1/lib/cmake
参考链接
https://github.com/EOSIO/eos/issues/43
missing: Intl_INCLUDE_DIR
ERROR: Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)
需要执行以下命令
brew unlink gettext && brew link --force gettext
参考链接
https://github.com/EOSIO/eos/issues/2028?ref=tokendaily
ERROR:找不到 libc.bc和libc++.bc的问题
解决方法:工具链依赖库要一个一个装上去,c++14的
编译智能合约错误
ERROR:'stdint.h' file not found when running the example of smart contract “Hello World”
需要执行以下命令
cd ~/eos/build
sudo make install
参考链接
https://github.com/EOSIO/eos/issues/1718
Mac环境下Boost和wasm安装目录:
set(BOOST_INSTALL_DIR /usr/local/include/boost)
set(WASM_INSTALL_DIR /usr/local/wasm)
binaryen找不到
CMake Error: File /Users/joey/eos/externals/binaryen/LICENSE does not exist.
CMake Error at CMakeLists.txt:272 (configure_file):
configure_file Problem configuring file
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Doxygen not found. Contract documentation will not be generated.
-- Configuring incomplete, errors occurred!
See also "/Users/joey/eos/build/CMakeFiles/CMakeOutput.log".
缺少binaryen
cd /Users/joey/eos/externals
git clone https://github.com/EOSIO/binaryen.git
EOS启动网络的详细过程
准备工作:
1.启动钱包(这里不再啰嗦)
2.三个账户的公私钥
<pre> eosio
EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
aiguoloveuip
EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr
5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y
eosproducer2
EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs
5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmu</pre>
3.genesis.json的准备
<pre>{
"initial_timestamp": "2018-06-01T12:00:00.000",
"initial_key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_</pre>
4.各个节点的端口规划
<pre>http-server-address
p2p-listen-endpoint
p2p-server-address
p2p-peer-address
创世节点(eosio)
8884
9004
</pre>
出块节点(aiguoloveuip)
<pre>8885
9005
9005
90</pre>
出块节点(eosproducer2)
<pre>8886
9006
9006
9004
90</pre>
启动创世节点:
1.代码:
<pre>/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos -e -p eosio --signature-provider=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --plugin eosio::history_api_plugin --http-server-address=172.26.247.122:8884 --p2p-listen-endpoint=172.26.247.122:9004 --p2p-server-address=172.26.247.122:9004 --p2p-peer-address 172.26.247.122:9005 --data-dir ./data/ --config-dir ./ --genesis-json genesis.json --max-transaction-time 3000</pre>
2.注意的地方
--data-dir 是数据存放的地方,包括blocks和state,所以不用另外在家--blocks-dir参数(为了更加整齐)
--max-tansaction-time 为的是解决报错Error 3080006: transaction took too long
--http-server-address --p2p-listen-endpoint --p2p-server-address三个都要指定,但是--p2p-peer-address不必添加,之后其他节点指定该节点后就会同步区块
将当前进程切换到后台 ctrl-z ,bg
--genesis-json每个节点第一次启动的时候都要加上genesis.json配置文件,get info得到的chainid是和genesis.json有关,所以必须指定
想要get transaction(get actions),可以加上参数--filter-on "*"
BIOS:
00_CONFIG.conf代码
<pre>{
"SOURCES_FOLDER": "/eos/home/Jungle/private_chain/eos-source",
"EOSIO_PRODUCER_PUB_KEY": "EOS7wp9yW6a9pwrnNmaUPGLdxmZmywY3B5mLEhrqJCrsNqSuev936",
"EOSIO_PRODUCER_PRIV_KEY": "5Kk7LCFTcoyK2PjaBjPrDAYBJie2xUycHiWgChuVjvtkLEYuSgq",
"WALLET_PASSWD":"",
"INIT_ACCOUNT": "aiguoloveuip",
"INIT_PUB_KEY": "EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr ",
"INIT_PRIV_KEY": "5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y",
"INIT_URL":"http://eos.aiguoloveuip.</pre>
01_BIOS_CONTRACT.sh代码
<pre> #!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
EOSIO_PRODUCER_KEY="$( jq -r '.EOSIO_PRODUCER_PUB_KEY' "00_CONFIG.conf" )"
./cleos.sh set contract eosio $CONTRACTS_FOLDER/eosio.bios -p eo</pre>
only eosio initial producer.. 注意这里我们没有将eosio作为生产者,因为后面我们要投票,大于15%票数才会主网才算真正启动,然后eosio就会停止出块,由投票权重前21个节点出块
<pre>#./cleos.sh push action eosio setprods '{"schedule":[{"producer_name":"eosio","block_signing_key":"'$EOSIO_PRODUCER_KEY'"}]}' -p eosio</pre>
02_SYSTEM_ACCOUNTS.sh代码
<pre>#!/bin/bash
./cleos.sh create account eosio eosio.bpay EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.msig EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.names EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.ram EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.ramfee EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.saving EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.stake EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.token EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq9HhutG
./cleos.sh create account eosio eosio.vpay EOS84BLRbGbFahNJEpnnJHYCoW9QPbQEk2iHsHGGS6qcVUq</pre>
03_TOKENMSIG_CONTRACTS.sh代码
<pre>#!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
./cleos.sh set contract eosio.token $CONTRACTS_FOLDER/eosio.token -p eosio.token
./cleos.sh set contract eosio.msig $CONTRACTS_FOLDER/eosio.msig -p eosio.</pre>
04_TOKEN_CREATE_ISSUE.sh代码
<pre>#!/bin/bash
./cleos.sh push action eosio.token create '["eosio", "1000000000.0000 EOS", 0, 0, 0]' -p eosio.token
./cleos.sh push action eosio.token issue '["eosio", "1000000000.0000 EOS", "init"]' -p eosio</pre>
05_SYSTEM_CONTRACTS.sh代码
<pre>#!/bin/bash
SOURCES_FOLDER="$( jq -r '.SOURCES_FOLDER' "00_CONFIG.conf" )"
CONTRACTS_FOLDER="$SOURCES_FOLDER/build/contracts"
./cleos.sh set contract eosio $CONTRACTS_FOLDER/eosio.system -p eosio
./cleos.sh push action eosio setpriv '["eosio.msig",1]' -p eo</pre>
06_TEST_ACCOUNTS.sh代码
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"</pre>
<pre>./cleos.sh system newaccount eosio INIT_PUB_KEY $INIT_PUB_KEY --stake-net "50.0000 EOS" --stake-cpu "500.0000 EOS" --buy-ram-kbytes 8888</pre>
07_TEST_ACCOUNTS_TRANSFER.sh代码
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
</pre>
这里我们转2亿个EOS,为后面抵押做准备,要大于EOS总数的15%,也就是1.5亿
<pre>./cleos.sh transfer eosio $INIT_ACCOUNT "200000000.0000 EOS" "init"</pre>
10_REGPRODUCER.sh 注册成为bp节点
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
INIT_URL="$( jq -r '.INIT_URL' "00_CONFIG.conf" )"
./cleos.sh system regproducer INIT_PUB_KEY "$INIT_URL" -p INIT_ACC</pre>
11_STAKE_TOKENS.sh cpu和net各抵押1亿EOS,就满足大于15%
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh push action eosio delegatebw '{"from":"'INIT_ACCOUNT'", "stake_net_quantity":"100000000.0000 EOS", "stake_cpu_quantity":"100000000.0000 EOS", "transfer": false}' -p $INIT_ACCOUN</pre>
13_VOTE_PRODUCER.sh 执行该命令后,创世节点开始停止出块
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh system voteproducer prods INIT_ACCOUNT -p $INIT_ACCOUNT
</pre>
cleos.sh的脚本
<pre>#!/bin/bash
CLEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/cleos/cleos
@"</pre>
之后执行各个脚本
1-5是主网BIOS启动过程
<pre>./01_BIOS_CONTRACT.sh
./02_SYSTEM_ACCOUNTS.sh
./03_TOKENMSIG_CONTRACTS.sh
./04_TOKEN_CREATE_ISSUE.sh
./05_SYSTEM_CONTRACTS.</pre>
6-10 是创建新账户并注册生产节点,抵押,投票,过程
<pre>./06_TEST_ACCOUNTS.sh
./07_TEST_ACCOUNTS_TRANSFER.sh
./10_REGPRODUCER.sh
./11_STAKE_TOKENS.sh
./13_VOTE_PRODUCER.s</pre>
注意运行完这个命令后,创世节点停止出块
<pre>#等到bp节点启动后,bp节点开始出块,创世节点转为接收区块,类似出现如下信息:1998000ms thread-0 controller.cpp:769 start_block ] promoting proposed schedule (set in block 404) to pending; current block: 405 lib: 404 schedule: {"version":1,"producers":[{"producer_name":"aiguoloveuip","block_signing_key":"EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr"}]}</pre>
出块节点aiguoloveuip的启动
config.ini中的配置
<pre> get-transactions-time-limit = 30
max-transaction-time=3000 #防止产生transaction too long 错误
#config.ini文件中的genesis-json没有生效,所以启动节点是要指明该文件--genesis-json
#genesis-json = "/eos/home/Jungle/aiguo/JungleTestnet-aiguoloveuip/genesis.json"
http-server-address = 172.26.247.122:8885
p2p-listen-endpoint = 172.26.247.122:9005
p2p-server-address = 172.26.247.122:9005
# SSL
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
contracts-console = true #该配置项是console端输出,用于智能合约调试,使用print()函数
http-validate-host = 0 从v1.0.9版本之后 加上该配置项才能从外部连通http server
#该值默认为1024; 如果启动node加上--filter-on "*"的话可能会出现bad acclocation 错误,issues中的#4661,所以增加了chain-state
chain-state-db-size-mb = 2048
allowed-connection = any
log-level-net-plugin = info
max-clients = 120
connection-cleanup-period = 30
network-version-match = 0
sync-fetch-span = 2000
enable-stale-production = true #要为true,不然不出块
required-participation = 33
mongodb-queue-size = 256
plugin = eosio::producer_plugin
plugin = eosio::producer_abi_plugin 这个插件不需要添加,放开后报错
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
agent-name = aiguoloveuip
private-key = ["EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr","5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y"] 注意这里的格式改变了
signature-provider = EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr=KEY:5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y
producer-name = aiguoloveuip
这里我们的p2p是连的创世区块,同步数据,即使创世区块没有指定p2p,也会同步到数据
</pre>
启动节点的脚本start.sh
<pre>#!/bin/bash
NODEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos
DATADIR=/eos/home/Jungle/private_chain/chain5/
$DATADIR/stop.sh
DATADIR/data/ --config-dir @" > DATADIR/stderr.txt & echo DATADIR/nodeos.pi</pre>
启动:
第一次启动
1.需要指明genesis.json文件
2.如果删除了数据,重新启动也用该命令(--delete-all-blocks就是将data数据删除了,所以不用手动删除)
<pre>./start.sh --genesis-json genesis.json --delete-all-blocks</pre>
以后如果数据还存在的话启动
<pre>./start.sh</pre>
如果重启后出现同步数据问题:
可以先尝试--replay-blockchain
再者可以:start.sh --hard-replay-blockchain --truncate-at-block [有问题的区块编号]
最后不行就--delete-all-blocks
--replay-blockchain
clear chain state database and replay all blocks
--hard-replay-blockchain
clear chain state database, recover as many blocks as possible from the block log, and then replay those blocks
--delete-all-blocks
clear chain state database and block log
--truncate-at-block arg (=0)
stop hard replay / block log recovery at this block number (if set to non-zero number)
出块节点eosproducer2的启动
config.ini中的配置
<pre> get-transactions-time-limit = 30
max-transaction-time=3000
#genesis-json = "/eos/home/Jungle/aiguo/JungleTestnet-aiguoloveuip/genesis.json"
http-server-address = 172.26.247.122:8886
p2p-listen-endpoint = 172.26.247.122:9006
p2p-server-address = 172.26.247.122:9006
access-control-allow-origin = *
# SSL
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-server-address =
# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =
# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =
allowed-connection = any
log-level-net-plugin = info
max-clients = 120
connection-cleanup-period = 30
network-version-match = 0
sync-fetch-span = 2000
enable-stale-production = true
required-participation = 33
mongodb-queue-size = 256
plugin = eosio::producer_plugin
plugin = eosio::producer_abi_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
agent-name = eosproducer2
private-key = ["EOS5YCbPBQqYoaMZKHkK2FhoNDSYFekqXSpYeWiCGDHCxU9w2U6mr","5JVK7ndrrqxZVzeM6MEMHb7QiULdxDuoA2upc37DqJhwCLTdG3y"]
signature-provider = EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs=KEY:5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmuwUCgz
producer-name = eosproducer2
这里我们同步9004和9005的数据
p2p-peer-address = 172.26.247.122:9004
</pre>
在这之前我们先要创建账户,注册出块节点,转账,抵押,投票
<pre>00_CONFIG.conf
{
"SOURCES_FOLDER": "/eos/home/Jungle/private_chain/eos-source",
"EOSIO_PRODUCER_PUB_KEY": "EOS7wp9yW6a9pwrnNmaUPGLdxmZmywY3B5mLEhrqJCrsNqSuev936",
"EOSIO_PRODUCER_PRIV_KEY": "5Kk7LCFTcoyK2PjaBjPrDAYBJie2xUycHiWgChuVjvtkLEYuSgq",
"WALLET_PASSWD":"",
"INIT_ACCOUNT": "eosproducer2",
"INIT_PUB_KEY": "EOS7buuQTWf4KqdDC5xwbhaBkkNX9bnAnc7XoEXtaJTDXfzakisjs",
"INIT_PRIV_KEY": "5HskFQ7GLQ6UEoQWqCJPBjtFFCvaJ2brfS2qo5AcabRXmuwUCgz",
"INIT_URL":"http://eosproducer2</pre>
06_TEST_ACCOUNTS.sh
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
./cleos.sh system newaccount eosio INIT_PUB_KEY $INIT_PUB_KEY --stake-net "50.0000 EOS" --stake-cpu "500.0000 EOS" --buy-ram-kbytes 88</pre>
07_TEST_ACCOUNTS_TRANSFER.sh
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh transfer eosio $INIT_ACCOUNT "200.0000 EOS" "init</pre>
10_REGPRODUCER.sh
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
INIT_PUB_KEY="$( jq -r '.INIT_PUB_KEY' "00_CONFIG.conf" )"
INIT_URL="$( jq -r '.INIT_URL' "00_CONFIG.conf" )"
./cleos.sh system regproducer INIT_PUB_KEY "$INIT_URL" -p INIT_ACC</pre>
11_STAKE_TOKENS.sh 由于主网已经启动,这次抵押不需要太多EOS,只要权重排在前21就可以
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh push action eosio delegatebw '{"from":"'INIT_ACCOUNT'", "stake_net_quantity":"100.0000 EOS", "stake_cpu_quantity":"100.0000 EOS", "transfer": false}' -p $INIT_ACCOUN</pre>
13_VOTE_PRODUCER.sh
<pre>#!/bin/bash
INIT_ACCOUNT="$( jq -r '.INIT_ACCOUNT' "00_CONFIG.conf" )"
./cleos.sh system voteproducer prods INIT_ACCOUNT -p $INIT_ACCOUNT
</pre>
执行脚本
<pre>./06_TEST_ACCOUNTS.sh
./07_TEST_ACCOUNTS_TRANSFER.sh
./10_REGPRODUCER.sh
./11_STAKE_TOKENS.sh
./13_VOTE_PRODUCER.sh
</pre>
启动节点的脚本 start.sh
<pre>#!/bin/bash
NODEOS=/eos/home/Jungle/private_chain/eos-source/build/programs/nodeos/nodeos
DATADIR=/eos/home/Jungle/private_chain/chain6/
$DATADIR/stop.sh
DATADIR/data/ --config-dir @" > DATADIR/stderr.txt & echo DATADIR/nodeos.</pre>
启动:
第一次启动(包括如果删除了数据,重新启动(--delete-all-blocks就是将data数据删除了,所以不用手动删除))
<pre>./start.sh --genesis-json genesis.json --delete-all-blocks</pre>
以后如果数据还存在的话启动
<pre>./start.sh</pre>
EOS主网连接与数据同步
一,从GitHub上克隆主网代码仓库:(注意EOS-Mainnet / eos与EOSIO / eos的版本是一致的。若以前在本地已经安装编译过EOSIO / eos的1.0.2版本及以上,则可以直接跳到步骤三)
git clone https://github.com/EOS-Mainnet/eos
cd eos
git submodule update --init --recursive
git tag
git checkout mainnet-1.0.2.2
二,编译EOS代码
./eosio_build.sh
三,替换config.ini和genesis.json文件
(1)运行nodeos节点后会生成默认的的config.ini / genesis.json文件,现在对其进行替换
(2)在不同系统中找到其文件地址:
linux-ubuntu:〜/ .local / share / eosio / nodeos / config /
mac-osx:〜/ Library / Application \ Support / eosio / nodeos / config /
(3)新的的config.ini文件设置如下:
fullnode sample config
blocks-dir = "blocks"
chain-state-db-size-mb = 1024
reversible-blocks-db-size-mb = 340
contracts-console = false
https-client-validate-peers = 1
http-server-address = 0.0.0.0:8888
access-control-allow-credentials = false
p2p-listen-endpoint = 0.0.0.0:9876
p2p-server-address = 0.0.0.0:9876
List of peers
p2p-peer-address = p2p.one.eosdublin.io:9876
p2p-peer-address = eu-west-nl.eosamsterdam.net:9876
p2p-peer-address = p2p.mainnet.eosgermany.online:9876
p2p-peer-address = 35.197.190.234:19878
p2p-peer-address = p2p.genereos.io:9876
p2p-peer-address = fullnode.eoslaomao.com:443
p2p-peer-address = new.eoshenzhen.io:10034
p2p-peer-address = node1.eosphere.io:9876
p2p-peer-address = p2p.meet.one:9876
p2p-peer-address = bp.eosbeijing.one:8080
p2p-peer-address = peer1.mainnet.helloeos.com.cn:80
p2p-peer-address = p2p-public.hkeos.com:19875
p2p-peer-address = pub1.eostheworld.io:9876
p2p-peer-address = eu1.eosdac.io:49876
p2p-peer-address = peer.eosio.sg:9876
p2p-max-nodes-per-host = 10
agent-name = "eosmainnet"
allowed-connection can be set to "specified" to use whitelisting with the "peer-key" option
allowed-connection = any
peer-private-key is needed if you are whitelisting specific peers with the "peer-key" option
peer-private-key = ["EOS6qTvpRYx35aLonqUkWAMwAf3mFVugYfQCbjV67zw2aoe7Vx7qd", "5JroNC1B4pz9gJzNZeU7tkU6YMtoeWRCr4CJJwKsVXnJhRbKXSC"]
max-clients = 250
connection-cleanup-period = 30
network-version-match = 1
sync-fetch-span = 100
max-implicit-request = 1500
enable-stale-production = false
pause-on-startup = false
max-transaction-time = 10000
max-irreversible-block-age = -1
txn-reference-block-lag = 0
Plugins used for full nodes
plugin = eosio::chain_api_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
plugin = eosio::history_plugin
plugin = eosio::net_plugin
plugin = eosio::net_api_plugin
其中P2P对等实体地址的配置来源于:
https://docs.google.com/spreadsheets/d/1K_un5Vak3eDh_b4Wdh43sOersuhs0A76HMCfeQplDOY/edit#gid=0
WX20180619-163221@2x.png
(4)genesis.json文件内容如下:
{
"initial_timestamp": "2018-06-08T08:08:08.888",
"initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
}
}
此文件称为创世JSON文件,来自以下链接:
https://github.com/EOS-Mainnet/eos/blob/launch-rc-1.0.2/mainnet-genesis.json
四,将以上的创世JSON文件,复制拷贝到〜/ EOS /构建/程序/ nodeos目录下,并启动nodeos节点:
./nodeos --genesis-json genesis.json
可以看到节点已经连上主网,on_incoming_block就代表正在同步区块内容了。不过有的节点地址会出现连接不上的误差。可以尝试在上述的谷歌链接地址中的表格选择稳定的对等节点进行设置。
3546494ms thread-0 producer_plugin.cpp:290 on_incoming_block ] Received block ccf596b268aea49a... #479000 @ 2018-06-13T05:29:49.000 signed by genesisblock [trxs: 0, lib: 478999, conf: 0, latency: 527357494 ms]
3552228ms thread-0 producer_plugin.cpp:290 on_incoming_block ] Received block 3adbcf84f3dea90c... #480000 @ 2018-06-13T05:38:09.000 signed by genesisblock [trxs: 0, lib: 479999, conf: 0, latency: 526863228 ms]
3557963ms thread-0 producer_plugin.cpp:290 on_incoming_block ] Received block ec80ea02b2d795cb... #481000 @ 2018-06-13T05:46:29.000 signed by genesisblock [trxs: 0, lib: 480999, conf: 0, latency: 526368963 ms]
3563672ms thread-0 producer_plugin.cpp:290 on_incoming_block ] Received block 580cf0926b807c85... #482000 @ 2018-06-13T05:54:49.000 signed by genesisblock [trxs: 0, lib: 481999, conf: 0, latency: 525874672 ms]
3569426ms thread-0 producer_plugin.cpp:290 on_incoming_block ] Received block cce03eebb64b3c80... #483000 @ 2018-06-13T06:03:09.000 signed by genesisblock [trxs: 0, lib: 482999, conf: 0, latency: 525380427 ms]
3571971ms thread-0 net_plugin.cpp:1915 connect ] host: node1.eosphere.io port: 9876
3571971ms thread-0 net_plugin.cpp:1915 connect ] host: eu1.eosdac.io port: 49876
3571971ms thread-0 net_plugin.cpp:1915 connect ] host: peer.eosio.sg port: 9876
3571971ms thread-0 net_plugin.cpp:1915 connect ] host: p2p.mainnet.eosgermany.online port: 9876
五,查看链信息:
比对chain_id是否为:aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
运行cleos命令:
cleos get info
返回信息为:
{
"server_version": "26ec83de",
"chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
"head_block_num": 493299,
"last_irreversible_block_num": 493298,
"last_irreversible_block_id": "000786f240401f6fcc24de5240ddd9fead88cbbbbec740c181258dc3e682fb96",
"head_block_id": "000786f36fafd9e98d703a004a302e86958de991dedbbc27f33c393c2adb2c6f",
"head_block_time": "2018-06-13T07:28:58",
"head_block_producer": "genesisblock",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}
六,查看区块数据
在数据正常同步后,使用cleos命令可以查看一些区块信息:譬如查看区块191的数据
cleos get block 191
返回信息如下,可以看到交易内容
{
"timestamp": "2018-06-09T11:58:04.500",
"producer": "eosio",
"confirmed": 0,
"previous": "000000be7ec418241839c376b35a4ae88b305e045a4f0e779215c5f5f4508e5d",
"transaction_mroot": "1f09d60c3b791e1fa29e7fe980807ec36fab1c9fbc130f72f492e3b4c965184b",
"action_mroot": "1ca50b0889e5c6b884e621ff113b17868dfbbc7cd2d4549784c8e50a5114e75c",
"schedule_version": 0,
"new_producers": null,
"header_extensions": [],
"producer_signature": "SIG_K1_K87sojWELjnYSUvpS1Xy1L1P5Etr7xrcnuauqM5zoUYZRTL6eLXA9fZASdvH1ynUq1ZXSceNqWGrcAxj6cZt3ERvgk2aD9",
"transactions": [{
"status": "executed",
"cpu_usage_us": 1593,
"net_usage_words": 35,
"trx": {
"id": "ad77575a8b4f52e477682e712b1cbd884299468db6a94d909f90c6961cea9b02",
"signatures": [
"SIG_K1_KfUNC7KHjSGKBrk8FHjq9tqZA12q1aD9pspfBbLW9iw58B6DqoyebmLaEP2VUuJZa2nDZ11YdgEi2VwuqY5sSogh7MaG8p"
],
"compression": "none",
"packed_context_free_data": "",
"context_free_data": [],
"packed_trx": "eac01b5bbd00421775ad000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232ba010000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f00",
"transaction": {
"expiration": "2018-06-09T11:58:34",
"ref_block_num": 189,
"ref_block_prefix": 2910132034,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": {
"from": "eosio",
"to": "b1",
"quantity": "10.0000 EOS",
"memo": "Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, it's the only thing that ever has - eosacknowledgments.io"
},
"hex_data": "0000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f"
}
],
"transaction_extensions": []
}
}
}
],
"block_extensions": [],
"id": "000000bf87a9db45034a46671514a225cb1a5c30e9b8dc172bc75ef30a812970",
"block_num": 191,
"ref_block_prefix": 1732659715
}
EOS调试
编译带调试信息的EOS
编译可以调试(带源码信息)的EOS程序,增加-o Debug参数即可,即
$./eosio_build.sh -o Debug
下载源码等其他步骤请参考【[EOS源码编译运行](https://blog.csdn.net/itleaks/article/details/80367131)】一文
下载VSCode
和比特币,以太坊源码调试一样,vscode是最佳的调试EOS源码的调试工具
https://code.visualstudio.com/Download
调试配置流程
导入源码
配置调试文件
执行后,会生成launch.json, 然后修改program字段值为对应的程序即可,比如要调试nodeos, 则修改为如下
添加断点并开始调试
在行号左边点击即可添加断点
点击调试界面的右三角开始调试程序
注意
如果你曾经执行过release版本的nodeos,需要将数据清空,否则会报错
database created by a different compiler, build, boost version, or operating system
执行如下命令清空老数据
$ rm -rf ~/Library/Application\ Support/eosio