vm

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 21 Imported by: 4

README

Vm is a module for managing all vms(vm-wasmer, vm-evm, vm-gasm and vm-wxvm). It provides the interface for running contracts.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotManageContract = fmt.Errorf("method is not init_contract or upgrade")

Functions

func NewTxSimContext

func NewTxSimContext(vmManager protocol.VmManager, snapshot protocol.Snapshot, tx *common.Transaction,
	blockVersion uint32) protocol.TxSimContext

func NewVmManager

func NewVmManager(instanceManagers map[commonPb.RuntimeType]protocol.VmInstancesManager, wxvmCodePathPrefix string,
	accessControl protocol.AccessControlProvider, chainNodesInfoProvider protocol.ChainNodesInfoProvider,
	chainConf protocol.ChainConf) protocol.VmManager

NewVmManager get vm runtime manager

func PrintTxReadSet

func PrintTxReadSet(txSimContext protocol.TxSimContext)

func PrintTxWriteSet

func PrintTxWriteSet(txSimContext protocol.TxSimContext)

Types

type Bool

type Bool int32

type VmManagerImpl

type VmManagerImpl struct {
	InstanceManagers       map[commonPb.RuntimeType]protocol.VmInstancesManager
	WxvmCodePath           string
	SnapshotManager        protocol.SnapshotManager
	AccessControl          protocol.AccessControlProvider
	ChainNodesInfoProvider protocol.ChainNodesInfoProvider
	ChainId                string
	Log                    *logger.CMLogger
	ChainConf              protocol.ChainConf // chain config
}

func (*VmManagerImpl) GetAccessControl

func (m *VmManagerImpl) GetAccessControl() protocol.AccessControlProvider

func (*VmManagerImpl) GetChainNodesInfoProvider

func (m *VmManagerImpl) GetChainNodesInfoProvider() protocol.ChainNodesInfoProvider

func (*VmManagerImpl) RunContract

func (m *VmManagerImpl) RunContract(contract *commonPb.Contract, method string, byteCode []byte,
	parameters map[string][]byte, txContext protocol.TxSimContext, gasUsed uint64, refTxType commonPb.TxType) (
	*commonPb.ContractResult, commonPb.TxStatusCode)

type Wacsi

type Wacsi interface {
	// state operation
	PutState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext) error
	GetState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte,
		data []byte, isLen bool) ([]byte, error)
	DeleteState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext) error
	// call other contract
	CallContract(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte, data []byte,
		gasUsed uint64, isLen bool) (*common.ContractResult, uint64, error)
	// result record
	SuccessResult(contractResult *common.ContractResult, data []byte) int32
	ErrorResult(contractResult *common.ContractResult, data []byte) int32
	// emit event
	EmitEvent(requestBody []byte, txSimContext protocol.TxSimContext, contractId *common.Contract,
		log protocol.Logger) (*common.ContractEvent, error)
	// paillier
	PaillierOperation(requestBody []byte, memory []byte, data []byte, isLen bool) ([]byte, error)
	// bulletproofs
	BulletProofsOperation(requestBody []byte, memory []byte, data []byte, isLen bool) ([]byte, error)

	// kv iterator
	KvIterator(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte) error
	KvPreIterator(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte) error
	KvIteratorHasNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error
	KvIteratorNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte, data []byte,
		contractName string, isLen bool) ([]byte, error)
	KvIteratorClose(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte) error

	// sql operation
	ExecuteQuery(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte,
		chainId string) error
	ExecuteQueryOne(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte,
		data []byte, chainId string, isLen bool) ([]byte, error)
	ExecuteUpdate(requestBody []byte, contractName string, method string, txSimContext protocol.TxSimContext,
		memory []byte, chainId string) error
	ExecuteDDL(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte,
		method string) error
	RSHasNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error
	RSNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte, data []byte,
		isLen bool) ([]byte, error)
	RSClose(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error
}

Wacsi WebAssembly chainmaker system interface

func NewWacsi

func NewWacsi(logger *logger.CMLogger, verifySql protocol.SqlVerifier) Wacsi

type WacsiImpl

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

func (*WacsiImpl) BulletProofsOperation

func (*WacsiImpl) BulletProofsOperation(requestBody []byte, memory []byte, data []byte, isLen bool) ([]byte, error)

func (*WacsiImpl) CallContract

func (w *WacsiImpl) CallContract(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte,
	data []byte, gasUsed uint64, isLen bool) (*common.ContractResult, uint64, error)

func (*WacsiImpl) DeleteState

func (w *WacsiImpl) DeleteState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext) error

func (*WacsiImpl) EmitEvent

func (w *WacsiImpl) EmitEvent(requestBody []byte, txSimContext protocol.TxSimContext, contractId *common.Contract,
	log protocol.Logger) (*common.ContractEvent, error)

EmitEvent emit event to chain

func (*WacsiImpl) ErrorResult

func (w *WacsiImpl) ErrorResult(contractResult *common.ContractResult, data []byte) int32

func (*WacsiImpl) ExecuteDDL

func (w *WacsiImpl) ExecuteDDL(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte, method string) error

func (*WacsiImpl) ExecuteQuery

func (w *WacsiImpl) ExecuteQuery(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte, chainId string) error

func (*WacsiImpl) ExecuteQueryOne

func (w *WacsiImpl) ExecuteQueryOne(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte, data []byte, chainId string, isLen bool) ([]byte, error)

func (*WacsiImpl) ExecuteUpdate

func (w *WacsiImpl) ExecuteUpdate(requestBody []byte, contractName string, method string,
	txSimContext protocol.TxSimContext, memory []byte, chainId string) error

func (*WacsiImpl) GetState

func (w *WacsiImpl) GetState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext, memory []byte,
	data []byte, isLen bool) ([]byte, error)

func (*WacsiImpl) KvIterator

func (w *WacsiImpl) KvIterator(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte) error

func (*WacsiImpl) KvIteratorClose

func (w *WacsiImpl) KvIteratorClose(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte) error

func (*WacsiImpl) KvIteratorHasNext

func (w *WacsiImpl) KvIteratorHasNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error

func (*WacsiImpl) KvIteratorNext

func (*WacsiImpl) KvIteratorNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte, data []byte,
	contractname string, isLen bool) ([]byte, error)

func (*WacsiImpl) KvPreIterator

func (w *WacsiImpl) KvPreIterator(requestBody []byte, contractName string, txSimContext protocol.TxSimContext,
	memory []byte) error

func (*WacsiImpl) PaillierOperation

func (*WacsiImpl) PaillierOperation(requestBody []byte, memory []byte, data []byte, isLen bool) ([]byte, error)

func (*WacsiImpl) PutState

func (w *WacsiImpl) PutState(requestBody []byte, contractName string, txSimContext protocol.TxSimContext) error

func (*WacsiImpl) RSClose

func (w *WacsiImpl) RSClose(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error

func (*WacsiImpl) RSHasNext

func (w *WacsiImpl) RSHasNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte) error

func (*WacsiImpl) RSNext

func (w *WacsiImpl) RSNext(requestBody []byte, txSimContext protocol.TxSimContext, memory []byte, data []byte,
	isLen bool) ([]byte, error)

func (*WacsiImpl) SuccessResult

func (w *WacsiImpl) SuccessResult(contractResult *common.ContractResult, data []byte) int32

Jump to

Keyboard shortcuts

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