Full Private Blockchain

This is a guide to setting up a full private Ledgerium Blockchain on a fresh Linux machine. The blockchain ecosystem is a combination of multiple technologies that come together. The tech stacks range from (not limited to this list) GoLang, NodeJS, Ledgerium Wallet, Solidity and supporting Web3.js.

One-click Installer

ledgerium_setup.sh is a Unix bash file that downloads and deploys one Ledgerium node (consists of Geth, Tessera, and Governance docker containers) in a single click.

Run the following commands in the console.

> mkdir ledgerium
> cd ledgerium
> git clone https://github.com/ledgerium-io/ledgeriumsetup.git
> cd ledgeriumsetup
> ./install_dependencies.sh

This script does the following:

  • Install prerequisite software (Docker and NodeJS) to run ledgerium tools

  • Add $USER to the docker group, to avoid using sudo before docker commands

  • Creates a docker network 'test_net'

sudo docker network create -d bridge --subnet 172.19.240.0/24 --gateway 172.19.240.1 test_net

Once the dependencies are installed, run the setup script.

./ledgerium_setup.sh

The setup script will pull ledgeriumtools GitHub repository, will execute npm install and starts the setup process further.

  • Enter '1' for 'full' setup

  • The script will ask whether all the block producer nodes should be set up on the local machine or distributed across multiple machines.

  • Lastly, it will ask for the network ID. This ID should be 4 digit number.

|***************** Running ledgerium tools application *****************|
+----------------------------------------------------------------------+
Select the type of node setup - full/blockproducer ('0' for 'blockproducer' and '1' for 'full')
MODE:1
Is this a local setup or distributed? ('0' for local and '1' for distributed)
Setup:0
|***************** Executing script for local full mode ****************|
Enter Network ID
Should be a 4 digit number. Ex: 2019
Network ID:2024
+--------------------------------------------------------------------+
YML file with full mode

Next, the script will ask for further details. In the example, 4 founding Ledgerium block producer nodes are created.

> Number of nodes : 4
> Total number of nodes 4

This script prompts the user for mnemonics seed for all the 4 Ledgerium block producer nodes.

Mnemonics Seed

A mnemonic phrase or mnemonic seed is a set of typically either 12 or 24 words taken from BIP 32 English Wordlist, which can be used to derive an infinite number of wallets. In the Ethereum ecosystem, mnemonic phrases are generally generated following the BIP 32 spec. The private key and the public key combination will be generated using the mnemonic seed. You can generate a new mnemonic seed if you install Ledgerium Wallet or even most of the other Ethereum based wallets.

The mnemonic seed needs to be saved safely. In case the private key is lost, it can be regenerated using mnemonic seed. Once the mnemonic seed is lost, it can't be regenerated or retrieved. Likewise, the private key needs to be saved safely and should not be shared with anyone.

  • Enter the mnemonic seed and password. To know the significance of password follow

    > Enter mnemonic 0 : *******
    > Enter password 0 : ***
    > Enter mnemonic 1 : **********
    > Enter password 1 : ****
    > Enter mnemonic 2 : *************
    > Enter password 2 : ****
    > Enter mnemonic 3 : ******************
    > Enter password 3 : *****

    The script finally creates a docker-compose file (.yml) and brings up the containers.

Confirming Ledgerium Network is up and running correctly

We can see if the setup ran correctly by going to Block Explorer. The newly added validator should be showing up in the list of active validators/block producers. Initially, the validator will synch with the network and download the entire public state of the blockchain and once ready, you can see the last block will be in synch with the rest of the network.

Docker Commands

A few Docker commands are useful for managing Ledgerium Docker container on your machine.

Once, you are inside file path ledgerium/ledgeriumtools/output, run the below commands.

To list all active containers on your machine, run:

> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2e85ec37bb4b ledgeriumengineering/blockexplorerclient:v1.1 "nginx -g 'daemon of…" 7 seconds ago Up 2 seconds 0.0.0.0:2000->80/tcp output_blockexplorerclient_1
663103b6e8cf ledgeriumengineering/governance_app_ui_img:v1.0 "/bin/sh -c 'set -u\n…" 11 seconds ago Up 4 seconds 0.0.0.0:3547->3003/tcp output_governance-ui-ledgeriumblockchain-setup2_1
a446733aa8d8 ledgeriumengineering/ledgeriumfaucet:v1.0 "/bin/sh -c 'set -u\n…" 12 seconds ago Up 7 seconds 0.0.0.0:5577->5577/tcp output_ledgeriumfaucet_1
fbfea0aa5f27 ledgeriumengineering/governance_app_ui_img:v1.0 "/bin/sh -c 'set -u\n…" 12 seconds ago Up 8 seconds 0.0.0.0:3545->3003/tcp output_governance-ui-ledgeriumblockchain-setup0_1
ab67b56f7b9b ledgeriumengineering/blockexplorerserver:v1.1 "/bin/sh -c 'set -u\n…" 12 seconds ago Up 7 seconds 0.0.0.0:2002->2002/tcp output_blockexplorerserver_1
b9a446b36c09 ledgeriumengineering/governance_app_ui_img:v1.0 "/bin/sh -c 'set -u\n…" 12 seconds ago Up 8 seconds 0.0.0.0:3548->3003/tcp output_governance-ui-ledgeriumblockchain-setup3_1
03d5bc05a093 ledgeriumengineering/governance_app_ui_img:v1.0 "/bin/sh -c 'set -u\n…" 13 seconds ago Up 11 seconds 0.0.0.0:3546->3003/tcp output_governance-ui-ledgeriumblockchain-setup1_1
5d5809b3505c ledgeriumengineering/ledgeriumcore:blockrewards "/bin/sh -c 'while […" 16 seconds ago Up 11 seconds 30303/udp, 0.0.0.0:8547->8545/tcp, 0.0.0.0:9002->9000/tcp, 0.0.0.0:30305->30303/tcp output_validator-ledgeriumblockchain-setup2_1
43d4967c839c ledgeriumengineering/ledgeriumcore:blockrewards "/bin/sh -c 'while […" 17 seconds ago Up 12 seconds 0.0.0.0:8545->8545/tcp, 0.0.0.0:9000->9000/tcp, 0.0.0.0:30303->30303/tcp, 30303/udp output_validator-ledgeriumblockchain-setup0_1
3b9e17e955b2 ledgeriumengineering/ledgeriumcore:blockrewards "/bin/sh -c 'while […" 20 seconds ago Up 14 seconds 30303/udp, 0.0.0.0:8546->8545/tcp, 0.0.0.0:9001->9000/tcp, 0.0.0.0:30304->30303/tcp output_validator-ledgeriumblockchain-setup1_1
f77066084fb1 ledgeriumengineering/ledgeriumcore:blockrewards "/bin/sh -c 'while […" 20 seconds ago Up 12 seconds 30303/udp, 0.0.0.0:8548->8545/tcp, 0.0.0.0:9003->9000/tcp, 0.0.0.0:30306->30303/tcp output_validator-ledgeriumblockchain-setup3_1
13e0f2e1e62a ledgeriumengineering/ledgeriumstats:v1.0 "npm start" About a minute ago Up 21 seconds 0.0.0.0:3000->3000/tcp output_ledgeriumstats_1
27be76ac18d3 ledgeriumengineering/tessera:v1.1 "/bin/sh -c 'DATE=`d…" About a minute ago Up 21 seconds 0.0.0.0:10001->10001/tcp, 0.0.0.0:10101->10101/tcp output_tessera-ledgeriumblockchain-setup1_1
7513f022fe99 ledgeriumengineering/tessera:v1.1 "/bin/sh -c 'DATE=`d…" About a minute ago Up 17 seconds 0.0.0.0:10000->10000/tcp, 0.0.0.0:10100->10100/tcp output_tessera-ledgeriumblockchain-setup0_1
932edfb07ca2 mongo:3.4.10 "mongod --smallfiles…" About a minute ago Up 17 seconds 0.0.0.0:27017->27017/tcp blk-free-mongodb
c219a425d7b7 redis:alpine "docker-entrypoint.s…" About a minute ago Up 16 seconds 0.0.0.0:6379->6379/tcp output_redis_1
266909f73b4d ledgeriumengineering/tessera:v1.1 "/bin/sh -c 'DATE=`d…" About a minute ago Up 16 seconds 0.0.0.0:10002->10002/tcp, 0.0.0.0:10102->10102/tcp output_tessera-ledgeriumblockchain-setup2_1
eb71861d8e6c ledgeriumengineering/tessera:v1.1 "/bin/sh -c 'DATE=`d…" About a minute ago Up 21 seconds 0.0.0.0:10003->10003/tcp, 0.0.0.0:10103->10103/tcp output_tessera-ledgeriumblockchain-setup3_1

Manually shutting down the validators docker containers

> cd ../ledgeriumtools/output
> docker-compose down
Stopping output_blockexplorerclient_1 ... done
Stopping output_governance-ui-ledgeriumblockchain-setup2_1 ... done
Stopping output_ledgeriumfaucet_1 ... done
Stopping output_governance-ui-ledgeriumblockchain-setup0_1 ... done
Stopping output_blockexplorerserver_1 ... done
Stopping output_governance-ui-ledgeriumblockchain-setup3_1 ... done
Stopping output_governance-ui-ledgeriumblockchain-setup1_1 ... done
Stopping output_validator-ledgeriumblockchain-setup2_1 ... done
Stopping output_validator-ledgeriumblockchain-setup0_1 ... done
Stopping output_validator-ledgeriumblockchain-setup1_1 ... done
Stopping output_validator-ledgeriumblockchain-setup3_1 ... done
Stopping output_ledgeriumstats_1 ... done
Stopping output_tessera-ledgeriumblockchain-setup1_1 ... done
Stopping output_tessera-ledgeriumblockchain-setup0_1 ... done
Stopping blk-free-mongodb ... done
Stopping output_redis_1 ... done
Stopping output_tessera-ledgeriumblockchain-setup2_1 ... done
Stopping output_tessera-ledgeriumblockchain-setup3_1 ... done
Removing output_blockexplorerclient_1 ... done
Removing output_governance-ui-ledgeriumblockchain-setup2_1 ... done
Removing output_ledgeriumfaucet_1 ... done
Removing output_governance-ui-ledgeriumblockchain-setup0_1 ... done
Removing output_blockexplorerserver_1 ... done
Removing output_governance-ui-ledgeriumblockchain-setup3_1 ... done
Removing output_governance-ui-ledgeriumblockchain-setup1_1 ... done
Removing output_validator-ledgeriumblockchain-setup2_1 ... done
Removing output_validator-ledgeriumblockchain-setup0_1 ... done
Removing output_validator-ledgeriumblockchain-setup1_1 ... done
Removing output_validator-ledgeriumblockchain-setup3_1 ... done
Removing output_ledgeriumstats_1 ... done
Removing output_tessera-ledgeriumblockchain-setup1_1 ... done
Removing output_tessera-ledgeriumblockchain-setup0_1 ... done
Removing blk-free-mongodb ... done
Removing output_redis_1 ... done
Removing output_tessera-ledgeriumblockchain-setup2_1 ... done
Removing output_tessera-ledgeriumblockchain-setup3_1 ... done
Network test_net is external, skipping

Manually starting the nodes

> docker-compose up -d
Creating output_tessera-ledgeriumblockchain-setup2_1 ... done
Creating output_tessera-ledgeriumblockchain-setup3_1 ... done
Creating output_redis_1 ... done
Creating blk-free-mongodb ... done
Creating output_tessera-ledgeriumblockchain-setup0_1 ... done
Creating output_ledgeriumstats_1 ... done
Creating output_tessera-ledgeriumblockchain-setup1_1 ... done
Creating output_validator-ledgeriumblockchain-setup0_1 ... done
Creating output_validator-ledgeriumblockchain-setup3_1 ... done
Creating output_validator-ledgeriumblockchain-setup1_1 ... done
Creating output_validator-ledgeriumblockchain-setup2_1 ... done
Creating output_ledgeriumfaucet_1 ... done
Creating output_blockexplorerserver_1 ... done
Creating output_governance-ui-ledgeriumblockchain-setup0_1 ... done
Creating output_governance-ui-ledgeriumblockchain-setup3_1 ... done
Creating output_governance-ui-ledgeriumblockchain-setup1_1 ... done
Creating output_governance-ui-ledgeriumblockchain-setup2_1 ... done
Creating output_blockexplorerclient_1 ... done

Deconstructing the docker-compose.yml file

A generated docker-compose file will consist of 3 image containers per Ledgerium node along with additional containers. These are as follows:

  • Ledgerium Core

    • Purpose: This is the actual Ledgerium node, implementing Ledgerium Protocol

    • Following open ports are required to synch with its peers of Blockchain network:

      • 30303 Network listening port

      • 8545 HTTP-RPC server listening port

      • 9000 WS-RPC server listening port

Ledgerium Blockchain node configuration

Each node of Ledgerium Blockchain is configured with following commands in its setup file docker-compose.yml.

Geth Commands

geth --datadir '/eth' --networkid 2019 --identity "validator-0" --rpc --rpcaddr '0.0.0.0' --rpcport 8545 --rpccorsdomain '*' --rpcapi 'db,eth,net,web3,istanbul,personal,admin,debug,txpool' --rpcvhosts=localhost --ws --wsorigins '' --wsapi 'db,eth,net,web3,personal,admin,debug,txpool' --wsaddr '0.0.0.0' --wsport 9000 --mine --minerthreads 1 --syncmode 'full' --targetgaslimit 9007199254740000 --port "30303" --debug --metrics --txpool.nolocals --txpool.accountslots 128 --txpool.globalslots 32768 --txpool.accountqueue 512 --txpool.globalqueue 8192 --nodekeyhex "83a5803e698a3642d5309f119643f6a729c7c51fac00fdffac31983cb5275bb5" --etherbase "f232a4bf183cf17d09bea23e19ceff58ad9dbfed" --ethstats "validator-0:bb98a0b6442334d0cdf8a31b267892c1@toorak.ledgerium.io/stats" --verbosity 6 *--emitcheckpoints //If enabled, emit specially formatted logging checkpoints e.g. QUORUM-CHECKPOINT

  • Tessera

    • Purpose: Quorum Transaction Manager - implementation of peer-to-peer encrypted message exchange for transaction privacy

    • Following open ports are to accet private transactions:

      • 10000

      • 10100

  • Governance

    • Purpose: Governance App contains smart contracts to manage admin and individual validators to come on the platform

    • Ports required:

      • 3545

  • Block Explorer

    • Purpose: Block Explorer App will display the entire state of newly setup blockchain by showing

      • No of Peers

      • No of Block Producers/Validators

      • List of Blocks

      • List of Transactions (and list of transactions per block)

        etc.

    • Ports required:

      • 2000

      • 2002

  • Faucet

    • Purpose: Faucet App can grant test XLG to any valid Ledgerium EOA account.

    • Ports required:

      • 5577