Skip to content

Commit 3be3bde

Browse files
committed
add debug mode
1 parent 6b0ebf0 commit 3be3bde

5 files changed

Lines changed: 38 additions & 6 deletions

File tree

‎src/main/java/org/tron/common/runtime/vm/VM.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.tron.common.runtime.vm.program.Program;
1818
import org.tron.common.runtime.vm.program.Program.OutOfResourceException;
1919
import org.tron.common.runtime.vm.program.Stack;
20+
import org.tron.core.config.args.Args;
2021
import org.tron.core.exception.ContractExeException;
2122

2223
public class VM {
@@ -297,7 +298,9 @@ public void step(Program program)
297298
// DEBUG System.out.println(" OP IS " + op.name() + " GASCOST IS " + gasCost + " NUM IS " + op.asInt());
298299
// program.spendDrop(dropCost, op.name());
299300

300-
program.checkCPULimit(op.name());
301+
if (!Args.getInstance().isDebug()) {
302+
program.checkCPULimit(op.name());
303+
}
301304
// logger.info("after opName: {}, {}", op.name(), System.nanoTime() / 1000 - lastTime);
302305

303306
// Execute operation

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.tron.common.utils.Utils;
6868
import org.tron.core.capsule.AccountCapsule;
6969
import org.tron.core.capsule.BlockCapsule;
70+
import org.tron.core.config.args.Args;
7071
import org.tron.core.exception.ContractExeException;
7172
import org.tron.protos.Protocol;
7273

@@ -469,7 +470,10 @@ public void createContract(DataWord value, DataWord memStart, DataWord memSize)
469470
newBalance = deposit.addBalance(newAddress, endowment);
470471
}
471472

472-
checkCPULimit("BEFORE CREATE");
473+
if (!Args.getInstance().isDebug()) {
474+
checkCPULimit("BEFORE CREATE");
475+
}
476+
473477

474478
// [5] COOK THE INVOKE AND EXECUTE
475479
InternalTransaction internalTx = addInternalTx(getDroplimit(), senderAddress, null, endowment,
@@ -495,7 +499,10 @@ this, new DataWord(newAddress), getOwnerAddress(), value,
495499
getResult().merge(result);
496500
}
497501

498-
checkCPULimit("AFTER CREATE");
502+
if (!Args.getInstance().isDebug()) {
503+
checkCPULimit("AFTER CREATE");
504+
}
505+
499506
// 4. CREATE THE CONTRACT OUT OF RETURN
500507
byte[] code = result.getHReturn();
501508

@@ -614,7 +621,9 @@ public void callToAddress(MessageCall msg)
614621
InternalTransaction internalTx = addInternalTx(getDroplimit(), senderAddress, contextAddress,
615622
endowment, data, "call");
616623

617-
//checkCPULimit("BEFORE CALL");
624+
if (!Args.getInstance().isDebug()) {
625+
checkCPULimit("BEFORE CALL");
626+
}
618627

619628
ProgramResult result = null;
620629
if (isNotEmpty(programCode)) {
@@ -664,7 +673,10 @@ this, new DataWord(contextAddress),
664673
deposit.commit();
665674
stackPushOne();
666675
}
667-
//checkCPULimit("AFTER CALL");
676+
677+
if (!Args.getInstance().isDebug()) {
678+
checkCPULimit("BEFORE CALL");
679+
}
668680

669681
// 3. APPLY RESULTS: result.getHReturn() into out_memory allocated
670682
if (result != null) {

‎src/main/java/org/tron/core/config/args/Args.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public class Args {
6565
@Parameter(names = {"-w", "--witness"})
6666
private boolean witness = false;
6767

68+
@Getter
69+
@Setter
70+
@Parameter(names = {"--debug"})
71+
private boolean debug = false;
72+
6873
@Getter
6974
@Parameter(description = "--seed-nodes")
7075
private List<String> seedNodes = new ArrayList<>();

‎src/main/java/org/tron/program/FullNode.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.tron.core.Constant;
99
import org.tron.core.config.DefaultConfig;
1010
import org.tron.core.config.args.Args;
11-
import org.tron.core.db.RevokingDatabase;
1211
import org.tron.core.services.RpcApiService;
1312
import org.tron.core.services.WitnessService;
1413
import org.tron.core.services.http.FullNodeHttpApiService;
@@ -29,6 +28,12 @@ public static void main(String[] args) throws InterruptedException {
2928
return;
3029
}
3130

31+
if (Args.getInstance().isDebug()) {
32+
System.out.println("in debug mode, it won't check cpu time");
33+
} else {
34+
System.out.println("not in debug mode, it will check cpu time");
35+
}
36+
3237
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
3338
beanFactory.setAllowCircularReferences(false);
3439
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory);

‎src/main/resources/config.conf‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ net {
77
storage {
88
# Directory for storing persistent data
99

10+
<<<<<<< HEAD
1011
db.version = 2,
12+
=======
13+
>>>>>>> fb269fdee
1114
db.directory = "database",
1215
index.directory = "index",
1316

@@ -203,7 +206,11 @@ localwitness = [
203206
block = {
204207
needSyncCheck = false # first node : false, other : true
205208
maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms)
209+
<<<<<<< HEAD
206210
}
207211

208212

209213

214+
=======
215+
}
216+
>>>>>>> fb269fdee

0 commit comments

Comments
 (0)