新手教程 EOSIO 4.0 测试网络启动教程

lome · 2018年05月13日 · 最后由 dnbstarz 回复于 2018年08月22日 · 10292 次阅读
本帖已被设为精华帖!

EOS4.0在昨天已经发布,本片文章将介绍EOS4.0网络的搭建过程。

与EOS3.0相比,EOS4.0无疑是具有重要意义的预发布版。其中对eosio.system合约的更改相当大。下面就来说一下搭建网络的具体步骤。

节点简介

首先说明一下,搭建测试网络的节点信息,以免后文更加清晰的讲述整个过程。

  1. node1(启动节点ip=111.11.11.111):
producer-name = eosio
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-peer-address = 222.22.22.222:9876
p2p-peer-address = 333.33.33.333:9876
enable-stale-production = true
  1. node2(启动节点:ip=222.22.22.222):
producer-name = eostea
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-peer-address = 111.11.11.111:9876
p2p-peer-address = 333.33.33.333:9876
enable-stale-production = false
  1. node3(启动节点:ip=333.33.33.333):
producer-name = eostea1
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-peer-address = 111.11.11.111:9876
p2p-peer-address = 222.22.22.222:9876
enable-stale-production = false

账号:lome, strahe, chare.

创建token

由于eosio.system已经没有发布代币的操作了,所有创建和发放代币只能通过eosio.token合约。

  1. 创建eosio.token账号 cleos create account eosio eosio.token EOS67Cjewqdy9kiS3uAy8RRxuYFzc4BuhMZk1crw69tdH2cVQSMw5 EOS67Cjewqdy9kiS3uAy8RRxuYFzc4BuhMZk1crw69tdH2cVQSMw5 输出结果如下: executed transaction: 4a96ee307283ca589fa9640f6e059b47bb25fae61c5b0cdb6a8810fa5a231131 288 bytes 218 us # eosio <= eosio::newaccount {"creator":"eosio","name":"eosio.token","owner":{"threshold":1,"keys":[{"key":"EOS67Cjewqdy9kiS3uAy8... warning: transaction executed locally, but may not be confirmed by the network yet
  2. 发布eosio.token合约 cleos set contract eosio.token eosio.token 结果如下: Reading WAST/WASM from eosio.token/eosio.token.wasm... Using already assembled WASM... Publishing contract... executed transaction: 04e7ef9d7434c9726b01ed964dfffc0d908f040993cb67c5a0138437e8f18e7f 8848 bytes 1421 us # eosio <= eosio::setcode {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d010000000182011560067f7e7f7f7f7f00... # eosio <= eosio::setabi {"account":"eosio.token","abi":{"types":[],"structs":[{"name":"transfer","base":"","fields":[{"name"... warning: transaction executed locally, but may not be confirmed by the network yet
  3. 创建EOS代币

    cleos  push action eosio.token create '["eosio","1000000000.0000 EOS",0,0,0]' -p eosio.token
    

    结果如下:

    executed transaction: 49fda5d0a205d867c5f92dfe1ca272bc399957c50e34340b1526fa2016da693f  208 bytes  4586 us
    #   eosio.token <= eosio.token::create          {"issuer":"eosio","maximum_supply":"1000000000.0000 EOS","can_freeze":0,"can_recall":0,"can_whitelis...
    warning: transaction executed locally, but may not be confirmed by the network yet
    
  4. 发布代币

    cleos  push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio
    

    结果如下:

    executed transaction: 33e6433957063ccea8c0afeb26c101b3064079622416b7e471e1e4a91d962124  216 bytes  632 us
    #   eosio.token <= eosio.token::issue           {"to":"eosio","quantity":"1000000000.0000 EOS","memo":"issue"}
    >> issueeosio balance: 1000000000.0000 EOS
    warning: transaction executed locally, but may not be confirmed by the network yet
    

发布eosio.system合约

注意: 

  1. 必须创建代币后才能发布合约
  2. 运行节点的主机速度必须块否则,发布合约可能会失败最后内存在16G以上。
cleos  set contract eosio eosio.system

运行结果:

Reading WAST/WASM from eosio.system/eosio.system.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: ff766928a0488566628c2ff37260937ab7b6ff2c235d65e844606754d11284a8  40368 bytes  5581 us
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001c1023060027f7e0060067f7e7e7f7f...
#         eosio <= eosio::setabi                {"account":"eosio","abi":{"types":[],"structs":[{"name":"buyrambytes","base":"","fields":[{"name":"p...
warning: transaction executed locally, but may not be confirmed by the network yet

创建账号

由于用cleos create account会出现以下错误:

$ cleos create account eosio lome2 EOS67Cjewqdy9kiS3uAy8RRxuYFzc4BuhMZk1crw69tdH2cVQSMw5 EOS67Cjewqdy9kiS3uAy8RRxuYFzc4BuhMZk1crw69tdH2cVQSMw5
Error 3080001: account using more than allotted RAM usage
Error Details:
account lome2 has insufficient ram bytes; needs 2996 has 0

错误原因是账户的ram不足,至于解决办法,笔者没有深究。所以直接用eosio.system中的newaccount操作创建账户。

创建账户代码如下:

cleos  system newaccount eosio eostea EOS8Ar1fUGtZxcJ8Rdkh3rc55Vqg3ariR6fdBV8zxz4WgTW3nT73L EOS8Ar1fUGtZxcJ8Rdkh3rc55Vqg3ariR6fdBV8zxz4WgTW3nT73L --stake-net '50.00 EOS' --stake-cpu '50.00 EOS'

执行结果如下:

1170388ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"0000000000ea3055000000001895315500200000"} arg: {"code":"eosio","action":"buyrambytes","args":{"payer":"eosio","receiver":"eostea","bytes":8192}}
1171112ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"0000000000ea3055000000001895315580f0fa020000000004454f530000000080f0fa020000000004454f530000000000"} arg: {"code":"eosio","action":"delegatebw","args":{"from":"eosio","receiver":"eostea","stake_net_quantity":"50.0000 EOS","stake_cpu_quantity":"50.0000 EOS","transfer":false}}
executed transaction: 8eae5e1e2d3ce126920fe2aa6e44376eb7c901a34dc820b0b95b0f33f8618375  424 bytes  2472 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"eostea","owner":{"threshold":1,"keys":[{"key":"EOS8Ar1fUGtZxcJ8Rdkh3rc55V...
>> eosio created eostea
#         eosio <= eosio::buyrambytes           {"payer":"eosio","receiver":"eostea","bytes":8192}
>> eosout: 0.1192 EOS 68719484928. RAM 999999.8808 EOS
#         eosio <= eosio::delegatebw            {"from":"eosio","receiver":"eostea","stake_net_quantity":"5000.0000 EOS","stake_cpu_quantity":"5000....
>> from: eosio to: eostea net: 5000.0000 EOS cpu: 5000.0000 EOStotalsvoters
warning: transaction executed locally, but may not be confirmed by the network yet

注册BP

注意这里的url是节点的http-server-address

代码如下:

cleos  system regproducer eostea EOS8Ar1fUGtZxcJ8Rdkh3rc55Vqg3ariR6fdBV8zxz4WgTW3nT73L http://http-server-address:8888

执行结果如下:

1381671ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"00000000189531550003b03a1cb0fa44023cbdb8cda51c2e0f08baf39742a6f50a241f4eee7b92c78a831a687474703a2f2f3134392e3132392e38312e3136333a36363636"} arg: {"code":"eosio","action":"regproducer","args":{"producer":"eostea","producer_key":"EOS8Ar1fUGtZxcJ8Rdkh3rc55Vqg3ariR6fdBV8zxz4WgTW3nT73L","url":"http://149.129.81.163:6666"}}
executed transaction: 835e6a4f8a892b607deac57beb64ccd558e95344ead9218a8cd8f6b51e8b6b15  256 bytes  879 us
#         eosio <= eosio::regproducer           {"producer":"eostea","producer_key":"EOS8Ar1fUGtZxcJ8Rdkh3rc55Vqg3ariR6fdBV8zxz4WgTW3nT73L","url":"h...
warning: transaction executed locally, but may not be confirmed by the network yet

转账

由于要投票必须要有EOS账号,所以在这之前通过newaccount创建投票账号。然后进行转账。

代码如下:

cleos  push action eosio.token transfer '["eosio", "lome","1000000000.0000 EOS","vote"]' -p eosio

执行结果如下:

executed transaction: 160c0e2bbd405f567dcf28e0db5c6eff12e80cb08a58dd66b5115bde27a7f44c  224 bytes  736 us
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eostea","quantity":"10000.0000 EOS","memo":"vote"}
>> transfer from eosio to eostea 10000.0000 EOS
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eostea","quantity":"10000.0000 EOS","memo":"vote"}
#        eostea <= eosio.token::transfer        {"from":"eosio","to":"eostea","quantity":"10000.0000 EOS","memo":"vote"}
warning: transaction executed locally, but may not be confirmed by the network yet

锁定代币

代码如下:

cleos system delegatebw lome lome '25000000.0000 EOS' '25000000.0000 EOS' --transfer

执行结果如下:

1717800ms thread-0   main.cpp:1002                 operator()           ] act_payload: {"from":"eostea","receiver":"eostea","stake_net_quantity":"5000.0000 EOS","stake_cpu_quantity":"5000.0000 EOS","transfer":true}
1718159ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"0000000018953155000000001895315580f0fa020000000004454f530000000080f0fa020000000004454f530000000001"} arg: {"code":"eosio","action":"delegatebw","args":{"from":"eostea","receiver":"eostea","stake_net_quantity":"5000.0000 EOS","stake_cpu_quantity":"5000.0000 EOS","transfer":true}}
executed transaction: 2eece2e97c122bb8403137290f492508b0ae0d625bc1cf56fe01348125658139  232 bytes  1996 us
#         eosio <= eosio::delegatebw            {"from":"eostea","receiver":"eostea","stake_net_quantity":"5000.0000 EOS","stake_cpu_quantity":"5000...
>> from: eostea to: eostea net: 5000.0000 EOS cpu: 5000.0000 EOStotalsvoters
#   eosio.token <= eosio.token::transfer        {"from":"eostea","to":"eosio","quantity":"10000.0000 EOS","memo":"stake bandwidth"}
>> transfer from eostea to eosio 10000.0000 EOS
#        eostea <= eosio.token::transfer        {"from":"eostea","to":"eosio","quantity":"10000.0000 EOS","memo":"stake bandwidth"}
#         eosio <= eosio.token::transfer        {"from":"eostea","to":"eosio","quantity":"10000.0000 EOS","memo":"stake bandwidth"}
warning: transaction executed locally, but may not be confirmed by the network yet

投票

激动人心的时刻到了,我们要进行投票了,在这之前,我已经在lome,strahe,chare三个投票账户分别抵押了5千万EOS,可能许多朋友都猜到了,是的,需要150,000,000.0000 TOKENS投票才能解锁网络。

投票代码如下:

cleos system voteproducer prods lome eostea

结果如下:

2581429ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"0000000000a0248d0000000000000000010000000018953155"} arg: {"code":"eosio","action":"voteproducer","args":{"voter":"lome","proxy":"","producers":["eostea"]}}
executed transaction: 5a752a45a5b26613394fecd082cdd26b0726168731e37c85f1777dbba6dff093  208 bytes  1372 us
#         eosio <= eosio::voteproducer          {"voter":"lome","proxy":"","producers":["eostea"]}
>> orig total_votes: 4.034073698549329e+22 delta: 2.017036849274665e+26
warning: transaction executed locally, but may not be confirmed by the network yet

当你的投票数超过150M时,你的节点BP将开始产生区块。

后记: 这就是一个EOS4.0测试网络搭建的全过程,但其中还有许多的东西,笔者并未深究。
例如:
1.是否投票后需要锁定三天,取消抵押需要三天后才生效。
2.创建账号是否只能够使用eosio.system合约中的newaccount
等等。。

希望后来者提出更多的问题,也期望后来者能来解决问题,谢谢~

*** 未经允许不得转载,如需转载请联系作者,谢谢!!!***

共收到 76 条回复
strahe 将本帖设为了精华贴 05月13日 20:36

部署eosio.system后就需要使用cleos system命令操作system合约,eosio.bios合约方法不再可用

部署eosio.system 合约时,报错:

Reading WAST/WASM from eosio.system/eosio.system.wasm...
Using already assembled WASM...
Publishing contract...
Error 3080006: transaction took too long
Error Details:
deadline exceeded

这个只能提升设备性能吗?感觉很坑啊,本地跑不起来

mcgtts 回复

是的,我的也是,在服务器上是可以的,不过偶尔也会报错。

mcgtts 回复

请求加上-x 1000之类的参数。

你在创建账号的时候不成功有可能是因为你部署了eosio.system这个合约,覆盖了原来的eosio.bios

alex 回复

敬谢!

@lome

由于eosio.system已经没有发布代币的操作了,所有创建和发放代币只能通过eosio.token合约。

意思是4.0之后,先前提到的 {https://eosfans.io/topics/442

在目前EOS网络中可以通过合约eosio.token产生多种名称为EOS的代币。但是还有一种通过合约eosio.system合约发布的代币,它是EOS网络中真正的EOS,他会存储在用户的账户中。可以通过cleos transfer来交易。

这种 真正的EOS,没有了?

root@iZ2zea5mjpcmz9m17k56daZ:/home/surou/Documents/github/eos/build/contracts# cleos system newaccount
ERROR: RequiredError: Subcommand required
Send eosio.system contract action to the blockchain.
Usage: cleos system SUBCOMMAND

Subcommands:
  regproducer                 Register a new producer
  unregprod                   Unregister an existing producer
  voteproducer                Vote for a producer
  delegatebw                  Delegate bandwidth
  undelegatebw                Undelegate bandwidth
  claimrewards                Claim producer rewards
  regproxy                    Register an account as a proxy (for voting)
  unregproxy                  Unregister an account as a proxy (for voting)
  postrecovery                Post recovery request
  vetorecovery                Veto a posted recovery
  canceldelay                 Cancel a delayed transaction

cleos system 下没有看到 newaccount ,pull 的最新代码

florije 回复

怎么加呢?我是用cleos set contract eosio eosio.system 命令部署合约。

Surou 回复

我用的是dawn-v4.0.0

Surou 回复

这个目前mongo_plugin不可用所以没法看

root@iZ2zea5mjpcmz9m17k56daZ:/home/surou/Documents/github/eos/build/contracts# cleos set contract eosio.token eosio.token
Reading WAST/WASM from eosio.token/eosio.token.wasm...
Using already assembled WASM...
Publishing contract...
Error 3030000: transaction validation exception
Ensure that your transaction satisfy the contract's constraint!
Error Details:
!"unresolvable": env.current_time

反复尝试都出现此问题 ,dawn-v4.0.0分支。
有没有遇到过此问题的 Orz

Surou 回复

已解决

rm -rf  eos/build
./eosio_build.sh

大版本更新 最好先 清理下,避免各种不开心

mcgtts 回复
cleos set contract eosio eosio.system -x 1000
Surou 回复

还是没成功啊

当你的投票数超过150M时,你的节点BP将开始产生区块。
root@iZ2zea5mjpcmz9m17k56daZ:/home/surou/Documents/github/eos/build/contracts# cleos system voteproducer prods eos.dos eos.cos
1048432ms thread-0   main.cpp:418                  create_action        ] result: {"binargs":"00000000d30430550000000000000000010000000053043055"} arg: {"code":"eosio","action":"voteproducer","args":{"voter":"eos.dos","proxy":"","producers":["eos.cos"]}} 
executed transaction: e8b86cdce4a40f72231aa8f0a190bd9f157462d064fcb44e83d0005c3d1aeb53  208 bytes  1882 us
#         eosio <= eosio::voteproducer          {"voter":"eos.dos","proxy":"","producers":["eos.cos"]}
>> orig total_votes: 3.973562593071089e+27 delta: 0.000000000000000e+00
warning: transaction executed locally, but may not be confirmed by the network yet

total_votes: 3.973562593071089e+27 BP还是没有产生区块,还有哪没操作对么?

cleos create account eosio eosiotoken EOS7r2x1o5qcFVEWYt3YdmA1hvRf6PmG9YWp12VNNRmtr6X8UgYuT EOS8JHjgyv4igaywBwQVh9NyqPxFWttbrkPU4rsufxCUcXuZ1ytsQ

cleos set contract eosiotoken eosio.token

Reading WAST/WASM from eosio.token/eosio.token.wasm...
Using already assembled WASM...
Publishing contract...
Error 3090003: provided keys, permissions, and delays do not satisfy declared authorizations
Error Details:
transaction declares authority '{"actor":"eosiotoken","permission":"active"}', but does not have signatures for it.

请问这是怎么回事。

yueyemingming 回复

cleos wallet import eosiotoken的私钥

谢谢。是的。

node2(启动节点:ip=222.22.22.222):
producer-name = eostea
http-server-address = 0.0.0.0:8888
p2p-listen-endpoint = 0.0.0.0:9876
p2p-peer-address = 111.11.11.111:9876
p2p-peer-address = 333.33.33.333:9876
enable-stale-production = false

按照你的教程,node2没有产生块,你的用意是只是在node1产生块吗??

enable-stale-production = true ,我把这个配置成true node2也不能产生块

shishi614 回复

p2p-peer-address,producer-name都是示例参数,需要你自己改的。

lome 回复

我知道,我改成自己的了,我想问的是你搭建过三个节点都可以产生区块的,按照你的配置只有第一个节点可以产生区块。

shishi614 回复

投票超过150M

imoonstal condition: assertion failed: unable to find key 中提及了此贴 05月17日 14:34

创建token的那个账户eosio.token是固定的名称,还是随便起个名就行?

imoonstal 回复

这个跟名字应该是无关的。

我连接一个外部的测试网络,结果出现了这个异常
964312ms thread-0 net_plugin.cpp:1185 process_next_message ] e.to_detail_string(): 8 out_of_range_exception: Out of Range
read datastream of length 1 over by 31
{"method":"read","len":1,"over":31}
thread-0 datastream.cpp:6 throw_datastream_range_error
error unpacking fc::sha256
{"type":"fc::sha256"}
thread-0 raw.hpp:602 unpack
Error unpacking field chain_id
{"field":"chain_id"}
thread-0 raw.hpp:361 operator()
error unpacking eosio::handshake_message
{"type":"eosio::handshake_message"}
thread-0 raw.hpp:602 unpack
964312ms thread-0 net_plugin.cpp:1312 request_next_chunk ] Unable to continue syncing at this time
有人知道这是什么原因吗

lome 使用 cleos 投票后 没有 producers 生成区块 中提及了此贴 05月18日 16:54
Surou 回复

我也遇到这个问题 +1

mcgtts 回复

将EOS 代币名改成 SYS

我看配置文件里面提供IP和http服务什么的.
是不是可以理解为,最近都在搞的主网启动测试,参加者角色都是竞选超级节点需要出块的?

如果没有符合硬件要求的服务器(有外网IP),那基本上不用关注,也参与不了了?

curl http://127.0.0.1:8888/v1/chain/push_transaction -X POST -d '{"compression": "none","transaction": {"expiration": "2018-05-31T10:37:06.500","ref_block_num": 1747630,"ref_block_prefix": 2309740677,"actions": [{"account": "eosio","name": "newaccount","authorization": [{"actor": "wxl","permission": "active"}],"data": "00000000000062e7000000008049b15101000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf0100000001000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca569d13df435cf01000000"}]},"signatures": ["SIG_K1_Kf4JgDozTtL9Rc2DXWL4XcegQH1Z8ATbiEDS5fxzF6PRTDZmcWVYZtYA9XEc1cytWLd6q8SVPQ67YndUEjGJnA94fEdxAq"]}'

{"code":500,"message":"Internal Service Error","error":{"code":3090003,"name":"unsatisfied_authorization","what":"provided keys, permissions, and delays do not satisfy declared authorizations","details":[{"message":"transaction declares authority '{\"actor\":\"wxl\",\"permission\":\"active\"}', but does not have signatures for it under a provided delay of 0 ms","file":"authorization_manager.cpp","line_number":405,"method":"check_authorization"}]}}这是怎么回事?

freeman 回复

提供的密钥,权限和延迟不符合声明的授权

lome 回复

如何解决呢,我也遇到了

Surou 回复

可能是时间的问题,需要把时间加上几秒,也可能是签名本身就是错误的。

37楼 已删除
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册