Remove asserts
This commit is contained in:
parent
88df96b7cc
commit
e7bab2a8ee
|
@ -93,7 +93,6 @@ public class VM {
|
|||
// charged in the following section
|
||||
break;
|
||||
case SSTORE:
|
||||
assert(stack.size() == 2);
|
||||
// for gas calculations [YP 9.2]
|
||||
DataWord newValue = stack.get(stack.size()-2);
|
||||
DataWord oldValue = program.storageLoad(stack.peek());
|
||||
|
@ -113,49 +112,40 @@ public class VM {
|
|||
|
||||
// These all operate on memory and therefore potentially expand it:
|
||||
case MSTORE:
|
||||
assert(stack.size() == 2);
|
||||
newMemSize = stack.peek().value().add(BigInteger.valueOf(32));
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case MSTORE8:
|
||||
assert(stack.size() == 2);
|
||||
newMemSize = stack.peek().value().add(BigInteger.ONE);
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case MLOAD:
|
||||
assert(stack.size() == 1);
|
||||
newMemSize = stack.peek().value().add(BigInteger.valueOf(32));
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case RETURN:
|
||||
assert(stack.size() == 2);
|
||||
newMemSize = stack.peek().value().add(stack.get(stack.size()-2).value());
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case SHA3:
|
||||
assert(stack.size() == 2);
|
||||
program.spendGas(GasCost.SHA3, op.name());
|
||||
newMemSize = stack.peek().value().add(stack.get(stack.size()-2).value());
|
||||
break;
|
||||
case CALLDATACOPY:
|
||||
assert(stack.size() == 3);
|
||||
newMemSize = stack.peek().value().add(stack.get(stack.size()-3).value());
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case CODECOPY:
|
||||
assert(stack.size() == 3);
|
||||
newMemSize = stack.peek().value().add(stack.get(stack.size()-3).value());
|
||||
program.spendGas(GasCost.STEP, op.name());
|
||||
break;
|
||||
case CALL:
|
||||
assert(stack.size() == 7);
|
||||
program.spendGas(GasCost.CALL, op.name());
|
||||
BigInteger x = stack.get(stack.size()-6).value().add(stack.get(stack.size()-7).value());
|
||||
BigInteger y = stack.get(stack.size()-4).value().add(stack.get(stack.size()-5).value());
|
||||
newMemSize = x.max(y);
|
||||
break;
|
||||
case CREATE:
|
||||
assert(stack.size() == 3);
|
||||
program.spendGas(GasCost.CREATE, op.name());
|
||||
newMemSize = stack.get(stack.size()-2).value().add(stack.get(stack.size()-3).value());
|
||||
break;
|
||||
|
@ -168,7 +158,6 @@ public class VM {
|
|||
}
|
||||
// memory gas calc
|
||||
long memoryUsage = (newMemSize.longValue() + 31) / 32 * 32;
|
||||
// long memoryUsage = (newMemSize - oldMemSize) / 32;
|
||||
if (memoryUsage > oldMemSize)
|
||||
program.spendGas(GasCost.MEMORY * ((memoryUsage - oldMemSize) / 32), op.name() + " (memory usage)");
|
||||
|
||||
|
@ -182,7 +171,6 @@ public class VM {
|
|||
program.stop();
|
||||
} break;
|
||||
case ADD:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -195,7 +183,6 @@ public class VM {
|
|||
|
||||
} break;
|
||||
case MUL:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -207,7 +194,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SUB:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -219,7 +205,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case DIV:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -231,7 +216,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SDIV:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -243,7 +227,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case MOD:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -255,7 +238,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SMOD:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -267,7 +249,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case EXP:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -279,7 +260,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case NEG:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord word1 = program.stackPop();
|
||||
word1.negate();
|
||||
|
||||
|
@ -290,7 +270,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case LT:{
|
||||
assert(stack.size() == 2);
|
||||
// TODO: can be improved by not using BigInteger
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
@ -308,7 +287,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SLT:{
|
||||
assert(stack.size() == 2);
|
||||
// TODO: can be improved by not using BigInteger
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
@ -326,7 +304,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SGT:{
|
||||
assert(stack.size() == 2);
|
||||
// TODO: can be improved by not using BigInteger
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
@ -344,7 +321,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case GT:{
|
||||
assert(stack.size() == 2);
|
||||
// TODO: can be improved by not using BigInteger
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
@ -362,7 +338,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case EQ:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -379,7 +354,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case NOT: {
|
||||
assert(stack.size() == 1);
|
||||
DataWord word1 = program.stackPop();
|
||||
if (word1.isZero()) {
|
||||
word1.getData()[31] = 1;
|
||||
|
@ -398,7 +372,6 @@ public class VM {
|
|||
* Bitwise Logic Operations
|
||||
*/
|
||||
case AND:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -410,7 +383,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case OR: {
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -422,7 +394,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case XOR: {
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
|
||||
|
@ -434,7 +405,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case BYTE:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word1 = program.stackPop();
|
||||
DataWord word2 = program.stackPop();
|
||||
DataWord result = null;
|
||||
|
@ -458,7 +428,6 @@ public class VM {
|
|||
* SHA3
|
||||
*/
|
||||
case SHA3:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord memOffsetData = program.stackPop();
|
||||
DataWord lengthData = program.stackPop();
|
||||
ByteBuffer buffer = program.memoryChunk(memOffsetData, lengthData);
|
||||
|
@ -486,7 +455,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case BALANCE:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord address = program.stackPop();
|
||||
DataWord balance = program.getBalance(address);
|
||||
|
||||
|
@ -526,7 +494,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case CALLDATALOAD:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord dataOffs = program.stackPop();
|
||||
DataWord value = program.getDataValue(dataOffs);
|
||||
|
||||
|
@ -546,7 +513,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case CALLDATACOPY:{
|
||||
assert(stack.size() == 3);
|
||||
DataWord memOffsetData = program.stackPop();
|
||||
DataWord dataOffsetData = program.stackPop();
|
||||
DataWord lengthData = program.stackPop();
|
||||
|
@ -569,7 +535,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case CODECOPY:{
|
||||
assert(stack.size() == 3);
|
||||
DataWord memOffsetData = program.stackPop();
|
||||
DataWord codeOffsetData = program.stackPop();
|
||||
DataWord lengthData = program.stackPop();
|
||||
|
@ -659,12 +624,10 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case POP:{
|
||||
assert(stack.size() == 1);
|
||||
program.stackPop();
|
||||
program.step();
|
||||
} break;
|
||||
case DUP:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord word_1 = program.stackPop();
|
||||
DataWord word_2 = word_1.clone();
|
||||
program.stackPush(word_1);
|
||||
|
@ -672,7 +635,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SWAP:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord word_1 = program.stackPop();
|
||||
DataWord word_2 = program.stackPop();
|
||||
program.stackPush(word_1);
|
||||
|
@ -680,7 +642,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case MLOAD:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord addr = program.stackPop();
|
||||
DataWord data = program.memoryLoad(addr);
|
||||
|
||||
|
@ -691,7 +652,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case MSTORE:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord addr = program.stackPop();
|
||||
DataWord value = program.stackPop();
|
||||
|
||||
|
@ -702,7 +662,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case MSTORE8:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord addr = program.stackPop();
|
||||
DataWord value = program.stackPop();
|
||||
byte[] byteVal = {value.getData()[31]};
|
||||
|
@ -710,7 +669,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SLOAD:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord key = program.stackPop();
|
||||
DataWord val = program.storageLoad(key);
|
||||
|
||||
|
@ -724,7 +682,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case SSTORE:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord addr = program.stackPop();
|
||||
DataWord value = program.stackPop();
|
||||
|
||||
|
@ -735,7 +692,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case JUMP:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord pos = program.stackPop();
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
|
@ -744,7 +700,6 @@ public class VM {
|
|||
program.setPC(pos);
|
||||
} break;
|
||||
case JUMPI:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord pos = program.stackPop();
|
||||
DataWord cond = program.stackPop();
|
||||
|
||||
|
@ -801,7 +756,6 @@ public class VM {
|
|||
program.stackPush(data);
|
||||
} break;
|
||||
case CREATE:{
|
||||
assert(stack.size() == 3);
|
||||
DataWord value = program.stackPop();
|
||||
DataWord inOffset = program.stackPop();
|
||||
DataWord inSize = program.stackPop();
|
||||
|
@ -816,7 +770,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case CALL:{
|
||||
assert(stack.size() == 7);
|
||||
DataWord gas = program.stackPop();
|
||||
DataWord toAddress = program.stackPop();
|
||||
DataWord value = program.stackPop();
|
||||
|
@ -837,7 +790,6 @@ public class VM {
|
|||
program.step();
|
||||
} break;
|
||||
case RETURN:{
|
||||
assert(stack.size() == 2);
|
||||
DataWord offset = program.stackPop();
|
||||
DataWord size = program.stackPop();
|
||||
|
||||
|
@ -851,7 +803,6 @@ public class VM {
|
|||
program.stop();
|
||||
} break;
|
||||
case SUICIDE:{
|
||||
assert(stack.size() == 1);
|
||||
DataWord address = program.stackPop();
|
||||
program.suicide(address);
|
||||
|
||||
|
|
Loading…
Reference in New Issue