diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-01-05 18:52:10 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-01-05 18:52:10 +0800 |
commit | bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88 (patch) | |
tree | d4743eaa073d1bc7788f5d4fc3771da37f3cb0b5 /core/vm/interface.go | |
parent | 2126d8148806b6d8597d6a1c761080e9dc98d745 (diff) | |
download | dexon-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.gz dexon-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.zst dexon-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.zip |
core/vm: improved EVM run loop & instruction calling (#3378)
The run loop, which previously contained custom opcode executes have been
removed and has been simplified to a few checks.
Each operation consists of 4 elements: execution function, gas cost function,
stack validation function and memory size function. The execution function
implements the operation's runtime behaviour, the gas cost function implements
the operation gas costs function and greatly depends on the memory and stack,
the stack validation function validates the stack and makes sure that enough
items can be popped off and pushed on and the memory size function calculates
the memory required for the operation and returns it.
This commit also allows the EVM to go unmetered. This is helpful for offline
operations such as contract calls.
Diffstat (limited to 'core/vm/interface.go')
-rw-r--r-- | core/vm/interface.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/core/vm/interface.go b/core/vm/interface.go index 918fde85f..b81f59125 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -22,14 +22,6 @@ import ( "github.com/ethereum/go-ethereum/common" ) -// Vm is the basic interface for an implementation of the EVM. -type Vm interface { - // Run should execute the given contract with the input given in in - // and return the contract execution return bytes or an error if it - // failed. - Run(c *Contract, in []byte) ([]byte, error) -} - // StateDB is an EVM database for full state querying. type StateDB interface { GetAccount(common.Address) Account @@ -83,15 +75,15 @@ type Account interface { Value() *big.Int } -// CallContext provides a basic interface for the EVM calling conventions. The EVM Environment +// CallContext provides a basic interface for the EVM calling conventions. The EVM EVM // depends on this context being implemented for doing subcalls and initialising new EVM contracts. type CallContext interface { // Call another contract - Call(env *Environment, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) + Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) // Take another's contract code and execute within our own context - CallCode(env *Environment, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) + CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) // Same as CallCode except sender and value is propagated from parent to child scope - DelegateCall(env *Environment, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) + DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) // Create a new contract - Create(env *Environment, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) + Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) } |