Skip to content
Open
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
42 changes: 42 additions & 0 deletions tools/gradlew/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
import org.gradle.nativeplatform.platform.internal.Architectures
import org.gradle.internal.os.OperatingSystem

plugins {
id 'java'
}

def arch = System.getProperty("os.arch").toLowerCase()
def javaVersion = JavaVersion.current()
def isArm64 = Architectures.AARCH64.isAlias(arch)
def archSource = isArm64 ? "arm" : "x86"
def isMac = OperatingSystem.current().isMacOsX()

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 ? '9.7.4' : '5.15.10',
// https://github.com/grpc/grpc-java/issues/7690
// https://github.com/grpc/grpc-java/pull/12319, Add support for macOS aarch64 with universal binary
// https://github.com/grpc/grpc-java/pull/11371 , 1.64.x is not supported CentOS 7.
ProtocGenVersion: isArm64 && isMac ? '1.76.0' : '1.60.0'
],
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}"

tasks.named('jar') {
enabled = false
}
Expand Down
27 changes: 17 additions & 10 deletions tools/stress_test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.current()
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
Expand Down Expand Up @@ -44,18 +44,25 @@ dependencies {
implementation "io.netty:netty-all:4.1.100.Final"
implementation("io.github.317787106:trident:0.9.2.5")
implementation group: 'com.typesafe', name: 'config', version: '1.3.2'
// implementation 'ch.qos.logback:logback-classic:1.2.6'

implementation group: 'info.picocli', name: 'picocli', version: '4.6.3'
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'

implementation('com.github.tronprotocol.java-tron:framework:GreatVoyage-v4.7.7') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
exclude group: "ch.qos.logback", module: "logback-classic"
if (rootProject.archInfo.isArm64) {
implementation('com.github.warku123.java-tron:framework:GreatVoyage-v4.8.1-arm') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
exclude group: "ch.qos.logback", module: "logback-classic"
}
} else {
implementation('com.github.federico2014.java-tron:framework:GreatVoyage-v4.8.1-x86_64') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
exclude group: "ch.qos.logback", module: "logback-classic"
}
}
implementation platform('com.fasterxml.jackson:jackson-bom:2.14.0')
implementation(project(":toolkit")) {
Expand Down
11 changes: 9 additions & 2 deletions tools/stress_test/src/main/java/org/tron/BroadcastTx.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.tron.core.config.args.Args;
import org.tron.core.net.TronNetDelegate;
import org.tron.core.net.TronNetService;
import org.tron.core.services.RpcApiService;
import org.tron.trident.core.ApiWrapper;
import org.tron.trident.core.exceptions.IllegalException;
import org.tron.trident.proto.Chain.Block;
Expand Down Expand Up @@ -105,10 +104,18 @@ public Integer call() throws IOException, InterruptedException, IllegalException
Args.getInstance().setNodeListenPort(nodeListenPort);
logger.info("rpc.port: {}, node.listen.port {}", rpcPort, nodeListenPort);
Args.getInstance().setOpenHistoryQueryWhenLiteFN(true);
Args.getInstance().setRpcEnable(true);
Args.getInstance().setRpcSolidityEnable(false);
Args.getInstance().setRpcPBFTEnable(false);
Args.getInstance().setFullNodeHttpEnable(false);
Args.getInstance().setSolidityNodeHttpEnable(false);
Args.getInstance().setPBFTHttpEnable(false);
Args.getInstance().setJsonRpcHttpFullNodeEnable(false);
Args.getInstance().setJsonRpcHttpSolidityNodeEnable(false);
Args.getInstance().setJsonRpcHttpPBFTNodeEnable(false);

context = new TronApplicationContext(DefaultConfig.class);
app = ApplicationFactory.create(context);
app.addService(context.getBean(RpcApiService.class));
app.startup();

String url = String.format("%s:%d", "127.0.0.1",
Expand Down
4 changes: 1 addition & 3 deletions tools/stress_test/src/main/java/org/tron/CollectAddress.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.tron;

import static org.tron.plugins.utils.Constant.ACCOUNT_STORE;

import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.typesafe.config.Config;
Expand Down Expand Up @@ -130,7 +128,7 @@ private Set<ByteString> getAddressListFromDB(String dbPath, int totalNumber)
throws IOException, RocksDBException {
Set<ByteString> addressList = new HashSet<>();
String srcDir = dbPath + File.separator + "database";
DBInterface accountStore = DbTool.getDB(srcDir, ACCOUNT_STORE);
DBInterface accountStore = DbTool.getDB(srcDir, "account");
DBIterator iterator = accountStore.iterator();
for (iterator.seekToFirst(); iterator.valid(); iterator.next()) {
addressList.add(ByteString.copyFrom(iterator.getKey()));
Expand Down
18 changes: 7 additions & 11 deletions tools/toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ expenses.
- `convert`: Covert leveldb to rocksdb.
- `lite`: Split lite data for java-tron.
- `cp, copy`: Quick copy leveldb or rocksdb data.
- `root`: compute merkle root for tiny db. NOTE: large db may GC overhead
limit exceeded.
- `root`: compute merkle root for tiny db. NOTE: large db may GC overhead limit exceeded.
- `fork`: Modify the database of java-tron for shadow fork testing.
- `query`: Query the latest vote and reward information from the database.

## DB Archive
## DB Archive(Requires x86 + LevelDB)

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

Expand All @@ -50,24 +50,21 @@ DB archive provides the ability to reformat the manifest according to the curren
java -jar Toolkit.jar db archive -m 128 #4. specify optimization only when Manifest exceeds 128M
```


## DB Convert
## DB Convert(Requires x86 + LevelDB)

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

### Available parameters:

- `<src>`: Input path for leveldb, default: output-directory/database.
- `<dest>`: Output path for rocksdb, default: output-directory-dst/database.
- `--safe`: In safe mode, read data from leveldb then put into rocksdb, it's a very time-consuming procedure. If not, just change engine.properties from leveldb to rocksdb, rocksdb
is compatible with leveldb for the current version. This may not be the case in the future, default: false.
- `-h | --help`: Provide the help info.

### Examples:

```shell script
# full command
java -jar Toolkit.jar db convert [-h] [--safe] <src> <dest>
java -jar Toolkit.jar db convert [-h] <src> <dest>
# examples
java -jar Toolkit.jar db convert output-directory/database /tmp/database
```
Expand All @@ -91,7 +88,7 @@ DB copy provides a helper which can copy LevelDB or RocksDB data quickly on the
java -jar Toolkit.jar db cp output-directory/database /tmp/databse
```

## DB Lite
## DB Lite(LevelDB unavailable on ARM)

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

Expand Down Expand Up @@ -159,7 +156,7 @@ Execute move command.
java -jar Toolkit.jar db mv -c main_net_config.conf -d /data/tron/output-directory
```

## DB Root
## DB Root(LevelDB unavailable on ARM)

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

Expand All @@ -171,7 +168,6 @@ NOTE: large db may GC overhead limit exceeded.
- `--db`: db name.
- `-h | --help`: provide the help info


## DB Fork
DB fork tool can help launch a private java-tron FullNode or network based on the state of public chain database to support shadow fork testing.

Expand Down
101 changes: 80 additions & 21 deletions tools/toolkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ plugins {
id 'application'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "org.sonarqube" version "2.6"
}

def springVersion = "5.3.39"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.current()
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

repositories {
Expand All @@ -17,6 +20,13 @@ repositories {
maven { url 'https://jitpack.io' }
}

// Force RocksDB version based on architecture (same as java-tron/platform module)
configurations.all {
resolutionStrategy {
force "org.rocksdb:rocksdbjni:${rootProject.archInfo.requires.RocksdbVersion}"
}
}

tasks.named('jar') {
enabled = false
dependsOn shadowJar
Expand All @@ -29,35 +39,67 @@ shadowJar {
mergeServiceFiles()
}

sourceSets {
main {
java.srcDirs = rootProject.archInfo.sourceSets.main.java.srcDirs
}
test {
java.srcDirs = rootProject.archInfo.sourceSets.test.java.srcDirs
}
}


dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation('com.github.tronprotocol.java-tron:framework:GreatVoyage-v4.7.7') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
testImplementation platform('com.fasterxml.jackson:jackson-bom:2.14.0')

implementation group: 'org.springframework', name: 'spring-context', version: "${springVersion}"
implementation group: 'info.picocli', name: 'picocli', version: '4.6.3'
implementation group: 'com.typesafe', name: 'config', version: '1.3.2'
implementation group: 'me.tongfei', name: 'progressbar', version: '0.9.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
implementation group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10'
implementation 'io.github.tronprotocol:leveldbjni-all:1.18.2'
implementation 'io.github.tronprotocol:leveldb:1.18.2'

implementation('com.github.tronprotocol.java-tron:chainbase:GreatVoyage-v4.7.7') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
implementation platform('com.fasterxml.jackson:jackson-bom:2.14.0')
implementation group: 'info.picocli', name: 'picocli', version: '4.6.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.79'

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'

implementation 'com.alibaba:fastjson:1.2.83'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
implementation group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
implementation "org.apache.commons:commons-lang3:3.4"
implementation "org.apache.commons:commons-collections4:4.1"
implementation platform('com.fasterxml.jackson:jackson-bom:2.14.0')

if (rootProject.archInfo.isArm64) {
// ARM64
testImplementation('com.github.warku123.java-tron:framework:GreatVoyage-v4.8.1-arm') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
implementation('com.github.warku123.java-tron:chainbase:GreatVoyage-v4.8.1-arm') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
implementation 'com.github.warku123.java-tron:platform:GreatVoyage-v4.8.1-arm'
} else {
// x86
testImplementation('com.github.federico2014.java-tron:framework:GreatVoyage-v4.8.1-x86_64') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
implementation('com.github.federico2014.java-tron:chainbase:GreatVoyage-v4.8.1-x86_64') {
exclude group: 'com.fasterxml.jackson', module: 'jackson-bom'
exclude group: "pull-parser", module: "pull-parser"
}
implementation('com.github.federico2014.java-tron:platform:GreatVoyage-v4.8.1-x86_64') {
exclude(group: 'org.fusesource.leveldbjni', module: 'leveldbjni-all')
exclude(group: 'io.github.tronprotocol', module: 'zksnark-java-sdk')
exclude(group: 'commons-io', module: 'commons-io')
}
implementation 'io.github.tronprotocol:leveldbjni-all:1.18.2'
implementation 'io.github.tronprotocol:leveldb:1.18.2'
}

}

application {
Expand Down Expand Up @@ -95,3 +137,20 @@ task checkstyleToolkitTest(type: Checkstyle) {
}

check.dependsOn checkstyleToolkitMain, checkstyleToolkitTest

test {
testLogging {
exceptionFormat = 'full'
}

if (rootProject.archInfo.isArm64) {
exclude 'org/tron/plugins/leveldb/**'
filter {
excludeTestsMatching '*.*leveldb*'
excludeTestsMatching '*.*Leveldb*'
excludeTestsMatching '*.*LevelDB*'
excludeTestsMatching '*.*LevelDb*'
excludeTestsMatching '*.*Archive*'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.tron.plugins;

import lombok.extern.slf4j.Slf4j;
import org.tron.common.arch.Arch;

/**
* ARM architecture only supports RocksDB,
* which does not require manifest rebuilding (manifest rebuilding is a LevelDB-only feature).
* This command is not supported but retained for compatibility.
**/
@Slf4j(topic = "archive")
public class ArchiveManifest {

public static void main(String[] args) {
int exitCode = run(args);
System.exit(exitCode);
}

public static int run(String[] args) {
String tips = String.format(
"%s architecture only supports RocksDB, which does not require manifest rebuilding "
+ "(manifest rebuilding is a LevelDB-only feature).",
Arch.getOsArch());
System.out.println(tips);
logger.warn(tips);
return 0;
}

}
Loading