processTransaction simplification

This commit is contained in:
andri lim 2019-03-19 22:18:43 +07:00
parent b73a1238e0
commit 9cc5db73c2
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 5 additions and 14 deletions

View File

@ -43,23 +43,9 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
if tx.isContractCreation and isCollision:
return tx.gasLimit
var snapshot = vmState.snapshot()
defer: snapshot.dispose()
var contractOK = true
result = tx.gasLimit
if execComputation(computation):
if tx.isContractCreation:
contractOK = computation.writeContract(fork)
result = computation.refundGas(tx, sender)
if not contractOK and fork == FkHomestead:
snapshot.revert()
# consume all gas
result = tx.gasLimit
else:
snapshot.commit()
if computation.isSuicided(vmState.blockHeader.coinbase):
return 0

View File

@ -81,6 +81,11 @@ proc execComputation*(computation: var BaseComputation): bool =
result = false
debug "execComputation() error", msg = getCurrentExceptionMsg()
if result and computation.msg.isCreate:
let fork = computation.getFork
let contractFailed = not computation.writeContract(fork)
result = not(contractFailed and fork == FkHomestead)
if result:
snapshot.commit()
computation.vmState.addLogs(computation.logEntries)