Skip to content

Commit 28667d4

Browse files
authored
Merge pull request tronprotocol#2280 from tronprotocol/release_3.6
Release 3.6 to master
2 parents 5e9845b + 7db63b1 commit 28667d4

File tree

5 files changed

+60
-38
lines changed

5 files changed

+60
-38
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ dependencies {
117117
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
118118

119119
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0'
120+
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.4.0'
120121

121122
compile "org.iq80.leveldb:leveldb:0.7"
122123

src/main/java/org/tron/common/logsfilter/ContractEventParserJson.java

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,24 @@ public static Map<String, String> parseTopics(List<byte[]> topicList, JSONObject
3232

3333
// in case indexed topics doesn't match
3434
if (topicsMatched(topicList, entry)) {
35-
for (int i = 0; i < inputs.size(); ++i) {
36-
JSONObject param = inputs.getJSONObject(i);
37-
Boolean indexed = param.getBoolean(INDEXED);
38-
if (indexed == null || !indexed) {
39-
continue;
40-
}
41-
if (index >= topicList.size()) {
42-
break;
43-
}
44-
String str = parseTopic(topicList.get(index++), param.getString("type"));
45-
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
46-
map.put(param.getString("name"), str);
35+
if (inputs != null) {
36+
for (int i = 0; i < inputs.size(); ++i) {
37+
JSONObject param = inputs.getJSONObject(i);
38+
if (param != null) {
39+
Boolean indexed = param.getBoolean(INDEXED);
40+
if (indexed == null || !indexed) {
41+
continue;
42+
}
43+
if (index >= topicList.size()) {
44+
break;
45+
}
46+
String str = parseTopic(topicList.get(index++), param.getString("type"));
47+
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
48+
map.put(param.getString("name"), str);
49+
}
50+
map.put("" + i, str);
51+
}
4752
}
48-
map.put("" + i, str);
4953
}
5054
} else {
5155
for (int i = 1; i < topicList.size(); ++i) {
@@ -82,21 +86,22 @@ public static Map<String, String> parseEventData(byte[] data,
8286
if (inputs != null) {
8387
for (Integer i = 0; i < inputs.size(); ++i) {
8488
JSONObject param = inputs.getJSONObject(i);
85-
Boolean indexed = param.getBoolean(INDEXED);
86-
if (indexed != null && indexed) {
87-
continue;
88-
}
89+
if (param != null) {
90+
Boolean indexed = param.getBoolean(INDEXED);
91+
if (indexed != null && indexed) {
92+
continue;
93+
}
8994

90-
if (startIndex == 0) {
91-
startIndex = i;
92-
}
95+
if (startIndex == 0) {
96+
startIndex = i;
97+
}
9398

94-
String str = parseDataBytes(data, param.getString("type"), index++);
95-
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
96-
map.put(param.getString("name"), str);
99+
String str = parseDataBytes(data, param.getString("type"), index++);
100+
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
101+
map.put(param.getString("name"), str);
102+
}
103+
map.put("" + i, str);
97104
}
98-
map.put("" + i, str);
99-
100105
}
101106
} else {
102107
map.put("0", Hex.toHexString(data));
@@ -115,14 +120,17 @@ private static boolean topicsMatched(List<byte[]> topicList, JSONObject entry) {
115120
}
116121
int inputSize = 1;
117122
JSONArray inputs = entry.getJSONArray(INPUTS);
118-
for (int i = 0; i < inputs.size(); i++) {
119-
JSONObject param = inputs.getJSONObject(i);
120-
Boolean indexed = param.getBoolean(INDEXED);
121-
if (indexed != null && indexed) {
122-
inputSize++;
123+
if (inputs != null) {
124+
for (int i = 0; i < inputs.size(); i++) {
125+
JSONObject param = inputs.getJSONObject(i);
126+
if (param != null) {
127+
Boolean indexed = param.getBoolean(INDEXED);
128+
if (indexed != null && indexed) {
129+
inputSize++;
130+
}
131+
}
123132
}
124133
}
125134
return inputSize == topicList.size();
126135
}
127-
128136
}

src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package org.tron.common.runtime.vm;
22

3+
import com.google.protobuf.InvalidProtocolBufferException;
4+
import com.google.protobuf.util.JsonFormat;
35
import java.util.HashMap;
46
import java.util.LinkedList;
57
import java.util.List;
68
import java.util.Map;
9+
import lombok.extern.slf4j.Slf4j;
710
import org.apache.commons.lang3.ArrayUtils;
811
import org.apache.commons.lang3.StringUtils;
912
import org.spongycastle.util.encoders.Hex;
@@ -12,9 +15,9 @@
1215
import org.tron.common.storage.Deposit;
1316
import org.tron.core.Wallet;
1417
import org.tron.core.capsule.ContractCapsule;
15-
import org.tron.core.services.http.JsonFormat;
1618
import org.tron.protos.Protocol.SmartContract.ABI;
1719

20+
@Slf4j
1821
public class LogInfoTriggerParser {
1922

2023
private Long blockNum;
@@ -64,7 +67,13 @@ public List<ContractTrigger> parseLogInfos(List<LogInfo> logInfos, Deposit depos
6467
signMap.put(strContractAddr, creatorAddr); // mark as found.
6568

6669
if (abi != null && abi.getEntrysCount() > 0) {
67-
abiMap.put(strContractAddr, JsonFormat.printToString(abi, false));
70+
try {
71+
abiMap
72+
.put(strContractAddr, JsonFormat.printer().includingDefaultValueFields().print(abi));
73+
} catch (InvalidProtocolBufferException e) {
74+
abiMap.put(strContractAddr, "");
75+
logger.info("abi to json empty:" + txId, e);
76+
}
6877
} else {
6978
abiMap.put(strContractAddr, "");
7079
}

src/main/java/org/tron/common/runtime/vm/program/Program.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd
516516
TransferActuator.validateForSmartContract(deposit, senderAddress, newAddress, endowment);
517517
} catch (ContractValidateException e) {
518518
// TODO: unreachable exception
519-
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
519+
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
520520
}
521521
deposit.addBalance(senderAddress, -endowment);
522522
newBalance = deposit.addBalance(newAddress, endowment);
@@ -710,7 +710,7 @@ public void callToAddress(MessageCall msg) {
710710
refundEnergy(msg.getEnergy().longValue(), "refund energy from message call");
711711
throw new TransferException("transfer trx failed: %s", e.getMessage());
712712
}
713-
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
713+
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
714714
}
715715
deposit.addBalance(senderAddress, -endowment);
716716
contextBalance = deposit.addBalance(contextAddress, endowment);
@@ -723,7 +723,7 @@ public void callToAddress(MessageCall msg) {
723723
refundEnergy(msg.getEnergy().longValue(), "refund energy from message call");
724724
throw new TransferException("transfer trc10 failed: %s", e.getMessage());
725725
}
726-
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
726+
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
727727
}
728728
deposit.addTokenBalance(senderAddress, tokenId, -endowment);
729729
deposit.addTokenBalance(contextAddress, tokenId, endowment);
@@ -1424,7 +1424,7 @@ public void callToPrecompiledAddress(MessageCall msg,
14241424
TransferAssetActuator
14251425
.validateForSmartContract(deposit, senderAddress, contextAddress, tokenId, endowment);
14261426
} catch (ContractValidateException e) {
1427-
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
1427+
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
14281428
}
14291429
deposit.addTokenBalance(senderAddress, tokenId, -endowment);
14301430
deposit.addTokenBalance(contextAddress, tokenId, endowment);
@@ -1558,6 +1558,10 @@ public static class BytecodeExecutionException extends RuntimeException {
15581558
public BytecodeExecutionException(String message) {
15591559
super(message);
15601560
}
1561+
1562+
public BytecodeExecutionException(String message, Object... args) {
1563+
super(format(message, args));
1564+
}
15611565
}
15621566

15631567
public static class TransferException extends BytecodeExecutionException {

ver.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fi
2525

2626

2727
versionPath="src/main/java/org/tron/program/Version.java"
28-
sed -i "s/versionName.*$/versionName = \"$versionName\";/g;s/versionCode.*$/versionCode = \"$versionCode\";/g" $versionPath
28+
sed -i -e "s/versionName.*$/versionName = \"$versionName\";/g;s/versionCode.*$/versionCode = \"$versionCode\";/g" $versionPath
2929
git add $versionPath
3030
git commit -m "update a new version. version name:$versionName,version code:$versionCode"
3131
git push origin $versionBranch

0 commit comments

Comments
 (0)