aboutsummaryrefslogtreecommitdiffstats
path: root/core/state_transition.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-01-05 18:52:10 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-01-05 18:52:10 +0800
commitbbc4ea4ae8e8a962deae3d5693d9d4a9376eab88 (patch)
treed4743eaa073d1bc7788f5d4fc3771da37f3cb0b5 /core/state_transition.go
parent2126d8148806b6d8597d6a1c761080e9dc98d745 (diff)
downloadgo-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.gz
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.bz2
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.lz
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.xz
go-tangerine-bbc4ea4ae8e8a962deae3d5693d9d4a9376eab88.tar.zst
go-tangerine-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/state_transition.go')
-rw-r--r--core/state_transition.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/state_transition.go b/core/state_transition.go
index 48540be14..38fbebfd9 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -57,7 +57,7 @@ type StateTransition struct {
data []byte
state vm.StateDB
- env *vm.Environment
+ env *vm.EVM
}
// Message represents a message sent to a contract.
@@ -106,7 +106,7 @@ func IntrinsicGas(data []byte, contractCreation, homestead bool) *big.Int {
}
// NewStateTransition initialises and returns a new state transition object.
-func NewStateTransition(env *vm.Environment, msg Message, gp *GasPool) *StateTransition {
+func NewStateTransition(env *vm.EVM, msg Message, gp *GasPool) *StateTransition {
return &StateTransition{
gp: gp,
env: env,
@@ -127,7 +127,7 @@ func NewStateTransition(env *vm.Environment, msg Message, gp *GasPool) *StateTra
// the gas used (which includes gas refunds) and an error if it failed. An error always
// indicates a core error meaning that the message would always fail for that particular
// state and would never be accepted within a block.
-func ApplyMessage(env *vm.Environment, msg Message, gp *GasPool) ([]byte, *big.Int, error) {
+func ApplyMessage(env *vm.EVM, msg Message, gp *GasPool) ([]byte, *big.Int, error) {
st := NewStateTransition(env, msg, gp)
ret, _, gasUsed, err := st.TransitionDb()
@@ -159,7 +159,7 @@ func (self *StateTransition) to() vm.Account {
func (self *StateTransition) useGas(amount *big.Int) error {
if self.gas.Cmp(amount) < 0 {
- return vm.OutOfGasError
+ return vm.ErrOutOfGas
}
self.gas.Sub(self.gas, amount)
@@ -233,7 +233,7 @@ func (self *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *b
)
if contractCreation {
ret, _, vmerr = vmenv.Create(sender, self.data, self.gas, self.value)
- if homestead && err == vm.CodeStoreOutOfGasError {
+ if homestead && err == vm.ErrCodeStoreOutOfGas {
self.gas = Big0
}
} else {