fix self destruct refund gas problem

This commit is contained in:
andri lim 2019-03-21 15:31:06 +07:00
parent 90924eef47
commit 1ad4e256b2
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 6 additions and 3 deletions

View File

@ -827,9 +827,6 @@ op selfDestruct, inline = false:
# Register the account to be deleted # Register the account to be deleted
computation.registerAccountForDeletion(beneficiary) computation.registerAccountForDeletion(beneficiary)
# FIXME: hook this into actual RefundSelfDestruct
let RefundSelfDestruct = 24_000
computation.gasMeter.refundGas(RefundSelfDestruct)
trace "SELFDESTRUCT", trace "SELFDESTRUCT",
storageAddress = computation.msg.storageAddress.toHex, storageAddress = computation.msg.storageAddress.toHex,

View File

@ -70,8 +70,14 @@ proc execComputation*(computation: var BaseComputation): bool =
result = computation.applyMessage(Call) result = computation.applyMessage(Call)
computation.vmState.mutateStateDB: computation.vmState.mutateStateDB:
var suicidedCount = 0
for deletedAccount in computation.accountsForDeletion: for deletedAccount in computation.accountsForDeletion:
db.deleteAccount deletedAccount db.deleteAccount deletedAccount
inc suicidedCount
# FIXME: hook this into actual RefundSelfDestruct
const RefundSelfDestruct = 24_000
computation.gasMeter.refundGas(RefundSelfDestruct * suicidedCount)
if result: if result:
computation.vmState.addLogs(computation.logEntries) computation.vmState.addLogs(computation.logEntries)