|
| 1 | +# SolidityNode and FullNode Deployment on The Same Host |
| 2 | + |
| 3 | +Create separate directories for fullnode and soliditynode |
| 4 | +```text |
| 5 | +/deploy/fullnode |
| 6 | +/deploy/soliditynode |
| 7 | +``` |
| 8 | + |
| 9 | +Create two folders for fullnode and soliditynode. |
| 10 | + |
| 11 | +Clone the latest master branch of [https://github.com/tronprotocol/java-tron](https://github.com/tronprotocol/java-tron) and extract it to |
| 12 | +```text |
| 13 | +/deploy/java-tron |
| 14 | +``` |
| 15 | + |
| 16 | +Make sure you have the proper dependencies. |
| 17 | + |
| 18 | +* JDK 1.8 (JDK 1.9+ is not supported yet) |
| 19 | +* On Linux Ubuntu system (e.g. Ubuntu 16.04.4 LTS), ensure that the machine has [__Oracle JDK 8__](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04), instead of having __Open JDK 8__ in the system. If you are building the source code by using __Open JDK 8__, you will get [__Build Failed__](https://github.com/tronprotocol/java-tron/issues/337) result. |
| 20 | +* Open **UDP** ports for connection to the network |
| 21 | +* **MINIMUM** 2 CPU Cores |
| 22 | + |
| 23 | +## Deployment Guide |
| 24 | + |
| 25 | +1. Build the java-tron project |
| 26 | +```text |
| 27 | +cd /deploy/java-tron |
| 28 | +./gradlew build |
| 29 | +``` |
| 30 | + |
| 31 | +2. Copy the FullNode.jar and SolidityNode.jar along with configuration files into the respective directories |
| 32 | +```text |
| 33 | +download your needed configuration file from https://github.com/tronprotocol/TronDeployment. |
| 34 | +
|
| 35 | +main_net_config.conf is the configuration for MainNet, and test_net_config.conf is the configuration for TestNet. |
| 36 | +
|
| 37 | +please rename the configuration file to `config.conf` and use this config.conf to start FullNode and SoliditNode. |
| 38 | +
|
| 39 | +cp build/libs/FullNode.jar ../fullnode |
| 40 | +
|
| 41 | +cp build/libs/SolidityNode.jar ../soliditynode |
| 42 | +``` |
| 43 | + |
| 44 | +3. You can now run your FullNode using the following command |
| 45 | +```text |
| 46 | +java -jar FullNode.jar -c config.conf // make sure that your config.conf is downloaded from https://github.com/tronprotocol/TronDeployment |
| 47 | +``` |
| 48 | + |
| 49 | +4. Configure the SolidityNode configuration file |
| 50 | + |
| 51 | +You need to edit `config.conf` to connect to your local FullNode. Change `trustNode` in `node` to local `127.0.0.1:50051`, which is the default rpc port. Set `listen.port` to any number within the range of 1024-65535. Please don't use any ports between 0-1024 since you'll most likely hit conflicts with other system services. Also change `rpc port` to `50052` or something to avoid conflicts. **Please forward the UDP port 18888 for FullNode.** |
| 52 | +```text |
| 53 | +rpc { |
| 54 | + port = 50052 |
| 55 | + } |
| 56 | +``` |
| 57 | + |
| 58 | +5. You can now run your SolidityNode using the following command: |
| 59 | +```text |
| 60 | +java -jar SolidityNode.jar -c config.conf //make sure that your config.conf is downloaded from https://github.com/tronprotocol/TronDeployment |
| 61 | +``` |
| 62 | + |
| 63 | +# Logging and Network Connection Verification |
| 64 | + |
| 65 | +Logs for both nodes are located in `/deploy/\*/logs/tron.log`. Use `tail -f /logs/tron.log/` to follow along with the block syncing. |
| 66 | + |
| 67 | +You should see something similar to this in your logs for block synchronization: |
| 68 | + |
| 69 | +**FullNode** |
| 70 | +```text |
| 71 | +12:00:57.658 INFO [pool-7-thread-1] [o.t.c.n.n.NodeImpl](NodeImpl.java:830) Success handle block Num:236610,ID:0000000000039c427569efa27cc2493c1fff243cc1515aa6665c617c45d2e1bf |
| 72 | +``` |
| 73 | +**SolidityNode** |
| 74 | +```text |
| 75 | +12:00:40.691 INFO [pool-17-thread-1] [o.t.p.SolidityNode](SolidityNode.java:88) sync solidity block, lastSolidityBlockNum:209671, remoteLastSolidityBlockNum:211823 |
| 76 | +``` |
| 77 | +# Stop Node Gracefully |
| 78 | +Create file stop.sh,use kill -15 to close java-tron.jar(or FullNode.jar、SolidityNode.jar). |
| 79 | +You need to modify pid=`ps -ef |grep java-tron.jar |grep -v grep |awk '{print $2}'` to find the correct pid. |
| 80 | +```text |
| 81 | +#!/bin/bash |
| 82 | +while true; do |
| 83 | + pid=`ps -ef |grep java-tron.jar |grep -v grep |awk '{print $2}'` |
| 84 | + if [ -n "$pid" ]; then |
| 85 | + kill -15 $pid |
| 86 | + echo "The java-tron process is exiting, it may take some time, forcing the exit may cause damage to the database, please wait patiently..." |
| 87 | + sleep 1 |
| 88 | + else |
| 89 | + echo "java-tron killed successfully!" |
| 90 | + break |
| 91 | + fi |
| 92 | +done |
| 93 | +``` |
0 commit comments