Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
- name: Build
run: ./gradlew clean build --no-daemon

- name: Toolkit jar smoke test
run: |
set -e
JAR=plugins/build/libs/Toolkit.jar
java -jar "$JAR" help
java -jar "$JAR" db --help
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

build-ubuntu:
name: Build ubuntu24 (JDK 17 / aarch64)
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'ubuntu' }}
Expand Down Expand Up @@ -84,6 +93,15 @@ jobs:
- name: Build
run: ./gradlew clean build --no-daemon

- name: Toolkit jar smoke test
run: |
set -e
JAR=plugins/build/libs/Toolkit.jar
java -jar "$JAR" help
java -jar "$JAR" db --help
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

docker-build-rockylinux:
name: Build rockylinux (JDK 8 / x86_64)
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'rockylinux' }}
Expand Down Expand Up @@ -127,6 +145,15 @@ jobs:
- name: Build
run: ./gradlew clean build --no-daemon

- name: Toolkit jar smoke test
run: |
set -e
JAR=plugins/build/libs/Toolkit.jar
java -jar "$JAR" help
java -jar "$JAR" db --help
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

- name: Test with RocksDB engine
run: ./gradlew :framework:testWithRocksDb --no-daemon

Expand Down Expand Up @@ -172,6 +199,15 @@ jobs:
- name: Build
run: ./gradlew clean build --no-daemon --no-build-cache

- name: Toolkit jar smoke test
run: |
set -e
JAR=plugins/build/libs/Toolkit.jar
java -jar "$JAR" help
java -jar "$JAR" db --help
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

- name: Test with RocksDB engine
run: ./gradlew :framework:testWithRocksDb --no-daemon --no-build-cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public class CommonParameter {

@Getter
@Setter
public boolean allowShieldedTransactionApi; // clearParam: true
public boolean allowShieldedTransactionApi; // clearParam: false
@Getter
@Setter
public long blockNumForEnergyLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class NodeConfig {
private boolean unsolidifiedBlockCheck = false;
private int maxUnsolidifiedBlocks = 54;
private String zenTokenId = "000000";
private boolean allowShieldedTransactionApi = true;
private boolean allowShieldedTransactionApi = false;
private double activeConnectFactor = 0.1;
private double connectFactor = 0.6;
// Legacy alias `maxActiveNodesWithSameIp` has no bean field: we only peek at it via
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ public ZksnarkException() {
public ZksnarkException(String message) {
super(message);
}

public ZksnarkException(String message, Throwable cause) {
super(message, cause);
}
}
2 changes: 1 addition & 1 deletion common/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ node {
minParticipationRate = 0

# Whether to enable shielded transaction API
allowShieldedTransactionApi = true
allowShieldedTransactionApi = false

# Whether to print config log at startup
openPrintLog = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,26 +284,26 @@ public void testLegacyAliasTakesPriorityOverModernKey() {
}

@Test
public void testShieldedApiDefaultsToTrueWhenNeitherKeySet() {
public void testShieldedApiDefaultsToFalseWhenNeitherKeySet() {
NodeConfig nc = NodeConfig.fromConfig(withRef());
assertTrue(nc.isAllowShieldedTransactionApi());
assertFalse(nc.isAllowShieldedTransactionApi());
}

@Test
public void testShieldedApiModernKeyRespected() {
NodeConfig nc = NodeConfig.fromConfig(
withRef("node.allowShieldedTransactionApi = false"));
assertFalse(nc.isAllowShieldedTransactionApi());
withRef("node.allowShieldedTransactionApi = true"));
assertTrue(nc.isAllowShieldedTransactionApi());
}

@Test
public void testShieldedApiLegacyKeyRespected() {
// Regression guard: reference.conf ships `allowShieldedTransactionApi = true`, which
// Regression guard: reference.conf ships `allowShieldedTransactionApi = false`, which
// used to make the legacy-key fallback dead code. A user who only set the legacy key
// must still have their value honored.
NodeConfig nc = NodeConfig.fromConfig(
withRef("node.fullNodeAllowShieldedTransaction = false"));
assertFalse(nc.isAllowShieldedTransactionApi());
withRef("node.fullNodeAllowShieldedTransaction = true"));
assertTrue(nc.isAllowShieldedTransactionApi());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.tron.core.exception;

import org.junit.Assert;
import org.junit.Test;

public class ZksnarkExceptionTest {

@Test
public void testNoArgConstructor() {
ZksnarkException e = new ZksnarkException();
Assert.assertNull(e.getMessage());
Assert.assertNull(e.getCause());
}

@Test
public void testMessageConstructor() {
ZksnarkException e = new ZksnarkException("boom");
Assert.assertEquals("boom", e.getMessage());
Assert.assertNull(e.getCause());
}

@Test
public void testMessageAndCauseConstructor() {
Throwable cause = new ArithmeticException("overflow");
ZksnarkException e = new ZksnarkException("wrapped", cause);
Assert.assertEquals("wrapped", e.getMessage());
Assert.assertSame(cause, e.getCause());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.tron.common.logsfilter;

import static org.tron.common.math.Maths.min;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
Expand Down Expand Up @@ -38,9 +37,14 @@ public static String parseDataBytes(byte[] data, String typeStr, int index) {
byte[] lengthBytes = subBytes(data, start, DATAWORD_UNIT_SIZE);
// this length is byte count. no need X 32
int length = intValueExact(lengthBytes);
if (length < 0) {
throw new OutputLengthException("data length:" + length);
}
byte[] realBytes =
length > 0 ? subBytes(data, start + DATAWORD_UNIT_SIZE, length) : new byte[0];
return type == Type.STRING ? new String(realBytes) : Hex.toHexString(realBytes);
return type == Type.STRING
? new String(realBytes, StandardCharsets.UTF_8)
: Hex.toHexString(realBytes);
}
} catch (OutputLengthException | ArithmeticException e) {
logger.debug("parseDataBytes ", e);
Expand Down Expand Up @@ -74,11 +78,15 @@ protected static Integer intValueExact(byte[] data) {
}

protected static byte[] subBytes(byte[] src, int start, int length) {
if (ArrayUtils.isEmpty(src) || start >= src.length || length < 0) {
throw new OutputLengthException("data start:" + start + ", length:" + length);
if (ArrayUtils.isEmpty(src)) {
throw new OutputLengthException("source data is empty");
}
if (start < 0 || start >= src.length || length < 0 || length > src.length - start) {
throw new OutputLengthException(
"data start:" + start + ", length:" + length + ", src.length:" + src.length);
}
byte[] dst = new byte[length];
System.arraycopy(src, start, dst, 0, min(length, src.length - start, true));
System.arraycopy(src, start, dst, 0, length);
return dst;
}

Expand Down
Loading
Loading