Documentation ¶
Overview ¶
Package runtime provides a basic execution model for executing EVM code.
Index ¶
- func Call(address libcommon.Address, input []byte, cfg *Config) ([]byte, uint64, error)
- func Create(input []byte, cfg *Config, blockNr uint64) ([]byte, libcommon.Address, uint64, error)
- func Execute(code, input []byte, cfg *Config, bn uint64) ([]byte, *state.IntraBlockState, error)
- func NewEnv(cfg *Config) *vm.EVM
- type Config
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
Call executes the code given by the contract's address. It will return the EVM's return value or an error if it failed.
Call, unlike Execute, requires a config and also requires the State field to be set.
func Execute ¶
Execute executes the code using the input as call data during the execution. It returns the EVM's return value, the new state and an error if it failed.
Execute sets up an in-memory, temporary, environment for the execution of the given code. It makes sure that it's restored to its original state afterwards.
Example ¶
package main import ( "fmt" "github.com/idrecun/zkevm-erigon/common" "github.com/idrecun/zkevm-erigon/core/vm/runtime" ) func main() { ret, _, err := runtime.Execute(common.Hex2Bytes("6060604052600a8060106000396000f360606040526008565b00"), nil, nil, 0) if err != nil { fmt.Println(err) } fmt.Println(ret) }
Output: [96 96 96 64 82 96 8 86 91 0]
Types ¶
type Config ¶
type Config struct { ChainConfig *chain.Config Difficulty *big.Int Origin libcommon.Address Coinbase libcommon.Address BlockNumber *big.Int Time *big.Int GasLimit uint64 GasPrice *uint256.Int Value *uint256.Int Debug bool EVMConfig vm.Config BaseFee *uint256.Int State *state.IntraBlockState GetHashFn func(n uint64) libcommon.Hash // contains filtered or unexported fields }
Config is a basic type specifying certain configuration flags for running the EVM.