Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ dependencies {
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'

compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0'
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.4.0'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,24 @@ public static Map<String, String> parseTopics(List<byte[]> topicList, JSONObject

// in case indexed topics doesn't match
if (topicsMatched(topicList, entry)) {
for (int i = 0; i < inputs.size(); ++i) {
JSONObject param = inputs.getJSONObject(i);
Boolean indexed = param.getBoolean(INDEXED);
if (indexed == null || !indexed) {
continue;
}
if (index >= topicList.size()) {
break;
}
String str = parseTopic(topicList.get(index++), param.getString("type"));
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
map.put(param.getString("name"), str);
if (inputs != null) {
for (int i = 0; i < inputs.size(); ++i) {
JSONObject param = inputs.getJSONObject(i);
if (param != null) {
Boolean indexed = param.getBoolean(INDEXED);
if (indexed == null || !indexed) {
continue;
}
if (index >= topicList.size()) {
break;
}
String str = parseTopic(topicList.get(index++), param.getString("type"));
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
map.put(param.getString("name"), str);
}
map.put("" + i, str);
}
}
map.put("" + i, str);
}
} else {
for (int i = 1; i < topicList.size(); ++i) {
Expand Down Expand Up @@ -82,21 +86,22 @@ public static Map<String, String> parseEventData(byte[] data,
if (inputs != null) {
for (Integer i = 0; i < inputs.size(); ++i) {
JSONObject param = inputs.getJSONObject(i);
Boolean indexed = param.getBoolean(INDEXED);
if (indexed != null && indexed) {
continue;
}
if (param != null) {
Boolean indexed = param.getBoolean(INDEXED);
if (indexed != null && indexed) {
continue;
}

if (startIndex == 0) {
startIndex = i;
}
if (startIndex == 0) {
startIndex = i;
}

String str = parseDataBytes(data, param.getString("type"), index++);
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
map.put(param.getString("name"), str);
String str = parseDataBytes(data, param.getString("type"), index++);
if (StringUtils.isNotNullOrEmpty(param.getString("name"))) {
map.put(param.getString("name"), str);
}
map.put("" + i, str);
}
map.put("" + i, str);

}
} else {
map.put("0", Hex.toHexString(data));
Expand All @@ -115,14 +120,17 @@ private static boolean topicsMatched(List<byte[]> topicList, JSONObject entry) {
}
int inputSize = 1;
JSONArray inputs = entry.getJSONArray(INPUTS);
for (int i = 0; i < inputs.size(); i++) {
JSONObject param = inputs.getJSONObject(i);
Boolean indexed = param.getBoolean(INDEXED);
if (indexed != null && indexed) {
inputSize++;
if (inputs != null) {
for (int i = 0; i < inputs.size(); i++) {
JSONObject param = inputs.getJSONObject(i);
if (param != null) {
Boolean indexed = param.getBoolean(INDEXED);
if (indexed != null && indexed) {
inputSize++;
}
}
}
}
return inputSize == topicList.size();
}

}
13 changes: 11 additions & 2 deletions src/main/java/org/tron/common/runtime/vm/LogInfoTriggerParser.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.tron.common.runtime.vm;

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.spongycastle.util.encoders.Hex;
Expand All @@ -12,9 +15,9 @@
import org.tron.common.storage.Deposit;
import org.tron.core.Wallet;
import org.tron.core.capsule.ContractCapsule;
import org.tron.core.services.http.JsonFormat;
import org.tron.protos.Protocol.SmartContract.ABI;

@Slf4j
public class LogInfoTriggerParser {

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

if (abi != null && abi.getEntrysCount() > 0) {
abiMap.put(strContractAddr, JsonFormat.printToString(abi, false));
try {
abiMap
.put(strContractAddr, JsonFormat.printer().includingDefaultValueFields().print(abi));
} catch (InvalidProtocolBufferException e) {
abiMap.put(strContractAddr, "");
logger.info("abi to json empty:" + txId, e);
}
} else {
abiMap.put(strContractAddr, "");
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/tron/common/runtime/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd
TransferActuator.validateForSmartContract(deposit, senderAddress, newAddress, endowment);
} catch (ContractValidateException e) {
// TODO: unreachable exception
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
}
deposit.addBalance(senderAddress, -endowment);
newBalance = deposit.addBalance(newAddress, endowment);
Expand Down Expand Up @@ -710,7 +710,7 @@ public void callToAddress(MessageCall msg) {
refundEnergy(msg.getEnergy().longValue(), "refund energy from message call");
throw new TransferException("transfer trx failed: %s", e.getMessage());
}
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
}
deposit.addBalance(senderAddress, -endowment);
contextBalance = deposit.addBalance(contextAddress, endowment);
Expand All @@ -723,7 +723,7 @@ public void callToAddress(MessageCall msg) {
refundEnergy(msg.getEnergy().longValue(), "refund energy from message call");
throw new TransferException("transfer trc10 failed: %s", e.getMessage());
}
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
}
deposit.addTokenBalance(senderAddress, tokenId, -endowment);
deposit.addTokenBalance(contextAddress, tokenId, endowment);
Expand Down Expand Up @@ -1424,7 +1424,7 @@ public void callToPrecompiledAddress(MessageCall msg,
TransferAssetActuator
.validateForSmartContract(deposit, senderAddress, contextAddress, tokenId, endowment);
} catch (ContractValidateException e) {
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE);
throw new BytecodeExecutionException(VALIDATE_FOR_SMART_CONTRACT_FAILURE, e.getMessage());
}
deposit.addTokenBalance(senderAddress, tokenId, -endowment);
deposit.addTokenBalance(contextAddress, tokenId, endowment);
Expand Down Expand Up @@ -1558,6 +1558,10 @@ public static class BytecodeExecutionException extends RuntimeException {
public BytecodeExecutionException(String message) {
super(message);
}

public BytecodeExecutionException(String message, Object... args) {
super(format(message, args));
}
}

public static class TransferException extends BytecodeExecutionException {
Expand Down
2 changes: 1 addition & 1 deletion ver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi


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