Skip to content

Commit

Permalink
set contractVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
neo hong committed Aug 26, 2021
1 parent a1f430a commit 1646399
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ private void create()
vmShouldEndInUs, energyLimit);
this.vm = new VM();
this.program = new Program(ops, programInvoke, rootInternalTransaction, vmConfig);
if (VMConfig.allowTvmCompatibleEvm()) {
this.program.setContractVersion(1);
}
byte[] txId = TransactionUtil.getTransactionId(trx).getBytes();
this.program.setRootTransactionId(txId);
if (enableEventListener && isCheckTransaction()) {
Expand Down Expand Up @@ -486,7 +489,10 @@ private void call()
this.vm = new VM();
rootInternalTransaction = new InternalTransaction(trx, trxType);
this.program = new Program(code, programInvoke, rootInternalTransaction, vmConfig);
this.program.setContractVersion(repository.getContract(contractAddress).getContractVersion());
if (VMConfig.allowTvmCompatibleEvm()) {
this.program.setContractVersion(
repository.getContract(contractAddress).getContractVersion());
}
byte[] txId = TransactionUtil.getTransactionId(trx).getBytes();
this.program.setRootTransactionId(txId);

Expand Down
8 changes: 7 additions & 1 deletion actuator/src/main/java/org/tron/core/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ this, new DataWord(newAddress), getContractAddress(), value, new DataWord(0),
VM vm = new VM(config);
Program program = new Program(programCode, programInvoke, internalTx, config);
program.setRootTransactionId(this.rootTransactionId);
if (VMConfig.allowTvmCompatibleEvm()) {
program.setContractVersion(this.contractVersion);
}
vm.play(program);
createResult = program.getResult();
getTrace().merge(program.getTrace());
Expand Down Expand Up @@ -1019,7 +1022,10 @@ this, new DataWord(contextAddress),
VM vm = new VM(config);
Program program = new Program(programCode, programInvoke, internalTx, config);
program.setRootTransactionId(this.rootTransactionId);
program.setContractVersion(invoke.getDeposit().getContract(codeAddress).getContractVersion());
if (VMConfig.allowTvmCompatibleEvm()) {
program.setContractVersion(
invoke.getDeposit().getContract(codeAddress).getContractVersion());
}
vm.play(program);
callResult = program.getResult();

Expand Down

0 comments on commit 1646399

Please sign in to comment.