diff --git a/GeneralStateTests.md b/GeneralStateTests.md index 5c4de8e5d..2f9d7daa6 100644 --- a/GeneralStateTests.md +++ b/GeneralStateTests.md @@ -186,14 +186,14 @@ OK: 50/79 Fail: 0/79 Skip: 29/79 createInitFailUndefinedInstruction.json Skip + createInitFail_OOGduringInit.json OK + createInitOOGforCREATE.json OK - createJS_ExampleContract.json Skip ++ createJS_ExampleContract.json OK + createJS_NoCollision.json OK + createNameRegistratorPerTxs.json OK + createNameRegistratorPerTxsNotEnoughGas.json OK + createNameRegistratorPreStore1NotEnoughGas.json OK + createNameRegistratorendowmentTooHigh.json OK ``` -OK: 18/39 Fail: 0/39 Skip: 21/39 +OK: 19/39 Fail: 0/39 Skip: 20/39 ## stCallDelegateCodesCallCodeHomestead ```diff callcallcallcode_001.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: 1309/2334 Fail: 0/2334 Skip: 1025/2334 +OK: 1310/2334 Fail: 0/2334 Skip: 1024/2334 diff --git a/nimbus/p2p/executor.nim b/nimbus/p2p/executor.nim index 54d62729f..45df6b321 100644 --- a/nimbus/p2p/executor.nim +++ b/nimbus/p2p/executor.nim @@ -29,17 +29,23 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta if balance < upfrontGasCost: return tx.gasLimit - var computation = setupComputation(vmState, tx, sender, forkOverride) + let recipient = tx.getRecipient() + let isCollision = vmState.readOnlyStateDb().hasCodeOrNonce(recipient) + + var computation = setupComputation(vmState, tx, sender, recipient, forkOverride) if computation.isNil: return 0 - + vmState.mutateStateDB: db.incNonce(sender) db.subBalance(sender, upfrontGasCost) + if tx.isContractCreation and isCollision: + return tx.gasLimit + var snapshot = vmState.snapshot() defer: snapshot.dispose() - + var contractOK = true result = tx.gasLimit diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index 024fada9c..18bcb5a50 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -35,11 +35,13 @@ template balance(addressDb: ReadOnlyStateDb, address: EthAddress): GasInt = proc binarySearchGas(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress, gasPrice: GasInt, tolerance = 1): GasInt = proc dummyComputation(vmState: var BaseVMState, transaction: Transaction, sender: EthAddress): BaseComputation = + let recipient = transaction.getRecipient() # Note that vmState may be altered setupComputation( vmState, transaction, - sender) + sender, + recipient) proc dummyTransaction(gasLimit, gasPrice: GasInt, destination: EthAddress, value: UInt256): Transaction = Transaction( diff --git a/nimbus/vm_state_transactions.nim b/nimbus/vm_state_transactions.nim index 699ecc7a2..b2a12f1d7 100644 --- a/nimbus/vm_state_transactions.nim +++ b/nimbus/vm_state_transactions.nim @@ -24,14 +24,13 @@ proc validateTransaction*(vmState: BaseVMState, transaction: Transaction, sender transaction.accountNonce == readOnlyDB.getNonce(sender) and readOnlyDB.getBalance(sender) >= gasCost -proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress, forkOverride=none(Fork)) : BaseComputation = +proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient: EthAddress, forkOverride=none(Fork)) : BaseComputation = let fork = if forkOverride.isSome: forkOverride.get else: vmState.blockNumber.toFork - var recipient: EthAddress var gas = tx.gasLimit - tx.intrinsicGas # TODO: refactor message to use byterange @@ -39,12 +38,10 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender: EthAddress var data, code: seq[byte] if tx.isContractCreation: - recipient = generateAddress(sender, tx.accountNonce) gas = gas - gasFees[fork][GasTXCreate] data = @[] code = tx.payload else: - recipient = tx.to data = tx.payload code = vmState.readOnlyStateDB.getCode(tx.to).toSeq diff --git a/tests/test_generalstate_failing.nim b/tests/test_generalstate_failing.nim index 08f49d7fc..dc2ef6bc2 100644 --- a/tests/test_generalstate_failing.nim +++ b/tests/test_generalstate_failing.nim @@ -78,8 +78,7 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool = "callcodecallcallcode_ABCB_RECURSIVE.json", "callcodecallcodecall_ABCB_RECURSIVE.json", "callcodecallcodecallcode_ABCB_RECURSIVE.json", - # Frontier failed test cases - "createJS_ExampleContract.json", + # Frontier failed test cases "callcallcallcode_001_OOGMAfter_1.json", "callcallcallcode_001_OOGMAfter_2.json", "createInitFailUndefinedInstruction.json",