Implemented selfDestruct op

This commit is contained in:
coffeepots 2018-07-24 17:21:29 +01:00
parent 473140f586
commit 52daaf49c0
2 changed files with 24 additions and 6 deletions

View File

@ -602,7 +602,7 @@ OK: 0/18 Fail: 0/18 Skip: 18/18
+ push30.json OK
+ push31.json OK
+ push32.json OK
- push32AndSuicide.json Fail
+ push32AndSuicide.json OK
+ push32FillUpInputWithZerosAtTheEnd.json OK
+ push32Undefined.json OK
+ push32Undefined2.json OK
@ -633,7 +633,7 @@ OK: 0/18 Fail: 0/18 Skip: 18/18
+ swap9.json OK
+ swapjump1.json OK
```
OK: 73/74 Fail: 1/74 Skip: 0/74
OK: 74/74 Fail: 0/74 Skip: 0/74
## vmRandomTest
```diff
201503102037PYTHON.json Skip
@ -722,6 +722,6 @@ OK: 0/36 Fail: 0/36 Skip: 36/36
- arith.json Fail
- boolean.json Fail
- mktx.json Fail
- suicide.json Fail
+ suicide.json OK
```
OK: 0/4 Fail: 4/4 Skip: 0/4
OK: 1/4 Fail: 3/4 Skip: 0/4

View File

@ -777,6 +777,24 @@ op selfDestruct, inline = false:
## 0xff Halt execution and register account for later deletion.
let beneficiary = computation.stack.popAddress()
## TODO
computation.vmState.mutateStateDB:
let
local_balance = db.get_balance(computation.msg.storage_address)
beneficiary_balance = db.get_balance(beneficiary)
computation.registerAccountForDeletion(beneficiary)
# Transfer to beneficiary
db.setBalance(beneficiary, local_balance + beneficiary_balance)
# Zero the balance of the address being deleted.
# This must come after sending to beneficiary in case the
# contract named itself as the beneficiary.
db.set_balance(computation.msg.storage_address, 0.u256)
# Register the account to be deleted
computation.registerAccountForDeletion(beneficiary)
computation.vm_state.logger.debug(
"SELFDESTRUCT: %s (%s) -> %s" &
computation.msg.storage_address.toHex &
local_balance.toString &
beneficiary.toHex)