diff options
author | obscuren <geffobscura@gmail.com> | 2014-10-15 06:40:41 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-10-15 06:40:41 +0800 |
commit | 3d177be73e127b08a52988fde308eed29eac4699 (patch) | |
tree | 4907a28db7a72af10cd1877d0932e6d71690c075 | |
parent | 7ca7938d8e4a63b4bd244ee46856ec657d63a374 (diff) | |
download | go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar.gz go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar.bz2 go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar.lz go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar.xz go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.tar.zst go-tangerine-3d177be73e127b08a52988fde308eed29eac4699.zip |
Couple of minor issues fixed
* CALLVALUE pushed incorrect value to the stack
* Set execution model to closure
-rw-r--r-- | ethstate/state.go | 6 | ||||
-rw-r--r-- | ethvm/closure.go | 1 | ||||
-rw-r--r-- | ethvm/environment.go | 1 | ||||
-rw-r--r-- | ethvm/execution.go | 1 | ||||
-rw-r--r-- | ethvm/vm.go | 2 | ||||
-rw-r--r-- | ethvm/vm_debug.go | 7 |
6 files changed, 13 insertions, 5 deletions
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: |