Running a Tron node on Ubuntu 20.04 WSL

Installed Java SDK:

sudo apt update
sudo apt install default-jdk
javac --version
javac 11.0.9.1

Cloned the repository:

git clone https://github.com/tronprotocol/wallet-cli

And found the following in wallet-cli\src\main\resources\config.conf:

net {
 type = mainnet
}

fullnode = {
  ip.list = [
    "127.0.0.1:50051"
  ]
}

#soliditynode = {
#  ip.list = [
#    "127.0.0.1:50052"
#  ]
#}

RPC_version = 2

# This field used in shielded transaction. It is recommended that this field is set to the block
# number in which the earliest relevant shielded contract was created. If the exact number is not
# known, this field can be set as follows. If used in mainnet, please set 22690588. If used in Nile
# testnet, please set 6380000. Otherwise, please set 0.
blockNumberStartToScan = 22690588

Tried to build it:

cd wallet-cli
./gradlew build
./gradlew run

But got an error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11.0.9.1'.

and switched to Open SDK 1.8:

sudo apt install openjdk-8-jdk
update-java-alternatives --list
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64
sudo update-java-alternatives --set /usr/lib/jvm/java-1.8.0-openjdk-amd64
javac -version
javac 1.8.0_275

Then tried to build it again:

cd wallet-cli
./gradlew build
./gradlew run

and got this:

I registered the wallet with RegisterWallet command and was able to do GetAddress, but not GetBalance.

Running java-tron

Tried to build java-tron:

git clone https://github.com/tronprotocol/java-tron.git
cd java-tron
git checkout -t origin/master
./gradlew build

but some tests failed:

I switched to a tag:

git tag
git describe --tags v4.1.1
git clean -dfx
git checkout GreatVoyage-v4.1.1
./gradlew build

but the same tests failed again.

Tried to run precompiled jar:

git clone https://github.com/tronprotocol/tron-deployment.git
cd tron-deployment/
./check-machine-config.sh
--2020-12-05 00:52:52--  https://raw.githubusercontent.com/tronprotocol/TronDeployment/master/Benchmark.jar
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.84.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 57994705 (55M) [application/octet-stream]
Saving to: ‘Benchmark.jar’

Benchmark.jar                        100%[=====================================================================>]  55.31M  4.43MB/s    in 10s

2020-12-05 00:53:06 (5.36 MB/s) - ‘Benchmark.jar’ saved [57994705/57994705]

1. JAVA VERSION:
before run java-tron, java MUST be oracle jdk, and version >= 1.8
2. CPU CORE:
new verson of java-tron needs at least 16 cores, currently your CPU core is 8, please improve your machine performance
3. MEMORY:
satisfied
when setup java, recommend to use: java -Xmx26215m
can see also start-recommend.sh
******** begin to pop revokingDb ********
******** before revokingDb size:0
******** after revokingStore size:0
******** after revokingStore contains:[]
******** end to pop revokingStore ********
-----------------------------------------------------
--------------------FAIL RESULT----------------------
Start fail! Please upgrade server configuration.
CPU needs at least 16 cores
Memory needs at least 30GB
Java MUST be oracle jdk, and version >= 1.8
-----------------------------------------------------

So I figured out that:

Tried:

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

but got:

E: The repository 'http://ppa.launchpad.net/webupd8team/java/ubuntu focal Release' does not have a Release file.

and followed Install Oracle JDK 8 on Linux replacing 261 with 271:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/jdk1.8.0_271/bin:/usr/lib/jvm/jdk1.8.0_271/db/bin:/usr/lib/jvm/jdk1.8.0_271/jre/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_271"
J2REDIR="/usr/lib/jvm/jdk1.8.0_271/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_271"
DERBY_HOME="/usr/lib/jvm/jdk1.8.0_271/db"
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_271/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_271/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_271/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_271/bin/javac
update-alternatives --list java
update-alternatives --list javac
java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
cd ../work/
cp ../repos/tron-deployment/main_net_config.conf .
java -Xmx24g -XX:+UseConcMarkSweepGC -jar FullNode.jar -c main_net_config.conf
telnet 127.0.0.1 50051
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
 ^]
^HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 5e5d0d0aConnection closed by foreign host.

and there were some exceptions:

Dec 05, 2020 12:31:10 AM io.grpc.netty.NettyServerTransport notifyTerminated
INFO: Transport failed
io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 5e5d0d0a
        at io.netty.handler.codec.http2.Http2Exception.connectionError(Http2Exception.java:85)
        at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.readClientPrefaceString(Http2ConnectionHandler.java:318)
        at io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:251)
        at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:450)
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:646)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

that probably mean that telnet client is not adequate.

When I started the node I had 210 GB of free space and it was doing something:

Recompiled the client:

cd ~
mkdir backup
cp -r repos/wallet-cli/Wallet/ backup/
ll backup/
cd repos/wallet-cli
git clean -dfx
./gradlew build
cd ~
cp -r backup/Wallet/ repos/wallet-cli
cd repos/wallet-cli
ll Wallet
./gradlew run
tail -n 100 logs/tron.log | grep -i "block\ num"
du -h --max-depth=1

Tron Address Activation

Tron new account are inactive after created. Energy and bandwidth will be shown in the resource page after transfer over 0.1 TRX from other address to the new address to activate.

Links:

Leave a Reply

Your email address will not be published. Required fields are marked *