Added suicide back in

This commit is contained in:
obscuren 2014-05-01 22:14:34 +02:00
parent 91aa189ef3
commit 17674fb888

View File

@ -73,10 +73,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
} }
}() }()
// If the amount of gas supplied is less equal to 0 ethutil.Config.Log.Debugf("[VM] Running closure %x\n", closure.object.Address())
if closure.Gas.Cmp(big.NewInt(0)) <= 0 {
// TODO Do something
}
// Memory for the current closure // Memory for the current closure
mem := &Memory{} mem := &Memory{}
@ -107,9 +104,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
val := closure.Get(pc) val := closure.Get(pc)
// Get the opcode (it must be an opcode!) // Get the opcode (it must be an opcode!)
op := OpCode(val.Uint()) op := OpCode(val.Uint())
if ethutil.Config.Debug { /*
ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String()) if ethutil.Config.Debug {
} ethutil.Config.Log.Debugf("%-3d %-4s", pc, op.String())
}
*/
gas := new(big.Int) gas := new(big.Int)
useGas := func(amount *big.Int) { useGas := func(amount *big.Int) {
@ -163,9 +162,6 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
case oLOG: case oLOG:
stack.Print() stack.Print()
mem.Print() mem.Print()
case oSTOP: // Stop the closure
return closure.Return(nil), nil
// 0x20 range // 0x20 range
case oADD: case oADD:
require(2) require(2)
@ -520,22 +516,18 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
return closure.Return(ret), nil return closure.Return(ret), nil
case oSUICIDE: case oSUICIDE:
/* require(1)
recAddr := stack.Pop().Bytes()
// Purge all memory
deletedMemory := contract.state.Purge()
// Add refunds to the pop'ed address
refund := new(big.Int).Mul(StoreFee, big.NewInt(int64(deletedMemory)))
account := state.GetAccount(recAddr)
account.Amount.Add(account.Amount, refund)
// Update the refunding address
state.UpdateAccount(recAddr, account)
// Delete the contract
state.trie.Update(string(addr), "")
ethutil.Config.Log.Debugf("(%d) => %x\n", deletedMemory, recAddr) receiver := vm.state.GetAccount(stack.Pop().Bytes())
break out receiver.AddAmount(closure.object.Amount)
*/
vm.stateManager.manifest.AddObjectChange(receiver)
closure.object.state.Purge()
fallthrough
case oSTOP: // Stop the closure
return closure.Return(nil), nil
default: default:
ethutil.Config.Log.Debugf("Invalid opcode %x\n", op) ethutil.Config.Log.Debugf("Invalid opcode %x\n", op)