Skip to content

Commit 78b1d76

Browse files
committed
feat(db): remove leveldb support for arm64
1 parent 0a905ec commit 78b1d76

47 files changed

Lines changed: 350 additions & 259 deletions

Some content is hidden

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

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: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ 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+
filter {
124+
excludeTestsMatching '*.*leveldb*'
125+
excludeTestsMatching '*.*Leveldb*'
126+
excludeTestsMatching '*.*LevelDB*'
127+
excludeTestsMatching '*.*LevelDb*'
128+
}
129+
}
119130
if (isWindows()) {
120131
exclude '**/ShieldedTransferActuatorTest.class'
121132
exclude '**/BackupDbUtilTest.class'
@@ -197,17 +208,8 @@ def createScript(project, mainClass, name) {
197208
}
198209
}
199210
}
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()}")
211+
applicationDistribution.from(rootProject.archInfo.VMOptions) {
212+
into "bin"
211213
}
212214
//distZip {
213215
// doLast {

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
}

plugins/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This package contains a set of tools for TRON, the followings are the documentation for each tool.
44

5-
## DB Archive
5+
## DB Archive(Requires x86 + LevelDB)
66

77
DB archive provides the ability to reformat the manifest according to the current `database`, parameters are compatible with the previous `ArchiveManifest`.
88

@@ -26,7 +26,7 @@ DB archive provides the ability to reformat the manifest according to the curren
2626
```
2727

2828

29-
## DB Convert
29+
## DB Convert(Requires x86 + LevelDB)
3030

3131
DB convert provides a helper which can convert LevelDB data to RocksDB data, parameters are compatible with previous `DBConvert`.
3232

@@ -64,7 +64,7 @@ DB copy provides a helper which can copy LevelDB or RocksDB data quickly on the
6464
java -jar Toolkit.jar db cp output-directory/database /tmp/databse
6565
```
6666

67-
## DB Lite
67+
## DB Lite(LevelDB unavailable on ARM)
6868

6969
DB lite provides lite database, parameters are compatible with previous `LiteFullNodeTool`.
7070

@@ -132,7 +132,7 @@ Execute move command.
132132
java -jar Toolkit.jar db mv -c main_net_config.conf -d /data/tron/output-directory
133133
```
134134

135-
## DB Root
135+
## DB Root(LevelDB unavailable on ARM)
136136

137137
DB root provides a helper which can compute merkle root for tiny db.
138138

plugins/build.gradle

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ configurations.getByName('checkstyleConfig') {
2020
transitive = false
2121
}
2222

23+
sourceSets {
24+
main {
25+
java.srcDirs = rootProject.archInfo.sourceSets.main.java.srcDirs
26+
}
27+
test {
28+
java.srcDirs = rootProject.archInfo.sourceSets.test.java.srcDirs
29+
}
30+
}
31+
2332
dependencies {
2433
//local libraries
2534
implementation fileTree(dir: 'libs', include: '*.jar')
@@ -29,12 +38,19 @@ dependencies {
2938
implementation group: 'com.typesafe', name: 'config', version: '1.3.2'
3039
implementation group: 'me.tongfei', name: 'progressbar', version: '0.9.3'
3140
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
32-
implementation 'com.halibobor:leveldbjni-all:1.18.3'
33-
implementation 'com.halibobor:leveldb:1.18.3'
34-
implementation project(":protocol")
35-
implementation project(":platform"), {
36-
exclude(group: 'org.fusesource.leveldbjni', module: 'leveldbjni-all')
41+
if (rootProject.archInfo.isArm64) {
42+
testRuntimeOnly group: 'org.fusesource.hawtjni', name: 'hawtjni-runtime', version: '1.18' // for test
43+
implementation project(":platform")
44+
} else {
45+
implementation project(":platform"), {
46+
exclude(group: 'org.fusesource.leveldbjni', module: 'leveldbjni-all')
47+
exclude(group: 'io.github.tronprotocol', module: 'zksnark-java-sdk')
48+
exclude(group: 'commons-io', module: 'commons-io')
49+
}
50+
implementation 'io.github.tronprotocol:leveldbjni-all:1.18.2'
51+
implementation 'io.github.tronprotocol:leveldb:1.18.2'
3752
}
53+
implementation project(":protocol")
3854
}
3955

4056
check.dependsOn 'lint'
@@ -78,6 +94,17 @@ test {
7894
destinationFile = file("../framework/build/jacoco/jacocoTest1.exec")
7995
classDumpDir = file("$buildDir/jacoco/classpathdumps")
8096
}
97+
98+
if (rootProject.archInfo.isArm64) {
99+
exclude 'org/tron/plugins/leveldb/**'
100+
filter {
101+
excludeTestsMatching '*.*leveldb*'
102+
excludeTestsMatching '*.*Leveldb*'
103+
excludeTestsMatching '*.*LevelDB*'
104+
excludeTestsMatching '*.*LevelDb*'
105+
excludeTestsMatching '*.*Archive*'
106+
}
107+
}
81108
}
82109

83110
jacocoTestReport {
@@ -129,17 +156,8 @@ def createScript(project, mainClass, name) {
129156
}
130157
}
131158
}
132-
if (JavaVersion.current().is(JavaVersion.VERSION_17)) {
133-
applicationDistribution.from("${project.rootDir}/gradle/jdk17/java-tron.vmoptions") {
134-
into "bin"
135-
}
136-
} else if (JavaVersion.current().isJava8()){
137-
applicationDistribution.from("${project.rootDir}/gradle/java-tron.vmoptions") {
138-
into "bin"
139-
}
140-
} else {
141-
throw new GradleException("Java 8 or Java 17 is supported to build Java-Tron.\n" +
142-
" Detected version ${JavaVersion.current()}")
159+
applicationDistribution.from(rootProject.archInfo.VMOptions) {
160+
into "bin"
143161
}
144162
createScript(project, 'org.tron.plugins.ArchiveManifest', 'ArchiveManifest')
145163
createScript(project, 'org.tron.plugins.Toolkit', 'Toolkit')

0 commit comments

Comments
 (0)