|
|
@ -93,7 +93,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro |
|
|
|
if r := recover(); r != nil { |
|
|
|
if r := recover(); r != nil { |
|
|
|
ret = closure.Return(nil) |
|
|
|
ret = closure.Return(nil) |
|
|
|
err = fmt.Errorf("%v", r) |
|
|
|
err = fmt.Errorf("%v", r) |
|
|
|
fmt.Println("vm err", err) |
|
|
|
fmt.Println(err) |
|
|
|
} |
|
|
|
} |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
@ -106,11 +106,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro |
|
|
|
require := func(m int) { |
|
|
|
require := func(m int) { |
|
|
|
if stack.Len() < m { |
|
|
|
if stack.Len() < m { |
|
|
|
isRequireError = true |
|
|
|
isRequireError = true |
|
|
|
panic(fmt.Sprintf("stack = %d, req = %d", stack.Len(), m)) |
|
|
|
panic(fmt.Sprintf("stack err = %d, req = %d", stack.Len(), m)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Instruction pointer
|
|
|
|
// Program counter
|
|
|
|
pc := big.NewInt(0) |
|
|
|
pc := big.NewInt(0) |
|
|
|
// Current step count
|
|
|
|
// Current step count
|
|
|
|
step := 0 |
|
|
|
step := 0 |
|
|
@ -593,16 +593,18 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro |
|
|
|
|
|
|
|
|
|
|
|
// Generate a new address
|
|
|
|
// Generate a new address
|
|
|
|
addr := ethutil.CreateAddress(closure.caller.Address(), closure.caller.N()) |
|
|
|
addr := ethutil.CreateAddress(closure.caller.Address(), closure.caller.N()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vm.Printf(" (*) %x", addr).Endl() |
|
|
|
|
|
|
|
|
|
|
|
// Create a new contract
|
|
|
|
// Create a new contract
|
|
|
|
contract := vm.state.NewStateObject(addr) |
|
|
|
contract := vm.state.NewStateObject(addr) |
|
|
|
contract.Amount = value |
|
|
|
contract.Amount = value |
|
|
|
|
|
|
|
|
|
|
|
// Set the init script
|
|
|
|
// Set the init script
|
|
|
|
contract.initScript = mem.Get(offset.Int64(), size.Int64()) |
|
|
|
contract.initScript = ethutil.BigD(mem.Get(offset.Int64(), size.Int64())).Bytes() |
|
|
|
// Transfer all remaining gas to the new
|
|
|
|
// Transfer all remaining gas to the new
|
|
|
|
// contract so it may run the init script
|
|
|
|
// contract so it may run the init script
|
|
|
|
gas := new(big.Int).Set(closure.Gas) |
|
|
|
gas := new(big.Int).Set(closure.Gas) |
|
|
|
//closure.UseGas(gas)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the closure
|
|
|
|
// Create the closure
|
|
|
|
c := NewClosure(closure.caller, |
|
|
|
c := NewClosure(closure.caller, |
|
|
@ -613,6 +615,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro |
|
|
|
closure.Price) |
|
|
|
closure.Price) |
|
|
|
// Call the closure and set the return value as
|
|
|
|
// Call the closure and set the return value as
|
|
|
|
// main script.
|
|
|
|
// main script.
|
|
|
|
|
|
|
|
var err error |
|
|
|
c.Script, gas, err = c.Call(vm, nil, hook) |
|
|
|
c.Script, gas, err = c.Call(vm, nil, hook) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|