diff options
author | JM <jm@dexon.org> | 2019-01-31 15:12:57 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:03 +0800 |
commit | 9b8cd76237318e173147a7c32763b6b9d9759951 (patch) | |
tree | 44f860e1ed7e63354f48096ee5df0fa475719cc9 /core/state_transition.go | |
parent | d3b485a5af768db59bd648175849f961e25bc630 (diff) | |
download | dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar.gz dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar.bz2 dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar.lz dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar.xz dexon-9b8cd76237318e173147a7c32763b6b9d9759951.tar.zst dexon-9b8cd76237318e173147a7c32763b6b9d9759951.zip |
core: vm: vm interface (#164)
Diffstat (limited to 'core/state_transition.go')
-rw-r--r-- | core/state_transition.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/core/state_transition.go b/core/state_transition.go index a9a700c2b..32589da90 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -27,7 +27,6 @@ import ( "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/vm" "github.com/dexon-foundation/dexon/core/vm/evm" - "github.com/dexon-foundation/dexon/core/vm/sqlvm" "github.com/dexon-foundation/dexon/log" "github.com/dexon-foundation/dexon/params" ) @@ -73,7 +72,6 @@ type StateTransition struct { data []byte state vm.StateDB evm *evm.EVM - sqlvm *sqlvm.SQLVM } // Message represents a message sent to a contract. @@ -254,6 +252,7 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo // Pay intrinsic gas gas, err := IntrinsicGas(st.data, contractCreation, homestead) + if err != nil { return nil, 0, false, err } @@ -262,23 +261,18 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo } var ( - evm = st.evm - sqlvm = st.sqlvm // vm errors do not effect consensus and are therefor // not assigned to err, except for insufficient balance // error. vmerr error ) + i := st.evm.Interpreter().(*evm.EVMInterpreter) if contractCreation { - if len(st.data) != 0 && st.data[0] == 0xed { - ret, _, st.gas, vmerr = sqlvm.Create(sender, st.data, st.gas, st.value) - } else { - ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value) - } + ret, _, st.gas, vmerr = vm.Create(sender, st.data, st.gas, st.value, i) } else { // Increment the nonce for the next transaction st.state.SetNonce(msg.From(), st.state.GetNonce(sender.Address())+1) - ret, st.gas, vmerr = evm.Call(sender, st.to(), st.data, st.gas, st.value) + ret, st.gas, vmerr = vm.Call(sender, st.to(), st.data, st.gas, st.value, i) } if vmerr != nil { log.Debug("VM returned with error", "err", vmerr) |