EOS Bios Boot Sequence

 

EOS version:v1.0.5 Date:2018-06-19
Host: Centos 7
 
     通过分析并运行eos/tutorials/bios-boot-tutorial目录下的bios-boot-tutorial.py脚本文件,结合以前的学习过的eos命令,对eos的启动过程做一个简略的分析。此文件在于用单台主机模拟eos的启动流程,最后创建了多个节点并轮流出块的环境,为以后布置多节点多主机环境创建一个良好的基础。
在运行bios-boot-tutorial.py脚本前,请安装好python及其依赖包。另外还有一些小的报错信息需要修改,比较简单,不再详述。脚本中的测试数据有20多万条,我们只取10条数据进行测试,命令如下:
./bios-boot-tutorial.py -a --producer-limit 10 --user-limit 10 --num-voters 5 --num-producers-vote 5 --producer-sync-delay 10
 
注:下面的所有命令是我根据脚本回显及脚本代码添加上去的,仅供参考。
 

1.创建默认的钱包

 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 wallet create
用于创建了一个default的钱包,其密匙为PW5JQ57Ee63S6bKPCzyZfNoFe5Se3SbaxJCSKo7oWh114VdPVLA1C;
 

2.将eosio用户和普通用户的私匙导入钱包

 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 wallet import EOS8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr
 
这里共有21个私匙导入,因为是测试数据,这里把eosio的私匙、10个普通用户的私匙、10个节点用户的私匙全部导入了default钱包里。
 

3.运行eosio 的nodeos进程

nodeos --max-irreversible-block-age 9999999 --contracts-console --genesis-json /home/hml/eos/tutorials/bios-boot-tutorial/genesis.json --blocks-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/00-eosio/blocks --config-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/00-eosio --data-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/00-eosio --chain-state-db-size-mb 1024 --http-server-address 127.0.0.1:8000 --p2p-listen-endpoint 127.0.0.1:9000 --max-clients 20 --p2p-max-nodes-per-host 20 --enable-stale-production --producer-name eosio --private-key '["EOS8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr","5K463ynhZoCDDa4RDcr63cUwWLTnKqmdcoTKTHBjqoKfv4u5V7p"]' --plugin eosio::http_plugin --plugin eosio::chain_api_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::history_api_plugin

 

4.创建用户

 
//创建9个系统用户,这9个用户必须创建,否则将无法继续进行
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 create account eosio eosio.bpay EOS857mMqsuY9T2fwxmYkZhhNJAMxjMhsNYpJGwoWvcPBfTYfe7Gq
 
这里一共需要创建9个系统用户,分别如下:
eosio.bpay: 生产者区块付款用户
eosio.msig: 多重签名,特权帐号;
eosio.name: 名字竞价的钱都会转到这个号上;
eosio.ram: 购买ram的手率真费(0.5%)会转到这个帐号上;
eosio.ramfee: 买ram的时候会产生0.5%的手续费,转到这个号上;
eosio.stake: 抵押网络和cpu资源时会得到股权,eos会转到这个帐号上,refund会从这个帐号转出;
eosio.token: 发行eosio.token合约的帐号;
eosio.saving: 未分配的通货膨胀资金用户
eosio.vpay: 生产者投票付款用户
 

5.加载智能合约

//加载token合约
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 set contract eosio.token /home/hml/eos/build/contracts/eosio.token
 
//加载多重标签合约
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 set contract eosio.msig /home/hml/eos/build/contracts/eosio.msig -p eosio.msig@active
 

6.创建并发行货币

//创建货币
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 push action eosio.token create '[ "eosio", "10000000000.0000 SYS" ]' -p eosio.token
 
//发行货币到eosio帐户
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 push action eosio.token issue '[ "eosio", "1000000000.0000 SYS", "memo" ]' -p eosio
 

7.创建系统合约

cleos --wallet-url http://localhost:6666 --url http://localhost:8000 set contract eosio /home/hml/eos/build/contracts/eosio.system -x 2000
 
注:这里的-x 2000 是指数据长度,要根据自己的数据长度具体调整大小。
 

8.设置eosio.msig为特权帐户

cleos --wallet-url http://localhost:6666 --url http://localhost:8000 push action eosio setpriv '["eosio.msig", 1]' -p eosio@active
 

9.为10个普通用户、10个生产者用户分配系统资源和货币

 
//创建普通用户useraaaaaaaa~useraaaaaaaj
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system newaccount --transfer eosio useraaaaaaaa EOS69X3383RzBZj41k73CSjUNXM5MYGpnDxyPnWUKPEtYQmTBWz4D --stake-net "207281665.4164 SYS" --stake-cpu "207281665.4163 SYS" --buy-ram "0.1000 SYS"
 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 transfer eosio useraaaaaaaa "10.0000 SYS"
 
//创建生产者用户producer111a~producer111j
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system newaccount --transfer eosio producer111a EOS8imf2TDq6FKtLZ8mvXPWcd6EF2rQwo8zKdLNzsbU9EiMSt9Lwz --stake-net "8674251.7040 SYS" --stake-cpu "8674251.7040 SYS" --buy-ram "0.1000 SYS"
 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 transfer eosio producer111a "10.0000 SYS"
 

10.将10个生产者用户注册为出块者,将来会轮巡出块

 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system regproducer producer111a EOS8imf2TDq6FKtLZ8mvXPWcd6EF2rQwo8zKdLNzsbU9EiMSt9Lwz https://producer111a.com/EOS8imf2TDq6FKtLZ8mvXPWcd6EF2rQwo8zKdLNzsbU9EiMSt9Lwz
 
//查看当前已注册为生产者的用户
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system listproducers
 
11.开启10个生产者用户的nodeos进程
 
//开户producer111b的nodeos
nodeos --max-irreversible-block-age 9999999 --contracts-console --genesis-json /home/hml/eos/tutorials/bios-boot-tutorial/genesis.json --blocks-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/02-producer111b/blocks --config-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/02-producer111b --data-dir /home/hml/eos/tutorials/bios-boot-tutorial/nodes/02-producer111b --chain-state-db-size-mb 1024 --http-server-address 127.0.0.1:8002 --p2p-listen-endpoint 127.0.0.1:9002 --max-clients 20 --p2p-max-nodes-per-host 20 --enable-stale-production --producer-name producer111b --private-key '["EOS7Ef4kuyTbXbtSPP5Bgethvo6pbitpuEz2RMWhXb8LXxEgcR7MC","5K6qk1KaCYYWX86UhAfUsbMwhGPUqrqHrZEQDjs9ekP5j6LgHUu"]' --plugin eosio::http_plugin --plugin eosio::chain_api_plugin --plugin eosio::producer_plugin --p2p-peer-address localhost:9000 --p2p-peer-address localhost:9001
 
这里用10个生产者,需要运行10个nodeos,相关的配置也要设置好。
 

11.使用已抵押的普通用户给生产者用户投票

cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system voteproducer prods useraaaaaaaa producer111d producer111i producer111c producer111b producer111e
 
投票:可以同时给多个生产者用户投票,也可以委托别人进行投票
 
//被委托的用户或者生产者需要先注册,producer111a注册为被委托人
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system regproxy producer111a
 
//委托人useraaaaaaaa 可以把投票权委托给已注册的节点或者帐户producer111a
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 system voteproducer proxy useraaaaaaaa producer111a
 

12.注销系统用户

 
当用生产者继承出块后,10个系统用户将会注销掉(eosio,eosio.bpay...).
 
//eosio注销
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 push action eosio updateauth '{"account": "eosio", "permission": "owner", "parent": "", "auth": {"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio.prods", "permission": "active"}}]}}' -p eosio@owner
 
cleos --wallet-url http://localhost:6666 --url http://localhost:8000 push action eosio updateauth '{"account": "eosio", "permission": "active", "parent": "owner", "auth": {"threshold": 1, "keys": [], "waits": [], "accounts": [{"weight": 1, "permission": {"actor": "eosio.prods", "permission": "active"}}]}}' -p eosio@active
 
 
到此为止,eos将正式启动,由系统合约创建的10个生产者将接替eosio用户进行出块,每个用户每次出块12个,系统用户eosio将不再参与出块。
posted @ 2018-06-27 17:10  HBright  阅读(976)  评论(0编辑  收藏  举报