From 3dd18bd8ec2eba5b4d7bce12ed7223a363dc4900 Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 25 Feb 2019 17:03:43 +0700 Subject: [PATCH] fix block 299804 problem --- nimbus/vm/computation.nim | 2 +- nimbus/vm/interpreter/opcodes_impl.nim | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index fa65b9d6f..0d8accd71 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -182,7 +182,7 @@ proc applyMessage(computation: var BaseComputation, opCode: static[Op]) = debug "applyMessageAux failed", msg = computation.error.info return - if computation.gasMeter.gasRemaining <= 0: + if computation.gasMeter.gasRemaining < 0: snapshot.commit() return diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index b61f1b183..718842a03 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -700,6 +700,9 @@ template genCall(callName: untyped, opCode: Op): untyped = else: (memOutPos, memOutLen) + if gas > high(GasInt).u256: + raise newException(TypeError, "GasInt Overflow (" & callName.astToStr & ")") + let (childGasFee, childGasLimit) = computation.gasCosts[opCode].c_handler( value, GasParams(kind: Call, @@ -742,8 +745,10 @@ template genCall(callName: untyped, opCode: Op): untyped = if sender != ZERO_ADDRESS: childMsg.sender = sender - - if opCode == CallCode: + else: + childMsg.sender = computation.msg.storageAddress + + if opCode == CallCode: childMsg.storageAddress = computation.msg.storageAddress var childComputation = applyChildComputation(computation, childMsg, opCode)