Commit 3d177be7 authored by obscuren's avatar obscuren

Couple of minor issues fixed

* CALLVALUE pushed incorrect value to the stack
* Set execution model to closure
parent 7ca7938d
......@@ -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)
......
......@@ -23,6 +23,7 @@ type Closure struct {
object *ethstate.StateObject
Code []byte
message *ethstate.Message
exe *Execution
Gas, UsedGas, Price *big.Int
......
......@@ -16,7 +16,6 @@ type Environment interface {
Coinbase() []byte
Time() int64
Difficulty() *big.Int
Value() *big.Int
BlockHash() []byte
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment