Skip to content

Commit 38dfe23

Browse files
authored
Merge pull request #4292 from tronprotocol/release_v4.4.4
Release v4.4.4 to master
2 parents 2d97908 + aa772ac commit 38dfe23

File tree

454 files changed

+3899
-6254
lines changed

Some content is hidden

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

454 files changed

+3899
-6254
lines changed

.travis.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ java-tron is an open source project.
44

55
It is the work of contributors. We appreciate your help!
66

7-
Here are instructions to get you started. They are not perfect, so
8-
please let us know if anything feels wrong or incomplete.
7+
Here are instructions to get started. They are not perfect,
8+
please let us know if you see any improvements, thanks.
99

1010
## Contribution guidelines
1111
First of all, java-tron follows GitFlow, the branches description in the java-tron project are listed as follow:
@@ -14,7 +14,7 @@ First of all, java-tron follows GitFlow, the branches description in the java-tr
1414
This branch contains the latest code released to the production environment. It can only be merged, and can not be modified directly in this branch.
1515

1616
- ``develop`` branch:
17-
This branch is the main development branch. It contains the complete code that is going to release. It can only be merged, and can not be modified directly in this branch.
17+
This branch is the main development branch. It contains the complete code that is going to be released. It can only be merged, and can not be modified directly in this branch.
1818

1919
- ``feature`` branch:
2020
This branch is used to develop new features. It is created based on ``develop`` branch. Once the development is finished, it should be merged into ``develop`` branch, and then delete the branch.
@@ -25,59 +25,50 @@ This is the branch that is going to be released. It is created based on ``develo
2525
- ``hotfix`` branch:
2626
This branch is used to fix a bug when an online bug is found. It is created based on ``master`` branch. When bug fix is done, it should be merged into ``master`` branch(as a new release) and ``develop`` and then delete the branch. branch.
2727

28-
### Pull requests
28+
## Pull requests
2929

3030
If you'd like to contribute to java-tron, you should follow the steps below:
31-
- **Fork** a repository from **tronprotocol/java-tron** allows you to freely experiment with changes without affecting the original project
32-
- **Fix** some code and **Commit** your modified code.
33-
- **Send** a Pull Request(PR)for the maintainers to review and merge into the main code base.
31+
- **Fork** a repository from **tronprotocol/java-tron** and working there without affecting the original project.
32+
- **Finish** your code modification and **Commit** your changes to your own repository.
33+
- **Submit** a Pull Request(PR)from your own repository to **tronprotocol/java-tron**.
3434
*notice*:When you create a new PR,please choose the **tronprotocol/java-tron** as the base repository and choose **your fork/java-tron** as the head repository.
35-
And you must choose **develop** as the base repository branch, which means we will merge the PR into our **develop** branch when reviewed and approved.
35+
And you must choose **develop** as the base repository branch, which means we will merge the PR into our **develop** branch after reviewed and approved.
3636
Additionally, if you are writing a new feature, please ensure you add appropriate test cases under ``/src/test``.
3737

38-
After the PR is checked by our Sonar check procedure and Travis CI continuous-integration check procedure automaticly,
39-
we maintainers will review the code changed and give some advices for modifying if necessary.Once approved,
40-
we will close the PR and merge into the protocol/java-tron's develop branch.
38+
The Sonar check and Travis CI continuous-integration check will be triggerred automatically after PR submitted, once all check passed, **java-tron** maintainers will review the PR and give feedback for modifying if necessary. Once approved, we will close the PR and merge it into the `develop` branch.
4139

42-
We are always happy to receive pull requests, and do our best to
43-
review them as fast as possible. Not sure if that typo is worth a pull
44-
request? Do it! We would appreciate it.
4540

46-
If your pull request is not accepted on the first try, don't be
47-
discouraged as it can be a possible oversight. Please explain your code as
48-
detailed as possible to make it easier for us to understand.
41+
We are always happy to receive pull requests, and do our best to review them as fast as possible. Not sure if A typo is worth a pull request? Do it! We would appreciate it.
4942

50-
Please make sure your contributions adhere to our coding guidelines:
43+
If your pull request is not accepted on the first attempt, please don’t get discouraged, as this may be an oversight. Please explain your code as much as possible to make it easier for us to understand.
5144

52-
- Code must be documented adhering to the [Google Style](https://google.github.io/styleguide/javaguide.html)
45+
Please make sure your commit follows below coding guidelines:
46+
47+
- Code must be conformed to the [Google Style](https://google.github.io/styleguide/javaguide.html)
5348
- Code must pass Sonar detection.
54-
- Pull requests need to be based on and opened against the develop branch.
49+
- Pull requests must be based on the `develop` branch.
5550
- Commit messages should be started with verb, and the first letter should be a lowercase.The length of commit message
56-
must be limited in 50 words.
57-
### Create issues
51+
must be less than 50 words.
52+
53+
## Create issues
5854

59-
Any significant improvement should be documented as [a GitHub
60-
issue](https://github.com/tronprotocol/java-tron/issues) before anyone
61-
starts working on it.
55+
Any significant improvement must be documented in [a GitHub issue](https://github.com/tronprotocol/java-tron/issues) before working on it.
6256

63-
When filing an issue, make sure to answer these three questions:
57+
When start an issue, make sure to answer these three questions:
6458

6559
- What did you do?
6660
- What did you expect to see?
6761
- What did you see instead?
6862

69-
### Please check existing issues and docs first!
63+
## Please check existing issues and docs first!
7064

71-
Please take a moment to check that your bug report or improvement proposal
72-
doesn't already exist. If it does, please add a quick "+1" or "I have this problem too".
65+
Please take a moment to check that your bug report or improvement proposal doesn't already exist. If it does, please add a quick "+1" or "I have this problem too".
7366
This will help prioritize the most common problems and requests.
7467

75-
## Community Developers Incentives Programme
68+
## Community Developers Incentives Programme(Paused)
7669

7770
Bonus point applies in TRON incentives programme. Developers can earn points by contributing to TRON.
7871

79-
You can find your points ranking at [Tronscan](https://tronscan.org/#/developersreward).
80-
8172
The Top 5 scored developers (for every month, quarter and year) can win a cash reward.
8273

8374
For more details, please visit [Incentives Policy](https://tronprotocol.github.io/documentation-en/developers/incentives/).

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN set -o errexit -o nounset \
2121
&& cd $TMP_DIR \
2222
&& git clone https://github.com/tronprotocol/java-tron.git \
2323
&& cd java-tron \
24-
&& git checkout docker \
24+
&& git checkout master \
2525
&& ./gradlew build -x test \
2626
&& cd build/distributions \
2727
&& unzip -o java-tron-1.0.0.zip \

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.tron.core.utils.TransactionUtil;
3535
import org.tron.core.vm.EnergyCost;
3636
import org.tron.core.vm.LogInfoTriggerParser;
37+
import org.tron.core.vm.OperationRegistry;
3738
import org.tron.core.vm.VM;
3839
import org.tron.core.vm.VMConstant;
3940
import org.tron.core.vm.VMUtils;
@@ -80,7 +81,7 @@ public class VMActuator implements Actuator2 {
8081

8182
@Getter
8283
@Setter
83-
private boolean isConstantCall = false;
84+
private boolean isConstantCall;
8485

8586
@Setter
8687
private boolean enableEventListener;
@@ -108,8 +109,10 @@ public void validate(Object object) throws ContractValidateException {
108109
throw new RuntimeException("TransactionContext is null");
109110
}
110111

111-
//Load Config
112+
// Load Config
112113
ConfigLoader.load(context.getStoreFactory());
114+
// Warm up registry class
115+
OperationRegistry.init();
113116
trx = context.getTrxCap().getInstance();
114117
blockCap = context.getBlockCap();
115118
if (VMConfig.allowTvmFreeze() && context.getTrxCap().getTrxTrace() != null) {
@@ -169,7 +172,7 @@ public void execute(Object object) throws ContractExeException {
169172
throw e;
170173
}
171174

172-
VM.play(program);
175+
VM.play(program, OperationRegistry.getTable(OperationRegistry.Version.TRON_V1));
173176
result = program.getResult();
174177

175178
if (TrxType.TRX_CONTRACT_CREATION_TYPE == trxType && !result.isRevert()) {
@@ -335,8 +338,8 @@ private void create()
335338
long feeLimit = trx.getRawData().getFeeLimit();
336339
if (feeLimit < 0 || feeLimit > rootRepository.getDynamicPropertiesStore().getMaxFeeLimit()) {
337340
logger.info("invalid feeLimit {}", feeLimit);
338-
throw new ContractValidateException(
339-
"feeLimit must be >= 0 and <= " + rootRepository.getDynamicPropertiesStore().getMaxFeeLimit());
341+
throw new ContractValidateException("feeLimit must be >= 0 and <= "
342+
+ rootRepository.getDynamicPropertiesStore().getMaxFeeLimit());
340343
}
341344
AccountCapsule creator = rootRepository
342345
.getAccount(newSmartContract.getOriginAddress().toByteArray());
@@ -466,8 +469,8 @@ private void call()
466469
long feeLimit = trx.getRawData().getFeeLimit();
467470
if (feeLimit < 0 || feeLimit > rootRepository.getDynamicPropertiesStore().getMaxFeeLimit()) {
468471
logger.info("invalid feeLimit {}", feeLimit);
469-
throw new ContractValidateException(
470-
"feeLimit must be >= 0 and <= " + rootRepository.getDynamicPropertiesStore().getMaxFeeLimit());
472+
throw new ContractValidateException("feeLimit must be >= 0 and <= "
473+
+ rootRepository.getDynamicPropertiesStore().getMaxFeeLimit());
471474
}
472475
AccountCapsule caller = rootRepository.getAccount(callerAddress);
473476
long energyLimit;
@@ -670,7 +673,8 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu
670673
} else {
671674
if (consumeUserResourcePercent < VMConstant.ONE_HUNDRED) {
672675
// creatorEnergyLimit =
673-
// min(callerEnergyLimit * (100 - percent) / percent, creatorLeftFrozenEnergy, originEnergyLimit)
676+
// min(callerEnergyLimit * (100 - percent) / percent,
677+
// creatorLeftFrozenEnergy, originEnergyLimit)
674678

675679
creatorEnergyLimit = min(
676680
BigInteger.valueOf(callerEnergyLimit)

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,35 @@ public class EnergyCost {
4949
private static final long STOP = 0;
5050
private static final long CREATE_DATA = 200;
5151

52-
public static long getZeroTierCost(Program program) {
52+
public static long getZeroTierCost(Program ignored) {
5353
return ZERO_TIER;
5454
}
5555

56-
public static long getVeryLowTierCost(Program program) {
56+
public static long getVeryLowTierCost(Program ignored) {
5757
return VERY_LOW_TIER;
5858
}
5959

60-
public static long getLowTierCost(Program program) {
60+
public static long getLowTierCost(Program ignored) {
6161
return LOW_TIER;
6262
}
6363

64-
public static long getMidTierCost(Program program) {
64+
public static long getMidTierCost(Program ignored) {
6565
return MID_TIER;
6666
}
6767

68-
public static long getBaseTierCost(Program program) {
68+
public static long getBaseTierCost(Program ignored) {
6969
return BASE_TIER;
7070
}
7171

72-
public static long getExtTierCost(Program program) {
72+
public static long getExtTierCost(Program ignored) {
7373
return EXT_TIER;
7474
}
7575

76-
public static long getHighTierCost(Program program) {
76+
public static long getHighTierCost(Program ignored) {
7777
return HIGH_TIER;
7878
}
7979

80-
public static long getSpecialTierCost(Program program) {
80+
public static long getSpecialTierCost(Program ignored) {
8181
return SPECIAL_TIER;
8282
}
8383

@@ -92,8 +92,8 @@ public static long getExpCost(Program program) {
9292
return EXP_ENERGY + EXP_BYTE_ENERGY * bytesOccupied;
9393
}
9494

95-
public static long getExtCodeSizeCost(Program program) {
96-
return EXT_CODE_SIZE;
95+
public static long getExtCodeSizeCost(Program ignored) {
96+
return EXT_CODE_SIZE;
9797
}
9898

9999
public static long getSha3Cost(Program program) {
@@ -143,7 +143,7 @@ public static long getExtCodeCopyCost(Program program) {
143143
return energyCost;
144144
}
145145

146-
public static long getExtCodeHashCost(Program program) {
146+
public static long getExtCodeHashCost(Program ignored) {
147147
return EXT_CODE_HASH;
148148
}
149149

@@ -174,7 +174,7 @@ public static long getMStore8Cost(Program program) {
174174
return energyCost;
175175
}
176176

177-
public static long getSloadCost(Program program) {
177+
public static long getSloadCost(Program ignored) {
178178
return SLOAD;
179179
}
180180

@@ -237,11 +237,11 @@ public static long getLogCost(Program program) {
237237
return energyCost;
238238
}
239239

240-
public static long getSuicideCost(Program program) {
240+
public static long getSuicideCost(Program ignored) {
241241
return SUICIDE;
242242
}
243243

244-
public static long getBalanceCost(Program program) {
244+
public static long getBalanceCost(Program ignored) {
245245
return BALANCE;
246246
}
247247

@@ -255,11 +255,11 @@ public static long getFreezeCost(Program program) {
255255
return FREEZE;
256256
}
257257

258-
public static long getUnfreezeCost(Program program) {
258+
public static long getUnfreezeCost(Program ignored) {
259259
return UNFREEZE;
260260
}
261261

262-
public static long getFreezeExpireTimeCost(Program program) {
262+
public static long getFreezeExpireTimeCost(Program ignored) {
263263
return FREEZE_EXPIRE_TIME;
264264
}
265265

@@ -285,7 +285,7 @@ public static long getVoteWitnessCost(Program program) {
285285
? amountArrayMemoryNeeded : witnessArrayMemoryNeeded), 0, Op.VOTEWITNESS);
286286
}
287287

288-
public static long getWithdrawRewardCost(Program program) {
288+
public static long getWithdrawRewardCost(Program ignored) {
289289
return WITHDRAW_REWARD;
290290
}
291291

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.tron.core.vm;
2+
3+
import java.util.Arrays;
4+
5+
public class JumpTable {
6+
7+
private static final Operation UNDEFINED =
8+
new Operation(
9+
-1, 0, 0,
10+
p -> 0L,
11+
p -> { },
12+
() -> false);
13+
14+
private final Operation[] table = new Operation[256];
15+
16+
public JumpTable() {
17+
// fill all op slots to undefined
18+
Arrays.fill(table, UNDEFINED);
19+
}
20+
21+
public Operation get(int op) {
22+
return table[op];
23+
}
24+
25+
public void set(Operation op) {
26+
table[op.getOpcode()] = op;
27+
}
28+
}

0 commit comments

Comments
 (0)