diff --git a/ethstate/state.go b/ethstate/state.go index 23b106e34..c2486849b 100644 --- a/ethstate/state.go +++ b/ethstate/state.go @@ -94,11 +94,15 @@ func (self *State) GetStateObject(addr []byte) *StateObject { } stateObject = NewStateObjectFromBytes(addr, []byte(data)) - self.stateObjects[string(addr)] = stateObject + self.SetStateObject(stateObject) return stateObject } +func (self *State) SetStateObject(object *StateObject) { + self.stateObjects[string(object.address)] = object +} + // Retrieve a state object or create a new state object if nil func (self *State) GetOrNewStateObject(addr []byte) *StateObject { stateObject := self.GetStateObject(addr) 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: