aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-11 02:40:12 +0800
committerobscuren <geffobscura@gmail.com>2014-04-11 02:40:12 +0800
commit6a530ea3717e592407737c6cd2ebeba0200c9cd8 (patch)
treebb5063b709a8d4f6f9baea6824807dd2cf0c610b /ethchain/vm.go
parent0fccbeabcc3b8c110ce3712e5488ad99245f92ee (diff)
downloadgo-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar.gz
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar.bz2
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar.lz
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar.xz
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.tar.zst
go-tangerine-6a530ea3717e592407737c6cd2ebeba0200c9cd8.zip
Call fixed
Diffstat (limited to 'ethchain/vm.go')
-rw-r--r--ethchain/vm.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go
index a6a02dc9f..f94425d2d 100644
--- a/ethchain/vm.go
+++ b/ethchain/vm.go
@@ -2,7 +2,7 @@ package ethchain
import (
_ "bytes"
- "fmt"
+ _ "fmt"
"github.com/ethereum/eth-go/ethutil"
_ "github.com/obscuren/secp256k1-go"
_ "math"
@@ -301,9 +301,14 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
// 0x50 range
case oPUSH: // Push PC+1 on to the stack
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)
+
+ pc.Add(pc, big.NewInt(31))
case oPOP:
stack.Pop()
case oDUP:
@@ -343,17 +348,16 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
stack.Push(big.NewInt(int64(mem.Len())))
// 0x60 range
case oCALL:
- // Pop return size and offset
- retSize, retOffset := stack.Popn()
+ // Closure addr
+ addr := stack.Pop()
+ // Pop gas and value of the stack.
+ gas, value := stack.Popn()
// Pop input size and offset
inSize, inOffset := stack.Popn()
- fmt.Println(inSize, inOffset)
+ // Pop return size and offset
+ retSize, retOffset := stack.Popn()
// Get the arguments from the memory
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
contract := vm.state.GetContract(addr.Bytes())
// Create a new callable closure
@@ -385,7 +389,9 @@ func (vm *Vm) RunClosure(closure *Closure) []byte {
break out
*/
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)