Skip to content

Commit a587203

Browse files
committed
feat(architecture): support arm64 based on JDK17 (tronprotocol#6327)
1 parent 1e35f79 commit a587203

106 files changed

Lines changed: 2626 additions & 1168 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,20 @@ TRON enables large-scale development and engagement. With over 2000 transactions
6363

6464
# Building the Source Code
6565

66-
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.
66+
Building java-tron requires `git` package
6767

68+
## Operating systems
69+
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.
70+
71+
## Architecture
72+
73+
### x86_64
74+
64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.
75+
76+
### ARM64
77+
64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.
78+
79+
### build
6880
Clone the repo and switch to the `master` branch
6981

7082
```bash
@@ -81,8 +93,19 @@ $ ./gradlew clean build -x test
8193

8294
# Running java-tron
8395

84-
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.
96+
## Operating systems
97+
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.
98+
99+
## Architecture
100+
101+
### X86_64
102+
Requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.
85103

104+
### ARM64
105+
Requires 64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.
106+
107+
108+
## Configuration flile
86109
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).
87110

88111
## Hardware Requirements
@@ -104,6 +127,7 @@ Recommended:
104127

105128
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:
106129

130+
### x86_64 JDK 1.8
107131
```bash
108132
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
109133
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -115,6 +139,19 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
115139
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
116140
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
117141
```
142+
### ARM64 JDK 17
143+
```bash
144+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
145+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
146+
-XX:ReservedCodeCacheSize=256m \
147+
-XX:+UseCodeCacheFlushing \
148+
-XX:MetaspaceSize=256m \
149+
-XX:MaxMetaspaceSize=512m \
150+
-XX:MaxDirectMemorySize=1g \
151+
-XX:+HeapDumpOnOutOfMemoryError \
152+
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
153+
```
154+
118155

119156
## Running a super representative node for mainnet
120157

@@ -130,6 +167,7 @@ Fill in the private key of a super representative address into the `localwitness
130167

131168
then run the following command to start the node:
132169

170+
### x86_64 JDK 1.8
133171
```bash
134172
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
135173
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -141,9 +179,22 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
141179
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
142180
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
143181
```
182+
### ARM64 JDK 17
183+
```bash
184+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
185+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
186+
-XX:ReservedCodeCacheSize=256m \
187+
-XX:+UseCodeCacheFlushing \
188+
-XX:MetaspaceSize=256m \
189+
-XX:MaxMetaspaceSize=512m \
190+
-XX:MaxDirectMemorySize=1g \
191+
-XX:+HeapDumpOnOutOfMemoryError \
192+
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
193+
```
144194

145195
## Quick Start Tool
146196

197+
### x86_64 JDK 1.8
147198
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.
148199

149200
Here are some common use cases of the scripting tool
@@ -154,6 +205,18 @@ Here are some common use cases of the scripting tool
154205

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

208+
### ARM64 JDK 17
209+
You can refer to the [start.sh.simple](start.sh.simple).
210+
211+
```bash
212+
# cp start.sh.simple start.sh
213+
# Usage:
214+
# sh start.sh # Start the java-tron FullNode
215+
# sh start.sh -s # Stop the java-tron FullNode
216+
# sh start.sh [options] # Start with additional java-tron options,such as: -c config.conf -d /path_to_data, etc.
217+
#
218+
```
219+
157220
## Run inside Docker container
158221

159222
One of the quickest ways to get `java-tron` up and running on your machine is by using Docker:

actuator/src/main/java/org/tron/core/vm/VM.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ public static void play(Program program, JumpTable jumpTable) {
108108
} catch (JVMStackOverFlowException | OutOfTimeException e) {
109109
throw e;
110110
} catch (RuntimeException e) {
111-
if (StringUtils.isEmpty(e.getMessage())) {
111+
// https://openjdk.org/jeps/358
112+
// https://bugs.openjdk.org/browse/JDK-8220715
113+
// since jdk 14, the NullPointerExceptions message is not empty
114+
if (e instanceof NullPointerException || StringUtils.isEmpty(e.getMessage())) {
112115
logger.warn("Unknown Exception occurred, tx id: {}",
113116
Hex.toHexString(program.getRootTransactionId()), e);
114117
program.setRuntimeFailure(new RuntimeException("Unknown Exception"));

actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public boolean equals(Object o) {
314314

315315
@Override
316316
public int hashCode() {
317-
return new Integer(Boolean.valueOf(byTestingSuite).hashCode()
317+
return Boolean.valueOf(byTestingSuite).hashCode()
318318
+ Boolean.valueOf(byTransaction).hashCode()
319319
+ address.hashCode()
320320
+ balance.hashCode()
@@ -326,8 +326,7 @@ public int hashCode() {
326326
+ origin.hashCode()
327327
+ prevHash.hashCode()
328328
+ deposit.hashCode()
329-
+ timestamp.hashCode()
330-
).hashCode();
329+
+ timestamp.hashCode();
331330
}
332331

333332
@Override

actuator/src/main/java/org/tron/core/vm/repository/Type.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public boolean equals(Object obj) {
7373

7474
@Override
7575
public int hashCode() {
76-
return new Integer(type).hashCode();
76+
return type;
7777
}
7878

7979
@Override

actuator/src/main/java/org/tron/core/vm/repository/Value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public boolean equals(Object obj) {
5858

5959
@Override
6060
public int hashCode() {
61-
return new Integer(type.hashCode() + Objects.hashCode(value)).hashCode();
61+
return type.hashCode() + Objects.hashCode(value);
6262
}
6363
}

build.gradle

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,49 @@
1+
import org.gradle.nativeplatform.platform.internal.Architectures
12
allprojects {
23
version = "1.0.0"
34
apply plugin: "java-library"
45
}
6+
def arch = System.getProperty("os.arch").toLowerCase()
7+
def javaVersion = JavaVersion.current()
8+
def isArm64 = Architectures.AARCH64.isAlias(arch)
9+
def archSource = isArm64 ? "arm" : "x86"
10+
11+
ext.archInfo = [
12+
name : arch,
13+
java : javaVersion,
14+
isArm64 : isArm64,
15+
sourceSets: [
16+
main: [
17+
java: [
18+
srcDirs: ["src/main/java/common", "src/main/java/${archSource}"]
19+
]
20+
],
21+
test: [
22+
java: [
23+
srcDirs: ["src/test/java"]
24+
]
25+
]
26+
],
27+
requires: [
28+
JavaVersion: isArm64 ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8,
29+
RocksdbVersion: isArm64 ? '7.7.3' : '5.15.10'
30+
],
31+
VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions"
32+
]
33+
34+
if (!archInfo.java.is(archInfo.requires.JavaVersion)) {
35+
throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}")
36+
}
37+
38+
println "Building for architecture: ${archInfo.name}, Java version: ${archInfo.java}"
39+
540

641
subprojects {
742
apply plugin: "jacoco"
843
apply plugin: "maven-publish"
944

1045
sourceCompatibility = JavaVersion.VERSION_1_8
11-
targetCompatibility = JavaVersion.VERSION_1_8
46+
targetCompatibility = JavaVersion.current()
1247

1348
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1449
jacoco {
@@ -49,10 +84,16 @@ subprojects {
4984
implementation group: 'joda-time', name: 'joda-time', version: '2.3'
5085
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
5186

52-
compileOnly 'org.projectlombok:lombok:1.18.12'
53-
annotationProcessor 'org.projectlombok:lombok:1.18.12'
54-
testCompileOnly 'org.projectlombok:lombok:1.18.12'
55-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
87+
compileOnly 'org.projectlombok:lombok:1.18.34'
88+
annotationProcessor 'org.projectlombok:lombok:1.18.34'
89+
testCompileOnly 'org.projectlombok:lombok:1.18.34'
90+
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
91+
92+
// https://www.oracle.com/java/technologies/javase/11-relnote-issues.html#JDK-8190378
93+
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
94+
// for json-rpc, see https://github.com/briandilley/jsonrpc4j/issues/278
95+
implementation group: 'javax.jws', name: 'javax.jws-api', version: '1.1'
96+
annotationProcessor group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
5697

5798
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
5899
testImplementation "org.mockito:mockito-core:4.11.0"
@@ -71,6 +112,10 @@ subprojects {
71112
reproducibleFileOrder = true
72113
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
73114
}
115+
tasks.withType(Test).configureEach {
116+
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:environment
117+
environment 'CI', 'true'
118+
}
74119
}
75120

76121
task copyToParent(type: Copy) {

chainbase/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies {
1010
api project(":common")
1111
api project(":crypto")
1212
api "org.fusesource.jansi:jansi:$jansiVersion"
13-
api 'io.github.tronprotocol:zksnark-java-sdk:1.0.0'
1413
api 'org.reflections:reflections:0.9.11'
1514
}
1615

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.tron.common.storage;
2+
3+
import org.tron.common.setting.RocksDbSettings;
4+
import org.tron.common.utils.StorageUtils;
5+
6+
public class OptionsPicker {
7+
8+
protected org.iq80.leveldb.Options getOptionsByDbNameForLevelDB(String dbName) {
9+
return StorageUtils.getOptionsByDbName(dbName);
10+
}
11+
12+
protected org.rocksdb.Options getOptionsByDbNameForRocksDB(String dbName) {
13+
return RocksDbSettings.getOptionsByDbName(dbName);
14+
}
15+
}

0 commit comments

Comments
 (0)