fix contract creation

This commit is contained in:
andri lim 2019-02-23 20:18:40 +07:00 committed by zah
parent f5e54b8d4f
commit bc675b1daa
2 changed files with 5 additions and 2 deletions

View File

@ -298,6 +298,9 @@ proc registerAccountForDeletion*(c: var BaseComputation, beneficiary: EthAddress
"registered for deletion multiple times")
c.accountsToDelete[c.msg.storageAddress] = beneficiary
proc isSuicided*(c: var BaseComputation, address: EthAddress): bool =
result = address in c.accountsToDelete
proc addLogEntry*(c: var BaseComputation, log: Log) {.inline.} =
c.vmState.addLogEntry(log)

View File

@ -87,7 +87,7 @@ proc applyCreateTransaction*(t: Transaction, vmState: BaseVMState, sender: EthAd
# once verified in GST fixture
let
gasRemaining = c.gasMeter.gasRemaining.u256
gasRefunded = c.gasMeter.gasRefunded.u256
gasRefunded = c.getGasRefund().u256
gasUsed2 = t.gasLimit.u256 - gasRemaining
gasRefund = min(gasRefunded, gasUsed2 div 2)
gasRefundAmount = (gasRefund + gasRemaining) * t.gasPrice.u256
@ -99,7 +99,7 @@ proc applyCreateTransaction*(t: Transaction, vmState: BaseVMState, sender: EthAd
# for purposes of accounting. Py-EVM apparently does consume the gas, but it is
# not matching observed blockchain balances if consumeGas is called.
if db.accountExists(contractAddress):
if not c.isSuicided(contractAddress):
# make changes only if it not selfdestructed
db.addBalance(contractAddress, t.value)
if gasRemaining >= codeCost.u256: