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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ language: java
jdk: oraclejdk8
addons:
ssh_known_hosts:
- 47.93.18.60:22008
- 47.93.18.60:22008
- 47.93.18.60:22008
- 47.93.42.145:22008
- 47.93.42.145:22008
- 47.93.42.145:22008
- 47.93.18.60:22008
- 47.93.18.60:22008
- 47.93.18.60:22008
sonarcloud:
organization: tron-zhaohong
token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ private void validateValue(Map.Entry<Long, Long> entry) throws ContractValidateE
break;
}
case (26): {
if (!dbManager.getForkController().pass(ForkBlockVersionEnum.VERSION_3_6)) {
throw new ContractValidateException("Bad chain parameter id");
}
if (entry.getValue() != 1) {
throw new ContractValidateException(
"This value[ALLOW_TVM_CONSTANTINOPLE] is only allowed to be 1");
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/org/tron/core/capsule/TransactionCapsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,29 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.tron.common.crypto.ECKey;
import org.tron.common.crypto.ECKey.ECDSASignature;
import org.tron.common.overlay.message.Message;
import org.tron.common.runtime.vm.program.Program;
import org.tron.common.runtime.vm.program.Program.BadJumpDestinationException;
import org.tron.common.runtime.vm.program.Program.IllegalOperationException;
import org.tron.common.runtime.vm.program.Program.JVMStackOverFlowException;
import org.tron.common.runtime.vm.program.Program.OutOfEnergyException;
import org.tron.common.runtime.Runtime;
import org.tron.common.runtime.vm.program.Program.OutOfMemoryException;
import org.tron.common.runtime.vm.program.Program.OutOfTimeException;
import org.tron.common.runtime.vm.program.Program.PrecompiledContractException;
import org.tron.common.runtime.vm.program.Program.StackTooLargeException;
import org.tron.common.runtime.vm.program.Program.StackTooSmallException;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.Wallet;
Expand Down Expand Up @@ -860,6 +873,61 @@ public String toString() {
return toStringBuff.toString();
}

public void setResult(Runtime runtime) {
RuntimeException exception = runtime.getResult().getException();
if (Objects.isNull(exception) && StringUtils
.isEmpty(runtime.getRuntimeError()) && !runtime.getResult().isRevert()) {
this.setResultCode(contractResult.SUCCESS);
return;
}
if (runtime.getResult().isRevert()) {
this.setResultCode(contractResult.REVERT);
return;
}
if (exception instanceof IllegalOperationException) {
this.setResultCode(contractResult.ILLEGAL_OPERATION);
return;
}
if (exception instanceof OutOfEnergyException) {
this.setResultCode(contractResult.OUT_OF_ENERGY);
return;
}
if (exception instanceof BadJumpDestinationException) {
this.setResultCode(contractResult.BAD_JUMP_DESTINATION);
return;
}
if (exception instanceof OutOfTimeException) {
this.setResultCode(contractResult.OUT_OF_TIME);
return;
}
if (exception instanceof OutOfMemoryException) {
this.setResultCode(contractResult.OUT_OF_MEMORY);
return;
}
if (exception instanceof PrecompiledContractException) {
this.setResultCode(contractResult.PRECOMPILED_CONTRACT);
return;
}
if (exception instanceof StackTooSmallException) {
this.setResultCode(contractResult.STACK_TOO_SMALL);
return;
}
if (exception instanceof StackTooLargeException) {
this.setResultCode(contractResult.STACK_TOO_LARGE);
return;
}
if (exception instanceof JVMStackOverFlowException) {
this.setResultCode(contractResult.JVM_STACK_OVER_FLOW);
return;
}
if (exception instanceof Program.TransferException) {
this.setResultCode(contractResult.TRANSFER_FAILED);
return;
}
this.setResultCode(contractResult.UNKNOWN);
return;
}

public void setResultCode(contractResult code) {
Result ret = Result.newBuilder().setContractRet(code).build();
if (this.transaction.getRetCount() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ public TransactionInfo processTransaction(final TransactionCapsule trxCap, Block

trace.finalization();
if (Objects.nonNull(blockCap) && getDynamicPropertiesStore().supportVM()) {
trxCap.setResultCode(trace.getReceipt().getResult());
trxCap.setResult(trace.getRuntime());
}
transactionStore.put(trxCap.getTransactionId().getBytes(), trxCap);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/tron/program/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class Version {
private static final String version = "3.6.0";
public static final String versionName = "Odyssey-v3.5.0.1-318-gc6864f595";
public static final String versionCode = "9911";
public static final String versionName = "Odyssey-v3.5.1-890-gd39973cbb";
public static final String versionCode = "10803";

public static String getVersion() {
return version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,62 @@ public void test5CanNotDelegateResourceToContract() {
maxFeeLimit, 0L, consumeUserResourcePercent, null, accountForDeployKey,
accountForDeployAddress, blockingStubFull);
PublicMethed.waitProduceNextBlock(blockingStubFull);

//Account4 DelegatedResource of Energy to Contract
//After 3.6 can not delegate resource to contract
Assert.assertFalse(PublicMethed.freezeBalanceForReceiver(
account4DelegatedResourceAddress, freezeAmount, freezeDuration, 1,
ByteString.copyFrom(contractAddress), account4DelegatedResourceKey, blockingStubFull));

//Account4 DelegatedResource Energy to deploy
// Assert.assertTrue(PublicMethed.freezeBalanceForReceiver(
// account4DelegatedResourceAddress, freezeAmount, freezeDuration, 1,
// ByteString.copyFrom(accountForDeployAddress),
// account4DelegatedResourceKey, blockingStubFull));
//
// //get Energy of Account013,Account4,Contract before trigger contract
// final long account013CurrentEnergyUsed = PublicMethed.getAccountResource(
// account013Address, blockingStubFull).getEnergyUsed();
// final long account013CurrentBandwidthUsed = PublicMethed.getAccountResource(
// account013Address, blockingStubFull).getFreeNetUsed();
// final long account4CurrentEnergyUsed = PublicMethed.getAccountResource(
// account4DelegatedResourceAddress, blockingStubFull).getEnergyUsed();
// final long contractCurrentEnergyUsed = PublicMethed.getAccountResource(
// contractAddress, blockingStubFull).getEnergyUsed();
// final long deployCurrentEnergyUsed = PublicMethed.getAccountResource(
// accountForDeployAddress, blockingStubFull).getEnergyUsed();
//
// //Account013 trigger contract
// String txid = PublicMethed.triggerContract(contractAddress,
// "add2(uint256)", "1", false,
// 0, 1000000000L, "0", 0, account013Address, testKeyForAccount013, blockingStubFull);
// logger.info(txid);
// infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
// logger.info(String.valueOf(infoById.get().getResultValue()));
// Assert.assertTrue(infoById.get().getResultValue() == 0);
// //get transaction info of Energy used and Bandwidth used
// final long contractTriggerEnergyUsed = infoById.get().getReceipt().getOriginEnergyUsage();
// final long contractTriggerBandwidthUsed = infoById.get().getReceipt().getNetUsage();
//
// //get Energy of Account013,Account4,Contract after trigger contract
// final long account013CurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource(
// account013Address, blockingStubFull).getEnergyUsed();
// final long account013CurrentBandwidthUsedAfterTrig = PublicMethed.getAccountResource(
// account013Address, blockingStubFull).getFreeNetUsed();
// final long account4CurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource(
// account4DelegatedResourceAddress, blockingStubFull).getEnergyUsed();
// final long contractCurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource(
// contractAddress, blockingStubFull).getEnergyUsed();
// final long deployCurrentEnergyUsedAfterTrig = PublicMethed.getAccountResource(
// accountForDeployAddress, blockingStubFull).getEnergyUsed();
// //compare energy changed
// Assert.assertTrue(account013CurrentEnergyUsed == account013CurrentEnergyUsedAfterTrig);
// Assert.assertTrue(account4CurrentEnergyUsed == account4CurrentEnergyUsedAfterTrig);
// Assert.assertTrue(contractCurrentEnergyUsed == contractCurrentEnergyUsedAfterTrig);
// Assert.assertTrue(deployCurrentEnergyUsed
// == deployCurrentEnergyUsedAfterTrig - contractTriggerEnergyUsed);
// //compare bandwidth of Account013 before and after trigger contract
// Assert.assertTrue(account013CurrentBandwidthUsed
// == account013CurrentBandwidthUsedAfterTrig - contractTriggerBandwidthUsed);

}

Expand Down