From 3dd18bd8ec2eba5b4d7bce12ed7223a363dc4900 Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 25 Feb 2019 17:03:43 +0700 Subject: [PATCH 1/2] 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) From d6f7dfde5cb03bb76c609b630f0535d52c61f28c Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 25 Feb 2019 17:10:38 +0700 Subject: [PATCH 2/2] pass additional 4 GST --- GeneralStateTests.md | 16 ++++++++-------- tests/test_generalstate_failing.nim | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/GeneralStateTests.md b/GeneralStateTests.md index ec2cb0f47..1e3e49a5d 100644 --- a/GeneralStateTests.md +++ b/GeneralStateTests.md @@ -349,9 +349,9 @@ OK: 49/58 Fail: 0/58 Skip: 9/58 + callcodecallcodecallcode_111_OOGMAfter_2.json OK + callcodecallcodecallcode_111_OOGMAfter_3.json OK + contractCreationMakeCallThatAskMoreGasThenTransactionProvided.jsonOK - createInitFail_OOGduringInit.json Skip ++ createInitFail_OOGduringInit.json OK ``` -OK: 26/30 Fail: 0/30 Skip: 4/30 +OK: 27/30 Fail: 0/30 Skip: 3/30 ## stCodeCopyTest ```diff + ExtCodeCopyTests.json OK @@ -414,14 +414,14 @@ OK: 11/30 Fail: 0/30 Skip: 19/30 callOutput3Fail.json Skip callOutput3partial.json Skip callOutput3partialFail.json Skip - callWithHighValueAndGasOOG.json Skip ++ callWithHighValueAndGasOOG.json OK callcodeOutput1.json Skip callcodeOutput2.json Skip callcodeOutput3.json Skip callcodeOutput3Fail.json Skip callcodeOutput3partial.json Skip callcodeOutput3partialFail.json Skip - callcodeWithHighValueAndGasOOG.json Skip ++ callcodeWithHighValueAndGasOOG.json OK deleagateCallAfterValueTransfer.json Skip + delegatecallAndOOGatTxLevel.json OK + delegatecallBasic.json OK @@ -435,7 +435,7 @@ OK: 11/30 Fail: 0/30 Skip: 19/30 delegatecodeDynamicCode.json Skip delegatecodeDynamicCode2SelfCall.json Skip ``` -OK: 5/34 Fail: 0/34 Skip: 29/34 +OK: 7/34 Fail: 0/34 Skip: 27/34 ## stEIP150Specific ```diff CallAndCallcodeConsumeMoreGasThenTransactionHas.json Skip @@ -1708,12 +1708,12 @@ OK: 15/16 Fail: 0/16 Skip: 1/16 + deploymentError.json OK failed_tx_xcf416c53.json Skip gasPrice0.json Skip - makeMoney.json Skip ++ makeMoney.json OK sha3_deja.json Skip txCost-sec73.json Skip tx_e1c174e2.json Skip ``` -OK: 3/13 Fail: 0/13 Skip: 10/13 +OK: 4/13 Fail: 0/13 Skip: 9/13 ## stStackTests ```diff shallowStack.json Skip @@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133 OK: 0/130 Fail: 0/130 Skip: 130/130 ---TOTAL--- -OK: 1154/2334 Fail: 0/2334 Skip: 1180/2334 +OK: 1158/2334 Fail: 0/2334 Skip: 1176/2334 diff --git a/tests/test_generalstate_failing.nim b/tests/test_generalstate_failing.nim index e87031da1..83e9d131d 100644 --- a/tests/test_generalstate_failing.nim +++ b/tests/test_generalstate_failing.nim @@ -147,17 +147,13 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "delegatecallBeforeTransition.json", # 2018-12-07: # 2019-02-07: - "makeMoney.json", # 2019-02-15: - "callWithHighValueAndGasOOG.json", - "callcodeWithHighValueAndGasOOG.json", "randomStatetest101.json", "randomStatetest116.json", "randomStatetest237.json", "randomStatetest7.json", # 2019-02-17: "RawCreateFailGasValueTransfer.json", - "createInitFail_OOGduringInit.json", "NewGasPriceForCodes.json", "NewGasPriceForCodesWithMemExpandingCalls.json", "NonZeroValue_CALLCODE_ToNonNonZeroBalance.json",