forked from cerc-io/plugeth
Couple of minor issues fixed
* CALLVALUE pushed incorrect value to the stack * Set execution model to closure
This commit is contained in:
parent
7ca7938d8e
commit
3d177be73e
@ -94,11 +94,15 @@ func (self *State) GetStateObject(addr []byte) *StateObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateObject = NewStateObjectFromBytes(addr, []byte(data))
|
stateObject = NewStateObjectFromBytes(addr, []byte(data))
|
||||||
self.stateObjects[string(addr)] = stateObject
|
self.SetStateObject(stateObject)
|
||||||
|
|
||||||
return 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
|
// Retrieve a state object or create a new state object if nil
|
||||||
func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
|
func (self *State) GetOrNewStateObject(addr []byte) *StateObject {
|
||||||
stateObject := self.GetStateObject(addr)
|
stateObject := self.GetStateObject(addr)
|
||||||
|
@ -23,6 +23,7 @@ type Closure struct {
|
|||||||
object *ethstate.StateObject
|
object *ethstate.StateObject
|
||||||
Code []byte
|
Code []byte
|
||||||
message *ethstate.Message
|
message *ethstate.Message
|
||||||
|
exe *Execution
|
||||||
|
|
||||||
Gas, UsedGas, Price *big.Int
|
Gas, UsedGas, Price *big.Int
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ type Environment interface {
|
|||||||
Coinbase() []byte
|
Coinbase() []byte
|
||||||
Time() int64
|
Time() int64
|
||||||
Difficulty() *big.Int
|
Difficulty() *big.Int
|
||||||
Value() *big.Int
|
|
||||||
BlockHash() []byte
|
BlockHash() []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) (ret []byte, err
|
|||||||
|
|
||||||
// Create a new callable closure
|
// Create a new callable closure
|
||||||
c := NewClosure(msg, caller, stateObject, code, self.gas, self.price)
|
c := NewClosure(msg, caller, stateObject, code, self.gas, self.price)
|
||||||
|
c.exe = self
|
||||||
// Executer the closure and get the return value (if any)
|
// Executer the closure and get the return value (if any)
|
||||||
ret, _, err = c.Call(self.vm, self.input)
|
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))
|
stack.Push(ethutil.BigD(caller))
|
||||||
|
|
||||||
case CALLVALUE:
|
case CALLVALUE:
|
||||||
value := self.env.Value()
|
value := closure.exe.value
|
||||||
|
|
||||||
stack.Push(value)
|
stack.Push(value)
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
|
|
||||||
self.Printf(" => %x", caller)
|
self.Printf(" => %x", caller)
|
||||||
case CALLVALUE:
|
case CALLVALUE:
|
||||||
value := self.env.Value()
|
value := closure.exe.value
|
||||||
|
|
||||||
stack.Push(value)
|
stack.Push(value)
|
||||||
|
|
||||||
@ -674,7 +674,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
val, loc := stack.Popn()
|
val, loc := stack.Popn()
|
||||||
closure.SetStorage(loc, ethutil.NewValue(val))
|
closure.SetStorage(loc, ethutil.NewValue(val))
|
||||||
|
|
||||||
|
// Debug sessions are allowed to run without message
|
||||||
|
if closure.message != nil {
|
||||||
closure.message.AddStorageChange(loc.Bytes())
|
closure.message.AddStorageChange(loc.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
self.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
||||||
case JUMP:
|
case JUMP:
|
||||||
|
Loading…
Reference in New Issue
Block a user