Skip to content

Commit

Permalink
Merge branch 'tronprotocol:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lxcmyf authored Dec 27, 2023
2 parents 20d7d3e + 989115a commit f0b3fb7
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 144 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Fill in the private key of super representative address into the `localwitness`

```
localwitness = [
650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812
<your_private_key>
]
```

Expand Down Expand Up @@ -193,7 +193,7 @@ Thank you for considering to help out with the source code! If you'd like to con

# Integrity Check

- After January 3, 2023, releases are signed the gpg key:
- After January 3, 2023, the release files will be signed using a GPG key pair, and the correctness of the signature will be verified using the following public key:
```
pub: 1254 F859 D2B1 BD9F 66E7 107D F859 BCB4 4A28 290B
uid: build@tron.network
Expand Down
16 changes: 0 additions & 16 deletions actuator/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
description = "actuator – a series of transactions for blockchain."

// Dependency versions
// ---------------------------------------

def junitVersion = "4.13.2"
def mockitoVersion = "2.1.0"
def testNgVersion = "6.11"
def slf4jVersion = "1.7.25"
// --------------------------------------

dependencies {
compile project(":chainbase")
compile project(":protocol")
compile project(":crypto")
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"

compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
compile 'org.reflections:reflections:0.9.11'
}

test {
Expand Down
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ subprojects {
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile "org.slf4j:jcl-over-slf4j:1.7.25"
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
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'
compile group: 'com.google.guava', name: 'guava', version: '30.1-jre'
compile "com.google.code.findbugs:jsr305:3.0.0"
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
Expand All @@ -52,7 +47,15 @@ subprojects {
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
compile "org.apache.commons:commons-collections4:4.1"
compile group: 'joda-time', name: 'joda-time', version: '2.3'
compile 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'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "org.mockito:mockito-core:2.1.0"
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
34 changes: 2 additions & 32 deletions chainbase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,16 @@ description = "chainbase – a decentralized database for blockchain."

// Dependency versions
// ---------------------------------------

def junitVersion = "4.13.2"
def mockitoVersion = "2.1.0"
def testNgVersion = "6.11"
def jacocoVersion = "0.8.0"
def leveldbVersion = "1.8"
def jansiVersion = "1.16"
// --------------------------------------

static def isWindows() {
return org.gradle.internal.os.OperatingSystem.current().isWindows()
}

if (isWindows()) {
ext {
leveldbGroup = "org.ethereum"
leveldbName = "leveldbjni-all"
leveldbVersion = "1.18.3"
}
} else {
ext {
leveldbGroup = "org.fusesource.leveldbjni"
leveldbName = "leveldbjni-all"
leveldbVersion = "1.8"
}
}

dependencies {
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"

compile group: leveldbGroup, name: leveldbName, version: leveldbVersion
compile "org.fusesource.jansi:jansi:$jansiVersion"
compile group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10'
compile group: 'com.typesafe', name: 'config', version: '1.3.2'
compile 'io.github.tronprotocol:zksnark-java-sdk:1.0.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'
compile project(":protocol")
compile project(":common")
compile project(":crypto")
compile "org.fusesource.jansi:jansi:$jansiVersion"
compile 'io.github.tronprotocol:zksnark-java-sdk:1.0.0'
compile 'org.reflections:reflections:0.9.11'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class BlockCapsule implements ProtoCapsule<Block> {

private Block block;
private List<TransactionCapsule> transactions = new ArrayList<>();
private StringBuilder toStringBuff = new StringBuilder();
private boolean isSwitch;
@Getter
@Setter
Expand Down Expand Up @@ -314,7 +313,7 @@ public boolean hasWitnessSignature() {

@Override
public String toString() {
toStringBuff.setLength(0);
StringBuilder toStringBuff = new StringBuilder();

toStringBuff.append("BlockCapsule \n[ ");
toStringBuff.append("hash=").append(getBlockId()).append("\n");
Expand Down
7 changes: 0 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ sourceCompatibility = 1.8

// Dependency versions
// ---------------------------------------

def leveldbVersion = "1.8"
// --------------------------------------

Expand All @@ -30,13 +29,7 @@ if (isWindows()) {
}
}

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.13.2'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.1'
compile "com.cedarsoftware:java-util:1.8.0"
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1'
Expand Down
2 changes: 1 addition & 1 deletion config/checkstyle/checkStyle.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
"https://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
Expand Down
2 changes: 1 addition & 1 deletion config/checkstyle/checkStyleAll.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
"https://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
Expand Down
13 changes: 0 additions & 13 deletions consensus/build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
description = "consensus – a distributed consensus arithmetic for blockchain."

// Dependency versions
// ---------------------------------------
def junitVersion = "4.13.2"
def mockitoVersion = "2.1.0"
def testNgVersion = "6.11"
def slf4jVersion = "1.7.25"
// --------------------------------------

dependencies {
compile project(":chainbase")
compile project(":protocol")
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
}

test {
Expand Down
2 changes: 0 additions & 2 deletions crypto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ repositories {
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.13.2'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
compile project(":common")
}

Expand Down
2 changes: 1 addition & 1 deletion docs/implement-a-customized-actuator-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public class SumActuatorTest {
@Test
public void sumActuatorTest() {
// this key is defined in config-localtest.conf as accountName=Sun
String key = "cba92a516ea09f620a16ff7ee95ce0df1d56550a8babe9964981a7144c8a784a";
String key = "<your_private_key>";
byte[] address = PublicMethed.getFinalAddress(key);
ECKey ecKey = null;
try {
Expand Down
2 changes: 1 addition & 1 deletion docs/implement-a-customized-actuator-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public class SumActuatorTest {
@Test
public void sumActuatorTest() {
// this key is defined in config-localtest.conf as accountName=Sun
String key = "cba92a516ea09f620a16ff7ee95ce0df1d56550a8babe9964981a7144c8a784a";
String key = "<your_private_key>";
byte[] address = PublicMethed.getFinalAddress(key);
ECKey ecKey = null;
try {
Expand Down
23 changes: 0 additions & 23 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,17 @@ dependencies {
//local libraries
compile fileTree(dir: 'libs', include: '*.jar')
// end local libraries
testCompile group: 'junit', name: 'junit', version: '4.13.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.13.0'
testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '1.0.0.1'
testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.16.0'

compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'

compile group: 'com.typesafe', name: 'config', version: '1.3.2'

compile "com.cedarsoftware:java-util:1.8.0"

compile group: 'com.beust', name: 'jcommander', version: '1.72'

compile group: 'junit', name: 'junit', version: '4.13.2'

compile group: 'net.jcip', name: 'jcip-annotations', version: '1.0'

compile group: 'com.google.inject', name: 'guice', version: '4.1.0'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.5'

compile group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.1.2'
compile group: 'com.github.davidb', name: 'metrics-influxdb', version: '0.8.2'

compile group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5'

//compile 'com.googlecode.cqengine:cqengine:2.12.4'
compile group: 'com.google.api.grpc', name: 'proto-google-common-protos', version: '2.15.0'

// http
compile 'org.eclipse.jetty:jetty-server:9.4.53.v20231009'
compile 'org.eclipse.jetty:jetty-servlet:9.4.53.v20231009'
compile 'com.alibaba:fastjson:1.2.83'
compile group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1'
// end http

// https://mvnrepository.com/artifact/com.github.briandilley.jsonrpc4j/jsonrpc4j
Expand Down
2 changes: 1 addition & 1 deletion framework/config/checkstyle/checkStyle.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
"https://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
Expand Down
2 changes: 1 addition & 1 deletion framework/config/checkstyle/checkStyleAll.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
"https://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">

<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.tron.core.net.message.MessageTypes;
import org.tron.core.net.message.TronMessage;
import org.tron.p2p.discover.Node;
import org.tron.program.Version;
import org.tron.protos.Discover.Endpoint;
import org.tron.protos.Protocol;
import org.tron.protos.Protocol.HelloMessage.Builder;
Expand Down Expand Up @@ -61,6 +62,7 @@ public HelloMessage(Node from, long timestamp, ChainBaseManager chainBaseManager
builder.setNodeType(chainBaseManager.getNodeType().getType());
builder.setLowestBlockNum(chainBaseManager.isLiteNode()
? chainBaseManager.getLowestBlockNum() : 0);
builder.setCodeVersion(ByteString.copyFrom(Version.getVersion().getBytes()));

this.helloMessage = builder.build();
this.type = MessageTypes.P2P_HELLO.asByte();
Expand Down Expand Up @@ -127,17 +129,23 @@ public String toString() {
.append("lowestBlockNum: ").append(helloMessage.getLowestBlockNum()).append("\n");

ByteString address = helloMessage.getAddress();
if (address != null && !address.isEmpty()) {
if (!address.isEmpty()) {
builder.append("address:")
.append(StringUtil.encode58Check(address.toByteArray())).append("\n");
}

ByteString signature = helloMessage.getSignature();
if (signature != null && !signature.isEmpty()) {
if (!signature.isEmpty()) {
builder.append("signature:")
.append(signature.toByteArray().length).append("\n");
}

ByteString codeVersion = helloMessage.getCodeVersion();
if (!codeVersion.isEmpty()) {
builder.append("codeVersion:")
.append(new String(codeVersion.toByteArray())).append("\n");
}

return builder.toString();
}

Expand Down
12 changes: 10 additions & 2 deletions framework/src/main/java/org/tron/core/services/RpcApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2475,9 +2475,13 @@ public void createShieldedContractParameters(
ShieldedTRC20Parameters shieldedTRC20Parameters = wallet
.createShieldedContractParameters(request);
responseObserver.onNext(shieldedTRC20Parameters);
} catch (ZksnarkException | ContractValidateException e) {
responseObserver.onError(getRunTimeException(e));
logger.info("createShieldedContractParameters: {}", e.getMessage());
return;
} catch (Exception e) {
responseObserver.onError(getRunTimeException(e));
logger.info("createShieldedContractParameters exception caught: " + e.getMessage());
logger.error("createShieldedContractParameters: ", e);
return;
}
responseObserver.onCompleted();
Expand Down Expand Up @@ -2518,9 +2522,13 @@ public void scanShieldedTRC20NotesByIvk(
request.getNk().toByteArray(),
request.getEventsList());
responseObserver.onNext(decryptNotes);
} catch (BadItemException | ZksnarkException e) {
responseObserver.onError(getRunTimeException(e));
logger.info("scanShieldedTRC20NotesByIvk: {}", e.getMessage());
return;
} catch (Exception e) {
responseObserver.onError(getRunTimeException(e));
logger.info("scanShieldedTRC20NotesByIvk exception caught: " + e.getMessage());
logger.error("scanShieldedTRC20NotesByIvk:", e);
return;
}
responseObserver.onCompleted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public static String getMemo(byte[] memo) {
}

public static void processError(Exception e, HttpServletResponse response) {
logger.debug("Exception: {}", e.getMessage());
logger.debug(e.getMessage(), e);
try {
response.getWriter().println(Util.printErrorMsg(e));
} catch (IOException ioe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.google.protobuf.ByteString;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.junit.AfterClass;
import org.junit.Assert;
Expand Down Expand Up @@ -146,4 +148,20 @@ public void testGetTimeStamp() {
Assert.assertEquals(1234L, blockCapsule0.getTimeStamp());
}

@Test
public void testConcurrentToString() throws InterruptedException {
List<Thread> threadList = new ArrayList<>();
int n = 10;
for (int i = 0; i < n; i++) {
threadList.add(new Thread(() -> blockCapsule0.toString()));
}
for (int i = 0; i < n; i++) {
threadList.get(i).start();
}
for (int i = 0; i < n; i++) {
threadList.get(i).join();
}
Assert.assertTrue(true);
}

}
Loading

0 comments on commit f0b3fb7

Please sign in to comment.