Logo
Explore Help
Sign In
gaspersic/go-ethereum
1
0
Fork 0
You've already forked go-ethereum
Code Issues Pull Requests Projects Releases Wiki Activity
go-ethereum/core/vm/stack_table.go

21 lines
418 B
Go
Raw Normal View History

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.
2017-01-05 11:52:10 +01:00
package vm
import (
"fmt"
"github.com/ethereum/go-ethereum/params"
)
func makeStackFunc(pop, push int) stackValidationFunc {
return func(stack *Stack) error {
if err := stack.require(pop); err != nil {
return err
}
if push > 0 && int64(stack.len()-pop+push) > params.StackLimit.Int64() {
return fmt.Errorf("stack limit reached %d (%d)", stack.len(), params.StackLimit.Int64())
}
return nil
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.7 Page: 718ms Template: 30ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API