Skip to content

Commit 36fc506

Browse files
authored
Merge pull request #5024 from tronprotocol/release_v4.7.1
Master-Release v4.7.1
2 parents cb6c15a + 954125e commit 36fc506

File tree

38 files changed

+862
-338
lines changed

38 files changed

+862
-338
lines changed

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ $ ./gradlew clean build -x test
8181
# Running java-tron
8282
Running java-tron requires `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems.
8383

84-
Get the mainnet configurate file: [main_net_config.conf](https://github.com/tronprotocol/tron-deployment/blob/master/main_net_config.conf), other network configuration files can be find [here](https://github.com/tronprotocol/tron-deployment).
84+
Get the mainnet configuration file: [main_net_config.conf](https://github.com/tronprotocol/tron-deployment/blob/master/main_net_config.conf), other network configuration files can be find [here](https://github.com/tronprotocol/tron-deployment).
8585
## Hardware Requirements
8686
Minimum:
8787
* CPU with 8 cores
8888
* 16GB RAM
89-
* 1TB free storage space to sync the Mainnet
89+
* 2TB free storage space to sync the Mainnet
9090

9191
Recommended:
9292
* CPU with 16+ cores(32+ cores for a super representative)
9393
* 32GB+ RAM(64GB+ for a super representative)
94-
* High Performance SSD with at least 1.5TB free space
94+
* High Performance SSD with at least 2.5TB free space
9595
* 100+ MB/s download Internet service
9696

9797

@@ -174,14 +174,11 @@ Thank you for considering to help out with the source code! If you'd like to con
174174
* [Wallet-cli](https://github.com/tronprotocol/wallet-cli) TRON network wallet using command line.
175175
* [TIP](https://github.com/tronprotocol/tips) TRON Improvement Proposal (TIP) describes standards for the TRON network.
176176
* [TP](https://github.com/tronprotocol/tips/tree/master/tp) TRON Protocol (TP) describes standards already implemented in TRON network but not published as a TIP.
177-
177+
# Integrity Check
178+
* After January 3, 2023, releases are signed the gpg key:
179+
```
180+
pub: 1254 F859 D2B1 BD9F 66E7 107D F859 BCB4 4A28 290B
181+
182+
```
178183
# License
179184
java-tron is released under the [LGPLv3 license](https://github.com/tronprotocol/java-tron/blob/master/LICENSE).
180-
181-
182-
183-
The minimum hardware requirements are `CPU with 8 cores`,`16GB RAM` and `1TB free storage space` to sync the Mainnet, the recommended hardware requirements:
184-
* CPU with 16+ cores(32+ cores for a super representative)
185-
* 32+ GB RAM(64+ GB for a super representative)
186-
* High Performance SSD with at least 1.5TB free space
187-
* 100+ MB/s download Internet service

actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@
6262
import org.tron.core.exception.ZksnarkException;
6363
import org.tron.core.vm.config.VMConfig;
6464
import org.tron.core.vm.program.Program;
65+
import org.tron.core.vm.program.Program.OutOfTimeException;
6566
import org.tron.core.vm.repository.Repository;
6667
import org.tron.core.vm.utils.FreezeV2Util;
68+
import org.tron.core.vm.utils.MUtil;
6769
import org.tron.core.vm.utils.VoteRewardUtil;
6870
import org.tron.protos.Protocol;
6971
import org.tron.protos.Protocol.Permission;
@@ -944,24 +946,33 @@ public Pair<Boolean, byte[]> execute(byte[] rawData) {
944946
long totalWeight = 0L;
945947
List<byte[]> executedSignList = new ArrayList<>();
946948
for (byte[] sign : signatures) {
947-
if (ByteArray.matrixContains(executedSignList, sign)) {
948-
continue;
949-
}
950949
byte[] recoveredAddr = recoverAddrBySign(sign, hash);
950+
951+
sign = merge(recoveredAddr, sign);
952+
if (ByteArray.matrixContains(executedSignList, recoveredAddr)) {
953+
if (ByteArray.matrixContains(executedSignList, sign)) {
954+
continue;
955+
}
956+
MUtil.checkCPUTime();
957+
}
951958
long weight = TransactionCapsule.getWeight(permission, recoveredAddr);
952959
if (weight == 0) {
953960
//incorrect sign
954961
return Pair.of(true, DATA_FALSE);
955962
}
956963
totalWeight += weight;
957964
executedSignList.add(sign);
965+
executedSignList.add(recoveredAddr);
958966
}
959967

960968
if (totalWeight >= permission.getThreshold()) {
961969
return Pair.of(true, dataOne());
962970
}
963971
}
964972
} catch (Throwable t) {
973+
if (t instanceof OutOfTimeException) {
974+
throw t;
975+
}
965976
logger.info("ValidateMultiSign error:{}", t.getMessage());
966977
}
967978
}

actuator/src/main/java/org/tron/core/vm/utils/MUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.tron.core.vm.utils;
22

3+
import org.tron.common.utils.ForkController;
34
import org.tron.core.capsule.AccountCapsule;
5+
import org.tron.core.config.Parameter;
46
import org.tron.core.exception.ContractValidateException;
57
import org.tron.core.vm.VMUtils;
8+
import org.tron.core.vm.program.Program.OutOfTimeException;
69
import org.tron.core.vm.repository.Repository;
710
import org.tron.protos.Protocol;
811

@@ -55,4 +58,10 @@ public static boolean isNullOrEmpty(String str) {
5558
public static boolean isNotNullOrEmpty(String str) {
5659
return !isNullOrEmpty(str);
5760
}
61+
62+
public static void checkCPUTime() {
63+
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
64+
throw new OutOfTimeException("CPU timeout for 0x0a executing");
65+
}
66+
}
5867
}

build.gradle

Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,84 @@
1-
allprojects {
2-
version = "1.0.0"
3-
apply plugin: "java"
4-
}
5-
6-
subprojects {
7-
apply plugin: "java"
8-
apply plugin: "jacoco"
9-
apply plugin: "maven"
10-
apply plugin: "maven-publish"
11-
12-
sourceCompatibility = JavaVersion.VERSION_1_8
13-
targetCompatibility = JavaVersion.VERSION_1_8
14-
15-
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
16-
17-
buildscript {
18-
repositories {
19-
mavenCentral()
20-
maven {
21-
url "https://plugins.gradle.org/m2/"
22-
}
23-
}
24-
dependencies {
25-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
26-
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
27-
}
28-
}
29-
30-
repositories {
31-
mavenLocal()
32-
mavenCentral()
33-
maven { url 'https://repo.spring.io/plugins-release' }
34-
}
35-
36-
dependencies {
37-
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
38-
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
39-
compile "org.slf4j:jcl-over-slf4j:1.7.25"
40-
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
41-
compileOnly 'org.projectlombok:lombok:1.18.12'
42-
annotationProcessor 'org.projectlombok:lombok:1.18.12'
43-
testCompileOnly 'org.projectlombok:lombok:1.18.12'
44-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
45-
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
46-
compile "com.google.code.findbugs:jsr305:3.0.0"
47-
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
48-
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.18'
49-
compile "org.apache.commons:commons-lang3:3.4"
50-
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
51-
compile "org.apache.commons:commons-collections4:4.1"
52-
compile group: 'joda-time', name: 'joda-time', version: '2.3'
53-
54-
}
55-
56-
task sourcesJar(type: Jar, dependsOn: classes) {
57-
classifier = "sources"
58-
from sourceSets.main.allSource
59-
}
60-
61-
62-
tasks.withType(AbstractArchiveTask) {
63-
preserveFileTimestamps = false
64-
reproducibleFileOrder = true
65-
}
66-
67-
configurations.all {
68-
resolutionStrategy {
69-
force group: 'com.google.guava', name: 'guava', version: '30.1-jre'
70-
}
71-
}
72-
}
73-
74-
task copyToParent(type: Copy) {
75-
into "$buildDir/libs"
76-
subprojects {
77-
from tasks.withType(Jar)
78-
}
79-
}
80-
81-
build.finalizedBy(copyToParent)
82-
1+
allprojects {
2+
version = "1.0.0"
3+
apply plugin: "java"
4+
}
5+
6+
subprojects {
7+
apply plugin: "java"
8+
apply plugin: "jacoco"
9+
apply plugin: "maven"
10+
apply plugin: "maven-publish"
11+
12+
sourceCompatibility = JavaVersion.VERSION_1_8
13+
targetCompatibility = JavaVersion.VERSION_1_8
14+
15+
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
16+
17+
buildscript {
18+
repositories {
19+
mavenCentral()
20+
maven { url 'https://jitpack.io' }
21+
maven {
22+
url "https://plugins.gradle.org/m2/"
23+
}
24+
}
25+
dependencies {
26+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
27+
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
28+
}
29+
}
30+
31+
repositories {
32+
mavenLocal()
33+
mavenCentral()
34+
maven { url 'https://repo.spring.io/plugins-release' }
35+
maven { url 'https://jitpack.io' }
36+
}
37+
38+
dependencies {
39+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
40+
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
41+
compile "org.slf4j:jcl-over-slf4j:1.7.25"
42+
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
43+
compileOnly 'org.projectlombok:lombok:1.18.12'
44+
annotationProcessor 'org.projectlombok:lombok:1.18.12'
45+
testCompileOnly 'org.projectlombok:lombok:1.18.12'
46+
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
47+
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
48+
compile "com.google.code.findbugs:jsr305:3.0.0"
49+
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
50+
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.18'
51+
compile "org.apache.commons:commons-lang3:3.4"
52+
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
53+
compile "org.apache.commons:commons-collections4:4.1"
54+
compile group: 'joda-time', name: 'joda-time', version: '2.3'
55+
56+
}
57+
58+
task sourcesJar(type: Jar, dependsOn: classes) {
59+
classifier = "sources"
60+
from sourceSets.main.allSource
61+
}
62+
63+
64+
tasks.withType(AbstractArchiveTask) {
65+
preserveFileTimestamps = false
66+
reproducibleFileOrder = true
67+
}
68+
69+
configurations.all {
70+
resolutionStrategy {
71+
force group: 'com.google.guava', name: 'guava', version: '30.1-jre'
72+
}
73+
}
74+
}
75+
76+
task copyToParent(type: Copy) {
77+
into "$buildDir/libs"
78+
subprojects {
79+
from tasks.withType(Jar)
80+
}
81+
}
82+
83+
build.finalizedBy(copyToParent)
84+

chainbase/src/main/java/org/tron/common/utils/ForkController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public boolean pass(ForkBlockVersionEnum forkBlockVersionEnum) {
4444
}
4545

4646
public synchronized boolean pass(int version) {
47+
if (manager == null) {
48+
throw new IllegalStateException("not inited");
49+
}
4750
if (version > ForkBlockVersionEnum.VERSION_4_0.getValue()) {
4851
return passNew(version);
4952
} else {

chainbase/src/main/java/org/tron/core/ChainBaseManager.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.google.protobuf.ByteString;
66
import java.util.List;
7+
import javax.annotation.PostConstruct;
78
import lombok.Getter;
89
import lombok.Setter;
910
import lombok.extern.slf4j.Slf4j;
@@ -236,6 +237,14 @@ public class ChainBaseManager {
236237
@Autowired
237238
private DbStatService dbStatService;
238239

240+
@Getter
241+
@Setter
242+
private NodeType nodeType;
243+
244+
@Getter
245+
@Setter
246+
private long lowestBlockNum = -1; // except num = 0.
247+
239248
public void closeOneStore(ITronChainBase database) {
240249
logger.info("******** Begin to close {}. ********", database.getName());
241250
try {
@@ -414,5 +423,28 @@ public static synchronized void init(ChainBaseManager manager) {
414423
AssetUtil.setAccountAssetStore(manager.getAccountAssetStore());
415424
AssetUtil.setDynamicPropertiesStore(manager.getDynamicPropertiesStore());
416425
}
426+
427+
@PostConstruct
428+
private void init() {
429+
this.lowestBlockNum = this.blockIndexStore.getLimitNumber(1, 1).stream()
430+
.map(BlockId::getNum).findFirst().orElse(0L);
431+
this.nodeType = getLowestBlockNum() > 1 ? NodeType.LITE : NodeType.FULL;
432+
}
433+
434+
public boolean isLiteNode() {
435+
return getNodeType() == NodeType.LITE;
436+
}
437+
438+
public enum NodeType {
439+
FULL(0),
440+
LITE(1);
441+
442+
@Getter
443+
private final int type;
444+
445+
NodeType(int type) {
446+
this.type = type;
447+
}
448+
}
417449
}
418450

chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
import org.tron.common.overlay.message.Message;
4747
import org.tron.common.parameter.CommonParameter;
4848
import org.tron.common.utils.ByteArray;
49+
import org.tron.common.utils.ForkController;
4950
import org.tron.common.utils.ReflectUtils;
5051
import org.tron.common.utils.Sha256Hash;
5152
import org.tron.core.actuator.TransactionFactory;
53+
import org.tron.core.config.Parameter;
5254
import org.tron.core.db.TransactionContext;
5355
import org.tron.core.db.TransactionTrace;
5456
import org.tron.core.exception.BadItemException;
@@ -213,6 +215,11 @@ public static long getWeight(Permission permission, byte[] address) {
213215
return 0;
214216
}
215217

218+
/**
219+
* make sure ForkController.init(ChainBaseManager) is invoked before invoke this method.
220+
*
221+
* @see ForkController#init(org.tron.core.ChainBaseManager)
222+
*/
216223
public static long checkWeight(Permission permission, List<ByteString> sigs, byte[] hash,
217224
List<ByteString> approveList)
218225
throws SignatureException, PermissionException, SignatureFormatException {
@@ -237,6 +244,9 @@ public static long checkWeight(Permission permission, List<ByteString> sigs, byt
237244
ByteArray.toHexString(sig.toByteArray()) + " is signed by " + encode58Check(address)
238245
+ " but it is not contained of permission.");
239246
}
247+
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
248+
base64 = encode58Check(address);
249+
}
240250
if (addMap.containsKey(base64)) {
241251
throw new PermissionException(encode58Check(address) + " has signed twice!");
242252
}

0 commit comments

Comments
 (0)