Deploy of Tron Node

As every SR and SR candidate we from tronlabs Romania had to deploy our nodes. The first ones ran on Ubuntu 16.04 LTS but now we’ve updated to Ubuntu 18.04 LTS. Here is a guide how you can deploy a tron node, regardless if it’s a witness, a full node or a solidity node.

Part 1 – The base install.

This is common for all 3 types.

First check the System requirements
Witness Node – minimum 16 CPU*, min 32 RAM and 256 GB HDD**.
Full Node – minimum 16 CPU*, min 16 Gb RAM and 256 GB HDD**.
Solidity Node – minimum 16 CPU*, min 16 Gb RAM and 256 GB HDD**.

Note:
*) Witness node runs the TVM. You need the CPU and RAM and this is the minimum ! Solidity and Full nodes are not that demanding. Based on the volume and transactions, you can go as low as 2-4 CPU in the current state.
**) DISK capacity depends on the actual transaction volume after deployment, but it’s always better to leave some excess capacity.

Steps:
a) Download the Ubuntu image from this link . Pick the ubuntu-18.04.1-live-server-amd64.iso and install it on a VM or physical server.
b) During the install you are asked to set your network settings, define the hostname, the user and also choose if you want a specific partitioning for it (with and without LVM). We are not going to cover this as it’s pretty much generic and you should have no trouble doing it. A base image will be provided via our git later with a default user and password that can be used in the lab.
c) As soon as the system has rebooted and you’ve logged with your previously defined user we can proceed with the steps below.

– edit the sources list to add universe

 sudo nano /etc/apt/sources.list 

Add universe at the end of each line like you see in the example below. Then press F2 to Save, click Y to confirm that you save and then ENTER to keep the file name.

 
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe

– update the package sources and upgrade the system

 sudo apt-get update && sudo apt-get -y upgrade  

it will fetch the sources list and then upgrade the system with new versions of the installed packages

– next we need to install the required packages to perform the build. this includes git, curl, wget, etc

 sudo apt-get -y -V install build-essential git git-core locate curl libcurl4-openssl-dev wget javascript-common libjs-jquery libcap2-bin software-properties-common unzip zip unattended-upgrades libcap2-bin aptitude  

– next we install npm

 sudo aptitude install npm  

– then we add Java to the apt-cache and update again the packages

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update 

– now that we got Java apt sources list we can install it.

sudo apt-get -y -V install oracle-java8-installer npm --allow-unauthenticated

When you are asked to agree to the license terms click OK and then ENTER.

– and the last step is to install grpc because it’s needed for the protobuf

 sudo npm install grpc  

Now the base install is ready and you can proceed with the specific role installation.


PART 2 – Deploy Witness Node

– we clone the java-tron git master

 git clone https://github.com/tronprotocol/java-tron.git  

– then we need to fix 1 single file (build.gradle) from the java-tron folder, because the build will fail due to issues with the Maven repository.

 
cd java-tron
nano build.gradle

You need to change this two URL’s for the Maven repository. The first is on Line Nr. 3 and the second is on line Nr. 49. change the url from maven { url ‘http://mvnrepository.com’ } to maven { url ‘http://central.maven.org/maven2/’ }

  maven { url 'http://central.maven.org/maven2/' }  

This is the example for the first change of line 3

 
buildscript {
    repositories {
        maven { url 'http://central.maven.org/maven2/' }  
        mavenCentral()
        jcenter()
    }

This is the example for the second change of line 47

 
repositories {
    maven { url 'http://central.maven.org/maven2/' }   
    mavenLocal()
    mavenCentral()
    maven { url 'http://repo.spring.io/plugins-release' }

Save the File by Pressing F2, they confirm with Y and press ENTER

now we build it

 ./gradlew build 
 ./gradlew clean ShadowJar

Just be patient. based on the number of current CPU cores this build process goes faster or slower.

When ready you can use one of these 3 ways to start it

Method 01 – From command line (example from the official tron documentation)

java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf

Method 02 – Via a simplified script

kill -9 `cat /home/tron/pid.txt`
nohup  java -jar /home/tron/java-tron/java-tron.jar -p $LOCAL_WITNESS_PRIVATE_KEY --witness -c /home/tron/config.conf > /home/tron/tron-shell.log 2>&1 & echo $! >/home/tron/pid.txt 

the nohup will allow it to run in the background.

Method 03 – via the work.sh script in the java-tron directory
You need to adapt the settings and variables to match yours. it will allow you to start, stop and restart it


Part 3 – Deploy Full Node or Solidity Node

There is a tron deployment script available on the official git (https://github.com/tronprotocol/tron-deployment)

Note (05.10.2018)
Unfortunately since the build.gradle file is broken and the maven repository has issues the below ways will fail. You need to

Deployment of FullNode on the one host.

wget https://raw.githubusercontent.com/tronprotocol/TronDeployment/master/deploy_tron.sh -O deploy_tron.sh
bash deploy_tron.sh

Deployment of SolidityNode on the one host.

 
wget https://raw.githubusercontent.com/tronprotocol/TronDeployment/master/deploy_tron.sh -O deploy_tron.sh
# User can self-configure the IP and Port of GRPC service in the turst-node field of SolidityNode. trust-node is the fullnode you just deploy.
bash deploy_tron.sh --app SolidityNode --trust-node <grpc-ip:grpc-port>

Deployment of FullNode and SolidityNode on the same host.

 
# You need to configure different gRPC ports on the same host because gRPC port is available on SolidityNode and FullNodeConfigure and it cannot be set as default value 50051. In this case the default value of rpc port is set as 50041.
wget https://raw.githubusercontent.com/tronprotocol/TronDeployment/master/deploy_tron.sh -O deploy_tron.sh
bash deploy_tron.sh --app FullNode
bash deploy_tron.sh --app SolidityNode --rpc-port 50041

Workarounds:
We’ve forked the official java tron and corrected the build gradle file. You can get it and build from here

 
git clone https://github.com/myitlabro/java-tron
cd java-tron
./gradlew build 
./gradlew clean ShadowJar

The finished java builds for Full and Solidity nodes can then be found under the /build/libs subfolders of java-tron

FullNode.jar
java-tron-1.0.0.jar
java-tron.jar
KeystoreFactory.jar
SolidityNode.jar

Just start it with

nohup java -jar /home/tron/java-tron/java-tron.jar -c /home/tron/config.conf >> start.log 2>&1 &
Part 4 – Performance test

You can test the performance of your VM and generate a recommended start file

 wget https://github.com/tronprotocol/tron-deployment/blob/master/check-machine-config.sh
chmod +x check-machine-config.sh
./check-machine-config.sh

This is how it looks for us

And here are the contents of the start-recommend.sh file generated by the script

#!/bin/bash
kill -9 `cat /home/tron/pid.txt`
nohup java -Xmx51610m -jar /home/tron/java-tron/java-tron.jar -p $LOCAL_WITNESS_PRIVATE_KEY --witness -c /home/tron/config.conf > /home/tron/tron-shell.log 2>&1 & echo $! >/home/tron/pid.txt