From ec918602bc3aa99e40dcefe5e160ed718fc9c495 Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 18 Apr 2019 13:23:04 +0700 Subject: [PATCH] fix accountsForDeletion iterator, GST +2 --- GeneralStateTests.md | 8 +++---- nimbus/vm/computation.nim | 15 ++++++++---- tests/test_generalstate_failing.nim | 36 ----------------------------- 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/GeneralStateTests.md b/GeneralStateTests.md index d4f8eade3..66bc5b348 100644 --- a/GeneralStateTests.md +++ b/GeneralStateTests.md @@ -2066,8 +2066,8 @@ OK: 1/284 Fail: 0/284 Skip: 283/284 + createNameRegistratorZeroMemExpansion.json OK + createWithInvalidOpcode.json OK + currentAccountBalance.json OK - doubleSelfdestructTest.json Skip - doubleSelfdestructTest2.json Skip ++ doubleSelfdestructTest.json OK ++ doubleSelfdestructTest2.json OK + extcodecopy.json OK + return0.json OK + return1.json OK @@ -2083,7 +2083,7 @@ OK: 1/284 Fail: 0/284 Skip: 283/284 + suicideSendEtherToMe.json OK + testRandomTest.json OK ``` -OK: 63/67 Fail: 0/67 Skip: 4/67 +OK: 65/67 Fail: 0/67 Skip: 2/67 ## stTransactionTest ```diff + ContractStoreClearsOOG.json OK @@ -2520,4 +2520,4 @@ OK: 5/133 Fail: 0/133 Skip: 128/133 OK: 0/130 Fail: 0/130 Skip: 130/130 ---TOTAL--- -OK: 1510/2334 Fail: 0/2334 Skip: 824/2334 +OK: 1512/2334 Fail: 0/2334 Skip: 822/2334 diff --git a/nimbus/vm/computation.nim b/nimbus/vm/computation.nim index 6be387098..9e21055d5 100644 --- a/nimbus/vm/computation.nim +++ b/nimbus/vm/computation.nim @@ -237,8 +237,6 @@ proc addChildComputation*(computation: BaseComputation, child: BaseComputation) computation.returnData = @[] else: computation.returnData = child.output - for k, v in child.accountsToDelete: - computation.accountsToDelete[k] = v computation.logEntries.add child.logEntries if not child.shouldBurnGas: @@ -258,9 +256,16 @@ proc addLogEntry*(c: BaseComputation, log: Log) {.inline.} = # many methods are basically TODO, but they still return valid values # in order to test some existing code iterator accountsForDeletion*(c: BaseComputation): EthAddress = - if not c.isError: - for account in c.accountsToDelete.keys: - yield account + var stack = @[c] + var deletedAccounts = initSet[EthAddress]() + while stack.len > 0: + let comp = stack.pop() + if comp.isError: continue + for account in comp.accountsToDelete.keys: + if account notin deletedAccounts: + deletedAccounts.incl account + yield account + stack.add comp.children proc getGasRefund*(c: BaseComputation): GasInt = if c.isError: diff --git a/tests/test_generalstate_failing.nim b/tests/test_generalstate_failing.nim index 6cbf9568f..1f9e086fb 100644 --- a/tests/test_generalstate_failing.nim +++ b/tests/test_generalstate_failing.nim @@ -16,42 +16,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "randomStatetest14.json", # SHA3 offset "randomStatetest85.json", # CALL* memoffset - # Tangerine failed GST - "doubleSelfdestructTest.json", - "doubleSelfdestructTest2.json", - - # Spurious Dragon failed GST - #"CallContractToCreateContractOOG.json", - #"failed_tx_xcf416c53.json", - #"TransactionSendingToZero.json" - #"OutOfGasContractCreation.json", - #"OutOfGasPrefundedContractCreation.json", - #"RevertOpcodeInInit.json", - #"RevertOpcodeWithBigOutputInInit.json", - #"createNameRegistratorPerTxsNotEnoughGasAfter.json", - #"createNameRegistratorPerTxsNotEnoughGasAt.json", - #"createNameRegistratorPerTxsNotEnoughGasBefore.json", - #"ZeroValue_CALLCODE_ToEmpty.json", - #"ZeroValue_CALLCODE_ToOneStorageKey.json", - #"NonZeroValue_CALLCODE_ToEmpty.json", - #"NonZeroValue_CALLCODE_ToOneStorageKey.json", - #"suicideCoinbase.json", - #"EmptyTransaction2.json", - #"SuicidesMixingCoinbase.json", - #"UserTransactionZeroCost.json", - #"UserTransactionZeroCostWithData.json", - #"NotEnoughCashContractCreation.json", - #"201503110226PYTHON_DUP6.json", - #"CreateTransactionReverted.json", - #"EmptyTransaction.json", - #"OverflowGasRequire.json", - #"RefundOverflow.json", - #"RefundOverflow2.json", - #"TransactionNonceCheck.json", - #"TransactionNonceCheck2.json", - #"TransactionToItselfNotEnoughFounds.json", - #"UserTransactionGasLimitIsTooLowWhenZeroCost.json", - # Homestead recursives #["ContractCreationSpam.json", "Call1024OOG.json",