Change VM log to be more like pyethereum

This commit is contained in:
nicksavers 2014-08-03 22:05:40 +02:00
parent 6f84df1477
commit adc2313308
1 changed files with 20 additions and 17 deletions

View File

@ -65,6 +65,10 @@ public class VM {
int oldMemSize = program.getMemSize(); int oldMemSize = program.getMemSize();
String hint = "";
long gasBefore = program.getGas().longValue();
int stepBefore = program.getPC();
switch (OpCode.code(op)) { switch (OpCode.code(op)) {
case SHA3: case SHA3:
program.spendGas(GasCost.SHA3, OpCode.code(op).name()); program.spendGas(GasCost.SHA3, OpCode.code(op).name());
@ -90,7 +94,6 @@ public class VM {
break; break;
} }
String hint = "";
switch (OpCode.code(op)) { switch (OpCode.code(op)) {
/** /**
* Stop and Arithmetic Operations * Stop and Arithmetic Operations
@ -271,7 +274,7 @@ public class VM {
DataWord word2 = program.stackPop(); DataWord word2 = program.stackPop();
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
hint = word1.longValue() + " = " + word2.longValue(); hint = word1.longValue() + " == " + word2.longValue();
if (word1.xor(word2).isZero()) { if (word1.xor(word2).isZero()) {
word1.and(DataWord.ZERO); word1.and(DataWord.ZERO);
@ -696,9 +699,10 @@ public class VM {
DataWord inSize = program.stackPop(); DataWord inSize = program.stackPop();
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
logger.info("[ {} ] Op: [ {} ] Gas: [ {} ] Deep: [ {} ] Hint: [ {} ]" ,program.getPC(), logger.info("[ {} ] Op: [ {} ] Gas: [ {} ] Deep: [ {} ] Hint: [ {} ]",
OpCode.code(op).name(), program.getGas().longValue(), program.getPC(), OpCode.code(op).name(), program
program.invokeData.getCallDeep(), hint); .getGas().longValue(), program.invokeData
.getCallDeep(), hint);
program.createContract(value, inOffset, inSize); program.createContract(value, inOffset, inSize);
program.step(); program.step();
@ -747,10 +751,9 @@ public class VM {
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
if (!OpCode.code(op).equals(CALL) && !OpCode.code(op).equals(CREATE)) if (!OpCode.code(op).equals(CALL) && !OpCode.code(op).equals(CREATE))
logger.info("[ {} ] Op: [ {} ] Gas: [ {} ] Deep: [ {} ] Hint: [ {} ]" ,program.getPC(), logger.info("[ {} ] Op: [ {} ] Gas: [ {} ] Deep: [ {} ] Hint: [ {} ]",
OpCode.code(op).name(), program.getGas().longValue(), stepBefore, OpCode.code(op).name(), gasBefore, program.invokeData
program.invokeData.getCallDeep(), hint); .getCallDeep(), hint);
// memory gas calc // memory gas calc
int newMemSize = program.getMemSize(); int newMemSize = program.getMemSize();