Skip to content

Commit ffc640e

Browse files
author
Yin Shucheng
committed
fix: constant call should be staticcall
1 parent 1179429 commit ffc640e

5 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/main/java/org/tron/common/runtime/Runtime.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ public Runtime(TransactionTrace trace, BlockCapsule block, Deposit deposit,
132132
/**
133133
* For constant trx with latest blockCap.
134134
*/
135+
private boolean isStaticCall = false;
136+
public Runtime(Transaction tx, BlockCapsule block, DepositImpl deposit,
137+
ProgramInvokeFactory programInvokeFactory, boolean isStaticCall) {
138+
this(tx, block, deposit, programInvokeFactory);
139+
140+
}
141+
135142
public Runtime(Transaction tx, BlockCapsule block, DepositImpl deposit,
136143
ProgramInvokeFactory programInvokeFactory) {
137144
this.trx = tx;
@@ -371,6 +378,9 @@ private void create()
371378
ProgramInvoke programInvoke = programInvokeFactory
372379
.createProgramInvoke(TRX_CONTRACT_CREATION_TYPE, executorType, trx,
373380
blockCap.getInstance(), deposit, vmStartInUs, vmShouldEndInUs, energyLimit);
381+
if (isStaticCall) {
382+
programInvoke.setStaticCall();
383+
}
374384
this.vm = new VM(config);
375385
this.program = new Program(ops, programInvoke, internalTransaction, config, this.blockCap);
376386
this.program.setRootTransactionId(new TransactionCapsule(trx).getTransactionId().getBytes());

‎src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ public interface ProgramInvoke {
7070
long getVmStartInUs();
7171

7272
long getEnergyLimit();
73+
74+
void setStaticCall();
7375
}

‎src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,9 @@ public long getEnergyLimit() {
369369
return energyLimit;
370370
}
371371

372+
@Override
373+
public void setStaticCall() {
374+
isStaticCall = true;
375+
}
376+
372377
}

‎src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ public long getEnergyLimit() {
223223
return 0;
224224
}
225225

226+
@Override
227+
public void setStaticCall() {
228+
229+
}
230+
226231
@Override
227232
public boolean byTestingSuite() {
228233
return false;

‎src/main/java/org/tron/core/Wallet.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ public Transaction triggerContract(TriggerSmartContract triggerSmartContract,
889889
}
890890

891891
Runtime runtime = new Runtime(trxCap.getInstance(), new BlockCapsule(headBlock), deposit,
892-
new ProgramInvokeFactoryImpl());
892+
new ProgramInvokeFactoryImpl(), true);
893893
runtime.execute();
894894
runtime.go();
895895
runtime.finalization();

0 commit comments

Comments
 (0)