PlatON之初体验--PPA方式安装及加入链

[toc]

1、条件

  • 说明,这次安装是根据platon0.8.0(即现在拉力赛的版本安装的),节点加入的是公有网络(我们单个节点通常都是加入公有网络,除非自己有许多的节点才考虑自己搭私有网络)。

1.1、硬件要求

  • Ubuntu18.04(据说官方也是ubuntu18.04,我们也用,安装成功率会大大提高)
  • 磁盘至少100G
  • CPU:4核
  • 内存:8G

1.2、时间同步

tom@localhost:~$sudo apt -y install ntp
tom@localhost:~$sudo systemctl start ntp && sudo systemctl enable ntp

1.3、创建一个用户tom用户

tom@localhost:~$useradd -r -m -s /bin/bash tom
tom@localhost:~$passwd tom #设置tom用户密码,输入两次

1.4、配置/etc/hosts

vim /etc/hosts
10.10.8.4 localhost #前者是你的ip,后者是hostname命令的执行结果输入

2、 安装platon

  • 安装platon0.8.0版本
# 1、添加platon的ppa源
tom@localhost:~$ sudo add-apt-repository ppa:ppatwo/platon
# 2、查看是否添加源成功
tom@localhost:~$ cat /etc/apt/sources.list.d/ppatwo-ubuntu-platon-bionic.list 
deb http://ppa.launchpad.net/ppatwo/platon/ubuntu bionic main
# 3、更新
tom@localhost:~$ sudo apt update -y
# 4、查看是否有platon0.8.0版本
tom@localhost:~$ sudo apt search platon0.8.0
platon0.8.0/bionic 0.8.0.3 amd64
  PlatON client
# 5、安装platon0.8.0版本
tom@localhost:~$ sudo apt install platon0.8.0
# 6、验证版本是否和链的一致,检查Commit一致就可以,链的Commit为:6b4a2cd340e87b82f7ffa008126113d350cde5a8
tom@localhost:~$ sudo platon version
.....
Git Commit: 6b4a2cd340e87b82f7ffa008126113d350cde5a8
.....省略
# 7、查看是否有keytool和platon
tom@localhost:~$ which keytool platon
/usr/bin/keytool
/usr/bin/

3、启动

  • 使用的是tom用户,进入/home/tom目录

3.1、生成两对key

# 1、创建data目录,节点公私钥和节点bls公私钥,节点的运行数据就放在platon-node目录下
tom@localhost:~$mkdir -p /home/tom/platon-node/data
tom@localhost:~$keytool genkeypair | tee >(grep "PrivateKey" | awk '{print $2}' > ./data/nodekey) >(grep "PublicKey" | awk '{print $3}' > ./data/nodeid)                 #节点公私钥
tom@localhost:~$ keytool genblskeypair | tee >(grep "PrivateKey" | awk '{print $2}' > ./data/blskey) >(grep "PublicKey" | awk '{print $3}' > ./data/blspub)  #节点bls公私钥
# 2、查看两对key
tom@localhost:~$ ls /home/tom/platon-node/data/
blskey  blspub  nodeid  nodekey  

公钥用于标识节点身份,可以被公开出去,私钥不能公开并且需要做好备份

  • nodeid 节点公钥(ID)文件,保存节点的公钥。
  • nodekey 节点私钥文件,保存节点的私钥。

PlatON节点除了需要节点公私钥外还需要一种被称为BLS公私钥的密钥对,这个密钥对在共识协议中将被使用。

3.2、启动platon

# 1、启动
tom@localhost:~$cd platon-node
tom@localhost:~$nohup platon --identity platon --datadir ./data --port 16789 --testnet --rpcport 6789 --rpcapi "db,platon,net,web3,admin,personal" --rpc --nodekey ./data/nodekey --cbft.blskey ./data/blskey --verbosity 3 --rpcaddr 0.0.0.0  --syncmode "full" > platon.log &
# 2、查看同步块高情况
tom@localhost:~$tail -f platon.log |grep num

4、配置nginx和mtool-client

4.1、配置nginx

  • 官方说是安全考虑,不建议节点 rpc 端口对外直接开放。可以考虑使用 Nginx 进行反向代理,并通过用户鉴权和 HTTPS 加强 Nginx 端口的安全性。
# 1、运行nginx脚本
tom@localhost:~$wget http://47.91.153.183/opensource/scripts/nginx_conf.sh
tom@localhost:~$chmod +x nginx_conf.sh  && ./nginx_conf.sh #记录好用户和密码,MTool 配置验证节点信息时需要填写
Enter your name:peiqi      
Enter your password:123456
# 2、验证nginx脚本是否成功,在脚本运行完的时候,看到以下这句话即成功了
ngnix conf succeed 

4.2、安装mtool-client,生成质押钱包和收益钱包

  • 质押钱包用于质押 token(就是我们的LAT),质押成功后才能成为备选节点候选人
  • 收益钱包 用于收取区块奖励和Staking奖励,Staking奖励统一发放给验证节点,由验证节点自行分配
# 1、下载mtool-client压缩包
tom@localhost:~$ wget http://47.91.153.183/mtool/0.8.0.0/mtool-client.zip
tom@localhost:~$ apt -y install unzip  && unzip mtool-client.zip  

# 2、下载mtool_install.sh的安装脚本,安装mtool-client所需环境
tom@localhost:~/$  wget http://47.91.153.183/opensource/scripts/mtool_install.sh -P ~/mtool-client-0.8.0.0

# 3、授权脚本执行的权限,并执行mtool_install.sh
tom@localhost:~/$  chmod +x mtool-client-0.8.0.0/mtool_install.sh && mtool-client-0.8.0.0/mtool_install.sh
#忽略下面这个报错
sed: can't read /home/tom/mtool-client-0.8.0.0/application.yml: No such file or directory  

# 4、使脚本配置的环境变量生效
tom@localhost:~$ source ~/.bashrc

# 5、验证环境变量是否生效
tom@localhost:~$ which mtool-client java
/usr/bin/mtool-client
/home/tom/jdk1.8.0_221/bin/java

# 6、生成钱包
tom@localhost:~$ mtool-client account new staking   #生成质押钱包
要求输入两次密码,请记住,记录密码:123456
tom@localhost:~$ mtool-client account new reward    #生成收益钱包
要求输入两次密码,请记住,记录密码:123456

# 7、验证钱包是否生成
tom@node02:~$ ls -l /home/tom/mtool-client-0.8.0.0/keystore
-rw-r--r-- 1 tom tom   8 Feb 11 15:33 IGNORE.me
-rw-rw-r-- 1 tom tom 490 Feb 20 08:55 reward.json   #质押钱包文件
-rw-rw-r-- 1 tom tom 490 Feb 20 08:53 staking.json  #收益钱包文件

5、准备节点信息

# 1、通过脚本validator_conf.sh生成节点信息
tom@localhost:~$ wget http://47.91.153.183/opensource/scripts/validator_conf.sh
tom@localhost:~$ chmod +x validator_conf.sh 
tom@localhost:~$ ip a   #记录ip地址,为下一步,填写内容准备
10.10.8.4
tom@localhost:~$ ./validator_conf.sh
Please enter the platon node IP address:10.10.8.4  #自身机器的ip
Please enter the platon chain id:101               #现在的链id为101
Please enter the delegatedRewardRate(0~10000):100  #个人推荐1000-5000,即(10%-50%)
Enter your name:peiqi                              #nginx_conf.sh执行输入的用户
Enter your password:123456                         #nginx_conf.sh执行输入的密码
Enter your platon node name:hornor                 #自己命名
Enter your platon node description:hahaha          #自己命名

6、质押成为验证节点

如果共识节点部署完成,并且已经同步区块成功,公链的块高通过下面的连接查看,就可以质押了,质押最低门槛为100万LAT。

PlatScan官网浏览器:https://platscan.test.platon.network/

  • 质押操作
# 查询钱包地址
tom@localhost:~$mtool-client account list
reward:0x0ad445afb9e.....dc181719a7ce095ad;
staking:0xf9f7196093......a960318cc5b141a0;
tom@localhost:~$cd cd mtool-client-0.8.0.0/
# 查看余额
tom@localhost:~$mtool-client account balance -a 0ad445afb9e.....dc181719a7ce095ad --config ./validator/validator_config.json
Balanceof: 0x0ad445afb9ed973bf2cf30edc181719a7ce095ad
LAT:200
#质押操作 ,100000为质押的数量
tom@localhost:~$mtool-client staking --amount 100000 --keystore ./keystore/staking.json --config ./validator/validator_config.json
please input keystore password: #生成质押输入密码
Insufficient wallet balance(Total payment: 100000.009687104000000000 LAT)  # (余额不足,有没有大佬有余额充足的,可怜的我只有200LAT)
#增加质押操作
tom@localhost:~$$mtool-client increasestaking --amount 5000000 ./keystore/staking.json --config ./validator/validator_config.json
#解质押操作(解质押扣手续费)
tom@localhost:~$ mtool-client unstaking  --keystore ./keystore/staking.json --config ./validator/validator_config.json

13 个赞

必须点赞 :+1: :+1:

这个绝对是死忠粉,得有奖励吧

厉害厉害 :+1:

这个厉害了,点赞 :+1: :+1:

楼主,您好,本帖已被选为最佳内容贡献奖,奖品为300主网LAT。我已经私信您询问钱包地址以及请求获得公众号转载许可。

感谢您对PlatON的支持,期待您有更多的作品在论坛上与大家分享。

1 个赞

感谢您的认可,期待主网早日开启。

这个说明写的必须赞:+1:

1 个赞

楼主很棒啊,这个帖子必须收藏 :ox:

1 个赞

虽然我看不太懂,但是还是觉得很赞啊 :+1:

牛的起飞,赞一个

牛皮66666666666

搞事情的搞~~~