Setting Up a Validator Node

All the instructions needed to get your node from zero to ready to create blocks.

Hardware Requirements

We recommend using a VPS with these minimum requirements:

  • 4 vCPUs

  • 8 GB RAM

  • 160 - 256 GB of Disk

(a full Pchain install is currently ~35 GB)

We recommend you use a Ubuntu 18.04 or Debian 10 OS, but Pchain can be run on other OS as outlined in the Alternate Installation Instructions.

Installing Pchain

To install from the latest release, run the following command. This automatically looks up the latest release and downloads that tar archive.

LOCATION=$(curl -s https://api.github.com/repos/pchain-org/pchain/releases/latest | grep "tag_name" | awk '{print "https://github.com/pchain-org/pchain/releases/download/" substr($2, 2, length($2)-3) "/pchain_mainnet_" substr($2, 2, length($2)-3) ".tar.gz"}') ; curl -L -o pchain_mainnet.tar.gz $LOCATION

If you would like to build from source or install via PPA, see the alternate installation instructions

Once this is done downloading, let's unpack it into its own directory:

mkdir -p pchain_main ; tar xzf pchain_mainnet.tar.gz --one-top-level=pchain_main --strip-components 1

After that, copy over the contents into your pchain directory:

mkdir -p pchain/log pchain/bin pchain/.pchain pchain/scripts
cp ~/pchain_main/pchain ~/pchain/bin/
cp ~/pchain_main/run.sh ~/pchain/

Downloading the Snapshot to Speed up the Sync

At this point, Pchain is ready to run. If you would like to begin syncing from block 0, you can start the node by executing:

~/pchain/run.sh

This can take a few days to sync though as there are now several million blocks. To quicken this up, we provide a snapshot of all the block data. To download this, make sure you are in the pchain directory:

cd ~/pchain

and then download the snapshot. If you are planning on running both the main chain and the subchain, download block data with this command:

wget https://pchainblockdata.s3-us-west-2.amazonaws.com/blockDataWithChild.tar.gz

Once this is complete, unpack it:

tar -xzf blockDataWithChild.tar.gz

If you are planning to run just the main chain, download the block data with this command:

wget https://pchainblockdata.s3-us-west-2.amazonaws.com/blockData.tar.gz

Once this is complete, unpack it:

tar -xzf blockData.tar.gz

You now can start Pchain and begin syncing from where the snapshot left off:

~/pchain/run.sh

Start Auto-update Scripts

We recommend you install Pchain's auto-update service, so you don't need to update the software manually after we release a new version.

sudo apt-get install jq -y
cd ~
cp ~/pchain_main/pchain.cron ~/pchain/scripts/
cp ~/pchain_main/scripts/* ~/pchain/scripts/
sudo crontab ~/pchain/scripts/pchain.cron 
crontab -l

If it returns

*/10 * * * * ~/pchain/scripts/updatefile.sh > ~/pchain/scripts/update.log
*/2 * * * * ~/pchain/scripts/monitor.sh > ~/pchain/scripts/monitor.log

You have started the service correctly.

Opening the Javascript Console

The Javascript console is one way to interact with your Validator Node and the Pchain network. To see a list of commands and examples, see Pchain Javascript Console.

Main Chain

To open the console for the main chain, execute:

~/pchain/bin/pchain attach ~/pchain/.pchain/pchain/pchain.ipc

Subchain

~/pchain/bin/pchain attach ~/pchain/.pchain/child_0/pchain.ipc

Creating an Executable Console

Main Chain

If you don't want to have to remember the command to open the console, you can create a simple bash script to open it. First, open a document called openconsole.sh

nano openconsole.sh

That will open a text editor. In the text editor, copy and paste the below:

#!/bin/bash

~/pchain/bin/pchain attach ~/pchain/.pchain/pchain/pchain.ipc

Then type ctrl-x then y to save and exit. To make it executable:

chmod u+x openconsole.sh

The console can now be opened by executing the command ./openconsole.sh

Subchain

The same can be done for creating an executable to attach to the subchain. To do that, open a document called openconsolecc.sh

nano openconsolecc.sh

That will open a text editor. In the text editor, copy and paste the below:

#!/bin/bash

~/pchain/bin/pchain attach ~/pchain/.pchain/pchain/pchain.ipc

Then type ctrl-x then y to save and exit. To make it executable:

chmod u+x openconsolecc.sh

The console can now be opened by executing the command ./openconsolecc.sh

Importing or Generating a New Address

If you have a PI address that you would like to use on your validator node, you can import it within the console, using your private key and executing:

personal.importRawKey(keydata, passphrase)

Where keydata is the private key and passphrase is the password to lock the key.

If you want to generate a new key, execute:

personal.newAccount()

and follow the prompts for entering your password.

Generating a BLS Validator Key

One of the most innovative and important features of the Plian blockchain is the use of BLS signatures which allows nodes to quickly aggregate signatures from other nodes in the network. This enables Pchain to not only create 2-second blocks but also in a network that supports hundreds of nodes.

To create a BLS key associated with your node key, execute:

~/pchain/bin/pchain --datadir ~/pchain/.pchain gen_priv_validator your_address

where your_address is the address you imported or generated above.

This will output something like this:

{
	"address": "986C40C28AF392FC1562E2BF930637D27D924C71",
	"consensus_priv_key": [
		4,
		"3C21501E0541186C09813BE9A6CC50184781E9F69566F66D985002091FF78648"
	],
	"consensus_pub_key": [
		4,
		"229965F5A8A507E17E191A303F974B06EB780F3DC8C46E97029789F3207D415A8F0BA4783302F7468198378244E9DB6CCDE166AF11373D52C5C2ADA57704304105B67C15B35EAE8049B0CAA061D4F459B0271150E526FFA5CF944E203706D6D8788D8418080518489AAC41EAB22BD4437D1ECE5EAD524FE61B83E9EB784A1531"
	]

This is the key that will be used for consensus. It is saved in a file called priv_validator.json and needs to be copied into the chain directories to enable the node software to use it to sign blocks. To copy it to the main chain directory:

cp ~/pchain/.pchain/priv_validator.json ~/pchain/.pchain/pchain/

and if you are also operating the subchain, copy it here:

cp ~/pchain/.pchain/priv_validator.json ~/pchain/.pchain/child_0/

Now let's restart Pchain so it recognizes the keys:

kill $(pidof pchain)
~/pchain/run.sh

Now the console will show your address when it is opened.

Your Validator Node is now ready to create and sign blocks for the network! Now you have to either stake enough PI to become a validator or register as a candidate for users to stake their PI to you.

Last updated