简介
此篇重点讲述如何在docker下部署6个节点的eos网络。使用eos1.4.1,并且再上一篇单节点docker部署的基础上完成。
多节点搭建的过程如下
创世节点搭建->创建钱包->解锁钱包->导入所有的私钥->创建系统账户->部署系统合约->发行SYS Token->授予eosio.msig特权->创建节点账号与普通账号->注册为生产者->配置新的EOS节点->用户投票->新的节点开始轮流出块->移除eosio特权账户
- eosio.token 发行和管理token的账户;
- eosio.msig 多重签名管理的账户;
- eosio.ram 内存买卖管理的账户;
- eosio.ramfee 内存买卖收取手续费的账户,按照每笔交易千分之5的费率收取手续费;
- eosio.stake 管理EOS抵押的账户;
- eosio.names 靓号账户拍卖管理的账户;
- eosio.saving 增发EOS临时存放账户,增发总量 5%,其中80%放在此账户,另外 20%再分成25%和75%,分别给eosio.bpay和eosio.vpay;
- eosio.bpay 矿工获取出块奖励的临时代管账户,增发EOS的1%的25%会先转到这个账户;
- eosio.vpay 矿工按照获得投票多少比例获取奖励的临时代管账户,增发EOS的1%的75%会先转到这个账户。
- eosio.token
- eosio.msig 此部署后需要授予eosio.msig特权
- eosio.system 最后部署,并且部署前将合约代码中的21全部修改为5(共两处;主网为21个生产节点)。
第一个EOS节点
首先请看上一篇单节点docker部署,完成docker环境的基本搭建,并使用如下命令创建第一个nodeos(相比上一篇仅仅多开放一个8288端口,是用来组建p2p网络的端口)
$ docker run \
--name nodeos1 -d -p 8888:8888 -p 8288:8288 \
--network eosdev \
--ip 172.18.0.11 \
--privileged=true \
-v /home/eosio/nodeos1/work:/work \
-v /home/eosio/nodeos1/data:/mnt/dev/data \
-v /home/eosio/nodeos1/config:/mnt/dev/config \
eosio/eos-dev \
/bin/bash -c \
"nodeos -d /mnt/dev/data --config-dir /mnt/dev/config"
再使用上篇一样的命令创建一个keosd
的容器:
$ docker run -d --name keosd \
--network=eosdev \
--ip 172.18.0.10 \
-i eosio/eos-dev /bin/bash -c "keosd --http-server-address=0.0.0.0:9876"
确认两个容器都再正常运行,然后创建数个密钥。
然后开始:创建钱包->解锁钱包->导入所有的私钥->创建系统账户->部署系统合约->发行SYS Token->授予eosio.msig特权->创建节点账号与普通账号->注册为生产者。这个流程看起来比较长,写成shell脚本执行。如下:
#!/bin/bash --login
URL="http://127.0.0.1:8888"
WTURL="http://172.18.0.10:9876"
alias cleos='docker exec -it nodeos1 /opt/eosio/bin/cleos --url "${URL}" --wallet-url "${WTURL}"'
alias eosiocpp='docker exec -it nodeos1 /opt/eosio/bin/eosiocpp'
shopt -s expand_aliases
# 解锁钱包
cleos wallet unlock --password PW5K6vKpt69VD9t4gZxRCHpNWC49wubwiKosQEgQYMH8Jf7SP9Dni
# 导入密钥
cleos wallet import --private-key 5JRM3h5y6nWZxYwvGjKNjKAPxT2Jc22QnidLcoms6P3vw4BNqbf
cleos wallet import --private-key 5KSzVdujy6J31ALfULwAAAnaoj8H377eURv39s8VQ1ij4NKoBoe
cleos wallet import --private-key 5J67dbxvh9rKuJWbGVS2ef24wtXsGH6WCx8wNLJQ68XwLpZU9bu
cleos wallet import --private-key 5HsKeJf7d6YYjDrZYt6J7ax6JP85S5bc14TBWtRWodA67CrSLWr
cleos wallet import --private-key 5JpkxcQ6dX8eSjacT9R4GwUAp7PAZyxt7xoMGEspG9ANdzddgB7
cleos wallet import --private-key 5KQ1MzBpKgZB1rX5nQ9jaUqCRGm7EV7pfFfVmFxuibsofFgafgA
cleos wallet import --private-key 5HvYbZHFyFRXd2axK4Dzm9gGP8S6cPoTZuqFS3tHgYWpAb1YFDy
cleos wallet import --private-key 5KaW3M8GKaTTsFMh5VrFNxru2YGznc4PpTCGLYd7Sz7B8j8ZSiU
# eosio key
cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
# 创建账户
cleos create account eosio eosio.token EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.msig EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.ram EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.ramfee EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.stake EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.names EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.savin EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.bpay EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
cleos create account eosio eosio.vpay EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu EOS6ggwSrZ4yGFKsnzESw4xzD8LsWB4YgCrqmqVh4pE5NgYrkPWvu
# 编译合约
eosiocpp -o /work/contracts/eosio.system/eosio.system.wast /work/contracts/eosio.system/eosio.system.cpp
eosiocpp -o /work/contracts/eosio.msig/eosio.msig.wast /work/contracts/eosio.msig/eosio.msig.cpp
# 部署系统合约并发行token
cleos set contract eosio.token /work/contracts/eosio.token -p eosio.token@active
cleos push action eosio.token create '["eosio", "10000000000.0000 SYS"]' -p eosio.token@active
cleos push action eosio.token issue '["eosio", "1000000000.0000 SYS", "memo"]' -p eosio@active
cleos set contract eosio.msig /work/contracts/eosio.msig -p eosio.msig@active
cleos set contract eosio /work/contracts/eosio.system -p eosio@active
# 授予eosio.msig特权
cleos push action eosio setpriv '["eosio.msig", 1]' -p eosio@active
# 创建账号
cleos system newaccount eosio --transfer producer.cya EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
cleos system newaccount eosio --transfer producer.cyb EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
cleos system newaccount eosio --transfer producer.cyc EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
cleos system newaccount eosio --transfer producer.cyd EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
cleos system newaccount eosio --transfer producer.cye EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
cleos system newaccount eosio --transfer producer.cyf EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa --stake-net "1000000.0000 SYS" --stake-cpu "1000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
# 将账号注册为生产者
cleos system regproducer producer.cya EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cya
cleos system regproducer producer.cyb EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cyb
cleos system regproducer producer.cyc EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyc
cleos system regproducer producer.cyd EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyd
cleos system regproducer producer.cye EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cye
cleos system regproducer producer.cyf EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cyf
上述的过程省略部分内容,比如钱包的创建、普通用户、分配token等,这些比较简单,可以自己搞定。
将用户注册为生产者之后就可以查看他们得票数了:
$ cleos system listproducers
Producer Producer key Url Scaled votes
producer.cya EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cya 0.0000
producer.cyb EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cyb 0.0000
producer.cyc EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyc 0.0000
producer.cyd EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyd 0.0000
producer.cye EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cye 0.0000
producer.cyf EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cyf 0.0000
然而我们并没有给他投票,这只是确认节点账户被我们正确的添加为生产者。再最后一部我们再给节点投票,让其开始工作。
创建生产节点
将用户注册为生产者之后,重新创建两新的docker容器为我们producer.cya
与producer.cyb
账号使用,其他几个账号也是同样的方法,不过我这里会将其他生产者部署到别的机器上,但是基本方法都是雷同的,这里就使用这两个作为例子:
# producer.cya
$ docker run \
--name nodeos2 -d -p 8889:8889 -p 8289:8289 \
--network eosdev \
--ip 172.18.0.12 \
--privileged=true \
-v /home/eosio/nodeos2/work:/work \
-v /home/eosio/nodeos2/data:/mnt/dev/data \
-v /home/eosio/nodeos2/config:/mnt/dev/config \
eosio/eos-dev \
/bin/bash -c \
"nodeos -d /mnt/dev/data --config-dir /mnt/dev/config"
# producer.cyb
$ docker run \
--name nodeos3 -d -p 8890:8890 -p 8290:8290 \
--network eosdev \
--ip 172.18.0.13 \
--privileged=true \
-v /home/eosio/nodeos3/work:/work \
-v /home/eosio/nodeos3/data:/mnt/dev/data \
-v /home/eosio/nodeos3/config:/mnt/dev/config \
eosio/eos-dev \
/bin/bash -c \
"nodeos -d /mnt/dev/data --config-dir /mnt/dev/config"
其他生产节点的配置
在这里我将再同一个docker内新增两个eos节点容器nodeos2
与nodeos3
。
节点 | docker内部网络 | p2p-port | RPC-port | 绑定账户 |
---|---|---|---|---|
nodeos1 | 172.18.0.11 | 0.0.0.0:8288 | 0.0.0.0:8888 | eosio |
nodeos2 | 172.18.0.12 | 0.0.0.0:8289 | 0.0.0.0:8889 | producer.cya |
nodeos3 | 172.18.0.13 | 0.0.0.0:8290 | 0.0.0.0:8890 | producer.cyb |
... | | | |||
... | | |
其他节点雷同。
创建后这两个容器处于待机中,先将这两个容器关闭,让我们先配置对应的config.ini
,以下是nodeos2
的配置文件(依然是除去默认配置之外的修改项),nodeos3
的配置雷同。
p2p-listen-endpoint = 0.0.0.0:8289
http-server-address = 0.0.0.0:8889
p2p-peer-address = 172.18.0.11:8288
p2p-peer-address = 172.18.0.13:8290
enable-stale-production = true
producer-name = producer.cya
plugin = eosio::producer_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
plugin = eosio::history_api_plugin
plugin = eosio::bnet_plugin
http-validate-host = 0
access-control-allow-origin = *
verbose-http-errors = true
filter-on = *
contracts-console = true
signature-provider = EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq=KEY:5KSzVdujy6J31ALfULwAAAnaoj8H377eURv39s8VQ1ij4NKoBoe
chain-state-db-size-mb = 10240
agent-name = "EOS Test Agent8889"
一定要将p2p-peer-address
配正确,再同一个的服务器内docker容器连接容器需要使用docker网络的IP,比如下图nodeos1
的172.18.0.11
,但是不适用与两台不同的机器:
$ docker network inspect eosdev
[
{
"Name": "eosdev",
"Id": "2a65feabd6ffc41f46d102b4309f39e2af57c599e5a7fc253ae241e06cf29cfd",
"Created": "2018-10-31T15:16:40.068224357+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"6be54ea999e5c74cd223690ef7210938dbeafa0ee776d5040d296b7e6a017c38": {
"Name": "nodeos2",
"EndpointID": "8c835b894010baec5c05f1eed169509eca86fabb3ea300f05a1be6f722ad2798",
"MacAddress": "02:42:ac:12:00:0c",
"IPv4Address": "172.18.0.12/16",
"IPv6Address": ""
},
"6c5265fa4b84323ceec535258815d342245d6f20393880472bd1f736c4d85847": {
"Name": "keosd",
"EndpointID": "9bfa31c2cc30be7b534c9084ef4b43d721eddf7cf3050151db184db2d47fc81c",
"MacAddress": "02:42:ac:12:00:0a",
"IPv4Address": "172.18.0.10/16",
"IPv6Address": ""
},
"702e66f3f092d742bbcb0170feb3443534cf4a727841c436c42c359987f6a549": {
"Name": "nodeos1",
"EndpointID": "1c6267abd9eac8634961694146aa279bd99ac582f507f30817145a81541c092a",
"MacAddress": "02:42:ac:12:00:0b",
"IPv4Address": "172.18.0.11/16",
"IPv6Address": ""
},
"ecffaabc4f9410043bbc537ee9cd7a2cb49f7af69867865513888cb29392445b": {
"Name": "nodeos3",
"EndpointID": "0904d2fd77c91bd4437d038c571581b1edf3d500fa0686a5c722679753dfa5b2",
"MacAddress": "02:42:ac:12:00:0d",
"IPv4Address": "172.18.0.13/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
配置完节点的config.ini
然后就可以启动容器了,如果启动成功的话,打印容器的日志能看到节点再同步之前的区块,而新的区块依然是由eosio生产的:
$ docker logs --tail 10 nodeos2
info 2018-11-01T09:51:33.831 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 7469030bca1c12fe... #29000 @ 2018-11-01T05:26:06.000 signed by eosio [trxs: 0, lib: 28999, conf: 0, latency: 15927831 ms]
info 2018-11-01T09:51:34.027 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block be62ee588fc698cd... #30000 @ 2018-11-01T05:34:26.000 signed by eosio [trxs: 0, lib: 29999, conf: 0, latency: 15428027 ms]
info 2018-11-01T09:51:34.222 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 35a2d7d1cbe18743... #31000 @ 2018-11-01T05:42:46.000 signed by eosio [trxs: 0, lib: 30999, conf: 0, latency: 14928222 ms]
info 2018-11-01T09:51:34.414 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block c6c5029d7efc4366... #32000 @ 2018-11-01T05:51:06.000 signed by eosio [trxs: 0, lib: 31999, conf: 0, latency: 14428414 ms]
info 2018-11-01T09:51:34.613 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block edf3543581a681cd... #33000 @ 2018-11-01T05:59:26.000 signed by eosio [trxs: 0, lib: 32999, conf: 0, latency: 13928613 ms]
info 2018-11-01T09:51:34.811 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block a2e0100d0e9e2385... #34000 @ 2018-11-01T06:07:46.000 signed by eosio [trxs: 0, lib: 33999, conf: 0, latency: 13428811 ms]
info 2018-11-01T09:51:35.004 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 3eaf4ede2c069978... #35000 @ 2018-11-01T06:16:06.000 signed by eosio [trxs: 0, lib: 34999, conf: 0, latency: 12929004 ms]
info 2018-11-01T09:51:35.196 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block a7bbdf82217155a3... #36000 @ 2018-11-01T06:24:26.000 signed by eosio [trxs: 0, lib: 35999, conf: 0, latency: 12429196 ms]
info 2018-11-01T09:51:35.388 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block a38414f88addffa0... #37000 @ 2018-11-01T06:32:46.000 signed by eosio [trxs: 0, lib: 36999, conf: 0, latency: 11929388 ms]
info 2018-11-01T09:51:35.586 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 2412aeec52101353... #38000 @ 2018-11-01T06:41:06.000 signed by eosio [trxs: 0, lib: 37999, conf: 0, latency: 11429586 ms]
$ docker logs --tail 10 nodeos3
info 2018-11-01T09:52:47.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 3e55a27c76a231d1... #61003 @ 2018-11-01T09:52:47.500 signed by eosio [trxs: 0, lib: 61002, conf: 0, latency: 0 ms]
info 2018-11-01T09:52:48.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block b6fa5be20ec314c8... #61004 @ 2018-11-01T09:52:48.000 signed by eosio [trxs: 0, lib: 61003, conf: 0, latency: 2 ms]
info 2018-11-01T09:52:48.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 05245ca9539dc880... #61005 @ 2018-11-01T09:52:48.500 signed by eosio [trxs: 0, lib: 61004, conf: 0, latency: 0 ms]
info 2018-11-01T09:52:49.001 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block c2282537973c02de... #61006 @ 2018-11-01T09:52:49.000 signed by eosio [trxs: 0, lib: 61005, conf: 0, latency: 1 ms]
info 2018-11-01T09:52:49.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 0c664eb752962a1e... #61007 @ 2018-11-01T09:52:49.500 signed by eosio [trxs: 0, lib: 61006, conf: 0, latency: 0 ms]
info 2018-11-01T09:52:50.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 40359bdb68673886... #61008 @ 2018-11-01T09:52:50.000 signed by eosio [trxs: 0, lib: 61007, conf: 0, latency: 2 ms]
info 2018-11-01T09:52:50.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 3007e6b7510ffb1c... #61009 @ 2018-11-01T09:52:50.500 signed by eosio [trxs: 0, lib: 61008, conf: 0, latency: 0 ms]
info 2018-11-01T09:52:51.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 23dd1cf734f2f6a8... #61010 @ 2018-11-01T09:52:51.000 signed by eosio [trxs: 0, lib: 61009, conf: 0, latency: 2 ms]
info 2018-11-01T09:52:51.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block a3835e6081a3c637... #61011 @ 2018-11-01T09:52:51.500 signed by eosio [trxs: 0, lib: 61010, conf: 0, latency: 0 ms]
info 2018-11-01T09:52:52.003 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block a9a895b8c72d4ea2... #61012 @ 2018-11-01T09:52:52.000 signed by eosio [trxs: 0, lib: 61011, conf: 0, latency: 3 ms]
其他的几个节点也是雷同的方法。
用户选举投票
实质上之前我们已经完成了多节点网络的搭建,只不过我们设定的生产者并没有开始生产区块,要让特定的节点生产区块必须要全网的投票达到一定数量,此规则这里不再赘述,直接开始投票;可以使用节点用户为自己投票,也可以使用其他账号进行不同的投票:
$ cleos system newaccount eosio --transfer voteaccounta EOS6MsdPhDAuBW4yaPnBdLqKs231fQ9S4wkpXNNCEqtobGeuf73Cs EOS6MsdPhDAuBW4yaPnBdLqKs231fQ9S4wkpXNNCEqtobGeuf73Cs --stake-net "10000000.0000 SYS" --stake-cpu "10000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
$ cleos system newaccount eosio --transfer voteaccountb EOS6MsdPhDAuBW4yaPnBdLqKs231fQ9S4wkpXNNCEqtobGeuf73Cs EOS6MsdPhDAuBW4yaPnBdLqKs231fQ9S4wkpXNNCEqtobGeuf73Cs --stake-net "10000000.0000 SYS" --stake-cpu "10000000.0000 SYS" --buy-ram-kbytes 8192 -p eosio@active
.....
.....
我们发行的tonken总量为10亿,按照要求需要至少15%的投票主网才算成功,及1.5亿的token投票;上述一个账户为0.2亿抵押的token,按照上边的多创建几个账户并进行投票:
$ cleos system voteproducer prods voteaccounta producer.cya -p voteaccounta@active
$ cleos system voteproducer prods voteaccountb producer.cyb -p voteaccountb@active
.....
.....
已经投票的token总量可以使用以下命令查看:
$ cleos get table eosio eosio global
{
"rows": [{
"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,
"max_ram_size": "68719476736",
"total_ram_bytes_reserved": 108480099,
"total_ram_stake": 15810893,
"last_producer_schedule_update": "2018-11-02T03:32:53.500",
"last_pervote_bucket_fill": "1541129574000000",
"pervote_bucket": 0,
"perblock_bucket": 0,
"total_unpaid_blocks": 45,
"total_activated_stake": "1520000000000",
"thresh_activated_stake_time": "1541129573500000",
"last_producer_schedule_size": 5,
"total_producer_vote_weight": "1703642049428201472.00000000000000000",
"last_name_close": "2000-01-01T00:00:00.000"
}
],
"more": false
}
其中total_activated_stake
除10000及为已经投票的token数量,再这里发现一个问题:如果是eosio账户直接转账出来的token进行抵押投票不会改变此字段,但是会影响投票比率。
节点得票比例:
$ cleos system listproducers
Producer Producer key Url Scaled votes
producer.cya EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cya 0.2898
producer.cyb EOS8Z7D7qJW9R1EbWXKwTrMQDM6W4b3kKmZmtJLw8Sbda4dMeLNVq https://producer.cyb 0.2330
producer.cyc EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyc 0.1193
producer.cyd EOS5sDeBRGjd9L66mFvnd86rMYvVH4Vx9supmwTKtZSqJBwkaHpcH https://producer.cyd 0.1193
producer.cye EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cye 0.1193
producer.cyf EOS68BWJ1AheB45Bf98XVYgrNUKSkniqiyKL1S29rizpyR3z9cvUa https://producer.cyf 0.1193
当达到15%的要求之后,我们新部署的节点就开始替代eosio交替生产区块了:
$ docker logs --tail 20 nodeos2
info 2018-11-02T04:02:32.001 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4c73d59ff48... #189639 @ 2018-11-02T04:02:32.000 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:32.500 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4c844ff6a08... #189640 @ 2018-11-02T04:02:32.500 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:33.001 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4c960fd1e7d... #189641 @ 2018-11-02T04:02:33.000 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:33.500 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4ca78c10946... #189642 @ 2018-11-02T04:02:33.500 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:34.001 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4cb20d7c072... #189643 @ 2018-11-02T04:02:34.000 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:34.500 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4cc8ff082d1... #189644 @ 2018-11-02T04:02:34.500 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:35.001 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4cd60467602... #189645 @ 2018-11-02T04:02:35.000 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:35.500 thread-0 producer_plugin.cpp:1490 produce_block ] Produced block 0002e4ce59a832ac... #189646 @ 2018-11-02T04:02:35.500 signed by producer.cya [trxs: 0, lib: 188217, confirmed: 0]
info 2018-11-02T04:02:36.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 4871e01b890b78c4... #189647 @ 2018-11-02T04:02:36.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 12, latency: 2 ms]
info 2018-11-02T04:02:36.501 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block c844c0712b676020... #189648 @ 2018-11-02T04:02:36.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 1 ms]
info 2018-11-02T04:02:37.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 3a505960ffa92bac... #189649 @ 2018-11-02T04:02:37.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 2 ms]
info 2018-11-02T04:02:37.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block f352af1e8b97976f... #189650 @ 2018-11-02T04:02:37.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 0 ms]
info 2018-11-02T04:02:38.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 2781dbf500213003... #189651 @ 2018-11-02T04:02:38.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 2 ms]
info 2018-11-02T04:02:38.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 5b864e6efee76cf1... #189652 @ 2018-11-02T04:02:38.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 0 ms]
info 2018-11-02T04:02:39.003 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block efa84826c9d42b60... #189653 @ 2018-11-02T04:02:39.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 3 ms]
info 2018-11-02T04:02:39.501 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block e5ae9eb5db800cce... #189654 @ 2018-11-02T04:02:39.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 1 ms]
info 2018-11-02T04:02:40.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 96f42c86efc2042f... #189655 @ 2018-11-02T04:02:40.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 2 ms]
info 2018-11-02T04:02:40.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 5da13fdcc067561b... #189656 @ 2018-11-02T04:02:40.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 0 ms]
info 2018-11-02T04:02:41.002 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 7d485d53dabcbe71... #189657 @ 2018-11-02T04:02:41.000 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 2 ms]
info 2018-11-02T04:02:41.500 thread-0 producer_plugin.cpp:337 on_incoming_block ] Received block 5ecca5e1fbbfe6c0... #189658 @ 2018-11-02T04:02:41.500 signed by producer.cyb [trxs: 0, lib: 188217, conf: 0, latency: 0 ms]
eosio账户权限消除
到这里多节点网络已经是完整的搭建了,但是还是有一点瑕疵,存在eosio特权账户,作为区块链网络这种特权不应该存在,所以需要将此账户的控制权限移除。比如eosio、eosio.token等等,按照官网的介绍使用以下命令移除密钥:
$ cleos 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 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
当然自己的测试环境还是保留此类账户控制权比较好。
.
.
.
.
.
.
【本文章出自NM1024.com,转载请注明作者出处。】
>>转载请注明原文链接地址:多节点EOS网络搭建
按照教程的方式,创建了3个节点,但是 Scaled votes 为0.5 不知道为啥 不会生产区块
如果是eosio账户直接转账出来的token进行抵押投票,实际上没有纳入15%总票数的统计,但是会影响投票比率