From 3d177be73e127b08a52988fde308eed29eac4699 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 15 Oct 2014 00:40:41 +0200 Subject: Couple of minor issues fixed * CALLVALUE pushed incorrect value to the stack * Set execution model to closure --- ethvm/closure.go | 1 + ethvm/environment.go | 1 - ethvm/execution.go | 1 + ethvm/vm.go | 2 +- ethvm/vm_debug.go | 7 +++++-- 5 files changed, 8 insertions(+), 4 deletions(-) (limited to 'ethvm') diff --git a/ethvm/closure.go b/ethvm/closure.go index 0cd3c768c..2d2204e5f 100644 --- a/ethvm/closure.go +++ b/ethvm/closure.go @@ -23,6 +23,7 @@ type Closure struct { object *ethstate.StateObject Code []byte message *ethstate.Message + exe *Execution Gas, UsedGas, Price *big.Int diff --git a/ethvm/environment.go b/ethvm/environment.go index e261f8462..38dbc6499 100644 --- a/ethvm/environment.go +++ b/ethvm/environment.go @@ -16,7 +16,6 @@ type Environment interface { Coinbase() []byte Time() int64 Difficulty() *big.Int - Value() *big.Int BlockHash() []byte } diff --git a/ethvm/execution.go b/ethvm/execution.go index 6273fc49e..0550a8bf3 100644 --- a/ethvm/execution.go +++ b/ethvm/execution.go @@ -66,6 +66,7 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err // Create a new callable closure c := NewClosure(msg, caller, stateObject, code, self.gas, self.price) + c.exe = self // Executer the closure and get the return value (if any) ret, _, err = c.Call(self.vm, self.input) diff --git a/ethvm/vm.go b/ethvm/vm.go index 8d58ffcb7..dad031e01 100644 --- a/ethvm/vm.go +++ b/ethvm/vm.go @@ -392,7 +392,7 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) { stack.Push(ethutil.BigD(caller)) case CALLVALUE: - value := self.env.Value() + value := closure.exe.value stack.Push(value) diff --git a/ethvm/vm_debug.go b/ethvm/vm_debug.go index 0a1e0155e..df8cbb10c 100644 --- a/ethvm/vm_debug.go +++ b/ethvm/vm_debug.go @@ -482,7 +482,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { self.Printf(" => %x", caller) case CALLVALUE: - value := self.env.Value() + value := closure.exe.value stack.Push(value) @@ -674,7 +674,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { val, loc := stack.Popn() closure.SetStorage(loc, ethutil.NewValue(val)) - closure.message.AddStorageChange(loc.Bytes()) + // Debug sessions are allowed to run without message + if closure.message != nil { + closure.message.AddStorageChange(loc.Bytes()) + } self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes()) case JUMP: -- cgit