1. 编译eos 3
[email protected]:/opt/git-eos/eos-3$ git clone https://github.com/eosio/eos --recursive -b dawn-v3.0.0
正克隆到 'eos'.
cd eos
./eosio_build.sh
2. block one的测试流程
2.1 文档
https://gist.github.com/spoonincode/fca5658326837b76fd744d39b2a25b4e
适应版本 “pre-dawn 3.0”
2.2 mkdir ~/eos.data
2.3 配置~/eos.data/logging.json文件,内容如下
----
{
"includes": [],
"appenders": [{
"name": "consoleout",
"type": "console",
"args": {
"stream": "std_out",
"level_colors": [{
"level": "debug",
"color": "green"
},{
"level": "warn",
"color": "brown"
},{
"level": "error",
"color": "red"
}
]
},
"enabled": true
}
],
"loggers": [{
"name": "default",
"level": "info",
"enabled": true,
"additivity": false,
"appenders": [
"consoleout"
]
}
]
}
EOF
----
3.终端分别执行如下命令
3.1 主要测试流程对应的文档 plugins/txn_test_gen_plugin/README.md
3.2 启动block producer,也就是BP,它负责出块。超级节点就是BP。它一启动,就不停出块。
nodeos -d ~/eos.data/producer_node --config-dir ~/eos.data/producer_node -l ~/eos.data/logging.json --http-server-address "" -p eosio -e
3.3 启动generator,它负责生成transaction。它一启动,就从BP同步区块。当设置生成测试帐号并启动测试,它会生成大量的transacion,这些transaction会发到BP进行打包出块,同时,它又从BP同步这些打包后的块。本节点,又相当于是一个普通节点/非BP节点,人人可以搭建,启动了钱包管理,链api等等,以便进行各种账户和数据查询操作。
nodeos -d ~/eos.data/generator_node --config-dir ~/eos.data/generator_node -l ~/eos.data/logging.json --plugin eosio::txn_test_gen_plugin --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --p2p-peer-address localhost:9876 --p2p-listen-endpoint localhost:5555
3.4 钱包和key
cleos wallet create
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JJFdti2wPx9NvGAZ74UN9w3vR4Qz1JQ1ENNBz5VFVMCWP6Sw7B"
cleos wallet unlock --password PW5JJFdti2wPx9NvGAZ74UN9w3vR4Qz1JQ1ENNBz5VFVMCWP6Sw7B
cleos set contract eosio /opt/git-eos/eos/build/contracts/eosio.bios/
Reading WAST/WASM from /opt/git-eos/eos/build/contracts/eosio.bios/eosio.bios.wast...
Assembling WASM...
Publishing contract...
executed transaction: 19a4c220164f864b5f7ee1aa240b9745ce2cb16fbe03297490065b8ddad3ed0c 3280 bytes 2200576 cycles
# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001581060037f7e7f0060057f7e7e7e7e...
# eosio <= eosio::setabi {"account":"eosio","abi":{"types":[],"structs":[{"name":"set_account_limits","base":"","fields":[{"n...
cleos create key
Private key: 5JWQcaFP8Fc1ZNRcc7Yofcp8bjTDjNS8EZLTxYNvhXBrhWsrQBf
Public key: EOS539erwKjbXPBjK5pUyXqDEdPnViLsXFJndPv4TtqPdz279QHN3
cleos wallet import 5JWQcaFP8Fc1ZNRcc7Yofcp8bjTDjNS8EZLTxYNvhXBrhWsrQBf
3.5 生成测试帐号
curl --data-binary '["eosio", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]' http://localhost:8888/v1/txn_test_gen/create_test_accounts
这条语句对应的参数是什么意思?这个函数是什么意思?
--data-binary以post方式提交二进制数据。
在代码里寻找create_test_accounts,有三处:
plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp:74: void create_test_accounts(const std::string& init_name, const std::string& init_priv_key) {
这个函数接受两个字符串参数,init_name和 init_priv_key。执行测试,要创建一系列账户,是用init_name来做创建者账户,init_priv_key是init_name的私钥。
3.6 模拟测试
curl --data-binary '["", 20, 20]' http://localhost:8888/v1/txn_test_gen/start_generation
start_generation这个函数,接受三个函数,第二个是周期间隔,第三个是每次产生的记录数。start_generation(const std::string& salt, const uint64_t& period, const uint64_t& batch_size)
这条语句,在每20毫秒产生20个交易记录,无法承受,会挂掉。
curl --data-binary '["", 200, 1]' http://localhost:8888/v1/txn_test_gen/start_generation
curl --data-binary '["", 50, 20]' http://localhost:8888/v1/txn_test_gen/start_generation
3.7 如果需要测试不同的参数,先停掉两个nodeos节点,然后重新启动,然后再执行3.6的新参数配置。