|
|
@ -2,7 +2,7 @@ package ethchain |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
_ "bytes" |
|
|
|
_ "bytes" |
|
|
|
"fmt" |
|
|
|
_ "fmt" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
"github.com/ethereum/eth-go/ethutil" |
|
|
|
_ "github.com/obscuren/secp256k1-go" |
|
|
|
_ "github.com/obscuren/secp256k1-go" |
|
|
|
_ "math" |
|
|
|
_ "math" |
|
|
@ -301,9 +301,14 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { |
|
|
|
// 0x50 range
|
|
|
|
// 0x50 range
|
|
|
|
case oPUSH: // Push PC+1 on to the stack
|
|
|
|
case oPUSH: // Push PC+1 on to the stack
|
|
|
|
pc.Add(pc, ethutil.Big1) |
|
|
|
pc.Add(pc, ethutil.Big1) |
|
|
|
|
|
|
|
//val := closure.GetMem(pc).BigInt()
|
|
|
|
|
|
|
|
data := closure.Gets(pc, big.NewInt(32)) |
|
|
|
|
|
|
|
val := ethutil.BigD(data.Bytes()) |
|
|
|
|
|
|
|
|
|
|
|
val := closure.GetMem(pc).BigInt() |
|
|
|
// Push value to stack
|
|
|
|
stack.Push(val) |
|
|
|
stack.Push(val) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pc.Add(pc, big.NewInt(31)) |
|
|
|
case oPOP: |
|
|
|
case oPOP: |
|
|
|
stack.Pop() |
|
|
|
stack.Pop() |
|
|
|
case oDUP: |
|
|
|
case oDUP: |
|
|
@ -343,17 +348,16 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { |
|
|
|
stack.Push(big.NewInt(int64(mem.Len()))) |
|
|
|
stack.Push(big.NewInt(int64(mem.Len()))) |
|
|
|
// 0x60 range
|
|
|
|
// 0x60 range
|
|
|
|
case oCALL: |
|
|
|
case oCALL: |
|
|
|
// Pop return size and offset
|
|
|
|
// Closure addr
|
|
|
|
retSize, retOffset := stack.Popn() |
|
|
|
addr := stack.Pop() |
|
|
|
|
|
|
|
// Pop gas and value of the stack.
|
|
|
|
|
|
|
|
gas, value := stack.Popn() |
|
|
|
// Pop input size and offset
|
|
|
|
// Pop input size and offset
|
|
|
|
inSize, inOffset := stack.Popn() |
|
|
|
inSize, inOffset := stack.Popn() |
|
|
|
fmt.Println(inSize, inOffset) |
|
|
|
// Pop return size and offset
|
|
|
|
|
|
|
|
retSize, retOffset := stack.Popn() |
|
|
|
// Get the arguments from the memory
|
|
|
|
// Get the arguments from the memory
|
|
|
|
args := mem.Get(inOffset.Int64(), inSize.Int64()) |
|
|
|
args := mem.Get(inOffset.Int64(), inSize.Int64()) |
|
|
|
// Pop gas and value of the stack.
|
|
|
|
|
|
|
|
gas, value := stack.Popn() |
|
|
|
|
|
|
|
// Closure addr
|
|
|
|
|
|
|
|
addr := stack.Pop() |
|
|
|
|
|
|
|
// Fetch the contract which will serve as the closure body
|
|
|
|
// Fetch the contract which will serve as the closure body
|
|
|
|
contract := vm.state.GetContract(addr.Bytes()) |
|
|
|
contract := vm.state.GetContract(addr.Bytes()) |
|
|
|
// Create a new callable closure
|
|
|
|
// Create a new callable closure
|
|
|
@ -385,7 +389,9 @@ func (vm *Vm) RunClosure(closure *Closure) []byte { |
|
|
|
break out |
|
|
|
break out |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
default: |
|
|
|
default: |
|
|
|
ethutil.Config.Log.Debugln("Invalid opcode", op) |
|
|
|
ethutil.Config.Log.Debugf("Invalid opcode %x\n", op) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return closure.Return(nil) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pc.Add(pc, ethutil.Big1) |
|
|
|
pc.Add(pc, ethutil.Big1) |
|
|
|