Plian
English
English
  • 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
      • Desktop Wallet
        • Light Wallet Mode
        • Local Node Mode
      • Mobile Wallets
      • How to Deploy a Smart Contract
    • PMetamask
    • MetaMask
      • How to import PIwallet address to MetaMask?
      • How to connect Metamask to Plian
      • How to import wallet address from MetaMask into PIWallet
      • How to deploy smart contract on Plian via Metamask + Remix
    • Advanced Features
      • Command Line Options
      • Management APIs
      • JSON RPC API
      • How to Sync and Run Testnet
    • How to buy Plian $PI
  • For Developers
    • 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
  • Install Docker
  • Get docker on Ubuntu
  • Get docker on Windows and Mac OS
  • Build Pchain Dockerfile
  • Start the containers
  • Single-node on docker
  • Multi-node on docker

Was this helpful?

  1. Using The Blockchain
  2. Validator Node Guides
  3. Alternate Installation Instructions

Running Pchain in Docker

PreviousBuilding From the SourceNextInstallation Instructions for Ubuntu

Last updated 4 years ago

Was this helpful?

One of the quickest ways to get Pchain up and running on your machine is by using Docker.

Install Docker

Get docker on Ubuntu

If your PC's operating system is Ubuntu, you can get docker as follows:

sudo apt-get remove docker docker-engine docker-ce docker.io
sudo apt-get install  docker
sudo apt-get install -y docker.io
sudo apt-get install  docker-registry
sudo systemctl start docker
sudo systemctl enable docker

To see more details, you can see the .

Note: To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:

  • Bionic 18.04 (LTS)

  • Xenial 16.04 (LTS)

  • Trusty 14.04 (LTS)

Get docker on Windows and Mac OS

Running docker requires a 64-bit operating system, win7 or higher, and supports " Hardware Virtualization Technology", and "virtualization" is available.

Build Pchain Dockerfile

To Run Pchain on dockers, you will make a Pchain docker image from Dockerfile as follows from within a pchain folder:

cd pchain
docker build -t pchian . 

You can check the image status by:

& docker images

If the Pchain image has been built correctly, you can find an image called pchain and the Tag is latest.

Start the containers

When the Pchain's docker image has been built, you can start Pchian in docker:

& docker run -it pchain

And you can see the containers status:

$ docker ps -a

Single-node on docker

To run a single-node Pchain in docker, execute docker run -it pchain. And create accounts with a specified balance, will generate eth_genesis.json:

./pchain --datadir pchainData init_eth_genesis "{10000000000000000000000000000000000, 100}"

Generate the Pchain genesis.json with epoch/reward scheme parameters:

./pchain --datadir pchainData init pchainData/pchain/eth_genesis.json

to start the node:

./run.sh

Multi-node on docker

You can deploy multiple nodes through docker in order to test jobs, smart contracts and child chains.

Add an ordinary node

Start another docker container, build a fresh node('B') but don't start it (not run the ./run.sh). Here are the steps to make the new node ('B') join the existing node ('A'):

  • stop Pchain on A

  • add the peer entry,

    • add B's ip:port(say 172.17.0.3:46656) to A's config.toml,

    • add A's ip:port(say 172.17.0.2:46656) to B's config.toml. Then, A's config.toml should look like:

#This is a TOML config file.
moniker = "anonymous"
node_laddr = "tcp://0.0.0.0:46656"
seeds = "172.17.0.3:46656"
fast_sync = true
db_backend = "leveldb"
log_level = "notice"
  • Copy A's genesis.json and eth_genesis.json to B, make their genesis.json keep the same, therefore the validators are the same between A and B.

  • Add A's enode to B, you can get A's enode by RPC command as follows:

curl -H "Content-Type:application/json" -X POST -d '{"method": "admin_nodeInfo", "params": [],"id":1}' "http://x.x.x.x/pchain"
  • Run Pchain on A and B (order is not relevant). After they are connected, B should start to synchronize blocks from A, and they will have the same blockchain behaviors when synchronization is complete.

Add a validator node

In order to add a validator node, there must be existing validators.

  • Start a new container from Pchain image, add a new node ('C') to the existing network but don't start it (not run the ./run.sh).

  • Pick one validator (node 'A'), add C's pub-key (the long hex-string of pub_key part in /path/to/priv_validator.json) to A's validators part in A's /path/to/genesis.json. then A's validators" part in genesis.json should look like:

"validators": [
                ...
                {
                		"eth_account": "0x7eff122b94897ea5b0e2a9abf47b86337fafebdc"
                        "amount": 10,
                        "name": "",
                        "pub_key": [
                                1,
                                "AE7AF8281D31B9A2CB0A9BC75D925CAD7E8DD6781601EF1519E0B0E01612F1FA"
                        ]
                },
                { #here is C's pub-key part
                        "eth_account": "0x32ef122b94897ea5b0e2a9abf4cda6337fafebdc"
                        "amount": 10,	#vote power
                        "name": "",   #name, could be empty
                        "pub_key": [  #pub-key part
                                1,
                                "E94937710077B38C2A1334B89B394D61CFBFEE732A54F9358A73E36ED0827B9A" #copy from C's priv_validator.json
                        ]
                },
                ...
        ]

Important: Make sure C's amount is smaller than 1/2 of the sum of all other validators' amount in order to maintain fault-tolerant consensus

  • Copy A's genesis.json and eth_genesis.json to all other nodes within the network, including C.

  • Stop all nodes within the network.

  • Start all nodes with C the last one to start.

  • Extension: This should work for batch-addition of new validators.

Multi-node automated deployment

openssh-server net-tools curl are installed in images. And all operation commands are contained in add_node.sh. You might execute this command step by step but not in one time.

You can find the install package on the . If you want to run docker on windows, DO NOT use windows containers but use Linux containers. And make sure the Virtualization Technology is enabled. To see more details, you can see the and .

Note: For more information, see .

Docker Official install Guide (Ubuntu)
Docker Official website
Docker Official install Guide (Windows)
Docker Official install Guide (Mac OS)
toml official guide