Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 53 additions & 0 deletions .github/workflows/arm64-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: arm64-Platform Matrix

on:
push:
branches: [ "exp/arm64" ]
pull_request:
branches: [ "exp/arm64" ]

jobs:
build:

name: ${{ matrix.os }} - ${{ matrix.os-version }}
runs-on: ${{ matrix.runner }}

strategy:
fail-fast: false
matrix:
include:
# Apple Silicon runners (using latest available)
- os: macOS
arch: arm64
runner: macos-14
os-version: "14"
- os: macOS
arch: arm64
runner: macos-15
os-version: "15"

permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew clean build --no-daemon
79 changes: 79 additions & 0 deletions .github/workflows/math-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Check Math Usage

on:
push:
branches: [ "exp/arm64" ]
pull_request:
branches: [ "exp/arm64" ]
workflow_dispatch:

jobs:
check-math:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check for java.lang.Math usage
id: check-math
shell: bash
run: |
echo "Checking for java.lang.Math usage..."

touch math_usage.txt

while IFS= read -r file; do
perl -0777 -ne '
s/"([^"\\]|\\.)*"//g;
s/'\''([^'\''\\]|\\.)*'\''//g;
s!/\*([^*]|\*[^/])*\*/!!g;
s!//[^\n]*!!g;
$hasMath = 0;
$hasMath = 1 if /^[\s]*import[\s]+java\.lang\.Math\b/m;
$hasMath = 1 if /\bjava\s*\.\s*lang\s*\.\s*Math\s*\./;
$hasMath = 1 if /(?<![\w\.])(?<!Strict)Math\s*\./;
print "$ARGV\n" if $hasMath;
' "$file" >> math_usage.txt
done < <(find . -type f -name "*.java")

sort -u math_usage.txt -o math_usage.txt

if [ -s math_usage.txt ]; then
echo "Found Math usage in:"
cat math_usage.txt
echo "math_found=true" >> $GITHUB_OUTPUT
else
echo "No Math usage found"
echo "math_found=false" >> $GITHUB_OUTPUT
fi

- name: Upload findings
if: steps.check-math.outputs.math_found == 'true'
uses: actions/upload-artifact@v4
with:
name: math-usage-report
path: math_usage.txt

- name: Create comment
if: github.event_name == 'pull_request' && steps.check-math.outputs.math_found == 'true'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const findings = fs.readFileSync('math_usage.txt', 'utf8');
const body = `### Math Usage Detection Results

Found usage of \`java.lang.Math\` in the following files:

\`\`\`
${findings}
\`\`\`

Please review if this usage is intended.`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
62 changes: 62 additions & 0 deletions .github/workflows/x86_64-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: X86_64-Platform Matrix

on:
push:
branches: [ "exp/arm64" ]
pull_request:
branches: [ "exp/arm64" ]

jobs:
build:

name: ${{ matrix.os }} - ${{ matrix.os-version }}
runs-on: ${{ matrix.runner }}

strategy:
fail-fast: false
matrix:
include:
# Macos Intel runners
- os: macOS
arch: x86_64
runner: macos-12
os-version: "12"
- os: macOS
arch: x86_64
runner: macos-13
os-version: "13"
# Linux x86_64 runners
- os: Linux
arch: x86_64
runner: ubuntu-20.04
os-version: "20.04"
- os: Linux
arch: x86_64
runner: ubuntu-22.04
os-version: "22.04"

permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'zulu'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew clean build --no-daemon
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
55 changes: 45 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
import org.gradle.nativeplatform.platform.internal.Architectures
allprojects {
version = "1.0.0"
apply plugin: "java-library"
}

static def isX86() {
def arch = System.getProperty("os.arch").toLowerCase()
return Architectures.X86_64.isAlias(arch) || Architectures.X86.isAlias(arch)
}

static def isArm64() {
def arch = System.getProperty("os.arch").toLowerCase()
return new Architectures.KnownArchitecture("arm64", "aarch64").isAlias(arch)
}

if (isArm64() && !JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
throw new GradleException("Java 17 or later is required to build Java-Tron for arm64.\n" +
" Detected version ${JavaVersion.current()}")
}

if (isX86() && !JavaVersion.current().isJava8()) {
throw new GradleException("Java 8 is required to build Java-Tron for x86.\n" +
" Detected version ${JavaVersion.current()}")
}

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 {
toolVersion = "0.8.12" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
}
buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -46,30 +69,42 @@ 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'
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:2.13.0"
// see https://github.com/mockito/mockito/releases/tag/v5.0.0
// Mockito 5 update the minimum supported Java version to 11
// Mockito 4 supports Java 8 and above.
testImplementation "org.mockito:mockito-core:4.11.0"
}

task sourcesJar(type: Jar, dependsOn: classes) {
tasks.register('sourcesJar', Jar) {
dependsOn classes
classifier = "sources"
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}


tasks.withType(AbstractArchiveTask) {
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
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) {
tasks.register('copyToParent', Copy) {
into "$buildDir/libs"
subprojects {
from tasks.withType(Jar)
Expand Down
4 changes: 0 additions & 4 deletions chainbase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ description = "chainbase – a decentralized database for blockchain."

// Dependency versions
// ---------------------------------------
def jacocoVersion = "0.8.0"
def jansiVersion = "1.16"
// --------------------------------------

Expand Down Expand Up @@ -41,9 +40,6 @@ test {
}
}

jacoco {
toolVersion = jacocoVersion // See http://www.eclemma.org/jacoco/.
}

jacocoTestReport {
reports {
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
Loading