diff --git a/nimbus/errors.nim b/nimbus/errors.nim index 42fb2ce89..36d1f718c 100644 --- a/nimbus/errors.nim +++ b/nimbus/errors.nim @@ -23,8 +23,6 @@ type VMError* = object of EVMError ## Class of errors which can be raised during VM execution. - erasesReturnData*: bool - burnsGas*: bool OutOfGas* = object of VMError ## Error signaling that VM execution has run out of gas. @@ -67,8 +65,3 @@ type StaticContextError* = object of VMError ## State changes not allowed in static call context - -proc makeVMError*: ref VMError = - new(result) - result.burnsGas = true - result.erasesReturnData = true diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index 23c55ab08..56d07d581 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -50,27 +50,16 @@ template isError*(c: Computation): bool = func shouldBurnGas*(c: Computation): bool = c.isError and c.error.burnsGas -func shouldEraseReturnData*(c: Computation): bool = - c.isError and c.error.erasesReturnData - func bytesToHex(x: openarray[byte]): string {.inline.} = ## TODO: use seq[byte] for raw data and delete this proc foldl(x, a & b.int.toHex(2).toLowerAscii, "0x") func output*(c: Computation): seq[byte] = - if c.shouldEraseReturnData: - @[] - else: - c.rawOutput + c.rawOutput func `output=`*(c: Computation, value: openarray[byte]) = c.rawOutput = @value -proc outputHex*(c: Computation): string = - if c.shouldEraseReturnData: - return "0x" - c.rawOutput.bytesToHex - proc isSuicided*(c: Computation, address: EthAddress): bool = result = address in c.suicides diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 250871696..acacc0c53 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -598,7 +598,7 @@ template genCreate(callName: untyped, opCode: Op): untyped = op callName, inline = false, val, startPosition, size: ## 0xf0, Create a new account with associated code. checkInStaticContext(c) - + let (memPos, len) = (startPosition.safeInt, size.safeInt) if not c.canTransfer(memPos, len, val, opCode): push: 0 @@ -614,7 +614,7 @@ template genCreate(callName: untyped, opCode: Op): untyped = push: 0 else: push: child.msg.contractAddress - + child.applyMessage(Create) genCreate(create, Create) @@ -777,8 +777,8 @@ template genCall(callName: untyped, opCode: Op): untyped = else: push: 1 - if not child.shouldEraseReturnData: - let actualOutputSize = min(c.memOutLen, child.output.len) + let actualOutputSize = min(c.memOutLen, child.output.len) + if actualOutputSize > 0: c.memory.write( c.memOutPos, child.output.toOpenArray(0, actualOutputSize - 1)) diff --git a/nimbus/vm_types.nim b/nimbus/vm_types.nim index ff7472e38..821b1c4bb 100644 --- a/nimbus/vm_types.nim +++ b/nimbus/vm_types.nim @@ -79,7 +79,6 @@ type Error* = ref object info*: string burnsGas*: bool - erasesReturnData*: bool GasMeter* = object gasRefunded*: GasInt