diff --git a/nimbus/vm/interpreter/opcodes_impl.nim b/nimbus/vm/interpreter/opcodes_impl.nim index 8bd461a59..67b43121c 100644 --- a/nimbus/vm/interpreter/opcodes_impl.nim +++ b/nimbus/vm/interpreter/opcodes_impl.nim @@ -827,9 +827,6 @@ op selfDestruct, inline = false: # Register the account to be deleted computation.registerAccountForDeletion(beneficiary) - # FIXME: hook this into actual RefundSelfDestruct - let RefundSelfDestruct = 24_000 - computation.gasMeter.refundGas(RefundSelfDestruct) trace "SELFDESTRUCT", storageAddress = computation.msg.storageAddress.toHex, diff --git a/nimbus/vm_state_transactions.nim b/nimbus/vm_state_transactions.nim index 07f91cc0e..eaeb7ae76 100644 --- a/nimbus/vm_state_transactions.nim +++ b/nimbus/vm_state_transactions.nim @@ -70,8 +70,14 @@ proc execComputation*(computation: var BaseComputation): bool = result = computation.applyMessage(Call) computation.vmState.mutateStateDB: + var suicidedCount = 0 for deletedAccount in computation.accountsForDeletion: db.deleteAccount deletedAccount + inc suicidedCount + + # FIXME: hook this into actual RefundSelfDestruct + const RefundSelfDestruct = 24_000 + computation.gasMeter.refundGas(RefundSelfDestruct * suicidedCount) if result: computation.vmState.addLogs(computation.logEntries)