diff --git a/GeneralStateTests.md b/GeneralStateTests.md index 20c3637e0..9aa72f0e2 100644 --- a/GeneralStateTests.md +++ b/GeneralStateTests.md @@ -1822,8 +1822,8 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_CalltoReturn2.json OK + static_CheckCallCostOOG.json OK + static_CheckOpcodes.json OK - static_CheckOpcodes2.json Skip - static_CheckOpcodes3.json Skip ++ static_CheckOpcodes2.json OK ++ static_CheckOpcodes3.json OK + static_CheckOpcodes4.json OK + static_CheckOpcodes5.json OK + static_ExecuteCallThatAskForeGasThenTrabsactionHas.json OK @@ -1845,9 +1845,9 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 static_RevertOpcodeCalls.json Skip + static_ZeroValue_CALL_OOGRevert.json OK + static_ZeroValue_SUICIDE_OOGRevert.json OK - static_callBasic.json Skip ++ static_callBasic.json OK + static_callChangeRevert.json OK - static_callCreate.json Skip ++ static_callCreate.json OK + static_callCreate2.json OK + static_callCreate3.json OK + static_callOutput1.json OK @@ -1856,9 +1856,9 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_callOutput3Fail.json OK + static_callOutput3partial.json OK + static_callOutput3partialFail.json OK - static_callToCallCodeOpCodeCheck.json Skip - static_callToCallOpCodeCheck.json Skip - static_callToDelCallOpCodeCheck.json Skip ++ static_callToCallCodeOpCodeCheck.json OK ++ static_callToCallOpCodeCheck.json OK ++ static_callToDelCallOpCodeCheck.json OK + static_callToStaticOpCodeCheck.json OK + static_callWithHighValue.json OK + static_callWithHighValueAndGasOOG.json OK @@ -1881,10 +1881,10 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_callcallcall_000_SuicideEnd.json OK + static_callcallcall_000_SuicideMiddle.json OK + static_callcallcall_ABCB_RECURSIVE.json OK - static_callcallcallcode_001.json Skip - static_callcallcallcode_001_2.json Skip - static_callcallcallcode_001_OOGE.json Skip - static_callcallcallcode_001_OOGE_2.json Skip ++ static_callcallcallcode_001.json OK ++ static_callcallcallcode_001_2.json OK ++ static_callcallcallcode_001_OOGE.json OK ++ static_callcallcallcode_001_OOGE_2.json OK + static_callcallcallcode_001_OOGMAfter.json OK + static_callcallcallcode_001_OOGMAfter2.json OK + static_callcallcallcode_001_OOGMAfter_2.json OK @@ -1895,44 +1895,44 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_callcallcallcode_001_SuicideEnd2.json OK + static_callcallcallcode_001_SuicideMiddle.json OK + static_callcallcallcode_001_SuicideMiddle2.json OK - static_callcallcallcode_ABCB_RECURSIVE.json Skip - static_callcallcallcode_ABCB_RECURSIVE2.json Skip - static_callcallcode_01_2.json Skip - static_callcallcode_01_OOGE_2.json Skip ++ static_callcallcallcode_ABCB_RECURSIVE.json OK ++ static_callcallcallcode_ABCB_RECURSIVE2.json OK ++ static_callcallcode_01_2.json OK ++ static_callcallcode_01_OOGE_2.json OK + static_callcallcode_01_SuicideEnd.json OK + static_callcallcode_01_SuicideEnd2.json OK - static_callcallcodecall_010.json Skip - static_callcallcodecall_010_2.json Skip - static_callcallcodecall_010_OOGE.json Skip - static_callcallcodecall_010_OOGE_2.json Skip ++ static_callcallcodecall_010.json OK ++ static_callcallcodecall_010_2.json OK ++ static_callcallcodecall_010_OOGE.json OK ++ static_callcallcodecall_010_OOGE_2.json OK + static_callcallcodecall_010_OOGMAfter.json OK + static_callcallcodecall_010_OOGMAfter2.json OK + static_callcallcodecall_010_OOGMAfter_2.json OK + static_callcallcodecall_010_OOGMAfter_3.json OK - static_callcallcodecall_010_OOGMBefore.json Skip - static_callcallcodecall_010_OOGMBefore2.json Skip - static_callcallcodecall_010_SuicideEnd.json Skip - static_callcallcodecall_010_SuicideEnd2.json Skip - static_callcallcodecall_010_SuicideMiddle.json Skip - static_callcallcodecall_010_SuicideMiddle2.json Skip - static_callcallcodecall_ABCB_RECURSIVE.json Skip - static_callcallcodecall_ABCB_RECURSIVE2.json Skip - static_callcallcodecallcode_011.json Skip - static_callcallcodecallcode_011_2.json Skip - static_callcallcodecallcode_011_OOGE.json Skip - static_callcallcodecallcode_011_OOGE_2.json Skip ++ static_callcallcodecall_010_OOGMBefore.json OK ++ static_callcallcodecall_010_OOGMBefore2.json OK ++ static_callcallcodecall_010_SuicideEnd.json OK ++ static_callcallcodecall_010_SuicideEnd2.json OK ++ static_callcallcodecall_010_SuicideMiddle.json OK ++ static_callcallcodecall_010_SuicideMiddle2.json OK ++ static_callcallcodecall_ABCB_RECURSIVE.json OK ++ static_callcallcodecall_ABCB_RECURSIVE2.json OK ++ static_callcallcodecallcode_011.json OK ++ static_callcallcodecallcode_011_2.json OK ++ static_callcallcodecallcode_011_OOGE.json OK ++ static_callcallcodecallcode_011_OOGE_2.json OK + static_callcallcodecallcode_011_OOGMAfter.json OK + static_callcallcodecallcode_011_OOGMAfter2.json OK + static_callcallcodecallcode_011_OOGMAfter_1.json OK + static_callcallcodecallcode_011_OOGMAfter_2.json OK - static_callcallcodecallcode_011_OOGMBefore.json Skip - static_callcallcodecallcode_011_OOGMBefore2.json Skip - static_callcallcodecallcode_011_SuicideEnd.json Skip - static_callcallcodecallcode_011_SuicideEnd2.json Skip - static_callcallcodecallcode_011_SuicideMiddle.json Skip - static_callcallcodecallcode_011_SuicideMiddle2.json Skip - static_callcallcodecallcode_ABCB_RECURSIVE.json Skip - static_callcallcodecallcode_ABCB_RECURSIVE2.json Skip ++ static_callcallcodecallcode_011_OOGMBefore.json OK ++ static_callcallcodecallcode_011_OOGMBefore2.json OK ++ static_callcallcodecallcode_011_SuicideEnd.json OK ++ static_callcallcodecallcode_011_SuicideEnd2.json OK ++ static_callcallcodecallcode_011_SuicideMiddle.json OK ++ static_callcallcodecallcode_011_SuicideMiddle2.json OK ++ static_callcallcodecallcode_ABCB_RECURSIVE.json OK ++ static_callcallcodecallcode_ABCB_RECURSIVE2.json OK + static_callcode_checkPC.json OK + static_callcodecall_10.json OK + static_callcodecall_10_2.json OK @@ -1956,22 +1956,22 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_callcodecallcall_100_SuicideMiddle2.json OK + static_callcodecallcall_ABCB_RECURSIVE.json OK + static_callcodecallcall_ABCB_RECURSIVE2.json OK - static_callcodecallcallcode_101.json Skip - static_callcodecallcallcode_101_2.json Skip - static_callcodecallcallcode_101_OOGE.json Skip - static_callcodecallcallcode_101_OOGE_2.json Skip ++ static_callcodecallcallcode_101.json OK ++ static_callcodecallcallcode_101_2.json OK ++ static_callcodecallcallcode_101_OOGE.json OK ++ static_callcodecallcallcode_101_OOGE_2.json OK + static_callcodecallcallcode_101_OOGMAfter.json OK + static_callcodecallcallcode_101_OOGMAfter2.json OK - static_callcodecallcallcode_101_OOGMAfter_1.json Skip - static_callcodecallcallcode_101_OOGMAfter_3.json Skip ++ static_callcodecallcallcode_101_OOGMAfter_1.json OK ++ static_callcodecallcallcode_101_OOGMAfter_3.json OK + static_callcodecallcallcode_101_OOGMBefore.json OK + static_callcodecallcallcode_101_OOGMBefore2.json OK + static_callcodecallcallcode_101_SuicideEnd.json OK + static_callcodecallcallcode_101_SuicideEnd2.json OK + static_callcodecallcallcode_101_SuicideMiddle.json OK + static_callcodecallcallcode_101_SuicideMiddle2.json OK - static_callcodecallcallcode_ABCB_RECURSIVE.json Skip - static_callcodecallcallcode_ABCB_RECURSIVE2.json Skip ++ static_callcodecallcallcode_ABCB_RECURSIVE.json OK ++ static_callcodecallcallcode_ABCB_RECURSIVE2.json OK + static_callcodecallcodecall_110.json OK + static_callcodecallcodecall_1102.json OK + static_callcodecallcodecall_110_2.json OK @@ -1987,12 +1987,12 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_callcodecallcodecall_110_SuicideEnd2.json OK + static_callcodecallcodecall_110_SuicideMiddle.json OK + static_callcodecallcodecall_110_SuicideMiddle2.json OK - static_callcodecallcodecall_ABCB_RECURSIVE.json Skip - static_callcodecallcodecall_ABCB_RECURSIVE2.json Skip ++ static_callcodecallcodecall_ABCB_RECURSIVE.json OK ++ static_callcodecallcodecall_ABCB_RECURSIVE2.json OK + static_callcodecallcodecallcode_111_SuicideEnd.json OK - static_calldelcode_01.json Skip - static_calldelcode_01_OOGE.json Skip - static_contractCreationMakeCallThatAskMoreGasThenTransactionProvided.jsonSkip ++ static_calldelcode_01.json OK ++ static_calldelcode_01_OOGE.json OK ++ static_contractCreationMakeCallThatAskMoreGasThenTransactionProvided.jsonOK + static_contractCreationOOGdontLeaveEmptyContractViaTransaction.jsonOK + static_log0_emptyMem.json OK + static_log0_logMemStartTooHigh.json OK @@ -2012,7 +2012,7 @@ OK: 7/7 Fail: 0/7 Skip: 0/7 + static_refund_CallToSuicideNoStorage.json OK + static_refund_CallToSuicideTwice.json OK ``` -OK: 217/284 Fail: 0/284 Skip: 67/284 +OK: 269/284 Fail: 0/284 Skip: 15/284 ## stSystemOperationsTest ```diff + ABAcalls0.json OK @@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133 OK: 0/130 Fail: 0/130 Skip: 130/130 ---TOTAL--- -OK: 1833/2334 Fail: 0/2334 Skip: 501/2334 +OK: 1885/2334 Fail: 0/2334 Skip: 449/2334 diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index a10ccaf81..8a8f324c7 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -590,8 +590,6 @@ proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256) op create, inline = false, value, startPosition, size: ## 0xf0, Create a new account with associated code. - checkInStaticContext(computation) - let (memPos, len) = (startPosition.cleanMemRef, size.cleanMemRef) if not computation.canTransfer(memPos, len, value): push: 0 @@ -609,6 +607,7 @@ op create, inline = false, value, startPosition, size: else: push: childComp.msg.storageAddress + checkInStaticContext(computation) childComp.applyMessage(Create) proc callParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) = @@ -767,8 +766,6 @@ template genCall(callName: untyped, opCode: Op): untyped = ## CALLCODE, 0xf2, Message-call into this account with an alternative account's code. ## DELEGATECALL, 0xf4, Message-call into this account with an alternative account's code, but persisting the current values for sender and value. ## STATICCALL, 0xfa, Static message-call into an account. - when opCode != StaticCall: - checkInStaticContext(computation) var childComp = `callName Setup`(computation, callName.astToStr) computation.child = childComp @@ -786,6 +783,10 @@ template genCall(callName: untyped, opCode: Op): untyped = computation.memOutPos, childComp.output.toOpenArray(0, actualOutputSize - 1)) + when opCode == Call: + if emvcStatic == computation.msg.flags and childComp.msg.value > 0.u256: + raise newException(StaticContextError, "Cannot modify state while inside of a STATICCALL context") + childComp.applyMessage(opCode) genCall(call, Call) diff --git a/tests/test_generalstate_failing.nim b/tests/test_generalstate_failing.nim index 6a10ebfd7..01f8f6c87 100644 --- a/tests/test_generalstate_failing.nim +++ b/tests/test_generalstate_failing.nim @@ -22,7 +22,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "returndatasize_after_failing_delegatecall.json", "ecmul_1-3_2_28000_96.json", "RevertInStaticCall.json", - "static_callcallcodecall_010_OOGMBefore.json", "modexp_3_09984_39936_25000.json", "ecadd_0-0_1-3_25000_128.json", "modexpRandomInput.json", @@ -33,7 +32,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "modexp_9_37111_37111_1000000.json", "ecmul_1-3_1_21000_96.json", "ecmul_1-3_340282366920938463463374607431768211456_28000_80.json", - "static_callcallcodecallcode_011_SuicideMiddle.json", "ecmul_1-2_9935_21000_128.json", "ecmul_0-0_0_21000_0.json", "ecmul_1-3_0_28000_96.json", @@ -48,7 +46,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_0-3_2_21000_96.json", "ecmul_0-3_5617_21000_128.json", "ecmul_0-0_5617_28000_128.json", - "static_CheckOpcodes2.json", "returndatasize_after_failing_callcode.json", "modexp_3_5_100_25000.json", "ecmul_1-2_2_28000_128.json", @@ -76,10 +73,8 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecadd_1145-3932_1145-4651_21000_192.json", "ecpairing_two_point_match_4.json", "modexp_39936_1_55201_20500.json", - "static_callcallcodecallcode_011_SuicideMiddle2.json", "ecmul_0-3_9935_21000_128.json", "ecpairing_one_point_with_g2_zero_and_g1_invalid.json", - "static_callcallcodecall_010_OOGE_2.json", "modexp_55190_55190_42965_22000.json", "ecmul_7827-6598_0_28000_96.json", "RevertInCreateInInit.json", @@ -93,7 +88,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_7827-6598_2_21000_128.json", "returndatacopy_following_call.json", "ecadd_0-0_1-2_21000_192.json", - "static_callcallcodecallcode_011_OOGE.json", "ecadd_1145-3932_2969-1336_21000_128.json", "returndatacopy_after_revert_in_staticcall.json", "ecmul_7827-6598_9935_21000_96.json", @@ -119,11 +113,9 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_7827-6598_5616_28000_128.json", "ecadd_0-0_1-2_25000_128.json", "modexp_3_09984_39936_22000.json", - "static_callcallcodecallcode_011_SuicideEnd2.json", "ecmul_1-2_9_28000_96.json", "modexp_55190_55190_42965_155000.json", "RevertOpcodeDirectCall.json", - "static_callcodecallcallcode_101_OOGMAfter_1.json", "ecmul_1-2_0_28000_64.json", "modexp_39936_1_55201_1000000.json", "ecmul_1-2_2_28000_96.json", @@ -133,7 +125,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-2_616_28000_96.json", "modexp_3_5_100_22000.json", "returndatacopy_following_revert_in_create.json", - "static_CheckOpcodes3.json", "ecmul_7827-6598_5617_28000_128.json", "ecmul_1-2_0_28000_128.json", "ecmul_1-3_5617_21000_128.json", @@ -151,7 +142,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_7827-6598_5617_21000_96.json", "ecmul_7827-6598_5617_28000_96.json", "ecpairing_three_point_match_1.json", - "static_callcallcodecall_010_SuicideEnd2.json", "ecmul_1-3_2_21000_96.json", "ecmul_0-3_9_21000_128.json", "RevertOpcodeReturn.json", @@ -165,7 +155,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_0-3_5617_21000_96.json", "ecmul_7827-6598_1456_28000_128.json", "ecmul_0-0_1_21000_128.json", - "static_callcallcodecall_010_OOGE.json", "ecmul_7827-6598_0_28000_128.json", "Opcodes_TransactionInit.json", "ecmul_7827-6598_0_21000_80.json", @@ -178,7 +167,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_0-3_0_28000_64.json", "ecadd_0-3_1-2_25000_128.json", "ecmul_0-0_9935_28000_128.json", - "static_callcallcodecall_010_SuicideMiddle2.json", "modexp_3_09984_39936_1000000.json", "ecmul_0-0_1_21000_96.json", "modexp_49_2401_2401_1000000.json", @@ -189,7 +177,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ZeroValue_TransactionCALLwithData_ToOneStorageKey_OOGRevert.json", "ecmul_1-3_340282366920938463463374607431768211456_21000_80.json", "ecmul_0-0_0_28000_96.json", - "static_callcallcodecall_010_SuicideEnd.json", "ecmul_1-2_340282366920938463463374607431768211456_21000_96.json", "ecmul_0-0_9_21000_128.json", "ecmul_0-0_5617_28000_96.json", @@ -245,7 +232,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_0-3_5616_28000_96.json", "ecmul_1-2_2_21000_96.json", "ecmul_7827-6598_9_28000_96.json", - "static_callcallcodecallcode_011_OOGMBefore.json", "ecmul_0-0_5616_21000_96.json", "ecmul_1-3_5617_21000_96.json", "returndatasize_initial_zero_read.json", @@ -256,8 +242,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "modexp_39936_1_55201_35000.json", "ecpairing_perturb_g2_by_curve_order.json", "RevertOpcodeCreate.json", - "static_callBasic.json", - "static_callcallcodecallcode_011_OOGMBefore2.json", "ecadd_1-2_1-2_25000_192.json", "ecmul_0-0_9_28000_96.json", "ecmul_7827-6598_2_28000_96.json", @@ -268,8 +252,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-3_0_28000_64.json", "randomStatetest642.json", "ecpairing_three_point_fail_1.json", - "static_callcallcodecall_010_SuicideMiddle.json", - "static_callcallcallcode_001_2.json", "ecmul_1-3_5617_28000_128.json", "ecadd_1-2_1-2_21000_128.json", "ecmul_7827-6598_9935_21000_128.json", @@ -285,9 +267,7 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "RevertOpcodeMultipleSubCalls.json", "modexp_39936_1_55201_155000.json", "ecmul_0-0_340282366920938463463374607431768211456_21000_80.json", - "static_callcodecallcallcode_101_OOGMAfter_3.json", "ecmul_1-2_9935_28000_96.json", - "static_callcallcallcode_001.json", "ecmul_0-0_0_28000_0.json", "ecadd_1-3_0-0_21000_80.json", "ecadd_0-0_0-0_21000_0.json", @@ -329,7 +309,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-3_2_21000_128.json", "ecmul_7827-6598_1_21000_96.json", "ecpairing_empty_data_insufficient_gas.json", - "static_callcallcodecallcode_011_SuicideEnd.json", "CreateOOGafterInitCodeRevert.json", "ecmul_0-0_1_28000_96.json", "RevertOpcode.json", @@ -344,7 +323,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-2_1_21000_96.json", "ecmul_1-3_0_21000_128.json", "ecpairing_bad_length_191.json", - "static_callcallcodecall_010_OOGMBefore2.json", "ecmul_7827-6598_5617_21000_128.json", "ecpairing_one_point_not_in_subgroup.json", "ecpairing_two_points_with_one_g2_zero.json", @@ -368,7 +346,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-2_9_21000_128.json", "ecmul_1-3_9_28000_96.json", "ecpairing_perturb_zeropoint_by_field_modulus.json", - "static_contractCreationMakeCallThatAskMoreGasThenTransactionProvided.json", "ecmul_0-3_9935_28000_128.json", "ecmul_0-3_9_21000_96.json", "modexp_37120_37111_37111_1000000.json", @@ -384,37 +361,8 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "ecmul_1-3_2_28000_128.json", "ecpairing_two_point_match_1.json", "delegatecallNonConst.json", - "static_callCreate.json", "ecmul_7827-6598_5616_28000_96.json", "ecmul_0-3_340282366920938463463374607431768211456_21000_80.json", - "static_callToCallCodeOpCodeCheck.json", - "static_callToCallOpCodeCheck.json", - "static_callToDelCallOpCodeCheck.json", - "static_callcallcallcode_001_OOGE.json", - "static_callcallcallcode_001_OOGE_2.json", - "static_callcallcallcode_ABCB_RECURSIVE.json", - "static_callcallcallcode_ABCB_RECURSIVE2.json", - "static_callcallcode_01_2.json", - "static_callcallcode_01_OOGE_2.json", - "static_callcallcodecall_010.json", - "static_callcallcodecall_010_2.json", - "static_callcallcodecall_ABCB_RECURSIVE.json", - "static_callcallcodecall_ABCB_RECURSIVE2.json", - "static_callcallcodecallcode_011.json", - "static_callcallcodecallcode_011_2.json", - "static_callcallcodecallcode_011_OOGE_2.json", - "static_callcallcodecallcode_ABCB_RECURSIVE.json", - "static_callcallcodecallcode_ABCB_RECURSIVE2.json", - "static_callcodecallcallcode_101.json", - "static_callcodecallcallcode_101_2.json", - "static_callcodecallcallcode_101_OOGE.json", - "static_callcodecallcallcode_101_OOGE_2.json", - "static_callcodecallcallcode_ABCB_RECURSIVE.json", - "static_callcodecallcallcode_ABCB_RECURSIVE2.json", - "static_callcodecallcodecall_ABCB_RECURSIVE.json", - "static_callcodecallcodecall_ABCB_RECURSIVE2.json", - "static_calldelcode_01.json", - "static_calldelcode_01_OOGE.json", # byzantium slow "LoopCallsDepthThenRevert3.json",