vm

package
v0.0.3-chain Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: GPL-3.0 Imports: 19 Imported by: 6

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 = 0x20 + iota
)
View Source
const (
	MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
)

Variables

View Source
var (
	ErrInsufficientBalance         = errors.New("insufficient balance for transfer")
	ErrContractAddressCreationFail = errors.New("contract address creation fail")
	ErrAddressCollision            = errors.New("contract address collision")
	ErrIdCollision                 = errors.New("id collision")
	ErrExecutionReverted           = errors.New("execution reverted")
	ErrInvalidData                 = errors.New("invalid data")
)
View Source
var SimpleCountingRuleList = map[contracts.ConditionCode]createConsensusGroupCondition{
	contracts.RegisterConditionOfPledge: &registerConditionOfPledge{},
	contracts.VoteConditionOfDefault:    &voteConditionOfDefault{},
	contracts.VoteConditionOfBalance:    &voteConditionOfKeepToken{},
}

Functions

func IsSnapshotGid

func IsSnapshotGid(gid types.Gid) bool

func IsViteToken

func IsViteToken(tokenId types.TokenTypeId) 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 VM

type VM struct {
	VMConfig
	// 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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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