vm

package
v0.78.1-pre Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 24 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// MaxArraySize is the maximum array size allowed in the VM.
	MaxArraySize = 1024

	// MaxItemSize is the maximum item size allowed in the VM.
	MaxItemSize = 1024 * 1024

	// MaxInvocationStackSize is the maximum size of an invocation stack.
	MaxInvocationStackSize = 1024

	// MaxBigIntegerSizeBits is the maximum size of BigInt item in bits.
	MaxBigIntegerSizeBits = 32 * 8

	// MaxStackSize is the maximum number of items allowed to be
	// on all stacks at once.
	MaxStackSize = 2 * 1024
)

Variables

This section is empty.

Functions

func EncodeBinaryStackItem

func EncodeBinaryStackItem(item StackItem, w *io.BinWriter)

EncodeBinaryStackItem encodes given StackItem into the given BinWriter. It's similar to io.Serializable's EncodeBinary, but works with StackItem interface.

func EnumeratorConcat

func EnumeratorConcat(v *VM) error

EnumeratorConcat handles syscall Neo.Enumerator.Concat.

func EnumeratorCreate

func EnumeratorCreate(v *VM) error

EnumeratorCreate handles syscall Neo.Enumerator.Create.

func EnumeratorNext

func EnumeratorNext(v *VM) error

EnumeratorNext handles syscall Neo.Enumerator.Next.

func EnumeratorValue

func EnumeratorValue(v *VM) error

EnumeratorValue handles syscall Neo.Enumerator.Value.

func GetInteropID

func GetInteropID(parameter []byte) uint32

GetInteropID converts instruction parameter to an interop ID.

func InteropNameToID

func InteropNameToID(name []byte) uint32

InteropNameToID returns an identificator of the method based on its name.

func IsMultiSigContract

func IsMultiSigContract(script []byte) bool

IsMultiSigContract checks whether the passed script is a multi-signature contract.

func IsSignatureContract

func IsSignatureContract(script []byte) bool

IsSignatureContract checks whether the passed script is a signature check contract.

func IsStandardContract

func IsStandardContract(script []byte) bool

IsStandardContract checks whether the passed script is a signature or multi-signature contract.

func IteratorConcat

func IteratorConcat(v *VM) error

IteratorConcat handles syscall Neo.Iterator.Concat.

func IteratorCreate

func IteratorCreate(v *VM) error

IteratorCreate handles syscall Neo.Iterator.Create.

func IteratorKey

func IteratorKey(v *VM) error

IteratorKey handles syscall Neo.Iterator.Key.

func IteratorKeys

func IteratorKeys(v *VM) error

IteratorKeys handles syscall Neo.Iterator.Keys.

func IteratorValues

func IteratorValues(v *VM) error

IteratorValues handles syscall Neo.Iterator.Values.

func ParseMultiSigContract

func ParseMultiSigContract(script []byte) ([][]byte, bool)

ParseMultiSigContract returns list of public keys from the verification script of the contract.

func RuntimeDeserialize

func RuntimeDeserialize(vm *VM) error

RuntimeDeserialize handles syscalls System.Runtime.Deserialize and Neo.Runtime.Deserialize.

func RuntimeSerialize

func RuntimeSerialize(vm *VM) error

RuntimeSerialize handles syscalls System.Runtime.Serialize and Neo.Runtime.Serialize.

func SerializeItem

func SerializeItem(item StackItem) ([]byte, error)

SerializeItem encodes given StackItem into the byte slice.

Types

type ArrayItem

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

ArrayItem represents a new ArrayItem object.

func NewArrayItem

func NewArrayItem(items []StackItem) *ArrayItem

NewArrayItem returns a new ArrayItem object.

func (*ArrayItem) Dup

func (i *ArrayItem) Dup() StackItem

Dup implements StackItem interface.

func (*ArrayItem) Equals

func (i *ArrayItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*ArrayItem) MarshalJSON

func (i *ArrayItem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ArrayItem) String

func (i *ArrayItem) String() string

func (*ArrayItem) ToContractParameter

func (i *ArrayItem) ToContractParameter(seen map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*ArrayItem) TryBytes

func (i *ArrayItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*ArrayItem) Value

func (i *ArrayItem) Value() interface{}

Value implements StackItem interface.

type BigIntegerItem

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

BigIntegerItem represents a big integer on the stack.

func NewBigIntegerItem

func NewBigIntegerItem(value int64) *BigIntegerItem

NewBigIntegerItem returns an new BigIntegerItem object.

func (*BigIntegerItem) Bytes

func (i *BigIntegerItem) Bytes() []byte

Bytes converts i to a slice of bytes.

func (*BigIntegerItem) Dup

func (i *BigIntegerItem) Dup() StackItem

Dup implements StackItem interface.

func (*BigIntegerItem) Equals

func (i *BigIntegerItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*BigIntegerItem) MarshalJSON

func (i *BigIntegerItem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*BigIntegerItem) String

func (i *BigIntegerItem) String() string

func (*BigIntegerItem) ToContractParameter

func (i *BigIntegerItem) ToContractParameter(map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*BigIntegerItem) TryBytes

func (i *BigIntegerItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*BigIntegerItem) Value

func (i *BigIntegerItem) Value() interface{}

Value implements StackItem interface.

type BoolItem

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

BoolItem represents a boolean StackItem.

func NewBoolItem

func NewBoolItem(val bool) *BoolItem

NewBoolItem returns an new BoolItem object.

func (*BoolItem) Bytes

func (i *BoolItem) Bytes() []byte

Bytes converts BoolItem to bytes.

func (*BoolItem) Dup

func (i *BoolItem) Dup() StackItem

Dup implements StackItem interface.

func (*BoolItem) Equals

func (i *BoolItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*BoolItem) MarshalJSON

func (i *BoolItem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*BoolItem) String

func (i *BoolItem) String() string

func (*BoolItem) ToContractParameter

func (i *BoolItem) ToContractParameter(map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*BoolItem) TryBytes

func (i *BoolItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*BoolItem) Value

func (i *BoolItem) Value() interface{}

Value implements StackItem interface.

type ByteArrayItem

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

ByteArrayItem represents a byte array on the stack.

func NewByteArrayItem

func NewByteArrayItem(b []byte) *ByteArrayItem

NewByteArrayItem returns an new ByteArrayItem object.

func (*ByteArrayItem) Dup

func (i *ByteArrayItem) Dup() StackItem

Dup implements StackItem interface.

func (*ByteArrayItem) Equals

func (i *ByteArrayItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*ByteArrayItem) MarshalJSON

func (i *ByteArrayItem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*ByteArrayItem) String

func (i *ByteArrayItem) String() string

func (*ByteArrayItem) ToContractParameter

func (i *ByteArrayItem) ToContractParameter(map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*ByteArrayItem) TryBytes

func (i *ByteArrayItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*ByteArrayItem) Value

func (i *ByteArrayItem) Value() interface{}

Value implements StackItem interface.

type Context

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

Context represents the current execution context of the VM.

func NewContext

func NewContext(b []byte) *Context

NewContext returns a new Context object.

func (*Context) Copy

func (c *Context) Copy() *Context

Copy returns an new exact copy of c.

func (*Context) CurrInstr

func (c *Context) CurrInstr() (int, opcode.Opcode)

CurrInstr returns the current instruction and opcode.

func (*Context) Dup

func (c *Context) Dup() StackItem

Dup implements StackItem interface.

func (*Context) Equals

func (c *Context) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*Context) IP

func (c *Context) IP() int

IP returns the absolute instruction without taking 0 into account. If that program starts the ip = 0 but IP() will return 1, cause its the first instruction.

func (*Context) LenInstr

func (c *Context) LenInstr() int

LenInstr returns the number of instructions loaded.

func (*Context) Next

func (c *Context) Next() (opcode.Opcode, []byte, error)

Next returns the next instruction to execute with its parameter if any. After its invocation the instruction pointer points to the instruction being returned.

func (*Context) NextIP

func (c *Context) NextIP() int

NextIP returns next instruction pointer.

func (*Context) Program

func (c *Context) Program() []byte

Program returns the loaded program.

func (*Context) ScriptHash

func (c *Context) ScriptHash() util.Uint160

ScriptHash returns a hash of the script in the current context.

func (*Context) String

func (c *Context) String() string

func (*Context) ToContractParameter

func (c *Context) ToContractParameter(map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*Context) TryBytes

func (c *Context) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*Context) Value

func (c *Context) Value() interface{}

Value implements StackItem interface.

type Element

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

Element represents an element in the double linked list (the stack), which will hold the underlying StackItem.

func NewElement

func NewElement(v interface{}) *Element

NewElement returns a new Element object, with its underlying value inferred to the corresponding type.

func (*Element) Array

func (e *Element) Array() []StackItem

Array attempts to get the underlying value of the element as an array of other items. Will panic if the item type is different which will be caught by the VM.

func (*Element) BigInt

func (e *Element) BigInt() *big.Int

BigInt attempts to get the underlying value of the element as a big integer. Will panic if the assertion failed which will be caught by the VM.

func (*Element) Bool

func (e *Element) Bool() bool

Bool attempts to get the underlying value of the element as a boolean. Will panic if the assertion failed which will be caught by the VM.

func (*Element) Bytes

func (e *Element) Bytes() []byte

Bytes attempts to get the underlying value of the element as a byte array. Will panic if the assertion failed which will be caught by the VM.

func (*Element) Interop

func (e *Element) Interop() *InteropItem

Interop attempts to get the underlying value of the element as an interop item.

func (*Element) Item

func (e *Element) Item() StackItem

Item returns StackItem contained in the element.

func (*Element) Next

func (e *Element) Next() *Element

Next returns the next element in the stack.

func (*Element) Prev

func (e *Element) Prev() *Element

Prev returns the previous element in the stack.

func (*Element) TryBool

func (e *Element) TryBool() (bool, error)

TryBool attempts to get the underlying value of the element as a boolean. Returns error if can't convert value to boolean type.

func (*Element) Value

func (e *Element) Value() interface{}

Value returns value of the StackItem contained in the element.

type InteropFunc

type InteropFunc func(vm *VM) error

InteropFunc allows to hook into the VM.

type InteropFuncPrice

type InteropFuncPrice struct {
	Func  InteropFunc
	Price int
}

InteropFuncPrice represents an interop function with a price.

type InteropGetterFunc

type InteropGetterFunc func(uint32) *InteropFuncPrice

InteropGetterFunc is a function that returns an interop function-price structure by the given interop ID.

type InteropItem

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

InteropItem represents interop data on the stack.

func NewInteropItem

func NewInteropItem(value interface{}) *InteropItem

NewInteropItem returns new InteropItem object.

func NewMapIterator

func NewMapIterator(m *MapItem) *InteropItem

NewMapIterator returns new interop item containing iterator over m.

func (*InteropItem) Dup

func (i *InteropItem) Dup() StackItem

Dup implements StackItem interface.

func (*InteropItem) Equals

func (i *InteropItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*InteropItem) MarshalJSON

func (i *InteropItem) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*InteropItem) String

func (i *InteropItem) String() string

String implements stringer interface.

func (*InteropItem) ToContractParameter

func (i *InteropItem) ToContractParameter(map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*InteropItem) TryBytes

func (i *InteropItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*InteropItem) Value

func (i *InteropItem) Value() interface{}

Value implements StackItem interface.

type Iterator added in v0.75.0

type Iterator interface {
	Key() StackItem
	// contains filtered or unexported methods
}

Iterator defined public interface for VM's iterator type.

type MapElement added in v0.75.0

type MapElement struct {
	Key   StackItem
	Value StackItem
}

MapElement is a key-value pair of StackItems.

type MapItem

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

MapItem represents Map object. It's ordered, so we use slice representation which should be fine for maps with less than 32 or so elements. Given that our VM has quite low limit of overall stack items, it should be good enough, but it can be extended with a real map for fast random access in the future if need be.

func NewMapItem

func NewMapItem() *MapItem

NewMapItem returns new MapItem object.

func (*MapItem) Add

func (i *MapItem) Add(key, value StackItem)

Add adds key-value pair to the map.

func (*MapItem) Drop added in v0.75.0

func (i *MapItem) Drop(index int)

Drop removes given index from the map (no bounds check done here).

func (*MapItem) Dup

func (i *MapItem) Dup() StackItem

Dup implements StackItem interface.

func (*MapItem) Equals

func (i *MapItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*MapItem) Has

func (i *MapItem) Has(key StackItem) bool

Has checks if map has specified key.

func (*MapItem) Index added in v0.75.0

func (i *MapItem) Index(key StackItem) int

Index returns an index of the key in map.

func (*MapItem) String

func (i *MapItem) String() string

func (*MapItem) ToContractParameter

func (i *MapItem) ToContractParameter(seen map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*MapItem) TryBytes

func (i *MapItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*MapItem) Value

func (i *MapItem) Value() interface{}

Value implements StackItem interface.

type Stack

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

Stack represents a Stack backed by a double linked list.

func NewStack

func NewStack(n string) *Stack

NewStack returns a new stack name by the given name.

func (*Stack) Back

func (s *Stack) Back() *Element

Back returns the element at the end of the stack. Nil if the stack is empty.

func (*Stack) Clear

func (s *Stack) Clear()

Clear clears all elements on the stack and set its length to 0.

func (*Stack) Dup

func (s *Stack) Dup(n int) *Element

Dup duplicates and returns the element at position n. Dup is used for copying elements on to the top of its own stack.

s.Push(s.Peek(0)) // will result in unexpected behaviour.
s.Push(s.Dup(0)) // is the correct approach.

func (*Stack) InsertAt

func (s *Stack) InsertAt(e *Element, n int) *Element

InsertAt inserts the given item (n) deep on the stack. Be very careful using it and _always_ check both e and n before invocation as it will silently do wrong things otherwise.

func (*Stack) Iter

func (s *Stack) Iter(f func(*Element))

Iter iterates over all the elements int the stack, starting from the top of the stack.

s.Iter(func(elem *Element) {
	// do something with the element.
})

func (*Stack) IterBack

func (s *Stack) IterBack(f func(*Element))

IterBack iterates over all the elements of the stack, starting from the bottom of the stack.

s.IterBack(func(elem *Element) {
	// do something with the element.
})

func (*Stack) Len

func (s *Stack) Len() int

Len returns the number of elements that are on the stack.

func (*Stack) MarshalJSON

func (s *Stack) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON marshalling interface.

func (*Stack) Peek

func (s *Stack) Peek(n int) *Element

Peek returns the element (n) far in the stack beginning from the top of the stack.

n = 0 => will return the element on top of the stack.

func (*Stack) Pop

func (s *Stack) Pop() *Element

Pop removes and returns the element on top of the stack.

func (*Stack) Push

func (s *Stack) Push(e *Element)

Push pushes the given element on the stack.

func (*Stack) PushVal

func (s *Stack) PushVal(v interface{})

PushVal pushes the given value on the stack. It will infer the underlying StackItem to its corresponding type.

func (*Stack) Remove

func (s *Stack) Remove(e *Element) *Element

Remove removes and returns the given element from the stack.

func (*Stack) RemoveAt

func (s *Stack) RemoveAt(n int) *Element

RemoveAt removes the element (n) deep on the stack beginning from the top of the stack.

func (*Stack) Roll

func (s *Stack) Roll(n int) error

Roll brings an item with the given index to the top of the stack, moving all the other elements down accordingly. It does all of that without popping and pushing elements.

func (*Stack) Swap

func (s *Stack) Swap(n1, n2 int) error

Swap swaps two elements on the stack without popping and pushing them.

func (*Stack) ToContractParameters

func (s *Stack) ToContractParameters() []smartcontract.Parameter

ToContractParameters converts Stack to slice of smartcontract.Parameter.

func (*Stack) Top

func (s *Stack) Top() *Element

Top returns the element on top of the stack. Nil if the stack is empty.

type StackItem

type StackItem interface {
	fmt.Stringer
	Value() interface{}
	// Dup duplicates current StackItem.
	Dup() StackItem
	// TryBytes converts StackItem to a byte slice.
	TryBytes() ([]byte, error)
	// Equals checks if 2 StackItems are equal.
	Equals(s StackItem) bool
	// ToContractParameter converts StackItem to smartcontract.Parameter
	ToContractParameter(map[StackItem]bool) smartcontract.Parameter
}

A StackItem represents the "real" value that is pushed on the stack.

func DecodeBinaryStackItem

func DecodeBinaryStackItem(r *io.BinReader) StackItem

DecodeBinaryStackItem decodes previously serialized StackItem from the given reader. It's similar to the io.Serializable's DecodeBinary(), but implemented as a function because StackItem itself is an interface. Caveat: always check reader's error value before using the returned StackItem.

func DeserializeItem

func DeserializeItem(data []byte) (StackItem, error)

DeserializeItem decodes StackItem from the given byte slice.

type State

type State uint8

State of the VM.

func StateFromString

func StateFromString(s string) (st State, err error)

StateFromString converts string into the VM State.

func (State) HasFlag

func (s State) HasFlag(f State) bool

HasFlag checks for State flag presence.

func (State) MarshalJSON

func (s State) MarshalJSON() (data []byte, err error)

MarshalJSON implements the json.Marshaler interface.

func (State) String

func (s State) String() string

String implements the stringer interface.

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Marshaler interface.

type StateMessage

type StateMessage string

StateMessage is a vm state message which could be used as additional info for example by cli.

type StructItem

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

StructItem represents a struct on the stack.

func NewStructItem

func NewStructItem(items []StackItem) *StructItem

NewStructItem returns an new StructItem object.

func (*StructItem) Clone

func (i *StructItem) Clone() *StructItem

Clone returns a Struct with all Struct fields copied by value. Array fields are still copied by reference.

func (*StructItem) Dup

func (i *StructItem) Dup() StackItem

Dup implements StackItem interface.

func (*StructItem) Equals

func (i *StructItem) Equals(s StackItem) bool

Equals implements StackItem interface.

func (*StructItem) String

func (i *StructItem) String() string

func (*StructItem) ToContractParameter

func (i *StructItem) ToContractParameter(seen map[StackItem]bool) smartcontract.Parameter

ToContractParameter implements StackItem interface.

func (*StructItem) TryBytes

func (i *StructItem) TryBytes() ([]byte, error)

TryBytes implements StackItem interface.

func (*StructItem) Value

func (i *StructItem) Value() interface{}

Value implements StackItem interface.

type VM

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

VM represents the virtual machine.

func New

func New() *VM

New returns a new VM object ready to load .avm bytecode scripts.

func (*VM) AddBreakPoint

func (v *VM) AddBreakPoint(n int)

AddBreakPoint adds a breakpoint to the current context.

func (*VM) AddBreakPointRel

func (v *VM) AddBreakPointRel(n int)

AddBreakPointRel adds a breakpoint relative to the current instruction pointer.

func (*VM) Astack

func (v *VM) Astack() *Stack

Astack returns the alt stack so interop hooks can utilize this.

func (*VM) AtBreakpoint

func (v *VM) AtBreakpoint() bool

AtBreakpoint returns whether VM is at breakpoint.

func (*VM) Context

func (v *VM) Context() *Context

Context returns the current executed context. Nil if there is no context, which implies no program is loaded.

func (*VM) Estack

func (v *VM) Estack() *Stack

Estack returns the evaluation stack so interop hooks can utilize this.

func (*VM) GasConsumed

func (v *VM) GasConsumed() util.Fixed8

GasConsumed returns the amount of GAS consumed during execution.

func (*VM) GetInteropByID

func (v *VM) GetInteropByID(id uint32) *InteropFuncPrice

GetInteropByID returns interop function together with price. Registered callbacks are checked in LIFO order.

func (*VM) GetPublicKeys

func (v *VM) GetPublicKeys() map[string]*keys.PublicKey

GetPublicKeys returns internal key cache (note that it doesn't copy it).

func (*VM) HasFailed

func (v *VM) HasFailed() bool

HasFailed returns whether VM is in the failed state now. Usually used to check status after Run.

func (*VM) HasHalted

func (v *VM) HasHalted() bool

HasHalted returns whether VM is in Halt state.

func (*VM) HasStopped

func (v *VM) HasStopped() bool

HasStopped returns whether VM is in Halt or Failed state.

func (*VM) Istack

func (v *VM) Istack() *Stack

Istack returns the invocation stack so interop hooks can utilize this.

func (*VM) Load

func (v *VM) Load(prog []byte)

Load initializes the VM with the program given.

func (*VM) LoadArgs

func (v *VM) LoadArgs(method []byte, args []StackItem)

LoadArgs loads in the arguments used in the Mian entry point.

func (*VM) LoadFile

func (v *VM) LoadFile(path string) error

LoadFile loads a program from the given path, ready to execute it.

func (*VM) LoadScript

func (v *VM) LoadScript(b []byte)

LoadScript loads a script from the internal script table. It will immediately push a new context created from this script to the invocation stack and starts executing it.

func (*VM) PopResult

func (v *VM) PopResult() interface{}

PopResult is used to pop the first item of the evaluation stack. This allows us to test compiler and vm in a bi-directional way.

func (*VM) PrintOps

func (v *VM) PrintOps()

PrintOps prints the opcodes of the current loaded program to stdout.

func (*VM) Ready

func (v *VM) Ready() bool

Ready returns true if the VM ready to execute the loaded program. Will return false if no program is loaded.

func (*VM) RegisterInteropGetter

func (v *VM) RegisterInteropGetter(f InteropGetterFunc)

RegisterInteropGetter registers the given InteropGetterFunc into VM. There can be many interop getters and they're probed in LIFO order wrt their registration time.

func (*VM) Run

func (v *VM) Run() error

Run starts the execution of the loaded program.

func (*VM) SetCheckedHash

func (v *VM) SetCheckedHash(h []byte)

SetCheckedHash sets checked hash for CHECKSIG and CHECKMULTISIG instructions.

func (*VM) SetGasLimit

func (v *VM) SetGasLimit(max util.Fixed8)

SetGasLimit sets maximum amount of gas which v can spent. If max <= 0, no limit is imposed.

func (*VM) SetPriceGetter

func (v *VM) SetPriceGetter(f func(*VM, opcode.Opcode, []byte) util.Fixed8)

SetPriceGetter registers the given PriceGetterFunc in v. f accepts vm's Context, current instruction and instruction parameter.

func (*VM) SetPublicKeys

func (v *VM) SetPublicKeys(keys map[string]*keys.PublicKey)

SetPublicKeys sets internal key cache to the specified value (note that it doesn't copy them).

func (*VM) SetScriptGetter

func (v *VM) SetScriptGetter(gs func(util.Uint160) ([]byte, bool))

SetScriptGetter sets the script getter for CALL instructions.

func (*VM) Stack

func (v *VM) Stack(n string) string

Stack returns json formatted representation of the given stack.

func (*VM) State

func (v *VM) State() string

State returns string representation of the state for the VM.

func (*VM) Step

func (v *VM) Step() error

Step 1 instruction in the program.

func (*VM) StepInto

func (v *VM) StepInto() error

StepInto behaves the same as “step over” in case if the line does not contain a function. Otherwise the debugger will enter the called function and continue line-by-line debugging there.

func (*VM) StepOut

func (v *VM) StepOut() error

StepOut takes the debugger to the line where the current function was called.

func (*VM) StepOver

func (v *VM) StepOver() error

StepOver takes the debugger to the line that will step over a given line. If the line contains a function the function will be executed and the result returned without debugging each line.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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