[EOS]单机部署测试网络(两个节点)
2018-06-04 本文已影响127人
ytxing
[EOS]单机部署测试网络(两个节点)
参考
https://github.com/EOSIO/eos/wiki/Testnet-Single-Host-Multinode
启动第一个节点
$ nohup ./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::wallet_api_plugin &
加载bios合约
$ cleos set contract eosio build/contracts/eosio.bios
Reading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 964d6e27d35e3a94e8c1ff33012c34d2d407c05312f5a10baad64dfba445e6ac 3712 bytes 748 us
# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001621260037f7e7f0060057f7e7e7e7e...
# eosio <= eosio::setabi {"account":"eosio","abi":"0e656f73696f3a3a6162692f312e30050c6163636f756e745f6e616d65046e616d650f7065...
warning: transaction executed locally, but may not be confirmed by the network yet
创建producernde1账户
作为第二个节点的生产者账户
$ cleos create account eosio producernde1 EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV EOS5Kth7yY94SHU54X7dvpUnthrfnRwgWSDBsdbuYPyEAbczdxRss
executed transaction: 1333aca9491e214740e89cc4cefcf26a64a38b38177f693900a779712090c1cb 200 bytes 253 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"producernde1","owner":{"threshold":1,"keys":[{"key":"EOS8UCi6r82EvzxKd5KF...
warning: transaction executed locally, but may not be confirmed by the network yet
启动第二个节点
$ nohup nodeos --producer-name producernde1 --plugin eosio::chain_api_plugin --plugin eosio::net_api_plugin --http-server-address 127.0.0.1:8889 --p2p-listen-endpoint 127.0.0.1:9877 --p2p-peer-address 127.0.0.1:9876 --config-dir node2 --data-dir node2 --private-key [\"EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV\",\"${owner-private-key}\"] &
设置产出权限
$ cleos push action eosio setprods "{ \"schedule\": [{\"producer_name\": \"producernde1\",\"block_signing_key\": \"EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV\"}]}" -p eosio@active
executed transaction: 076cabc41e12ed77665034858dc45eb8ef20b55b221d657377d5a3dedb371b9b 136 bytes 354 us
# eosio <= eosio::setprods {"schedule":[{"producer_name":"producernde1","block_signing_key":"EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5...
warning: transaction executed locally, but may not be confirmed by the network yet
检查
$ cleos get info
{
"server_version": "d9df25ac",
"chain_id": "706a7ddd808de9fc2b8879904f3b392256c83104c1d544b38302cc07d9fca477",
"head_block_num": 508089,
"last_irreversible_block_num": 508088,
"last_irreversible_block_id": "0007c0b865a1adbf4b9d0f4f8d9bb20bebd3531b7841102fb874c9a78a761d00",
"head_block_id": "0007c0b9f727c1b4d01fd2f0c99f07ef380f4b57b755f1026353efeffebf01df",
"head_block_time": "2018-06-04T02:16:29",
"head_block_producer": "producernde1",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}
$ cleos -u http://localhost:8889 get info
{
"server_version": "d9df25ac",
"chain_id": "706a7ddd808de9fc2b8879904f3b392256c83104c1d544b38302cc07d9fca477",
"head_block_num": 508125,
"last_irreversible_block_num": 508124,
"last_irreversible_block_id": "0007c0dcc2afe567b533dd743a944830f2502ec60dbe1c002ca4b1ec4dd9c132",
"head_block_id": "0007c0dd1b22286c2b29d732f73627c00de6f1d8ae52fcb68d5d63404009fa9c",
"head_block_time": "2018-06-04T02:16:47",
"head_block_producer": "producernde1",
"virtual_block_cpu_limit": 200000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}
多个区块生产者
上边的设置,只让其中一个节点产出区块,设置后第一个节点的eosio就不再产生区块,如果想让第一个产生,可以这样设置
cleos push action eosio setprods "{ \"schedule\": [{\"producer_name\": \"eosio\",\"block_signing_key\": \"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\"}]}" -p eosio@active
或者同时让两个节点都产生区块
cleos push action eosio setprods "{ \"schedule\": [{\"producer_name\": \"eosio\",\"block_signing_key\": \"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV\"},{\"producer_name\": \"producernde1\",\"block_signing_key\": \"EOS8UCi6r82EvzxKd5KFv3um3fnfaczqZ5aWT6L4zb9ZkHGQUkVkV\"}]}" -p eosio@active