vm

package
v1.2.3-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: GPL-3.0 Imports: 24 Imported by: 9

Documentation

Overview

* Package vm implements the vite virtual machine

Index

Constants

View Source
const (
	Retry   = true
	NoRetry = false
)
View Source
const (
	STOP opCode = iota
	ADD
	MUL
	SUB
	DIV
	SDIV
	MOD
	SMOD
	ADDMOD
	MULMOD
	EXP
	SIGNEXTEND
)

0x0 range - arithmetic ops.

View Source
const (
	LT opCode = iota + 0x10
	GT
	SLT
	SGT
	EQ
	ISZERO
	AND
	OR
	XOR
	NOT
	BYTE
	SHL
	SHR
	SAR
)

0x10 range - comparison ops.

View Source
const (
	ADDRESS opCode = 0x30 + iota
	BALANCE
	ORIGIN
	CALLER
	CALLVALUE
	CALLDATALOAD
	CALLDATASIZE
	CALLDATACOPY
	CODESIZE
	CODECOPY
	GASPRICE
	EXTCODESIZE
	EXTCODECOPY
	RETURNDATASIZE
	RETURNDATACOPY
	EXTCODEHASH
)

0x30 range - closure state.

View Source
const (
	BLOCKHASH opCode = 0x40 + iota
	COINBASE
	TIMESTAMP
	HEIGHT
	DIFFICULTY
	GASLIMIT
	TOKENID
)

0x40 range - block operations.

View Source
const (
	POP opCode = 0x50 + iota
	MLOAD
	MSTORE
	MSTORE8
	SLOAD
	SSTORE
	JUMP
	JUMPI
	PC
	MSIZE
	GAS
	JUMPDEST
)

0x50 range - 'storage' and execution.

View Source
const (
	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
)

0x60 range.

View Source
const (
	LOG0 opCode = 0xa0 + iota
	LOG1
	LOG2
	LOG3
	LOG4
)

0xa0 range - logging ops.

View Source
const (
	CREATE opCode = 0xf0 + iota
	CALL
	CALLCODE
	RETURN
	DELEGATECALL
	STATICCALL = 0xfa

	REVERT       = 0xfd
	SELFDESTRUCT = 0xff
)

0xf0 range - closures.

View Source
const (
	BLAKE2B opCode = 0x21
)
View Source
const (
	MaxCodeSize = 24575 // Maximum bytecode to permit for a contract

)

Variables

View Source
var (
	ResultSuccess  = byte(0)
	ResultFail     = byte(1)
	ResultDepthErr = byte(2)
)

Functions

func GetPrecompiledContract added in v1.3.0

func GetPrecompiledContract(addr types.Address, methodSelector []byte) (contracts.PrecompiledContractMethod, bool, error)

func InitLog added in v1.2.0

func InitLog(dir, lvl string)

func InitVmConfig

func InitVmConfig(isTest bool, isTestParam bool, isDebug bool, datadir string)

func IsTest added in v1.2.0

func IsTest() bool

func StringToOp

func StringToOp(str string) opCode

StringToOp finds the opcode whose name is stored in `str`.

Types

type Interpreter

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

func (*Interpreter) Run

func (i *Interpreter) Run(vm *VM, c *contract) (ret []byte, err error)

type NodeConfig

type NodeConfig struct {
	IsDebug bool
	// contains filtered or unexported fields
}

type VM

type VM struct {
	VMConfig

	VmContext
	// contains filtered or unexported fields
}

func NewVM

func NewVM() *VM

func (*VM) Cancel

func (vm *VM) Cancel()

func (*VM) Run

func (vm *VM) Run(database vmctxt_interface.VmDatabase, block *ledger.AccountBlock, sendBlock *ledger.AccountBlock) (blockList []*vm_context.VmAccountBlock, isRetry bool, err error)

type VMConfig

type VMConfig struct {
	Debug bool
}

type VmContext

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

func (*VmContext) AppendBlock

func (context *VmContext) AppendBlock(block *vm_context.VmAccountBlock)

func (*VmContext) GetNewBlockHeight

func (context *VmContext) GetNewBlockHeight(block *vm_context.VmAccountBlock) uint64

Directories

Path Synopsis
abi

Jump to

Keyboard shortcuts

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