以太坊私有链搭建——POA(多服务器)

以太坊私有链搭建——POA(多服务器)

一、环境准备

参考往期文章:以太坊私有链搭建——POA(单主机)

注意geth版本问题

二、以太坊POA搭建

1、创建文件夹

mkdir node1,node2,node3

2、创建钱包账户

geth --datadir node1 account new

0x81F1572b96c8124963E56773D53136F8771fbd0E

geth --datadir node2 account new

0x0F63F5f33E5A526e0C83d847ECB5178c481BfDbe

geth --datadir node3 account new

0x16CDF66aEaB4E2beD4f322CC27eD4014D15C0C4C

记录下账户地址,如下所示

在这里插入图片描述

3、配置初始化文件(创世块等信息)

运行指令:puppeth

root@0da3d8e84434:/workspace/app/poachain3# puppeth
+-----------------------------------------------------------+
| Welcome to puppeth, your Ethereum private network manager |
|                                                           |
| This tool lets you create a new Ethereum network down to  |
| the genesis block, bootnodes, miners and ethstats servers |
| without the hassle that it would normally entail.         |
|                                                           |
| Puppeth uses SSH to dial in to remote servers, and builds |
| its network components out of Docker containers using the |
| docker-compose toolset.                                   |
+-----------------------------------------------------------+

Please specify a network name to administer (no spaces, hyphens or capital letters please)
> poachain

Sweet, you can set this via --network=poachain next time!

INFO [03-11|06:13:29.924] Administering Ethereum network           name=poachain
WARN [03-11|06:13:29.924] No previous configurations found         path=/root/.puppeth/poachain

What would you like to do? (default = stats)
 1. Show network stats
 2. Configure new genesis
 3. Track new remote server
 4. Deploy network components
> 2

What would you like to do? (default = create)
 1. Create new genesis from scratch
 2. Import already existing genesis
> 1

Which consensus engine to use? (default = clique)
 1. Ethash - proof-of-work
 2. Clique - proof-of-authority
> 2

How many seconds should blocks take? (default = 15)
> 10

Which accounts are allowed to seal? (mandatory at least one)
> 0x81F1572b96c8124963E56773D53136F8771fbd0E
> 0x

Which accounts should be pre-funded? (advisable at least one)
> 0x81F1572b96c8124963E56773D53136F8771fbd0E
> 0x

Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)
>

Specify your chain/network ID if you want an explicit one (default = random)
> 10011
INFO [03-11|06:14:10.391] Configured new genesis block

What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components
>

4、生成poa_test.json文件

What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components
> 2

 1. Modify existing configurations
 2. Export genesis configurations
 3. Remove genesis configuration
> 2

Which folder to save the genesis specs into? (default = current)
  Will create poachain.json, poachain-aleth.json, poachain-harmony.json, poachain-parity.json
>
INFO [03-11|06:16:32.957] Saved native genesis chain spec          path=poachain.json
ERROR[03-11|06:16:32.962] Failed to create Aleth chain spec        err="unsupported consensus engine"
ERROR[03-11|06:16:32.962] Failed to create Parity chain spec       err="unsupported consensus engine"
INFO [03-11|06:16:32.964] Saved genesis chain spec                 client=harmony path=poachain-harmony.json

What would you like to do? (default = stats)
 1. Show network stats
 2. Manage existing genesis
 3. Track new remote server
 4. Deploy network components
>

可以发现文件夹下多了

poachain-harmony.json poachain.json

5、初始化私有链

./geth --datadir node1/data init poachain.json
./geth --datadir node2/data init poachain.json
./geth --datadir node3/data init poachain.json

把node2和node3文件分别发到另外两台服务器

scp ./node2 root@192.168.5.23:/root/Desktop/poachain

6、在各节点(主机)分别启动私有链

主机1:./geth --datadir node1/data --networkid 10011 --port 3000 console

主机2:./geth --datadir node2/data --networkid 10011 --port 3000 console

主机3:./geth --datadir node3/data --networkid 10011 --port 3000 console

7、建立节点通信

在node2,node3的分别进行如下操作,连接node1:admin.addPeer("enode://e4bcc55c8798a5dabd6ee5335816471d97f21588874da48ceaccefca6058aa84c931df2ad03484a0fc41445186b9febef092cc97829e5f51f5ad2932a2d07e5b@192.168.5.22:3000")

节点1的enode可以在节点1运行admin.nodeInfo查看,注意需要把127.0.0.1换为主机1的ip地址

三、验证交易配置

1、在主机3执行:

miner.start()

这样就可以对交易进行挖矿验证了,否则当交易发生时不会确认,即转账交易在未打包交易池中不会进行转账操作,只有挖矿验证该交易才会实际发生转账

2、在已经是授权节点node3的console上执行,即给node4节点授权

clique.propose("0x5e390a88062c4f8eff2686cdef5b4c5abe7d7f7e",true)

3、node4重新启动

./geth --datadir node4/data --networkid 10011 --port 3003 --unlock 5e390a88062c4f8eff2686cdef5b4c5abe7d7f7e console

这样的话node3,node4一起进行挖矿,验证一笔交易需要二者的签名

‍其他基础操作查看:以太坊私有链搭建

  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值