Skip to content

Commit 28aaa52

Browse files
committed
Merge branch 'release_v4.8.1' into fix/local_witness
# Conflicts: # framework/src/main/java/org/tron/core/config/args/Args.java # framework/src/test/java/org/tron/core/config/args/ArgsTest.java # plugins/build.gradle
2 parents 34b4f21 + 6a75d50 commit 28aaa52

File tree

168 files changed

+3925
-2361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+3925
-2361
lines changed

README.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ TRON enables large-scale development and engagement. With over 2000 transactions
5959

6060
# Building the Source Code
6161

62-
Building java-tron requires `git` package and 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems.
62+
Building java-tron requires `git` package
6363

64+
## Operating systems
65+
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.
66+
67+
## Architecture
68+
69+
### x86_64
70+
64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.
71+
72+
### ARM64
73+
64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.
74+
75+
### build
6476
Clone the repo and switch to the `master` branch
6577

6678
```bash
@@ -77,8 +89,19 @@ $ ./gradlew clean build -x test
7789

7890
# Running java-tron
7991

80-
Running java-tron requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet. Make sure you operate on `Linux` and `MacOS` operating systems.
92+
## Operating systems
93+
Make sure you operate on `Linux` or `MacOS` operating systems, other operating systems are not supported yet.
94+
95+
## Architecture
96+
97+
### X86_64
98+
Requires 64-bit version of `Oracle JDK 1.8` to be installed, other JDK versions are not supported yet.
8199

100+
### ARM64
101+
Requires 64-bit version of `JDK 17` to be installed, other JDK versions are not supported yet.
102+
103+
104+
## Configuration flile
82105
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 found [here](https://github.com/tronprotocol/tron-deployment).
83106

84107
## Hardware Requirements
@@ -100,6 +123,7 @@ Recommended:
100123

101124
Full node has full historical data, it is the entry point into the TRON network, it can be used by other processes as a gateway into the TRON network via HTTP and GRPC endpoints. You can interact with the TRON network through full node:transfer assets, deploy contracts, interact with contracts and so on. `-c` parameter specifies a configuration file to run a full node:
102125

126+
### x86_64 JDK 1.8
103127
```bash
104128
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
105129
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -111,6 +135,19 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
111135
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
112136
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
113137
```
138+
### ARM64 JDK 17
139+
```bash
140+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
141+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
142+
-XX:ReservedCodeCacheSize=256m \
143+
-XX:+UseCodeCacheFlushing \
144+
-XX:MetaspaceSize=256m \
145+
-XX:MaxMetaspaceSize=512m \
146+
-XX:MaxDirectMemorySize=1g \
147+
-XX:+HeapDumpOnOutOfMemoryError \
148+
-jar FullNode.jar -c main_net_config.conf >> start.log 2>&1 &
149+
```
150+
114151

115152
## Running a super representative node for mainnet
116153

@@ -126,6 +163,7 @@ Fill in the private key of a super representative address into the `localwitness
126163

127164
then run the following command to start the node:
128165

166+
### x86_64 JDK 1.8
129167
```bash
130168
$ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
131169
-XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m \
@@ -137,9 +175,22 @@ $ nohup java -Xms9G -Xmx9G -XX:ReservedCodeCacheSize=256m \
137175
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \
138176
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
139177
```
178+
### ARM64 JDK 17
179+
```bash
180+
$ nohup java -Xms9G -Xmx9G -XX:+UseZGC \
181+
-Xlog:gc*:file=gc.log:time,uptime,level,tags:filecount=50,filesize=100M \
182+
-XX:ReservedCodeCacheSize=256m \
183+
-XX:+UseCodeCacheFlushing \
184+
-XX:MetaspaceSize=256m \
185+
-XX:MaxMetaspaceSize=512m \
186+
-XX:MaxDirectMemorySize=1g \
187+
-XX:+HeapDumpOnOutOfMemoryError \
188+
-jar FullNode.jar --witness -c main_net_config.conf >> start.log 2>&1 &
189+
```
140190

141191
## Quick Start Tool
142192

193+
### x86_64 JDK 1.8
143194
An easier way to build and run java-tron is to use `start.sh`. `start.sh` is a quick start script written in the Shell language. You can use it to build and run java-tron quickly and easily.
144195

145196
Here are some common use cases of the scripting tool
@@ -150,6 +201,18 @@ Here are some common use cases of the scripting tool
150201

151202
For more details, please refer to the tool [guide](./shell.md).
152203

204+
### ARM64 JDK 17
205+
You can refer to the [start.sh.simple](start.sh.simple).
206+
207+
```bash
208+
# cp start.sh.simple start.sh
209+
# Usage:
210+
# sh start.sh # Start the java-tron FullNode
211+
# sh start.sh -s # Stop the java-tron FullNode
212+
# sh start.sh [options] # Start with additional java-tron options,such as: -c config.conf -d /path_to_data, etc.
213+
#
214+
```
215+
153216
## Run inside Docker container
154217

155218
One of the quickest ways to get `java-tron` up and running on your machine is by using Docker:
@@ -169,7 +232,7 @@ This will mount the `output-directory` and `logs` directories on the host, the d
169232

170233
[Tron Developers & SRs](https://discord.gg/hqKvyAM) is Tron's official Discord channel. Feel free to join this channel if you have any questions.
171234

172-
[Core Devs Community](https://t.me/troncoredevscommunity) is the Telegram channel for java-tron community developers. If you want to contribute to java-tron, please join this channel.
235+
The [Core Devs Community](https://t.me/troncoredevscommunity) and [Tron Official Developer Group](https://t.me/TronOfficialDevelopersGroupEn) are Telegram channels specifically designed for java-tron community developers to engage in technical discussions.
173236

174237
[tronprotocol/allcoredev](https://gitter.im/tronprotocol/allcoredev) is the official Gitter channel for developers.
175238

@@ -180,7 +243,7 @@ Thank you for considering to help out with the source code! If you'd like to con
180243
# Resources
181244

182245
- [Medium](https://medium.com/@coredevs) java-tron's official technical articles are published there.
183-
- [Documentation](https://tronprotocol.github.io/documentation-en/introduction/) java-tron's official technical documentation website.
246+
- [Documentation](https://tronprotocol.github.io/documentation-en/) and [TRON Developer Hub](https://developers.tron.network/) serve as java-tron’s primary documentation websites.
184247
- [Test network](http://nileex.io/) A stable test network of TRON contributed by TRON community.
185248
- [Tronscan](https://tronscan.org/#/) TRON network blockchain browser.
186249
- [Wallet-cli](https://github.com/tronprotocol/wallet-cli) TRON network wallet using command line.

actuator/src/main/java/org/tron/core/actuator/ProposalCreateActuator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.util.Map;
1010
import java.util.Objects;
1111
import lombok.extern.slf4j.Slf4j;
12-
import org.tron.common.parameter.CommonParameter;
1312
import org.tron.common.utils.DecodeUtil;
1413
import org.tron.common.utils.StringUtil;
1514
import org.tron.core.capsule.ProposalCapsule;
@@ -53,7 +52,7 @@ public boolean execute(Object result) throws ContractExeException {
5352

5453
long currentMaintenanceTime =
5554
chainBaseManager.getDynamicPropertiesStore().getNextMaintenanceTime();
56-
long now3 = now + CommonParameter.getInstance().getProposalExpireTime();
55+
long now3 = now + chainBaseManager.getDynamicPropertiesStore().getProposalExpireTime();
5756
long round = (now3 - currentMaintenanceTime) / maintenanceTimeInterval;
5857
long expirationTime =
5958
currentMaintenanceTime + (round + 1) * maintenanceTimeInterval;

actuator/src/main/java/org/tron/core/actuator/ShieldedTransferActuator.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,28 +170,27 @@ private void executeShielded(List<SpendDescription> spends, List<ReceiveDescript
170170
}
171171
nullifierStore.put(new BytesCapsule(spend.getNullifier().toByteArray()));
172172
}
173-
if (CommonParameter.getInstance().isFullNodeAllowShieldedTransactionArgs()) {
174-
IncrementalMerkleTreeContainer currentMerkle = merkleContainer.getCurrentMerkle();
173+
174+
IncrementalMerkleTreeContainer currentMerkle = merkleContainer.getCurrentMerkle();
175+
try {
176+
currentMerkle.wfcheck();
177+
} catch (ZksnarkException e) {
178+
ret.setStatus(fee, code.FAILED);
179+
ret.setShieldedTransactionFee(fee);
180+
throw new ContractExeException(e.getMessage());
181+
}
182+
//handle receives
183+
for (ReceiveDescription receive : receives) {
175184
try {
176-
currentMerkle.wfcheck();
185+
merkleContainer
186+
.saveCmIntoMerkleTree(currentMerkle, receive.getNoteCommitment().toByteArray());
177187
} catch (ZksnarkException e) {
178-
ret.setStatus(fee, code.FAILED);
188+
ret.setStatus(0, code.FAILED);
179189
ret.setShieldedTransactionFee(fee);
180190
throw new ContractExeException(e.getMessage());
181191
}
182-
//handle receives
183-
for (ReceiveDescription receive : receives) {
184-
try {
185-
merkleContainer
186-
.saveCmIntoMerkleTree(currentMerkle, receive.getNoteCommitment().toByteArray());
187-
} catch (ZksnarkException e) {
188-
ret.setStatus(0, code.FAILED);
189-
ret.setShieldedTransactionFee(fee);
190-
throw new ContractExeException(e.getMessage());
191-
}
192-
}
193-
merkleContainer.setCurrentMerkle(currentMerkle);
194192
}
193+
merkleContainer.setCurrentMerkle(currentMerkle);
195194
}
196195

197196
@Override
@@ -236,8 +235,7 @@ public boolean validate() throws ContractValidateException {
236235
throw new ContractValidateException("duplicate sapling nullifiers in this transaction");
237236
}
238237
nfSet.add(spendDescription.getNullifier());
239-
if (CommonParameter.getInstance().isFullNodeAllowShieldedTransactionArgs()
240-
&& !merkleContainer.merkleRootExist(spendDescription.getAnchor().toByteArray())) {
238+
if (!merkleContainer.merkleRootExist(spendDescription.getAnchor().toByteArray())) {
241239
throw new ContractValidateException("Rt is invalid.");
242240
}
243241
if (nullifierStore.has(spendDescription.getNullifier().toByteArray())) {

actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import static org.tron.core.Constant.CREATE_ACCOUNT_TRANSACTION_MIN_BYTE_SIZE;
55
import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE;
66
import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE;
7+
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
8+
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
79
import static org.tron.core.config.Parameter.ChainConstant.ONE_YEAR_BLOCK_NUMBERS;
810

911
import org.tron.common.utils.ForkController;
@@ -839,6 +841,20 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
839841
}
840842
break;
841843
}
844+
case PROPOSAL_EXPIRE_TIME: {
845+
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
846+
throw new ContractValidateException(
847+
"Bad chain parameter id [PROPOSAL_EXPIRE_TIME]");
848+
}
849+
if (value <= MIN_PROPOSAL_EXPIRE_TIME
850+
|| value >= MAX_PROPOSAL_EXPIRE_TIME) {
851+
throw new ContractValidateException(
852+
"This value[PROPOSAL_EXPIRE_TIME] is only allowed to be greater than "
853+
+ MIN_PROPOSAL_EXPIRE_TIME + " and less than "
854+
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
855+
}
856+
break;
857+
}
842858
default:
843859
break;
844860
}
@@ -921,7 +937,8 @@ public enum ProposalType { // current value, value range
921937
ALLOW_TVM_CANCUN(83), // 0, 1
922938
ALLOW_STRICT_MATH(87), // 0, 1
923939
CONSENSUS_LOGIC_OPTIMIZATION(88), // 0, 1
924-
ALLOW_TVM_BLOB(89); // 0, 1
940+
ALLOW_TVM_BLOB(89), // 0, 1
941+
PROPOSAL_EXPIRE_TIME(92); // (0, 31536003000)
925942

926943
private long code;
927944

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.apache.commons.lang3.tuple.Triple;
4242
import org.tron.common.crypto.Blake2bfMessageDigest;
4343
import org.tron.common.crypto.Hash;
44+
import org.tron.common.crypto.Rsv;
4445
import org.tron.common.crypto.SignUtils;
4546
import org.tron.common.crypto.SignatureInterface;
4647
import org.tron.common.crypto.zksnark.BN128;
@@ -352,22 +353,13 @@ private static byte[] encodeMultiRes(byte[]... words) {
352353
}
353354

354355
private static byte[] recoverAddrBySign(byte[] sign, byte[] hash) {
355-
byte v;
356-
byte[] r;
357-
byte[] s;
358356
byte[] out = null;
359357
if (ArrayUtils.isEmpty(sign) || sign.length < 65) {
360358
return new byte[0];
361359
}
362360
try {
363-
r = Arrays.copyOfRange(sign, 0, 32);
364-
s = Arrays.copyOfRange(sign, 32, 64);
365-
v = sign[64];
366-
if (v < 27) {
367-
v += 27;
368-
}
369-
370-
SignatureInterface signature = SignUtils.fromComponents(r, s, v,
361+
Rsv rsv = Rsv.fromSignature(sign);
362+
SignatureInterface signature = SignUtils.fromComponents(rsv.getR(), rsv.getS(), rsv.getV(),
371363
CommonParameter.getInstance().isECKeyCryptoEngine());
372364
if (signature.validateComponents()) {
373365
out = SignUtils.signatureToAddress(hash, signature,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ public static void play(Program program, JumpTable jumpTable) {
108108
} catch (JVMStackOverFlowException | OutOfTimeException e) {
109109
throw e;
110110
} catch (RuntimeException e) {
111-
if (StringUtils.isEmpty(e.getMessage())) {
111+
// https://openjdk.org/jeps/358
112+
// https://bugs.openjdk.org/browse/JDK-8220715
113+
// since jdk 14, the NullPointerExceptions message is not empty
114+
if (e instanceof NullPointerException || StringUtils.isEmpty(e.getMessage())) {
112115
logger.warn("Unknown Exception occurred, tx id: {}",
113116
Hex.toHexString(program.getRootTransactionId()), e);
114117
program.setRuntimeFailure(new RuntimeException("Unknown Exception"));

actuator/src/main/java/org/tron/core/vm/program/invoke/ProgramInvokeImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public boolean equals(Object o) {
314314

315315
@Override
316316
public int hashCode() {
317-
return new Integer(Boolean.valueOf(byTestingSuite).hashCode()
317+
return Boolean.valueOf(byTestingSuite).hashCode()
318318
+ Boolean.valueOf(byTransaction).hashCode()
319319
+ address.hashCode()
320320
+ balance.hashCode()
@@ -326,8 +326,7 @@ public int hashCode() {
326326
+ origin.hashCode()
327327
+ prevHash.hashCode()
328328
+ deposit.hashCode()
329-
+ timestamp.hashCode()
330-
).hashCode();
329+
+ timestamp.hashCode();
331330
}
332331

333332
@Override

actuator/src/main/java/org/tron/core/vm/repository/Type.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public boolean equals(Object obj) {
7373

7474
@Override
7575
public int hashCode() {
76-
return new Integer(type).hashCode();
76+
return type;
7777
}
7878

7979
@Override

actuator/src/main/java/org/tron/core/vm/repository/Value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public boolean equals(Object obj) {
5858

5959
@Override
6060
public int hashCode() {
61-
return new Integer(type.hashCode() + Objects.hashCode(value)).hashCode();
61+
return type.hashCode() + Objects.hashCode(value);
6262
}
6363
}

0 commit comments

Comments
 (0)