aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-23 07:01:26 +0800
committerobscuren <geffobscura@gmail.com>2014-10-23 07:01:26 +0800
commit29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1 (patch)
treecd850fc126869e382ceb56f546aa579b37f7b63d /vm
parent51ecab6967a15b82f9285cd0ffd3352607dc8612 (diff)
downloadgo-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.gz
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.bz2
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.lz
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.xz
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.zst
go-tangerine-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.zip
Updated the VM & VM tests
* Stack Error shouldn't revert to previous state * Updated VM Test tool * Added Transfer method to VM Env
Diffstat (limited to 'vm')
-rw-r--r--vm/common.go2
-rw-r--r--vm/execution.go14
-rw-r--r--vm/types.go2
-rw-r--r--vm/vm.go4
-rw-r--r--vm/vm_debug.go5
5 files changed, 9 insertions, 18 deletions
diff --git a/vm/common.go b/vm/common.go
index 6921b38ff..3d9f57290 100644
--- a/vm/common.go
+++ b/vm/common.go
@@ -39,7 +39,7 @@ var (
S256 = ethutil.S256
)
-const MaxCallDepth = 1024
+const MaxCallDepth = 1025
func calcMemSize(off, l *big.Int) *big.Int {
if l.Cmp(ethutil.Big0) == 0 {
diff --git a/vm/execution.go b/vm/execution.go
index 4c4bd1e3c..bd174d64e 100644
--- a/vm/execution.go
+++ b/vm/execution.go
@@ -13,6 +13,7 @@ type Execution struct {
address, input []byte
Gas, price, value *big.Int
object *ethstate.StateObject
+ SkipTransfer bool
}
func NewExecution(vm VirtualMachine, address, input []byte, gas, gasPrice, value *big.Int) *Execution {
@@ -49,17 +50,17 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
})
from, to := caller.Object(), env.State().GetOrNewStateObject(self.address)
- err = env.Transfer(from, to, self.value)
+ // Skipping transfer is used on testing for the initial call
+ if !self.SkipTransfer {
+ err = env.Transfer(from, to, self.value)
+ }
+
if err != nil {
caller.ReturnGas(self.Gas, self.price)
err = fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, from.Balance)
} else {
self.object = to
-
- //caller.Object().SubAmount(self.value)
- //stateObject.AddAmount(self.value)
-
// Pre-compiled contracts (address.go) 1, 2 & 3.
naddr := ethutil.BigD(caddr).Uint64()
if p := Precompiled[naddr]; p != nil {
@@ -73,14 +74,13 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
c.exe = self
if self.vm.Depth() == MaxCallDepth {
- c.UseGas(c.Gas)
+ c.UseGas(self.Gas)
return c.Return(nil), fmt.Errorf("Max call depth exceeded (%d)", MaxCallDepth)
}
// Executer the closure and get the return value (if any)
ret, _, err = c.Call(self.vm, self.input)
-
msg.Output = ret
}
}
diff --git a/vm/types.go b/vm/types.go
index 5fd92052b..6fb9a5c95 100644
--- a/vm/types.go
+++ b/vm/types.go
@@ -151,7 +151,6 @@ const (
CALLCODE = 0xf3
// 0x70 range - other
- LOG = 0xfe // XXX Unofficial
SUICIDE = 0xff
)
@@ -300,7 +299,6 @@ var opCodeToString = map[OpCode]string{
CALLCODE: "CALLCODE",
// 0x70 range - other
- LOG: "LOG",
SUICIDE: "SUICIDE",
}
diff --git a/vm/vm.go b/vm/vm.go
index b5c7c0e21..1a7a40a36 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -660,8 +660,6 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
// Get the arguments from the memory
args := mem.Get(inOffset.Int64(), inSize.Int64())
- //snapshot := self.env.State().Copy()
-
var executeAddr []byte
if op == CALLCODE {
executeAddr = closure.Address()
@@ -673,8 +671,6 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
ret, err := msg.Exec(addr.Bytes(), closure)
if err != nil {
stack.Push(ethutil.BigFalse)
-
- //self.env.State().Set(snapshot)
} else {
stack.Push(ethutil.BigTrue)
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index acdeb4be9..ba1781109 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -237,10 +237,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
mem.Resize(newMemSize.Uint64())
switch op {
- case LOG:
- stack.Print()
- mem.Print()
- // 0x20 range
+ // 0x20 range
case ADD:
require(2)
x, y := stack.Popn()