Commit 6212175b authored by obscuren's avatar obscuren

reverted vm back

parent 6095edac
...@@ -5,10 +5,11 @@ import ( ...@@ -5,10 +5,11 @@ import (
"math/big" "math/big"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
) )
type Environment interface { type Environment interface {
//State() *state.State State() *state.State
Origin() []byte Origin() []byte
BlockNumber() *big.Int BlockNumber() *big.Int
...@@ -18,16 +19,8 @@ type Environment interface { ...@@ -18,16 +19,8 @@ type Environment interface {
Difficulty() *big.Int Difficulty() *big.Int
BlockHash() []byte BlockHash() []byte
GasLimit() *big.Int GasLimit() *big.Int
Transfer(from, to Account, amount *big.Int) error Transfer(from, to Account, amount *big.Int) error
AddLog(addr []byte, topics [][]byte, data []byte) AddLog(*state.Log)
DeleteAccount(addr []byte)
SetState(addr, key, value []byte)
GetState(addr, key []byte) []byte
Balance(addr []byte) *big.Int
AddBalance(addr []byte, balance *big.Int)
GetCode(addr []byte) []byte
Refund(addr []byte, gas, price *big.Int)
} }
type Object interface { type Object interface {
...@@ -50,5 +43,9 @@ func Transfer(from, to Account, amount *big.Int) error { ...@@ -50,5 +43,9 @@ func Transfer(from, to Account, amount *big.Int) error {
from.SubBalance(amount) from.SubBalance(amount)
to.AddBalance(amount) to.AddBalance(amount)
// Add default LOG. Default = big(sender.addr) + 1
//addr := ethutil.BigD(receiver.Address())
//tx.addLog(vm.Log{sender.Address(), [][]byte{ethutil.U256(addr.Add(addr, ethutil.Big1)).Bytes()}, nil})
return nil return nil
} }
...@@ -26,7 +26,7 @@ func (self *Execution) Addr() []byte { ...@@ -26,7 +26,7 @@ func (self *Execution) Addr() []byte {
func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error) { func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error) {
// Retrieve the executing code // Retrieve the executing code
code := self.vm.Env().GetCode(codeAddr) code := self.vm.Env().State().GetCode(codeAddr)
return self.exec(code, codeAddr, caller) return self.exec(code, codeAddr, caller)
} }
...@@ -34,11 +34,13 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error) ...@@ -34,11 +34,13 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error)
func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, err error) { func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, err error) {
env := self.vm.Env() env := self.vm.Env()
vmlogger.Debugf("pre state %x\n", env.State().Root())
snapshot := env.State().Copy() snapshot := env.State().Copy()
defer func() { defer func() {
if IsDepthErr(err) || IsOOGErr(err) { if IsDepthErr(err) || IsOOGErr(err) {
env.State().Set(snapshot) env.State().Set(snapshot)
} }
vmlogger.Debugf("post state %x\n", env.State().Root())
}() }()
msg := env.State().Manifest().AddMessage(&state.Message{ msg := env.State().Manifest().AddMessage(&state.Message{
...@@ -89,6 +91,6 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, ...@@ -89,6 +91,6 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
return return
} }
func (self *Execution) Create(caller []byte) (ret []byte, err error) { func (self *Execution) Create(caller ClosureRef) (ret []byte, err error) {
return self.exec(self.input, nil, caller) return self.exec(self.input, nil, caller)
} }
This diff is collapsed.
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