Couple of minor issues fixed

* CALLVALUE pushed incorrect value to the stack
* Set execution model to closure
This commit is contained in:
obscuren 2014-10-15 00:40:41 +02:00
parent 7ca7938d8e
commit 3d177be73e
6 changed files with 13 additions and 5 deletions

View File

@ -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)

View File

@ -23,6 +23,7 @@ type Closure struct {
object *ethstate.StateObject
Code []byte
message *ethstate.Message
exe *Execution
Gas, UsedGas, Price *big.Int

View File

@ -16,7 +16,6 @@ type Environment interface {
Coinbase() []byte
Time() int64
Difficulty() *big.Int
Value() *big.Int
BlockHash() []byte
}

View File

@ -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)

View File

@ -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)

View File

@ -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: