Skip to content

Commit 371e165

Browse files
committed
redo runtime when time out.
1 parent 5997fea commit 371e165

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎src/main/java/org/tron/core/db/Manager.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,18 @@ public boolean processTransaction(final TransactionCapsule trxCap, BlockCapsule
967967

968968
trace.init();
969969
trace.exec(runtime);
970-
970+
if (Objects.nonNull(blockCap) && !blockCap.getInstance().getBlockHeader().getWitnessSignature()
971+
.isEmpty()) {
972+
if (trace.checkNeedRetry()) {
973+
deposit = DepositImpl.createRoot(this);
974+
runtime = new Runtime(trace, blockCap, deposit, new ProgramInvokeFactoryImpl());
975+
if (runtime.isCallConstant()) {
976+
throw new VMIllegalException("cannot call constant method ");
977+
}
978+
trace.init();
979+
trace.exec(runtime);
980+
}
981+
}
971982
if (Objects.nonNull(blockCap)) {
972983
trace.setResult(runtime);
973984
if (!blockCap.getInstance().getBlockHeader().getWitnessSignature().isEmpty()) {

‎src/main/java/org/tron/core/db/TransactionTrace.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ public void pay() throws BalanceInsufficientException {
185185
dbManager.getWitnessController().getHeadSlot());
186186
}
187187

188+
public boolean checkNeedRetry() {
189+
if (!needVM()) {
190+
return false;
191+
}
192+
if (Objects.isNull(trx.getContractRet())) {
193+
return true;
194+
}
195+
if (!trx.getContractRet().equals(receipt.getResult())) {
196+
logger.info("this tx resultCode in received block: {}", trx.getContractRet());
197+
logger.info("this tx resultCode in self: {}", receipt.getResult());
198+
return true;
199+
}
200+
return false;
201+
}
202+
188203
public void check() throws ReceiptCheckErrException {
189204
if (!needVM()) {
190205
return;

0 commit comments

Comments
 (0)