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
43 changes: 21 additions & 22 deletions actuator/src/main/java/org/tron/core/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -1815,9 +1814,9 @@ public boolean freeze(DataWord receiverAddress, DataWord frozenBalance, DataWord
repository.commit();
return true;
} catch (ContractValidateException e) {
logger.error("TVM Freeze: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM Freeze: validate failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM Freeze: frozenBalance out of long range.");
logger.warn("TVM Freeze: frozenBalance out of long range.");
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -1848,7 +1847,7 @@ public boolean unfreeze(DataWord receiverAddress, DataWord resourceType) {
}
return true;
} catch (ContractValidateException e) {
logger.error("TVM Unfreeze: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM Unfreeze: validate failure. Reason: {}", e.getMessage());
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -1911,9 +1910,9 @@ public boolean freezeBalanceV2(DataWord frozenBalance, DataWord resourceType) {
repository.commit();
return true;
} catch (ContractValidateException e) {
logger.error("TVM FreezeBalanceV2: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM FreezeBalanceV2: validate failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM FreezeBalanceV2: frozenBalance out of long range.");
logger.warn("TVM FreezeBalanceV2: frozenBalance out of long range.");
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -1947,9 +1946,9 @@ public boolean unfreezeBalanceV2(DataWord unfreezeBalance, DataWord resourceType
}
return true;
} catch (ContractValidateException e) {
logger.error("TVM UnfreezeBalanceV2: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM UnfreezeBalanceV2: validate failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM UnfreezeBalanceV2: balance out of long range.");
logger.warn("TVM UnfreezeBalanceV2: balance out of long range.");
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -1978,9 +1977,9 @@ public long withdrawExpireUnfreeze() {
}
return expireUnfreezeBalance;
} catch (ContractValidateException e) {
logger.error("TVM WithdrawExpireUnfreeze: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM WithdrawExpireUnfreeze: validate failure. Reason: {}", e.getMessage());
} catch (ContractExeException e) {
logger.error("TVM WithdrawExpireUnfreeze: execute failure. Reason: {}", e.getMessage());
logger.warn("TVM WithdrawExpireUnfreeze: execute failure. Reason: {}", e.getMessage());
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -2011,9 +2010,9 @@ public boolean cancelAllUnfreezeV2Action() {
}
return true;
} catch (ContractValidateException e) {
logger.error("TVM CancelAllUnfreezeV2: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM CancelAllUnfreezeV2: validate failure. Reason: {}", e.getMessage());
} catch (ContractExeException e) {
logger.error("TVM CancelAllUnfreezeV2: execute failure. Reason: {}", e.getMessage());
logger.warn("TVM CancelAllUnfreezeV2: execute failure. Reason: {}", e.getMessage());
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -2045,9 +2044,9 @@ public boolean delegateResource(
repository.commit();
return true;
} catch (ContractValidateException e) {
logger.error("TVM DelegateResource: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM DelegateResource: validate failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM DelegateResource: balance out of long range.");
logger.warn("TVM DelegateResource: balance out of long range.");
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -2079,9 +2078,9 @@ public boolean unDelegateResource(
repository.commit();
return true;
} catch (ContractValidateException e) {
logger.error("TVM UnDelegateResource: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM UnDelegateResource: validate failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM UnDelegateResource: balance out of long range.");
logger.warn("TVM UnDelegateResource: balance out of long range.");
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -2114,7 +2113,7 @@ private Common.ResourceCode parseResourceCodeV2(DataWord resourceType) {
return Common.ResourceCode.UNRECOGNIZED;
}
} catch (ArithmeticException e) {
logger.error("TVM ParseResourceCodeV2: invalid resource code: {}", resourceType.sValue());
logger.warn("TVM ParseResourceCodeV2: invalid resource code: {}", resourceType.sValue());
return Common.ResourceCode.UNRECOGNIZED;
}
}
Expand Down Expand Up @@ -2180,11 +2179,11 @@ public boolean voteWitness(int witnessArrayOffset, int witnessArrayLength,
repository.commit();
return true;
} catch (ContractValidateException e) {
logger.error("TVM VoteWitness: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM VoteWitness: validate failure. Reason: {}", e.getMessage());
} catch (ContractExeException e) {
logger.error("TVM VoteWitness: execute failure. Reason: {}", e.getMessage());
logger.warn("TVM VoteWitness: execute failure. Reason: {}", e.getMessage());
} catch (ArithmeticException e) {
logger.error("TVM VoteWitness: int or long out of range. caused by: {}", e.getMessage());
logger.warn("TVM VoteWitness: int or long out of range. caused by: {}", e.getMessage());
}
if (internalTx != null) {
internalTx.reject();
Expand Down Expand Up @@ -2213,9 +2212,9 @@ public long withdrawReward() {
}
return allowance;
} catch (ContractValidateException e) {
logger.error("TVM WithdrawReward: validate failure. Reason: {}", e.getMessage());
logger.warn("TVM WithdrawReward: validate failure. Reason: {}", e.getMessage());
} catch (ContractExeException e) {
logger.error("TVM WithdrawReward: execute failure. Reason: {}", e.getMessage());
logger.warn("TVM WithdrawReward: execute failure. Reason: {}", e.getMessage());
}
if (internalTx != null) {
internalTx.reject();
Expand Down
7 changes: 3 additions & 4 deletions framework/src/main/java/org/tron/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -3029,13 +3029,12 @@ public Transaction callConstantContract(TransactionCapsule trxCap,
if (!isEstimating && result.getException() != null
|| result.getException() instanceof Program.OutOfTimeException) {
RuntimeException e = result.getException();
logger.warn("Constant call has an error {}", e.getMessage());
logger.warn("Constant call failed for reason: {}", e.getMessage());
throw e;
}

TransactionResultCapsule ret = new TransactionResultCapsule();
builder.setEnergyUsed(result.getEnergyUsed());
builder.setEnergyPenalty(result.getEnergyPenaltyTotal());
builder.setBlockNumber(headBlockCapsule.getNum());
builder.setBlockHash(ByteString.copyFrom(headBlockCapsule.getBlockId().getBytes()));
builder.setEnergyPenalty(result.getEnergyPenaltyTotal());
Expand Down Expand Up @@ -3867,7 +3866,7 @@ private boolean isShieldedTRC20NoteSpent(GrpcAPI.Note note, long pos, byte[] ak,
retBuilder.setResult(false).setCode(response_code.CONTRACT_EXE_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
trxExtBuilder.setResult(retBuilder);
logger.warn("When run constant call in VM, have RuntimeException: " + e.getMessage());
logger.warn("When run constant call in VM, failed for reason: " + e.getMessage());
} catch (Exception e) {
retBuilder.setResult(false).setCode(response_code.OTHER_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
Expand Down Expand Up @@ -4131,7 +4130,7 @@ private byte[] getShieldedContractScalingFactor(byte[] contractAddress)
retBuilder.setResult(false).setCode(response_code.CONTRACT_EXE_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
trxExtBuilder.setResult(retBuilder);
logger.warn("When run constant call in VM, have RuntimeException: " + e.getMessage());
logger.warn("When run constant call in VM, failed for reason: " + e.getMessage());
} catch (Exception e) {
retBuilder.setResult(false).setCode(response_code.OTHER_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private void callContract(TriggerSmartContract request,
retBuilder.setResult(false).setCode(response_code.CONTRACT_EXE_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
trxExtBuilder.setResult(retBuilder);
logger.warn("When run constant call in VM, have RuntimeException: " + e.getMessage());
logger.warn("When run constant call in VM, failed for reason: " + e.getMessage());
} catch (Exception e) {
retBuilder.setResult(false).setCode(response_code.OTHER_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
Expand Down Expand Up @@ -2077,7 +2077,7 @@ private void callContract(TriggerSmartContract request,
retBuilder.setResult(false).setCode(response_code.CONTRACT_EXE_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
trxExtBuilder.setResult(retBuilder);
logger.warn("When run constant call in VM, have Runtime Exception: " + e.getMessage());
logger.warn("When run constant call in VM, failed for reason: " + e.getMessage());
} catch (Exception e) {
retBuilder.setResult(false).setCode(response_code.OTHER_ERROR)
.setMessage(ByteString.copyFromUtf8(e.getClass() + " : " + e.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ private void validateParameter(String contract) {
if (StringUtil.isNullOrEmpty(jsonObject.getString(Util.CONTRACT_ADDRESS))) {
throw new InvalidParameterException(Util.CONTRACT_ADDRESS + " isn't set.");
}
if (!StringUtil.isNullOrEmpty(jsonObject.getString(Util.FUNCTION_SELECTOR))
^ StringUtil.isNullOrEmpty(jsonObject.getString(Util.CALL_DATA))) {
throw new InvalidParameterException("Only one of "
+ Util.FUNCTION_SELECTOR + " and " + Util.CALL_DATA + " can be set.");
}
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
Expand Down
11 changes: 6 additions & 5 deletions framework/src/main/java/org/tron/core/services/http/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public static List<Log> convertLogAddressToTronAddress(TransactionInfo transacti
* Validate parameters for trigger constant and estimate energy
* - Rule-1: owner address must be set
* - Rule-2: either contract address is set or call data is set
* - Rule-3: only one of function selector and call data can be set
* - Rule-3: if try to deploy, function selector and call data can not be both set
* @param contract parameters in json format
* @throws InvalidParameterException if validation is not passed, this kind of exception is thrown
*/
Expand All @@ -568,10 +568,11 @@ public static void validateParameter(String contract) throws InvalidParameterExc
throw new InvalidParameterException("At least one of "
+ CONTRACT_ADDRESS + " and " + CALL_DATA + " must be set.");
}
if (!StringUtils.isEmpty(jsonObject.getString(FUNCTION_SELECTOR))
^ StringUtils.isEmpty(jsonObject.getString(CALL_DATA))) {
throw new InvalidParameterException("Only one of "
+ FUNCTION_SELECTOR + " and " + CALL_DATA + " can be set.");
if (StringUtils.isEmpty(jsonObject.getString(CONTRACT_ADDRESS))
&& !StringUtils.isEmpty(jsonObject.getString(FUNCTION_SELECTOR))
&& !StringUtils.isEmpty(jsonObject.getString(CALL_DATA))) {
throw new InvalidParameterException("While trying to deploy, "
+ FUNCTION_SELECTOR + " and " + CALL_DATA + " can not be both set.");
}
}

Expand Down