Plian
Chinese
Chinese
  • Overview
  • Links
  • Downloads
  • FAQ
    • Node Status
    • Full Balance
    • Flow and FAQ on Becoming a Validator
    • Delegation
    • Staking Rewards
    • Monitor
    • PIScan
    • PIWallet
    • Cross-Chain Transactions
    • DApps
  • About The Blockchain
    • Multichain Framework
    • PDBFT 2.0 Consensus Algorithm
    • Validator Nodes
    • Building with Plian
  • Using The Blockchain
    • Overview
    • Delegating or Staking PI
    • Validator Node Guides
      • Express Node Setup Guide
      • Setting Up a Validator Node
      • Registering Your Node as Validator
      • Submitting Your Vote as Validator
      • Revealing Your Vote
      • Removing Your Node From the Candidate List
      • Alternate Installation Instructions
        • Building From the Source
        • Running Pchain in Docker
        • Installation Instructions for Ubuntu
        • Installation Instructions for Mac OS X
        • Installation Instructions for Windows 10
      • What is FullBalance
    • Token Swaps
    • Plian Javascript Console
    • PIwallet
      • Web
      • Desktop Wallet
        • Light Wallet Mode
        • Local Node Mode
      • Mobile Wallets
      • How to Deploy a Smart Contract
    • PMetamask
    • Advanced Features
      • Command Line Options
      • Management APIs
      • JSON RPC API
      • How to Sync and Run Testnet
  • For Developers
    • How to connect Metamask to Plian
    • How to deploy smart contract on Plian via Metamask + Remix
    • PWeb3 Javascript API
    • How to Create Your Own Subchain
    • Writing Smart Contracts With Solidity
      • Introduction to Smart Contracts
      • Installing the Solidity Compiler
      • Solidity by Example
      • Solidity in Depth
        • Layout of a Solidity Source File
        • Structure of a Contract
        • Types
        • Units and Globally Available Variables
        • Expressions and Control Structures
        • Contracts
        • Solidity Assembly
        • Miscellaneous
      • Security Considerations
      • Resources
      • Using the compiler
      • Contract Metadata
      • Contract ABI Specification
      • Yul
      • Style Guide
      • Common Patterns
      • List of Known Bugs
      • Contributing
      • Frequently Asked Questions
      • LLL
      • Index
Powered by GitBook
On this page
  • Hardware Requirements
  • Installing Pchain
  • Downloading the Snapshot to Speed up the Sync
  • Start Auto-update Scripts
  • Opening the Javascript Console
  • Main Chain
  • Subchain
  • Creating an Executable Console
  • Importing or Generating a New Address
  • Generating a BLS Validator Key

Was this helpful?

  1. Using The Blockchain
  2. Validator Node Guides

Setting Up a Validator Node

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

PreviousExpress Node Setup GuideNextRegistering Your Node as Validator

Last updated 4 years ago

Was this helpful?

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

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

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

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.

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.

Alternate Installation Instructions.
alternate installation instructions
Javascript Console