Skip to content

Commit 59e48ee

Browse files
authored
Merge branch 'tronprotocol:develop' into develop
2 parents b4c57d7 + 5312d41 commit 59e48ee

22 files changed

Lines changed: 519 additions & 91 deletions

File tree

.github/CODEOWNERS

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# CODEOWNERS — java-tron PR Review assignments
2+
#
3+
# Rule: when multiple rules match the same file, the last one takes precedence.
4+
# Recommendation: put more specific paths further down.
5+
6+
# Default owner — applies to any file not matched by a more specific rule below.
7+
* @zeusoo001 @317787106
8+
9+
# ────────────────────────────────────────────────────────────────
10+
# 1. Top-level Gradle modules (corresponds to the "Level-1/Level-2 module" column)
11+
# ────────────────────────────────────────────────────────────────
12+
13+
/framework/ @xxo1shine @bladehan1
14+
/chainbase/ @halibobo1205 @bladehan1
15+
/actuator/ @Sunny6889 @lxcmyf
16+
/consensus/ @kuny0707 @xxo1shine
17+
/protocol/ @lvs0075 @waynercheung
18+
/common/ @lvs0075 @lxcmyf
19+
/crypto/ @Federico2014 @3for
20+
/plugins/ @halibobo1205 @warku123
21+
/docker/ @3for @kuny0707
22+
23+
# ────────────────────────────────────────────────────────────────
24+
# 2. CI / Build configuration
25+
# ────────────────────────────────────────────────────────────────
26+
27+
/.github/ @317787106 @halibobo1205
28+
*.gradle @317787106 @halibobo1205
29+
/gradle/ @317787106 @halibobo1205
30+
31+
# ────────────────────────────────────────────────────────────────
32+
# 3. Sub-module paths (more specific than top-level; placed later to override rules above)
33+
# ────────────────────────────────────────────────────────────────
34+
35+
# db — covers the db, db2, and storage packages inside chainbase
36+
/chainbase/src/main/java/org/tron/core/db/ @halibobo1205 @bladehan1
37+
/chainbase/src/main/java/org/tron/core/db2/ @halibobo1205 @bladehan1
38+
/chainbase/src/main/java/org/tron/common/storage/ @halibobo1205 @bladehan1
39+
40+
# trie
41+
/framework/src/main/java/org/tron/core/trie/ @halibobo1205 @317787106
42+
43+
# net
44+
/framework/src/main/java/org/tron/core/net/ @317787106 @xxo1shine
45+
46+
# vm / tvm
47+
/actuator/src/main/java/org/tron/core/vm/ @yanghang8612 @CodeNinjaEvan
48+
49+
# jsonrpc
50+
/framework/src/main/java/org/tron/core/services/jsonrpc/ @0xbigapple @waynercheung
51+
/framework/src/main/java/org/tron/core/services/interfaceJsonRpcOnSolidity/ @0xbigapple @waynercheung
52+
53+
# rpc (gRPC) — non-HTTP parts of interfaceOnPBFT / interfaceOnSolidity + RpcService
54+
/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/ @317787106 @waynercheung
55+
/framework/src/main/java/org/tron/common/application/ @317787106 @waynercheung
56+
57+
# http (REST) — overrides the rpc rule above for the http sub-directories inside interfaceOnXxx
58+
/framework/src/main/java/org/tron/core/services/http/ @Sunny6889 @waynercheung
59+
/framework/src/main/java/org/tron/core/services/interfaceOnSolidity/http/ @Sunny6889 @waynercheung
60+
61+
# event
62+
/framework/src/main/java/org/tron/core/services/event/ @xxo1shine @0xbigapple
63+
/framework/src/main/java/org/tron/common/logsfilter/ @xxo1shine @0xbigapple
64+
65+
# config
66+
/framework/src/main/java/org/tron/core/config/ @317787106 @kuny0707
67+
/chainbase/src/main/java/org/tron/core/config/ @317787106 @kuny0707
68+
69+
# backup
70+
/framework/src/main/java/org/tron/common/backup/ @xxo1shine @317787106
71+
/framework/src/main/java/org/tron/core/db/backup/ @xxo1shine @317787106
72+
73+
# metrics
74+
/framework/src/main/java/org/tron/core/metrics/ @halibobo1205 @Sunny6889
75+
76+
# rewards — logic is spread across chainbase service/store
77+
/chainbase/src/main/java/org/tron/core/service/ @Sunny6889 @kuny0707
78+
/chainbase/src/main/java/org/tron/core/store/ @Sunny6889 @kuny0707
79+
80+
# lite — DbLite in plugins module; lite-related filters in framework
81+
/plugins/src/main/java/common/org/tron/plugins/DbLite.java @bladehan1 @halibobo1205
82+
/plugins/src/main/java/common/org/tron/plugins/DbCopy.java @bladehan1 @halibobo1205
83+
/framework/src/main/java/org/tron/core/services/filter/ @bladehan1 @halibobo1205
84+
85+
# ────────────────────────────────────────────────────────────────
86+
# 4. Test code — mirrors the module ownership above
87+
# ────────────────────────────────────────────────────────────────
88+
89+
/framework/src/test/ @xxo1shine @bladehan1
90+
/chainbase/src/test/ @halibobo1205 @bladehan1
91+
/actuator/src/test/ @Sunny6889 @lxcmyf
92+
/consensus/src/test/ @kuny0707 @xxo1shine
93+
/protocol/src/test/ @lvs0075 @waynercheung
94+
/common/src/test/ @lvs0075 @lxcmyf
95+
/crypto/src/test/ @Federico2014 @3for
96+
/plugins/src/test/ @halibobo1205 @warku123

CONTRIBUTING.md

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ Here are some guidelines to get started quickly and easily:
2323
- [Conduct](#Conduct)
2424

2525

26-
### Reporting An Issue
26+
## Reporting An Issue
2727

28-
If you're about to raise an issue because you think you've found a problem or bug with java-tron, please respect the following restrictions:
28+
If you have any question about java-tron, please search [existing issues](https://github.com/tronprotocol/java-tron/issues?q=is%3Aissue%20state%3Aclosed%20OR%20state%3Aopen) first to avoid duplicates. Your questions might already be under discussion or part of our roadmap. Checking first helps us streamline efforts and focus on new contributions.
2929

30-
- Please search for existing issues. Help us keep duplicate issues to a minimum by checking to see if someone has already reported your problem or requested your idea.
30+
### Ask a question
31+
Feel free to ask any java-tron related question to solve your doubt. Please click **Ask a question** in GitHub Issues, using [Ask a question](.github/ISSUE_TEMPLATE/ask-a-question.md) template.
3132

32-
- Use the Issue Report Template below.
33-
```
34-
1.What did you do?
33+
### Report a bug
3534

36-
2.What did you expect to see?
35+
If you think you've found a bug with java-tron, please click **Report a bug** in GitHub Issues, using [Report a bug](.github/ISSUE_TEMPLATE/report-a-bug.md) template.
3736

38-
3.What did you see instead?
39-
```
37+
### Request a feature
38+
39+
If you have any good feature suggestions for java-tron, please click **Request a feature** in GitHub Issues, using [Request a feature](.github/ISSUE_TEMPLATE/request-a-feature.md) template.
4040

4141

4242
## Working on java-tron
@@ -69,43 +69,56 @@ java-tron only has `master`, `develop`, `release-*`, `feature-*`, and `hotfix-*`
6969

7070
### Submitting Code
7171

72-
If you want to contribute codes to java-tron, please follow the following steps:
72+
If you want to contribute code to java-tron, please follow the following steps.
73+
74+
* Fork the Repository
75+
76+
Visit [tronprotocol/java-tron](https://github.com/tronprotocol/java-tron/) and click **Fork** to create a fork repository under your GitHub account.
7377

74-
* Fork code repository
75-
Fork a new repository from tronprotocol/java-tron to your personal code repository
78+
* Setup Local Environment
7679

77-
* Edit the code in the fork repository
80+
Clone your fork repository to local and add the official repository as **upstream**.
7881
```
7982
git clone https://github.com/yourname/java-tron.git
8083
81-
git remote add upstream https://github.com/tronprotocol/java-tron.git ("upstream" refers to upstream projects repositories, namely tronprotocol's repositories, and can be named as you like it. We usually call it "upstream" for convenience)
84+
cd java-tron
85+
86+
git remote add upstream https://github.com/tronprotocol/java-tron.git
8287
```
83-
Before developing new features, please synchronize your fork repository with the upstream repository.
88+
89+
* Synchronize and Develop
90+
91+
Before developing new features, please synchronize your local `develop` branch with the upstream repository and update to your fork repository.
8492
```
85-
git fetch upstream
86-
git checkout develop
87-
git merge upstream/develop --no-ff (Add --no-ff to turn off the default fast merge mode)
93+
git fetch upstream
94+
git checkout develop
95+
# `--no-ff` means to turn off the default fast merge mode
96+
git merge upstream/develop --no-ff
97+
git push origin develop
8898
```
8999
90-
Pull a new branch from the develop branch of your repository for local development. Please refer to [Branch Naming Conventions](#Branch-Naming-Conventions),
100+
Create a new branch for development. Please refer to [Branch Naming Conventions](#Branch-Naming-Conventions).
91101
```
92102
git checkout -b feature/branch_name develop
93103
```
94104
95-
Write and commit the new code when it is completed. Please refer to [Commit Messages](#Commit-Messages)
105+
* Commit and Push
106+
107+
Write and commit the new code when it is completed. Please refer to [Commit Messages](#Commit-Messages).
96108
```
97109
git add .
98110
git commit -m 'commit message'
99111
```
100-
Commit the new branch to your personal remote repository
112+
113+
Push the new branch to your fork repository
101114
```
102115
git push origin feature/branch_name
103116
```
104117
105-
* Push code
118+
* Submit a pull request
106119
107-
Submit a pull request (PR) from your repository to `tronprotocol/java-tron`.
108-
Please be sure to click on the link in the red box shown below. Select the base branch for tronprotocol and the compare branch for your personal fork repository.
120+
Submit a pull request (PR) from your fork repository to `tronprotocol/java-tron`.
121+
Please be sure to click on the link in the red box shown below. Select the base branch for `tronprotocol/java-tron` and the compare branch for your fork repository.
109122
![image](https://raw.githubusercontent.com/tronprotocol/documentation-en/master/images/javatron_pr.png)
110123
111124

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,21 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
871871
}
872872
break;
873873
}
874+
case ALLOW_TVM_OSAKA: {
875+
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_8_2)) {
876+
throw new ContractValidateException(
877+
"Bad chain parameter id [ALLOW_TVM_OSAKA]");
878+
}
879+
if (dynamicPropertiesStore.getAllowTvmOsaka() == 1) {
880+
throw new ContractValidateException(
881+
"[ALLOW_TVM_OSAKA] has been valid, no need to propose again");
882+
}
883+
if (value != 1) {
884+
throw new ContractValidateException(
885+
"This value[ALLOW_TVM_OSAKA] is only allowed to be 1");
886+
}
887+
break;
888+
}
874889
default:
875890
break;
876891
}
@@ -955,7 +970,8 @@ public enum ProposalType { // current value, value range
955970
CONSENSUS_LOGIC_OPTIMIZATION(88), // 0, 1
956971
ALLOW_TVM_BLOB(89), // 0, 1
957972
PROPOSAL_EXPIRE_TIME(92), // (0, 31536003000)
958-
ALLOW_TVM_SELFDESTRUCT_RESTRICTION(94); // 0, 1
973+
ALLOW_TVM_SELFDESTRUCT_RESTRICTION(94), // 0, 1
974+
ALLOW_TVM_OSAKA(96); // 0, 1
959975

960976
private long code;
961977

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

33
import java.util.Set;
4+
import java.util.concurrent.atomic.AtomicBoolean;
45
import lombok.extern.slf4j.Slf4j;
56
import org.reflections.Reflections;
67
import org.tron.core.actuator.AbstractActuator;
8+
import org.tron.core.exception.TronError;
79

810
@Slf4j(topic = "TransactionRegister")
911
public class TransactionRegister {
1012

13+
private static final AtomicBoolean REGISTERED = new AtomicBoolean(false);
14+
private static final String PACKAGE_NAME = "org.tron.core.actuator";
15+
1116
public static void registerActuator() {
12-
Reflections reflections = new Reflections("org.tron");
13-
Set<Class<? extends AbstractActuator>> subTypes = reflections
14-
.getSubTypesOf(AbstractActuator.class);
15-
for (Class _class : subTypes) {
16-
try {
17-
_class.newInstance();
18-
} catch (Exception e) {
19-
logger.error("{} contract actuator register fail!", _class, e);
17+
if (REGISTERED.get()) {
18+
logger.debug("Actuator already registered.");
19+
return;
20+
}
21+
22+
synchronized (TransactionRegister.class) {
23+
if (REGISTERED.get()) {
24+
logger.debug("Actuator already registered.");
25+
return;
26+
}
27+
logger.debug("Register actuator start.");
28+
Reflections reflections = new Reflections(PACKAGE_NAME);
29+
Set<Class<? extends AbstractActuator>> subTypes = reflections
30+
.getSubTypesOf(AbstractActuator.class);
31+
32+
for (Class<? extends AbstractActuator> clazz : subTypes) {
33+
try {
34+
logger.debug("Registering actuator: {} start", clazz.getName());
35+
clazz.getDeclaredConstructor().newInstance();
36+
logger.debug("Registering actuator: {} done", clazz.getName());
37+
} catch (Exception e) {
38+
Throwable cause = e.getCause() != null ? e.getCause() : e;
39+
String detail = cause.getMessage() != null ? cause.getMessage() : cause.toString();
40+
throw new TronError(clazz.getName() + ": " + detail,
41+
e, TronError.ErrCode.ACTUATOR_REGISTER);
42+
}
2043
}
44+
45+
REGISTERED.set(true);
46+
logger.debug("Register actuator done, total {}.", subTypes.size());
2147
}
2248
}
2349

50+
static boolean isRegistered() {
51+
return REGISTERED.get();
52+
}
53+
54+
// For testing only — resets registration state between tests.
55+
static void resetForTesting() {
56+
REGISTERED.set(false);
57+
}
2458
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ public static class ModExp extends PrecompiledContract {
622622

623623
private static final int ARGS_OFFSET = 32 * 3; // addresses length part
624624

625+
private static final int UPPER_BOUND = 1024;
626+
625627
@Override
626628
public long getEnergyForData(byte[] data) {
627629

@@ -660,6 +662,11 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
660662
int expLen = parseLen(data, 1);
661663
int modLen = parseLen(data, 2);
662664

665+
if (VMConfig.allowTvmOsaka()
666+
&& (baseLen > UPPER_BOUND || expLen > UPPER_BOUND || modLen > UPPER_BOUND)) {
667+
return Pair.of(false, EMPTY_BYTE_ARRAY);
668+
}
669+
663670
BigInteger base = parseArg(data, ARGS_OFFSET, baseLen);
664671
BigInteger exp = parseArg(data, addSafely(ARGS_OFFSET, baseLen), expLen);
665672
BigInteger mod = parseArg(data, addSafely(addSafely(ARGS_OFFSET, baseLen), expLen), modLen);

actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public static void load(StoreFactory storeFactory) {
4545
VMConfig.initDisableJavaLangMath(ds.getConsensusLogicOptimization());
4646
VMConfig.initAllowTvmBlob(ds.getAllowTvmBlob());
4747
VMConfig.initAllowTvmSelfdestructRestriction(ds.getAllowTvmSelfdestructRestriction());
48+
VMConfig.initAllowTvmOsaka(ds.getAllowTvmOsaka());
4849
}
4950
}
5051
}

chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
238238
private static final byte[] ALLOW_TVM_SELFDESTRUCT_RESTRICTION =
239239
"ALLOW_TVM_SELFDESTRUCT_RESTRICTION".getBytes();
240240

241+
private static final byte[] ALLOW_TVM_OSAKA = "ALLOW_TVM_OSAKA".getBytes();
242+
241243
@Autowired
242244
private DynamicPropertiesStore(@Value("properties") String dbName) {
243245
super(dbName);
@@ -2980,6 +2982,17 @@ public long getProposalExpireTime() {
29802982
.orElse(CommonParameter.getInstance().getProposalExpireTime());
29812983
}
29822984

2985+
public long getAllowTvmOsaka() {
2986+
return Optional.ofNullable(getUnchecked(ALLOW_TVM_OSAKA))
2987+
.map(BytesCapsule::getData)
2988+
.map(ByteArray::toLong)
2989+
.orElse(CommonParameter.getInstance().getAllowTvmOsaka());
2990+
}
2991+
2992+
public void saveAllowTvmOsaka(long value) {
2993+
this.put(ALLOW_TVM_OSAKA, new BytesCapsule(ByteArray.fromLong(value)));
2994+
}
2995+
29832996
private static class DynamicResourceProperties {
29842997

29852998
private static final byte[] ONE_DAY_NET_LIMIT = "ONE_DAY_NET_LIMIT".getBytes();

common/src/main/java/org/tron/common/args/GenesisBlock.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,17 @@ public void setAssets(final List<Account> assets) {
6161
*/
6262
public void setTimestamp(final String timestamp) {
6363
this.timestamp = timestamp;
64-
6564
if (this.timestamp == null) {
6665
this.timestamp = DEFAULT_TIMESTAMP;
67-
}
68-
69-
try {
70-
long l = Long.parseLong(this.timestamp);
71-
if (l < 0) {
66+
} else {
67+
try {
68+
long l = Long.parseLong(this.timestamp);
69+
if (l < 0) {
70+
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be greater than or equal to 0.");
71+
}
72+
} catch (NumberFormatException e) {
7273
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type.");
7374
}
74-
} catch (NumberFormatException e) {
75-
throw new IllegalArgumentException("Timestamp(" + timestamp + ") must be a Long type.");
7675
}
7776
}
7877

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,10 @@ public class CommonParameter {
633633
@Setter
634634
public long allowTvmBlob;
635635

636+
@Getter
637+
@Setter
638+
public long allowTvmOsaka;
639+
636640
private static double calcMaxTimeRatio() {
637641
return 5.0;
638642
}

0 commit comments

Comments
 (0)