aboutsummaryrefslogtreecommitdiffstats
path: root/vm/execution.go
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/execution.go
parent51ecab6967a15b82f9285cd0ffd3352607dc8612 (diff)
downloaddexon-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.gz
dexon-29b8a0bc5ffa7a674a06a211e1c8bdd1b6ed07b1.tar.zst
dexon-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/execution.go')
-rw-r--r--vm/execution.go14
1 files changed, 7 insertions, 7 deletions
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
}
}