# Deployment of A IBAX Network

In this section, we will show you how to deploy your own blockchain network.

# An deployment example

A blockchain network will be deployed with the following three nodes as an example.

Three network nodes:

  • Node 1 is the first node in the blockchain network, which can generate new blocks and send transactions from clients connected to it;
  • Node 2 is another honor node, which can generate new blocks and send transactions from clients connected to it;
  • Node 3 is a guardian node, which cannot generate new blocks, but can send transactions from clients connected to it.

Configurations of the three nodes to be deployed:

  • Each node uses its own PostgreSQL database system instance;
  • Each node uses its own Centrifugo service instance;
  • The server side github-backend is deployed on the same host as other backend components.

The sample addresses and ports used by the nodes are described in the following table:

Node Component IP & port
1 PostgreSQL 127.0.0.1:5432
1 Centrifugo 192.168.1.1:8000
1 go-ibax (TCP service) 192.168.1.1:7078
1 go-ibax (API service) 192.168.1.1:7079
2 PostgreSQL 127.0.0.1:5432
2 Centrifugo 192.168.1.2:8000
2 go-ibax (TCP service) 192.168.1.2:7078
2 go-ibax (API service) 192.168.1.2:7079
3 PostgreSQL 127.0.0.1:5432
3 Centrifugo 192.168.1.3:8000
3 go-ibax (TCP service) 192.168.1.3:7078
3 go-ibax (API service) 192.168.1.3:7079

# Deploy phase

Your own blockchain network must be deployed in several stages:

# Server deployment

# Deploy the first node

The first node is a special one because it is essential to launch the blockchain network. The first block of the blockchain is generated by the first node, and all other nodes would download the blockchain from it. The owner of the first node is the platform creator.

# Dependencies and environment settings

# sudo

All commands of Debian 9 must be run as a non-root user. However, some system commands require super user permissions to execute. By default, sudo is not installed on Debian 9, you must install it first.

  1. Become a super user.
su -
  1. Upgrade your system.
apt update -y && apt upgrade -y && apt dist-upgrade -y
  1. Install sudo。
apt install sudo -y
  1. Add your user to the sudo group.
usermod -a -G sudo user
  1. After restarting, the changes take effect.

# Golang

Install Go according to the Official Documents (opens new window).

  1. Download the latest stable version of Go (> 1.10.x) from Golang official website (opens new window) or through the command line:
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
  1. Use tar to extract the tarball to the /usr/local directory.
tar -C /usr/local -xzf go1.11.2.linux-amd64.tar.gz
  1. Add /usr/local/go/bin to PATH environment variables (located at /etc/profile or $HOME/.profile).
export PATH=$PATH:/usr/local/go/bin
  1. Execute the source file to make the changes take effect, for example:
source $HOME/.profile
  1. Delete temporary files:
rm go1.11.2.linux-amd64.tar.gz

# PostgreSQL

  1. Install PostgreSQL (> v.10) and psql:
sudo apt install -y postgresql

# Centrifugo

  1. Download Centrifugo V.1.8.0 from GitHub (opens new window) or through the command line:
wget https://github.com/centrifugal/centrifugo/releases/download/v1.8.0/centrifugo-1.8.0-linux-amd64.zip \
&& unzip centrifugo-1.8.0-linux-amd64.zip \
&& mkdir centrifugo \
&& mv centrifugo-1.8.0-linux-amd64/* centrifugo/
  1. Delete temporary files:
rm -R centrifugo-1.8.0-linux-amd64 \
&& rm centrifugo-1.8.0-linux-amd64.zip

# Directory structure

For the Debian 9 system, it is recommended to store all software used by the blockchain platform in a separate directory.

The /opt/backenddir directory is used here, but you can use any directory. In this case, please change all commands and configuration files accordingly.

  1. Create a directory for the blockchain platform:
sudo mkdir /opt/backenddir
  1. Make your user the owner of the directory:
sudo chown user /opt/backenddir/
  1. Create subdirectories for Centrifugo, go-ibax and node data. All node data is stored in a directory named nodeX, where X is the node number. According to the node to be deployed, node1 is Node 1, node2 is Node 2, and so forth.
mkdir /opt/backenddir/go-ibax \
mkdir /opt/backenddir/go-ibax/node1 \
mkdir /opt/backenddir/centrifugo \

# Create a database

  1. Change the user password postgres to the default password 123456. You can set your own password, but you must change it in the node configuration file config.toml.
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '123456'"
  1. Create a current state database for the node, for example chaindb:
sudo -u postgres psql -c "CREATE DATABASE chaindb"

# Configure Centrifugo

  1. Create the Centrifugo configuration file:
echo '{"secret":"CENT_SECRET"}' > /opt/backenddir/centrifugo/config.json

You can set your own secret, but you must also change it in the node configuration file config.toml.

# Install go-ibax

  1. Download github-backend from GitHub:
  2. Copy the go-ibax binary file to the /opt/backenddir/go-ibax directory. If you are using default Go workspace, the binary files are located in the $HOME/go/bin directory:
cp $HOME/go/bin/go-ibax /opt/backenddir/go-ibax

# Configure the first node

  1. Create the configuration file for Node 1:
/opt/backenddir/go-ibax config \
 --dataDir=/opt/backenddir/node1 \
 --dbName=chaindb \
 --centSecret="CENT_SECRET" --centUrl=http://192.168.1.1:8000 \
 --httpHost=192.168.1.1 \
 --httpPort=7079 \
 --tcpHost=192.168.1.1 \
 --tcpPort=7078
  1. Generate the keys of Node 1, including the public and private keys of the node and the account:
/opt/backenddir/go-ibax generateKeys \
 --config=/opt/backenddir/node1/config.toml
  1. Generate the first block:

Note

If you want to create your own blockchain network, you must use the --test=true option. Otherwise, you cannot create a new account.

/opt/backenddir/go-ibax generateFirstBlock \
 --config=/opt/backenddir/node1/config.toml \
 --test=true
  1. Initialize the database:
/opt/backenddir/go-ibax initDatabase \
 --config=/opt/backenddir/node1/config.toml

# Initiate the first node server

To start the first node server, you must start the following two services:

  • centrifugo
  • go-ibax

If you failed to create services with these files, you may execute binary files from directories in different consoles.

  1. Run centrifugo:
/opt/backenddir/centrifugo/centrifugo \
 -a 192.168.1.1 -p 8000 \
 --config /opt/backenddir/centrifugo/config.json
  1. Run go-ibax:
/opt/backenddir/go-ibax start \
 --config=/opt/backenddir/node1/config.toml

# Deploy other nodes

Although the deployment of all other nodes (Node 2 and Node 3) is similar to the first, but there are three differences:

  • You do not need to generate the first block. But it must be copied from Node 1 to the current node data directory;
  • The node must download blocks from Node 1 by configuring the --nodesAddr option;
  • The node must use its own addresses and ports.

# Node 2

Follow operational instructions as shown below:

  1. Dependencies and environment settings
  2. Create database
  3. Centrifugo
  4. Install go-ibax
  5. Create the configuration file for Node 2:
 /opt/backenddir/go-ibax config \
--dataDir=/opt/backenddir/node2 \
--dbName=chaindb \
--centSecret="CENT_SECRET" --centUrl=http://192.168.1.2:8000 \
--httpHost=192.168.1.2 \
--httpPort=7079 \
--tcpHost=192.168.1.2 \
--tcpPort=7078 \
--nodesAddr=192.168.1.1
  1. Copy the first block file to Node 2. For example, you can perform this operation on Node 2 throughscp:
 scp user@192.168.1.1:/opt/backenddir/node1/1block /opt/backenddir/node2/
  1. Generate the keys of Node 2, including the public and private keys of the node and the account:
 /opt/backenddir/go-ibax generateKeys \
--config=/opt/backenddir/node2/config.toml
  1. Initiate the database:
 ./go-ibax initDatabase --config\=node2/config.toml
  1. Run centrifugo:
/opt/backenddir/centrifugo/centrifugo \
-a 192.168.1.2 -p 8000 \
--config/opt/backenddir/centrifugo/config.json
  1. Run go-ibax:
/opt/backenddir/go-ibax start \
 --config=/opt/backenddir/node2/config.toml

As a result, the node downloads the block from the first node. As this node is not a verification node, it cannot generate a new block. Node 2 will be added to the list of verification nodes later.

# Node 3

Follow operational instructions as shown below:

  1. Dependencies and environment settings

  2. Create database

  3. Centrifugo

  4. Install go-ibax

  5. Create the configuration file for Node 3:

 /opt/backenddir/go-ibax config \
--dataDir=/opt/backenddir/node3 \
--dbName=chaindb \
--centSecret="CENT_SECRET" --centUrl=http://192.168.1.3:8000 \
--httpHost=192.168.1.3 \
--httpPort=7079 \
--tcpHost=192.168.1.3 \
--tcpPort=7078 \
--nodesAddr=192.168.1.1
  1. Copy the first block file to Node 3. For example, you can perform this operation on Node 3 through scp:
 scp user@192.168.1.1:/opt/backenddir/node1/1block /opt/backenddir/node3/

7.Generate the key of Node 3, including the public and private keys of the node and the account:

 /opt/backenddir/go-ibax generateKeys \
--config=/opt/backenddir/node3/config.toml

8.Initiate the database:

 ./go-ibax initDatabase --config=node3/config.toml

9.Run centrifugo:

 /opt/backenddir/centrifugo/centrifugo \
-a 192.168.1.3 -p 8000 \
--config/opt/backenddir/centrifugo/config.json

10.Run go-ibax:

 /opt/backenddir/go-ibax start \
 --config=/opt/backenddir/node3/config.toml

As a result, the node downloads the block from the first node. As this node is not a verification node, it cannot generate a new block. The client may be connected to the node, and it may send transactions to the network.

# Front-end deployment

Only after installing GNOME GUI on Debian 9 (Stretch) 64-bit Official Release, the Govis client can be built with the yarn package manager.

# Software prerequisites

  1. Download Node.js LTS version 8.11 from Node.js official website or through the command line:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash
  1. Install Node.js:
sudo apt install -y nodejs
  1. Download Yarn version 1.7.0 from yarn's Github (opens new window) repository or through the command line:
cd/opt/backenddir \
&& wget https://github.com/yarnpkg/yarn/releases/download/v1.7.0/yarn_1.7.0_all.deb
  1. Install Yarn:
sudo dpkg -i yarn_1.7.0_all.deb && rm yarn_1.7.0_all.deb

# Build a Weaver application

  1. Download the latest version of Weaver from github-frontend via git:
cd/opt/backenddir \
&& git clone https://github.com/ibax-io/ibax-front.git
  1. Install Weaver dependencies via Yarn:
cd/opt/backenddir/ibax-front/ \
&& yarn install

# Add the configuration file for the blockchain network

  1. Create a settings.json file that contains information about node connection:
cp/opt/backenddir/ibax-front/public/settings.json.dist \
 /opt/backenddir/ibax-front/public/public/settings.json
  1. Edit the settings.json file in any text editor and add the required settings in this format:
http://Node_IP-address:Node_HTTP-Port

Examples of settings.json files for the three nodes:

{
  "fullNodes": [
    "http://192.168.1.1:7079",
    "http://192.168.1.2:7079",
    "http://192.168.1.3:7079"
  ]
}

Build Weaver Desktop Application

1.Use yarn to build the desktop version:

cd/opt/backenddir/ibax-front \
&& yarn build-desktop

2.The desktop version will be packaged into AppImage suffix format:

yarn release --publish never -l

After building, your application can be used, but its connection configuration cannot be changed. If these settings need to be changed, a new version of the application must be built.

# Build Weaver Web Application

1.Build a web application:

cd/opt/backenddir/ibax-front/ \
&& yarn build

After building, the redistributable files will be placed in the /build directory. You can use any web server of your choice for deployment, and the settings.json file must also be placed in this directory. Note that if the connection settings are changed, there is no need to build the application again. Instead, edit the settings.json file and restart the web server.

1.For development or testing purposes, you can build Yarn's web server:

sudo yarn global add serve \
&& serve -s build

After that, your Weaver web application will be available at the following location: http://localhost:5000.

# Configure the blockchain network

# Create the creator account

Create an account for the first node owner. This account is the creator of the new blockchain platform and has the administrator access.

1.Run Weaver;

2.Import the existing account using the following data:

–Load the backup of the node owner's private key located in the /opt/backenddir/node1/PrivateKey file.

Note

There are two private key files in this directory. The PrivateKey file is used create the node owner's account. The NodePrivateKey file is the private key of the node itself and must be kept secret.

3.After logging in to the account, since no role has been created at this time, please select the Without role option.

# Import applications, roles and templates

At this time, the blockchain platform is in a blank state. You can configure it by adding roles, templates, and application frameworks that support basic ecosystem functions.

1.Clone the application repository;

cd/opt/backenddir \
&& git clone https://github.com/ibax-io/dapps.git

2.Navigate to Developer> Import in Weaver;

3.Import applications as per the following order:

 A./opt/backenddir/dapps/system.json 
 B./opt/backenddir/dapps/conditions.json 
 C./opt/backenddir/dapps/basic.json 
 D./opt/backenddir/dapps/lang_res.json

4.Navigate to Admin> Role, and click Install Default Role;

5.Exit the system through the configuration file menu in the upper right corner;

6.Log in to the system as Admin;

7.Navigate to Home> Vote> Template List, and click Install Default Template.

# Add the first node to the node list

1.Navigate to Developer> Platform Parameters, and click the first_nodes parameter;

2.Specify the parameters of the first blockchain network node.

  • public_key - The public key of the node is located in the /opt/backenddir/node1/NodePublicKey file;
{"api_address":"http://192.168.1.1:7079","public_key":"%node_public_key%","tcp_address":"192.168.1.1:7078"}

# Add other honor nodes

# Add members into the consensus role group

By default, only members in the consensus role (Consensus) group can participate in the voting required to add other master nodes. This means that before adding a new master node, members of the ecosystem must be assigned to the role. In this section, the creator's account is designated as the only member of the consensus role group. In a production environment, this role must be assigned to platform members that perform governance.

1.Navigate to Home> Role and click Consensus;

2.Click Assign to assign the creator's account to the role.

# Create the owner account for other nodes

  1. Run Weaver;

  2. Import the existing account using the following data: – Load the backup of the node owner's private key located in the /opt/backenddir/node2/PrivateKey file.

  3. After logging in to the account, since no role has been created at this time, please select the Without role option.

  4. Navigate to Home> Personal Information, and click the title of the personal information;

  5. Add account details (personal information title, description, etc.).

# Assign the node owner with the Validators role

  1. Operations by the new node owner:
    1. Navigate to Home> Verifier;
    2. Click Create Request and fill in the application form of the verifier candidate;
    3. Click send request.
  2. Operations by the creator:
    1. Log in with a consensus role (Consensus);
    2. Navigate to Home> Verifier;
    3. Click the "Play" icon to start voting according to the candidate's request;
    4. Navigate to Home> Vote, and click Update voting status;
    5. Click the voting name and vote for the node owner.

As a result, the account of the owner of the new node is assigned with the Validator role, and the new node is added to the list of master nodes.