Commit 6212175b authored by obscuren's avatar obscuren

reverted vm back

parent 6095edac
......@@ -5,10 +5,11 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
)
type Environment interface {
//State() *state.State
State() *state.State
Origin() []byte
BlockNumber() *big.Int
......@@ -18,16 +19,8 @@ type Environment interface {
Difficulty() *big.Int
BlockHash() []byte
GasLimit() *big.Int
Transfer(from, to Account, amount *big.Int) error
AddLog(addr []byte, topics [][]byte, data []byte)
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)
AddLog(*state.Log)
}
type Object interface {
......@@ -50,5 +43,9 @@ func Transfer(from, to Account, amount *big.Int) error {
from.SubBalance(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
}
......@@ -26,7 +26,7 @@ func (self *Execution) Addr() []byte {
func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error) {
// Retrieve the executing code
code := self.vm.Env().GetCode(codeAddr)
code := self.vm.Env().State().GetCode(codeAddr)
return self.exec(code, codeAddr, caller)
}
......@@ -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) {
env := self.vm.Env()
vmlogger.Debugf("pre state %x\n", env.State().Root())
snapshot := env.State().Copy()
defer func() {
if IsDepthErr(err) || IsOOGErr(err) {
env.State().Set(snapshot)
}
vmlogger.Debugf("post state %x\n", env.State().Root())
}()
msg := env.State().Manifest().AddMessage(&state.Message{
......@@ -89,6 +91,6 @@ func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte,
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)
}
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