Skip to content

Commit 18deb27

Browse files
committed
feat(db): remove leveldb support for arm64
1 parent 298b059 commit 18deb27

50 files changed

Lines changed: 422 additions & 265 deletions

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: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ TRON enables large-scale development and engagement. With over 2000 transactions
5959

6060
# Building the Source Code
6161

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

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

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

7890
# Running java-tron
7991

80-
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.
92+
## Operating systems
93+
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.
94+
95+
## Architecture
8196

97+
### X86_64
98+
Requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.
99+
100+
### ARM64
101+
Requires 64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.
102+
103+
104+
## Configuration flile
82105
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).
83106

84107
## Hardware Requirements
@@ -100,6 +123,7 @@ Recommended:
100123

101124
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:
102125

126+
### x86_64 JDK 1.8
103127
```bash
104128
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
105129
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -111,6 +135,19 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
111135
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
112136
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
113137
```
138+
### ARM64 JDK 17
139+
```bash
140+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
141+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
142+
-XX:ReservedCodeCacheSize=256m \
143+
-XX:+UseCodeCacheFlushing \
144+
-XX:MetaspaceSize=256m \
145+
-XX:MaxMetaspaceSize=512m \
146+
-XX:MaxDirectMemorySize=1g \
147+
-XX:+HeapDumpOnOutOfMemoryError \
148+
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
149+
```
150+
114151

115152
## Running a super representative node for mainnet
116153

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

127164
then run the following command to start the node:
128165

166+
### x86_64 JDK 1.8
129167
```bash
130168
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
131169
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -137,6 +175,18 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
137175
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
138176
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
139177
```
178+
### ARM64 JDK 17
179+
```bash
180+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
181+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
182+
-XX:ReservedCodeCacheSize=256m \
183+
-XX:+UseCodeCacheFlushing \
184+
-XX:MetaspaceSize=256m \
185+
-XX:MaxMetaspaceSize=512m \
186+
-XX:MaxDirectMemorySize=1g \
187+
-XX:+HeapDumpOnOutOfMemoryError \
188+
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
189+
```
140190

141191
## Quick Start Tool
142192

build.gradle

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,40 @@ allprojects {
66
springVersion = "5.3.39"
77
}
88
}
9-
10-
static def isX86() {
11-
def arch = System.getProperty("os.arch").toLowerCase()
12-
return Architectures.X86_64.isAlias(arch) || Architectures.X86.isAlias(arch)
9+
def arch = System.getProperty("os.arch").toLowerCase()
10+
def javaVersion = JavaVersion.current()
11+
def isArm64 = Architectures.AARCH64.isAlias(arch)
12+
def archSource = isArm64 ? "arm" : "x86"
13+
14+
ext.archInfo = [
15+
name : arch,
16+
java : javaVersion,
17+
isArm64 : isArm64,
18+
sourceSets: [
19+
main: [
20+
java: [
21+
srcDirs: ["src/main/java/common", "src/main/java/${archSource}"]
22+
]
23+
],
24+
test: [
25+
java: [
26+
srcDirs: ["src/test/java"]
27+
]
28+
]
29+
],
30+
requires: [
31+
JavaVersion: isArm64 ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8,
32+
RocksdbVersion: isArm64 ? '7.7.3' : '5.15.10'
33+
],
34+
VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions"
35+
]
36+
37+
if (!archInfo.java.is(archInfo.requires.JavaVersion)) {
38+
throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}")
1339
}
1440

15-
static def isArm64() {
16-
def arch = System.getProperty("os.arch").toLowerCase()
17-
return new Architectures.KnownArchitecture("arm64", "aarch64").isAlias(arch)
18-
}
41+
println "Building for architecture: ${archInfo.name}, Java version: ${archInfo.java}"
1942

20-
if (isArm64() && !JavaVersion.current().is(JavaVersion.VERSION_17)) {
21-
throw new GradleException("Java 17 is required to build Java-Tron for arm64.\n" +
22-
" Detected version ${JavaVersion.current()}")
23-
}
24-
25-
if (isX86() && !JavaVersion.current().isJava8()) {
26-
throw new GradleException("Java 8 is required to build Java-Tron for x86.\n" +
27-
" Detected version ${JavaVersion.current()}")
28-
}
2943

3044
subprojects {
3145
apply plugin: "jacoco"

chainbase/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ dependencies {
1010
api project(":common")
1111
api project(":crypto")
1212
api "org.fusesource.jansi:jansi:$jansiVersion"
13-
api group: 'commons-io', name: 'commons-io', version: '2.18.0'
14-
api 'io.github.tronprotocol:zksnark-java-sdk:1.0.0' exclude(group: 'commons-io', module: 'commons-io')
1513
api 'org.reflections:reflections:0.9.11'
1614
}
1715

framework/build.gradle

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ test {
116116
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
117117
classDumpDir = file("$buildDir/jacoco/classpathdumps")
118118
}
119+
if (rootProject.archInfo.isArm64) {
120+
exclude { element ->
121+
element.file.name.toLowerCase().contains('leveldb')
122+
}
123+
exclude('org/tron/program/DBConvertTest.class')
124+
filter {
125+
excludeTestsMatching '*.*leveldb*'
126+
excludeTestsMatching '*.*Leveldb*'
127+
excludeTestsMatching '*.*LevelDB*'
128+
excludeTestsMatching '*.*LevelDb*'
129+
}
130+
}
119131
if (isWindows()) {
120132
exclude '**/ShieldedTransferActuatorTest.class'
121133
exclude '**/BackupDbUtilTest.class'
@@ -197,17 +209,8 @@ def createScript(project, mainClass, name) {
197209
}
198210
}
199211
}
200-
if (JavaVersion.current().is(JavaVersion.VERSION_17)) {
201-
applicationDistribution.from("${project.rootDir}/gradle/jdk17/java-tron.vmoptions") {
202-
into "bin"
203-
}
204-
} else if (JavaVersion.current().isJava8()){
205-
applicationDistribution.from("${project.rootDir}/gradle/java-tron.vmoptions") {
206-
into "bin"
207-
}
208-
} else {
209-
throw new GradleException("Java 8 or Java 17 is supported to build Java-Tron.\n" +
210-
" Detected version ${JavaVersion.current()}")
212+
applicationDistribution.from(rootProject.archInfo.VMOptions) {
213+
into "bin"
211214
}
212215
//distZip {
213216
// doLast {

framework/src/main/java/org/tron/program/DBConvert.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.rocksdb.RocksDBException;
3333
import org.rocksdb.RocksIterator;
3434
import org.rocksdb.Status;
35+
import org.tron.common.arch.Arch;
3536
import org.tron.common.utils.FileUtil;
3637
import org.tron.common.utils.MarketOrderPriceComparatorForLevelDB;
3738
import org.tron.common.utils.MarketOrderPriceComparatorForRocksDB;
@@ -91,6 +92,13 @@ public static org.iq80.leveldb.Options newDefaultLevelDbOptions() {
9192
}
9293

9394
public static void main(String[] args) {
95+
if (Arch.isArm64()) {
96+
String tips = String.format("This tool is not supported on %s architecture.",
97+
Arch.getOsArch());
98+
System.err.println(tips);
99+
logger.error(tips);
100+
return;
101+
}
94102
int code = run(args);
95103
logger.info("exit code {}.", code);
96104
System.out.printf("exit code %d.\n", code);

framework/src/main/resources/config.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ net {
55

66
storage {
77
# Directory for storing persistent data
8-
db.engine = "LEVELDB",
8+
db.engine = "LEVELDB", // deprecated for arm, because arm only support "ROCKSDB".
99
db.sync = false,
1010
db.directory = "database",
1111
index.directory = "index",
@@ -19,7 +19,7 @@ storage {
1919
# Otherwise, db configs will remain default and data will be stored in
2020
# the path of "output-directory" or which is set by "-d" ("--output-directory").
2121

22-
# setting can impove leveldb performance .... start
22+
# setting can impove leveldb performance .... start, deprecated for arm
2323
# node: if this will increase process fds,you may be check your ulimit if 'too many open files' error occurs
2424
# see https://github.com/tronprotocol/tips/blob/master/tip-343.md for detail
2525
# if you find block sync has lower performance,you can try this settings
@@ -32,21 +32,21 @@ storage {
3232
#defaultL = {
3333
# maxOpenFiles = 1000
3434
#}
35-
# setting can impove leveldb performance .... end
35+
# setting can impove leveldb performance .... end, deprecated for arm
3636

3737
# Attention: name is a required field that must be set !!!
3838
properties = [
3939
// {
4040
// name = "account",
4141
// path = "storage_directory_test",
42-
// createIfMissing = true,
42+
// createIfMissing = true, // deprecated for arm start
4343
// paranoidChecks = true,
4444
// verifyChecksums = true,
4545
// compressionType = 1, // compressed with snappy
4646
// blockSize = 4096, // 4 KB = 4 * 1024 B
4747
// writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
4848
// cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
49-
// maxOpenFiles = 100
49+
// maxOpenFiles = 100 // deprecated for arm end
5050
// },
5151
// {
5252
// name = "account-index",

gradle/verification-metadata.xml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -551,35 +551,6 @@
551551
<sha256 value="cf8878e091c721ce2944d74979e9e38972019381781fcd6882f1562ba8d47e60" origin="Generated by Gradle"/>
552552
</artifact>
553553
</component>
554-
<component group="com.halibobor" name="leveldb" version="1.18.3">
555-
<artifact name="leveldb-1.18.3.jar">
556-
<sha256 value="0f722db29feb192377769555c73bc1a9bc6b81d31400957d596c645c957e45cc" origin="Generated by Gradle"/>
557-
</artifact>
558-
<artifact name="leveldb-1.18.3.pom">
559-
<sha256 value="4ae67f61cef4c5e2f460215f1b92832c5bc5a97c6c3d5b0219ddd20156143fd8" origin="Generated by Gradle"/>
560-
</artifact>
561-
</component>
562-
<component group="com.halibobor" name="leveldb-api" version="1.18.3">
563-
<artifact name="leveldb-api-1.18.3.jar">
564-
<sha256 value="3da4c1711f01e9087ca1cc58c55ac098d02c808d401d5595d084532ca227b101" origin="Generated by Gradle"/>
565-
</artifact>
566-
<artifact name="leveldb-api-1.18.3.pom">
567-
<sha256 value="825a008e567eb81d422581a567ba780b45a21ff0537e11d1fea9f49a3c332d33" origin="Generated by Gradle"/>
568-
</artifact>
569-
</component>
570-
<component group="com.halibobor" name="leveldb-project" version="1.18.3">
571-
<artifact name="leveldb-project-1.18.3.pom">
572-
<sha256 value="c908cfdc66a933a890ab0ae77ceb28676c995a9abbb15e4946a436ce1fc995b5" origin="Generated by Gradle"/>
573-
</artifact>
574-
</component>
575-
<component group="com.halibobor" name="leveldbjni-all" version="1.18.3">
576-
<artifact name="leveldbjni-all-1.18.3.jar">
577-
<sha256 value="83a72983b6a8e0b90449f7f1e9d56c9db54526288c21c93614c9c52b351fb232" origin="Generated by Gradle"/>
578-
</artifact>
579-
<artifact name="leveldbjni-all-1.18.3.pom">
580-
<sha256 value="2559bdc07dfda47215c6bad79a540566def47c2c110963e6e48402320530fd90" origin="Generated by Gradle"/>
581-
</artifact>
582-
</component>
583554
<component group="com.mchange" name="c3p0" version="0.9.5.4">
584555
<artifact name="c3p0-0.9.5.4.jar">
585556
<sha256 value="60cf2906cd6ad6771f514a3e848b74b3e3da99c1806f2a63c38e2dd8da5ef11f" origin="Generated by Gradle"/>

platform/build.gradle

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,17 @@
1-
import org.gradle.nativeplatform.platform.internal.Architectures
2-
31
description = "platform – a distributed consensus arithmetic for blockchain."
42

5-
6-
static def isX86() {
7-
def arch = System.getProperty("os.arch").toLowerCase()
8-
return Architectures.X86_64.isAlias(arch) || Architectures.X86.isAlias(arch)
9-
}
10-
11-
static def isArm64() {
12-
def arch = System.getProperty("os.arch").toLowerCase()
13-
return new Architectures.KnownArchitecture("arm64", "aarch64").isAlias(arch)
14-
}
15-
16-
if (isX86()) {
17-
ext {
18-
leveldbGroup = "org.fusesource.leveldbjni"
19-
leveldbName = "leveldbjni-all"
20-
leveldbVersion = "1.8"
21-
rocksDBVersion = "5.15.10"
22-
}
23-
} else if (isArm64()) {
24-
ext {
25-
leveldbGroup = "com.halibobor"
26-
leveldbName = "leveldbjni-all"
27-
leveldbVersion = "1.18.3"
28-
rocksDBVersion = "7.7.3"
29-
}
30-
} else {
31-
throw new GradleException("Unsupported architecture: ${System.getProperty("os.arch")}")
32-
}
33-
343
sourceSets {
35-
x86 {
36-
java {
37-
srcDirs 'src/main/java/x86', 'src/main/java/common'
38-
}
4+
main {
5+
java.srcDirs = rootProject.archInfo.sourceSets.main.java.srcDirs
396
}
40-
arm {
41-
java {
42-
srcDirs 'src/main/java/arm', 'src/main/java/common'
43-
}
7+
test {
8+
java.srcDirs = rootProject.archInfo.sourceSets.test.java.srcDirs
449
}
4510
}
4611

4712
dependencies {
48-
api group: leveldbGroup, name: leveldbName, version: leveldbVersion
49-
api group: 'org.rocksdb', name: 'rocksdbjni', version: rocksDBVersion
50-
}
51-
52-
tasks.withType(JavaCompile).configureEach {
53-
source = isX86() ? sourceSets.x86.java : sourceSets.arm.java
13+
api group: 'org.fusesource.leveldbjni', name: 'leveldbjni-all', version: '1.8'
14+
api group: 'org.rocksdb', name: 'rocksdbjni', version: "${rootProject.archInfo.requires.RocksdbVersion}"
15+
api group: 'commons-io', name: 'commons-io', version: '2.18.0'
16+
api 'io.github.tronprotocol:zksnark-java-sdk:1.0.0' exclude(group: 'commons-io', module: 'commons-io')
5417
}

platform/src/main/java/common/org/tron/common/arch/Arch.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ public static boolean isArm64() {
5757
String osArch = getOsArch();
5858
return osArch.contains("arm64") || osArch.contains("aarch64");
5959
}
60+
61+
public static void throwUnsupportedArm64Exception() {
62+
if (isArm64()) {
63+
throw new UnsupportedOperationException("unsupported on " + getOsArch() + " architecture");
64+
}
65+
}
6066
}

0 commit comments

Comments
 (0)