runtime

package
v1.4.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2016 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package runtime provides a basic execution model for executing EVM code.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(address common.Address, input []byte, cfg *Config) ([]byte, error)

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

func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error)

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.

Executes sets up a in memory, temporarily, environment for the execution of the given code. It enabled the JIT by default and make sure that it's restored to it's original state afterwards.

Example
package main

import (
	"fmt"

	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/vm/runtime"
)

func main() {
	ret, _, err := runtime.Execute(common.Hex2Bytes("6060604052600a8060106000396000f360606040526008565b00"), nil, nil)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(ret)
}
Output:

[96 96 96 64 82 96 8 86 91 0]

func NewEnv

func NewEnv(cfg *Config, state *state.StateDB) vm.Environment

NewEnv returns a new vm.Environment

Types

type Config

type Config struct {
	RuleSet     vm.RuleSet
	Difficulty  *big.Int
	Origin      common.Address
	Coinbase    common.Address
	BlockNumber *big.Int
	Time        *big.Int
	GasLimit    *big.Int
	GasPrice    *big.Int
	Value       *big.Int
	DisableJit  bool // "disable" so it's enabled by default
	Debug       bool

	State     *state.StateDB
	GetHashFn func(n uint64) common.Hash
}

Config is a basic type specifying certain configuration flags for running the EVM.

type Env added in v1.3.2

type Env struct {
	// contains filtered or unexported fields
}

Env is a basic runtime environment required for running the EVM.

func (*Env) AddLog added in v1.3.2

func (self *Env) AddLog(log *vm.Log)

func (*Env) AddStructLog added in v1.3.2

func (self *Env) AddStructLog(log vm.StructLog)

func (*Env) BlockNumber added in v1.3.2

func (self *Env) BlockNumber() *big.Int

func (*Env) Call added in v1.3.2

func (self *Env) Call(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error)

func (*Env) CallCode added in v1.3.2

func (self *Env) CallCode(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error)

func (*Env) CanTransfer added in v1.3.2

func (self *Env) CanTransfer(from common.Address, balance *big.Int) bool

func (*Env) Coinbase added in v1.3.2

func (self *Env) Coinbase() common.Address

func (*Env) Create added in v1.3.2

func (self *Env) Create(caller vm.ContractRef, data []byte, gas, price, value *big.Int) ([]byte, common.Address, error)

func (*Env) Db added in v1.3.2

func (self *Env) Db() vm.Database

func (*Env) DelegateCall added in v1.3.4

func (self *Env) DelegateCall(me vm.ContractRef, addr common.Address, data []byte, gas, price *big.Int) ([]byte, error)

func (*Env) Depth added in v1.3.2

func (self *Env) Depth() int

func (*Env) Difficulty added in v1.3.2

func (self *Env) Difficulty() *big.Int

func (*Env) GasLimit added in v1.3.2

func (self *Env) GasLimit() *big.Int

func (*Env) GetHash added in v1.3.2

func (self *Env) GetHash(n uint64) common.Hash

func (*Env) MakeSnapshot added in v1.3.2

func (self *Env) MakeSnapshot() vm.Database

func (*Env) Origin added in v1.3.2

func (self *Env) Origin() common.Address

func (*Env) RuleSet added in v1.4.0

func (self *Env) RuleSet() vm.RuleSet

func (*Env) SetDepth added in v1.3.2

func (self *Env) SetDepth(i int)

func (*Env) SetSnapshot added in v1.3.2

func (self *Env) SetSnapshot(copy vm.Database)

func (*Env) StructLogs added in v1.3.2

func (self *Env) StructLogs() []vm.StructLog

func (*Env) Time added in v1.3.2

func (self *Env) Time() *big.Int

func (*Env) Transfer added in v1.3.2

func (self *Env) Transfer(from, to vm.Account, amount *big.Int)

func (*Env) Vm added in v1.4.0

func (self *Env) Vm() vm.Vm

func (*Env) VmType added in v1.3.2

func (self *Env) VmType() vm.Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL