P2Pool Node Setup

本指南描述如何架设达世币P2Pool节点来管理矿池。与集中式矿池不同,P2Pool以与达世币相同的peer-2-peer(点对点)模式为基础,使矿池作为一个整体高度抵抗恶意攻击,并维持和保护达世币的去中心化性质。当您启动P2Pool节点时,它会与其他P2Pool节点(也被称为对等节点)的去中心化网络查找、连接和共享数据。P2Pool节点共享一个表示价值的加密数据链,类似于达世币的区块链。P2Pool版本被称为共享链。这种挖矿模式的去中心化和公平性意味着人们强烈鼓励使用P2Pool进行挖矿。达世币的P2Pool使用在GitHub上的p2pool-dash软件,它是比特币p2pool的分叉。有关更多信息,请参阅此处.

由于P2Pool在共享链上管理难度调整的方式,重要的是保持矿工和P2Pool节点之间的低延迟,以避免矿工提交算力太晚而无法进入共享链。在设置您的节点时,相对于您打算连接到该节点的矿工,您需要考虑其物理和网络位置。如果您经营一个矿场,您的P2Pool节点可能是与您的矿工相同的本地网络上的物理机器。如果您计划运营一个公共节点,最好将您的P2Pool节点设置为具有高速连接的数据中心的虚拟机,以便地理位置相近的矿工能够以相对较低的延迟挖到您的矿池。

This following section describes the steps to setup an Ubuntu Server running P2Pool for Dash. It has been tested with Ubuntu 20.04 LTS and Dash 0.16.0.1. While a reasonable effort will be made to keep it up to date, it should be possible to modify the instructions slightly to support different versions or operating systems as necessary.

设置主机服务器

Download a copy of Ubuntu Server LTS from https://ubuntu.com/download/server and install it on your system according to the steps described here. If you are using a VPS such as Vultr or AWS, your provider will most likely provide an option to install this system during provisioning. Ensure you enable OpenSSH server during setup so you can control your server from a remote console. Once you have access to your server, create a new non-root user if you have not already done so using the following command, replacing <username> with a username of your choice:

adduser <username>

您将被提示输入密码。输入并确认使用新的密码 (与root密码不同),并将其存储在安全的地方。您还将看到有关用户信息的提示,但此提示可以保留为空白。一旦用户被创建,我们将把它们添加到sudo组中,这样它们就可以root用户的身份执行命令:

usermod -aG sudo <username>

重新启动您的服务器并以新用户的身份登录。此时如果您还没有进行远程连接,建议使用PuTTY(Windows版本)或ssh(Linux和MacOS版本)进行远程连接。

设置端口转发

If you are on a private network behind a router, you will need to set up port forwarding for at least port 8999 (UDP/TCP) for access to the sharechain, as well as port 7903 (UDP/TCP) if you want your node to be accessible to the public. How this is done depends on your particular network router and is therefore beyond the scope of this documentation. An example from the popular DD-WRT open source router distribution is shown below. Guides to setting up port forwarding can be found here and here.

从您的路由器管理接口或通过访问 https://www.whatismyip.com 来记录您的IP地址。

../_images/p2pool-ddwrt.png

在DD-WRT下设置端口转发

Manual setup

首先按以下方式更新您的操作系统:

sudo apt update
sudo apt upgrade

设置dashd

P2Pool requires a full Dash node to be running to get block and transaction data. To download and install Dash, visit https://www.dash.org/downloads/ on your computer to find the link to the latest Dash Core wallet. Click Linux, then right-click on Download TGZ for Dash Core x64 and select Copy link address. Go back to your terminal window and enter the following command, pasting in the address to the latest version of Dash Core by right clicking or pressing Ctrl + V:

cd ~
wget https://github.com/dashpay/dash/releases/download/v0.16.0.1/dashcore-0.16.0.1-x86_64-linux-gnu.tar.gz

Verify the authenticity of your download by checking its detached signature against the public key published by the Dash Core development team. All releases of Dash are signed using GPG with one of the following keys:

curl https://keybase.io/codablock/pgp_keys.asc | gpg --import
curl https://keybase.io/pasta/pgp_keys.asc | gpg --import
wget https://github.com/dashpay/dash/releases/download/v0.16.0.1/dashcore-0.16.0.1-x86_64-linux-gnu.tar.gz.asc
gpg --verify dashcore-0.16.0.1-x86_64-linux-gnu.tar.gz.asc

为达世币创建一个工作目录,解压压缩的归档文件,将必要的文件复制到目录中,并将它们设置为可执行文件:

mkdir ~/.dashcore
tar xfvz dashcore-0.16.0.1-x86_64-linux-gnu.tar.gz
cp dashcore-0.16.0/bin/dashd .dashcore/
cp dashcore-0.16.0/bin/dash-cli .dashcore/

清理不需要的文件:

rm dashcore-0.16.0.1-x86_64-linux-gnu.tar.gz
rm -r dashcore-0.16.0/

使用以下命令创建配置文件:

nano ~/.dashcore/dash.conf

一个编辑器窗口将会出现。现在我们需要指定几个变量来创建一个配置文件。复制并粘贴以下文本以开始创建,然后按如下所示替换您配置中的具体变量:

#----
rpcuser=XXXXXXXXXXXXX
rpcpassword=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
rpcallowip=127.0.0.1
#----
listen=1
server=1
daemon=1
maxconnections=64
#----

按如下所示替换标记为 XXXXXXX 的字段:

  • rpcuser: 输入任何数字或字母字符串,不允许有特殊字符
  • rpcpassword: 输入任何数字或字母字符串,不允许有特殊字符

结果应该是这样的:

../_images/p2pool-dash-conf.png

在P2Pool节点上的 dash.conf 中输入密钥数据

Ctrl + X 以关闭编辑器,并按 YEnter 保存该文件。您现在可以开始在主节点上运行达世币,以便开始与区块链同步:

~/.dashcore/dashd

您将看到一条消息显示 Dash Core服务器启动 。您可以继续执行以下步骤,并使用以下命令定期检查同步状况。当 区块 的数量等于达世币区块链中的当前区块数量时,同步完成,从任何同步的达世币钱包或 区块浏览器中可以看到这一过程:

~/.dashcore/dash-cli getblockcount

设置 P2Pool

我们现在将设置P2Pool软件及其依赖项。从依赖项开始:

sudo apt install python2 python2-dev gcc g++ git
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
sudo python2 get-pip.py
pip install twisted

创建工作目录并设置p2pool-dash:

git clone https://github.com/dashpay/p2pool-dash
cd p2pool-dash
git submodule update --init
cd dash_hash
python2 setup.py install --user

我们将向控制面板添加一些可选的额外接口:

cd ..
mv web-static web-static.old
git clone https://github.com/justino/p2pool-ui-punchy web-static
mv web-static.old web-static/legacy
cd web-static
git clone https://github.com/hardcpp/P2PoolExtendedFrontEnd ext
cd ..

您现在可以启动p2pool,并按以下方式选择性地指定支付地址、外部IP(如有必要)、费用和捐款:

python2 ~/p2pool-dash/run_p2pool.py --external-ip <public_ip> -w <port> -f <fee> -a <payout_address> --give-author <donation>

然后,您可以通过浏览到以下地址来检测您的节点,用您P2Pool节点的IP地址替换 <ip_address> :

../_images/p2pool-antminer.png
../_images/p2pool-running.png

显示在本地网络上连接到p2pool-达世币节点的单个Bitmain Antminer D3的示例配置