Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,20 @@ TRON enables large-scale development and engagement. With over 2000 transactions

# Building the Source Code

Building java-tron requires `git` package and 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems.
Building java-tron requires `git` package

## Operating systems
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.

## Architecture

### x86_64
64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.

### ARM64
64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.

### build
Clone the repo and switch to the `master` branch

```bash
Expand All @@ -77,8 +89,19 @@ $ ./gradlew clean build -x test

# Running java-tron

Running java-tron requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems.
## Operating systems
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.

## Architecture

### X86_64
Requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.

### ARM64
Requires 64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.


## Configuration flile
Get the mainnet configuration file: [main_net_config.conf](https://github.com/tronprotocol/tron-deployment/blob/master/main_net_config.conf), other network configuration files can be found [here](https://github.com/tronprotocol/tron-deployment).

## Hardware Requirements
Expand All @@ -100,6 +123,7 @@ Recommended:

Full node has full historical data, it is the entry point into the TRON network, it can be used by other processes as a gateway into the TRON network via HTTP and GRPC endpoints. You can interact with the TRON network through full node:transfer assets, deploy contracts, interact with contracts and so on. `-c` parameter specifies a configuration file to run a full node:

### x86_64 JDK 1.8
```bash
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
Expand All @@ -111,6 +135,19 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
```
### ARM64 JDK 17
```bash
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest make the -Xmx14G

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for above x86_64 JDK8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 16GB nodes, the -Xmx9G JVM parameter in this example reserves sufficient memory for database off-heap allocation (2-4GB). Setting -Xmx too aggressively could lead to memory pressure and OOM issues.

-XX:ReservedCodeCacheSize=256m \
-XX:+UseCodeCacheFlushing \
-XX:MetaspaceSize=256m \
-XX:MaxMetaspaceSize=512m \
-XX:MaxDirectMemorySize=1g \
-XX:+HeapDumpOnOutOfMemoryError \
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
```


## Running a super representative node for mainnet

Expand All @@ -126,6 +163,7 @@ Fill in the private key of a super representative address into the `localwitness

then run the following command to start the node:

### x86_64 JDK 1.8
```bash
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
Expand All @@ -137,9 +175,22 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
```
### ARM64 JDK 17
```bash
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
-XX:ReservedCodeCacheSize=256m \
-XX:+UseCodeCacheFlushing \
-XX:MetaspaceSize=256m \
-XX:MaxMetaspaceSize=512m \
-XX:MaxDirectMemorySize=1g \
-XX:+HeapDumpOnOutOfMemoryError \
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
```

## Quick Start Tool

### x86_64 JDK 1.8
An easier way to build and run java-tron is to use `start.sh`. `start.sh` is a quick start script written in the Shell language. You can use it to build and run java-tron quickly and easily.

Here are some common use cases of the scripting tool
Expand All @@ -150,6 +201,18 @@ Here are some common use cases of the scripting tool

For more details, please refer to the tool [guide](./shell.md).

### ARM64 JDK 17
You can refer to the [start.sh.simple](start.sh.simple).

```bash
# cp start.sh.simple start.sh
# Usage:
# sh start.sh # Start the java-tron FullNode
# sh start.sh -s # Stop the java-tron FullNode
# sh start.sh [options] # Start with additional java-tron options,such as: -c config.conf -d /path_to_data, etc.
#
```

## Run inside Docker container

One of the quickest ways to get `java-tron` up and running on your machine is by using Docker:
Expand Down
5 changes: 4 additions & 1 deletion actuator/src/main/java/org/tron/core/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ public static void play(Program program, JumpTable jumpTable) {
} catch (JVMStackOverFlowException | OutOfTimeException e) {
throw e;
} catch (RuntimeException e) {
if (StringUtils.isEmpty(e.getMessage())) {
// https://openjdk.org/jeps/358
// https://bugs.openjdk.org/browse/JDK-8220715
// since jdk 14, the NullPointerExceptions message is not empty
if (e instanceof NullPointerException || StringUtils.isEmpty(e.getMessage())) {
logger.warn("Unknown Exception occurred, tx id: {}",
Hex.toHexString(program.getRootTransactionId()), e);
program.setRuntimeFailure(new RuntimeException("Unknown Exception"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return new Integer(Boolean.valueOf(byTestingSuite).hashCode()
return Boolean.valueOf(byTestingSuite).hashCode()
+ Boolean.valueOf(byTransaction).hashCode()
+ address.hashCode()
+ balance.hashCode()
Expand All @@ -326,8 +326,7 @@ public int hashCode() {
+ origin.hashCode()
+ prevHash.hashCode()
+ deposit.hashCode()
+ timestamp.hashCode()
).hashCode();
+ timestamp.hashCode();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return new Integer(type).hashCode();
return type;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return new Integer(type.hashCode() + Objects.hashCode(value)).hashCode();
return type.hashCode() + Objects.hashCode(value);
}
}
55 changes: 50 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,52 @@
import org.gradle.nativeplatform.platform.internal.Architectures
allprojects {
version = "1.0.0"
apply plugin: "java-library"
ext {
springVersion = "5.3.39"
}
}
def arch = System.getProperty("os.arch").toLowerCase()
def javaVersion = JavaVersion.current()
def isArm64 = Architectures.AARCH64.isAlias(arch)
def archSource = isArm64 ? "arm" : "x86"

ext.archInfo = [
name : arch,
java : javaVersion,
isArm64 : isArm64,
sourceSets: [
main: [
java: [
srcDirs: ["src/main/java/common", "src/main/java/${archSource}"]
]
],
test: [
java: [
srcDirs: ["src/test/java"]
]
]
],
requires: [
JavaVersion: isArm64 ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8,
RocksdbVersion: isArm64 ? '7.7.3' : '5.15.10'
],
VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions"
]

if (!archInfo.java.is(archInfo.requires.JavaVersion)) {
throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}")
}

println "Building for architecture: ${archInfo.name}, Java version: ${archInfo.java}"


subprojects {
apply plugin: "jacoco"
apply plugin: "maven-publish"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.current()

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
jacoco {
Expand Down Expand Up @@ -51,10 +86,16 @@ subprojects {
implementation group: 'joda-time', name: 'joda-time', version: '2.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'

compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'

// https://www.oracle.com/java/technologies/javase/11-relnote-issues.html#JDK-8190378
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
// for json-rpc, see https://github.com/briandilley/jsonrpc4j/issues/278
implementation group: 'javax.jws', name: 'javax.jws-api', version: '1.1'
annotationProcessor group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "org.mockito:mockito-core:4.11.0"
Expand All @@ -73,6 +114,10 @@ subprojects {
reproducibleFileOrder = true
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}
tasks.withType(Test).configureEach {
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:environment
environment 'CI', 'true'
}
}

task copyToParent(type: Copy) {
Expand Down
2 changes: 0 additions & 2 deletions chainbase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ dependencies {
api project(":common")
api project(":crypto")
api "org.fusesource.jansi:jansi:$jansiVersion"
api group: 'commons-io', name: 'commons-io', version: '2.18.0'
api 'io.github.tronprotocol:zksnark-java-sdk:1.0.0' exclude(group: 'commons-io', module: 'commons-io')
api 'org.reflections:reflections:0.9.11'
}

Expand Down
15 changes: 15 additions & 0 deletions chainbase/src/main/java/org/tron/common/storage/OptionsPicker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.tron.common.storage;

import org.tron.common.setting.RocksDbSettings;
import org.tron.common.utils.StorageUtils;

public class OptionsPicker {

protected org.iq80.leveldb.Options getOptionsByDbNameForLevelDB(String dbName) {
return StorageUtils.getOptionsByDbName(dbName);
}

protected org.rocksdb.Options getOptionsByDbNameForRocksDB(String dbName) {
return RocksDbSettings.getOptionsByDbName(dbName);
}
}
Loading