Documentation ¶
Index ¶
- Constants
- Variables
- func Disassemble(script []byte) (asm []string)
- func IsDepthErr(err error) bool
- func IsOOGErr(err error) bool
- func IsStack(err error) bool
- func PrecompiledContracts() map[string]*PrecompiledAccount
- func Transfer(from, to Account, amount *big.Int) error
- type Account
- type Address
- type Context
- func (c *Context) Address() []byte
- func (c *Context) GetByte(n uint64) byte
- func (c *Context) GetBytes(x, y int) []byte
- func (c *Context) GetCode(x, size uint64) []byte
- func (c *Context) GetOp(n uint64) OpCode
- func (c *Context) GetRangeValue(x, size uint64) []byte
- func (c *Context) Return(ret []byte) []byte
- func (c *Context) ReturnGas(gas, price *big.Int)
- func (self *Context) SetCode(code []byte)
- func (c *Context) UseGas(gas *big.Int) bool
- type ContextRef
- type Debugger
- type DepthError
- type Environment
- type Log
- type Memory
- type OpCode
- type OpType
- type OutOfGasError
- type PrecompiledAccount
- type Stack
- func (st *Stack) Data() []*big.Int
- func (st *Stack) Dupn(n int) *big.Int
- func (st *Stack) Get(amount *big.Int) []*big.Int
- func (st *Stack) Len() int
- func (st *Stack) Peek() *big.Int
- func (st *Stack) Peekn() (*big.Int, *big.Int)
- func (st *Stack) Pop() *big.Int
- func (st *Stack) Popn() (*big.Int, *big.Int)
- func (st *Stack) Print()
- func (st *Stack) Push(d *big.Int)
- func (st *Stack) Swapn(n int) (*big.Int, *big.Int)
- type StackError
- type TxCallback
- type Type
- type VirtualMachine
- type Vm
- func (self *Vm) Endl() VirtualMachine
- func (self *Vm) Env() Environment
- func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine
- func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, ...) (ret []byte, err error)
- func (self *Vm) RunPrecompiled(p *PrecompiledAccount, callData []byte, context *Context) (ret []byte, err error)
Constants ¶
View Source
const MaxCallDepth = 1025
Variables ¶
View Source
var ( GasStep = big.NewInt(1) GasSha = big.NewInt(10) GasSLoad = big.NewInt(20) GasSStore = big.NewInt(100) GasSStoreRefund = big.NewInt(100) GasBalance = big.NewInt(20) GasCreate = big.NewInt(100) GasCall = big.NewInt(20) GasCreateByte = big.NewInt(5) GasSha3Byte = big.NewInt(10) GasSha256Byte = big.NewInt(50) GasRipemdByte = big.NewInt(50) GasMemory = big.NewInt(1) GasData = big.NewInt(5) GasTx = big.NewInt(500) GasLog = big.NewInt(32) GasSha256 = big.NewInt(50) GasRipemd = big.NewInt(50) GasEcrecover = big.NewInt(500) GasMemCpy = big.NewInt(1) Pow256 = ethutil.BigPow(2, 256) LogTyPretty byte = 0x1 LogTyDiff byte = 0x2 U256 = ethutil.U256 S256 = ethutil.S256 )
View Source
var Precompiled = PrecompiledContracts()
Functions ¶
func Disassemble ¶
func IsDepthErr ¶
func PrecompiledContracts ¶
func PrecompiledContracts() map[string]*PrecompiledAccount
XXX Could set directly. Testing requires resetting and setting of pre compiled contracts.
Types ¶
type Context ¶
type Context struct { Code []byte Gas, UsedGas, Price *big.Int Args []byte // contains filtered or unexported fields }
func NewContext ¶
func NewContext(caller ContextRef, object ContextRef, code []byte, gas, price *big.Int) *Context
Create a new context for the given data items
func (*Context) GetRangeValue ¶
type ContextRef ¶
type DepthError ¶
type DepthError struct{}
func (DepthError) Error ¶
func (self DepthError) Error() string
type Environment ¶
type Environment interface { State() *state.StateDB Origin() []byte BlockNumber() *big.Int GetHash(n uint64) []byte Coinbase() []byte Time() int64 Difficulty() *big.Int GasLimit() *big.Int Transfer(from, to Account, amount *big.Int) error AddLog(state.Log) VmType() Type Depth() int SetDepth(i int) Call(me ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) CallCode(me ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) Create(me ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, ContextRef) }
type OpCode ¶
type OpCode byte
const ( // 0x0 range - arithmetic ops STOP OpCode = iota ADD MUL SUB DIV SDIV MOD SMOD ADDMOD MULMOD EXP SIGNEXTEND )
Op codes
const ( // 0x60 range PUSH1 OpCode = 0x60 + iota PUSH2 PUSH3 PUSH4 PUSH5 PUSH6 PUSH7 PUSH8 PUSH9 PUSH10 PUSH11 PUSH12 PUSH13 PUSH14 PUSH15 PUSH16 PUSH17 PUSH18 PUSH19 PUSH20 PUSH21 PUSH22 PUSH23 PUSH24 PUSH25 PUSH26 PUSH27 PUSH28 PUSH29 PUSH30 PUSH31 PUSH32 DUP1 DUP2 DUP3 DUP4 DUP5 DUP6 DUP7 DUP8 DUP9 DUP10 DUP11 DUP12 DUP13 DUP14 DUP15 DUP16 SWAP1 SWAP2 SWAP3 SWAP4 SWAP5 SWAP6 SWAP7 SWAP8 SWAP9 SWAP10 SWAP11 SWAP12 SWAP13 SWAP14 SWAP15 SWAP16 )
type OutOfGasError ¶
type OutOfGasError struct {
// contains filtered or unexported fields
}
func OOG ¶
func OOG(req, has *big.Int) OutOfGasError
func (OutOfGasError) Error ¶
func (self OutOfGasError) Error() string
type PrecompiledAccount ¶
type PrecompiledAccount struct { Gas func(l int) *big.Int // contains filtered or unexported fields }
func (PrecompiledAccount) Call ¶
func (self PrecompiledAccount) Call(in []byte) []byte
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Simple push/pop stack mechanism
type StackError ¶
type StackError struct {
// contains filtered or unexported fields
}
func StackErr ¶
func StackErr(req, has int) StackError
func (StackError) Error ¶
func (self StackError) Error() string
type TxCallback ¶
type VirtualMachine ¶
type VirtualMachine interface { Env() Environment Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, data []byte) ([]byte, error) Printf(string, ...interface{}) VirtualMachine Endl() VirtualMachine }
func NewJitVm ¶
func NewJitVm(env Environment) VirtualMachine
func NewVm ¶
func NewVm(env Environment) VirtualMachine
type Vm ¶
type Vm struct { Dbg Debugger BreakPoints []int64 Stepping bool Fn string Recoverable bool // contains filtered or unexported fields }
func New ¶
func New(env Environment) *Vm
func (*Vm) Endl ¶
func (self *Vm) Endl() VirtualMachine
func (*Vm) Env ¶
func (self *Vm) Env() Environment
func (*Vm) Printf ¶
func (self *Vm) Printf(format string, v ...interface{}) VirtualMachine
func (*Vm) RunPrecompiled ¶
Click to show internal directories.
Click to hide internal directories.