wasmer

package module
v0.0.0-...-3f6d56f Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

vm-wasmer

介绍

hercules 链vm-wasmer智能合约虚拟机模块

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallDeallocate

func CallDeallocate(instance *wasmer.Instance) error

CallDeallocate deallocate vm memory before closing the instance

func GetVmBridgeManager

func GetVmBridgeManager() *vmBridgeManager

GetVmBridgeManager get singleton vmBridgeManager struct

Types

type CMEnvironment

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

type InstancesManager

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

InstancesManager manages vm pools for all contracts

func NewInstancesManager

func NewInstancesManager(chainId string) *InstancesManager

NewInstancesManager return InstancesManager for every chain

func (*InstancesManager) CloseAVmPool

func (m *InstancesManager) CloseAVmPool(contractId *commonPb.Contract)

close the contract vm pool

func (*InstancesManager) CloseAllVmPool

func (m *InstancesManager) CloseAllVmPool()

close all contract vm pool

func (*InstancesManager) NewRuntimeInstance

func (m *InstancesManager) NewRuntimeInstance(
	txSimContext protocol.TxSimContext,
	chainId, method, codePath string,
	contract *commonPb.Contract,
	byteCode []byte,
	log protocol.Logger) (protocol.RuntimeInstance, error)

NewRuntimeInstance init vm pool and check byteCode correctness

func (*InstancesManager) ResetAVmPool

func (m *InstancesManager) ResetAVmPool(contractId *commonPb.Contract)

FIXME: 确认函数名是否多了字符A?@taifu reset a contract vm pool install

func (*InstancesManager) ResetAllPool

func (m *InstancesManager) ResetAllPool()

reset all contract pool instance

func (*InstancesManager) StartVM

func (m *InstancesManager) StartVM() error

func (*InstancesManager) StopVM

func (m *InstancesManager) StopVM() error

type RuntimeInstance

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

RuntimeInstance wasm runtime

func (*RuntimeInstance) Invoke

func (r *RuntimeInstance) Invoke(contract *commonPb.Contract, method string, byteCode []byte,
	parameters map[string][]byte, txContext protocol.TxSimContext, gasUsed uint64) (
	contractResult *commonPb.ContractResult, specialTxType protocol.ExecOrderTxType)

Invoke contract by call vm, implement protocol.RuntimeInstance

func (*RuntimeInstance) Pool

func (r *RuntimeInstance) Pool() *vmPool

type SimContext

type SimContext struct {
	TxSimContext   protocol.TxSimContext
	Contract       *commonPb.Contract
	ContractResult *commonPb.ContractResult
	Log            *logger.CMLogger
	Instance       *wasmer.Instance

	CtxPtr        int32
	GetStateCache []byte // cache call method GetStateLen value result, one cache per transaction
	ChainId       string
	ContractEvent []*commonPb.ContractEvent
	SpecialTxType protocol.ExecOrderTxType
	// contains filtered or unexported fields
}

SimContext record the contract context

func NewSimContext

func NewSimContext(method string, log *logger.CMLogger, chainId string) *SimContext

NewSimContext for every transaction

func (*SimContext) CallMethod

func (sc *SimContext) CallMethod(instance *wasmer.Instance) error

CallMethod will call contract method

type WaciInstance

type WaciInstance struct {
	Sc          *SimContext
	RequestBody []byte // sdk request param
	Memory      []byte // vm memory
	ChainId     string
}

WaciInstance record wasmer vm request parameter

func (*WaciInstance) CallContract

func (s *WaciInstance) CallContract() int32

CallContractLen get cross contract call result from cache

func (*WaciInstance) CallContractLen

func (s *WaciInstance) CallContractLen() int32

CallContractLen invoke cross contract calls, save result to cache and putout result length

func (*WaciInstance) DeleteState

func (s *WaciInstance) DeleteState() int32

DeleteState delete state from chain

func (*WaciInstance) EmitEvent

func (s *WaciInstance) EmitEvent() int32

EmitEvent emit event to chain

func (*WaciInstance) ErrorResult

func (s *WaciInstance) ErrorResult() int32

ErrorResult record the results of contract execution error

func (*WaciInstance) ExecuteDDL

func (s *WaciInstance) ExecuteDDL() int32

ExecuteDDL execute DDL sql, for init_contract or upgrade method. allow table create/alter/drop/truncate

allow: [CREATE TABLE tableName] [ALTER TABLE tableName]

[DROP TABLE tableName]   [TRUNCATE TABLE tableName]

not allow: [CREATE DATABASE dbName] [CREATE TABLE dbName.tableName] [ALTER TABLE dbName.tableName]

[DROP DATABASE dbName]   [DROP TABLE dbName.tableName]   [TRUNCATE TABLE dbName.tableName]

You must have a primary key to create a table

func (*WaciInstance) ExecuteQuery

func (s *WaciInstance) ExecuteQuery() int32

ExecuteQuery execute query sql, return result set index

func (*WaciInstance) ExecuteQueryOne

func (s *WaciInstance) ExecuteQueryOne() int32

ExecuteQuery execute query sql, return result set index

func (*WaciInstance) ExecuteQueryOneLen

func (s *WaciInstance) ExecuteQueryOneLen() int32

ExecuteQuery execute query sql, return result set index

func (*WaciInstance) ExecuteUpdate

func (s *WaciInstance) ExecuteUpdate() int32

ExecuteUpdate execute update and insert sql, allow single row change as: update table set name = 'Tom' where uniqueKey='xxx'

func (*WaciInstance) GetBulletProofsResult

func (s *WaciInstance) GetBulletProofsResult() int32

GetBulletProofsResult get bulletproofs operation result from chain

func (*WaciInstance) GetBulletProofsResultLen

func (s *WaciInstance) GetBulletProofsResultLen() int32

GetBulletProofsResultLen get bulletproofs operation result length from chain

func (*WaciInstance) GetPaillierResult

func (s *WaciInstance) GetPaillierResult() int32

GetPaillierResult get paillier operation result from chain

func (*WaciInstance) GetPaillierResultLen

func (s *WaciInstance) GetPaillierResultLen() int32

GetPaillierResultLen get paillier operation result length from chain

func (*WaciInstance) GetState

func (s *WaciInstance) GetState() int32

GetStateLen get state from chain

func (*WaciInstance) GetStateLen

func (s *WaciInstance) GetStateLen() int32

GetStateLen get state length from chain

func (*WaciInstance) KvIterator

func (s *WaciInstance) KvIterator() int32

KvIterator Select kv statement

func (*WaciInstance) KvIteratorClose

func (s *WaciInstance) KvIteratorClose() int32

KvIteratorClose Close kv statement

func (*WaciInstance) KvIteratorHasNext

func (s *WaciInstance) KvIteratorHasNext() int32

KvIteratorHasNext to determine whether db has next statement

func (*WaciInstance) KvIteratorNext

func (s *WaciInstance) KvIteratorNext() int32

KvIteratorNext to get kv statement

func (*WaciInstance) KvIteratorNextLen

func (s *WaciInstance) KvIteratorNextLen() int32

func (*WaciInstance) KvPreIterator

func (s *WaciInstance) KvPreIterator() int32

func (*WaciInstance) LogMessage

func (s *WaciInstance) LogMessage() int32

LogMessage print log to file

func (*WaciInstance) PutState

func (s *WaciInstance) PutState() int32

PutState put state to chain

func (*WaciInstance) RSClose

func (s *WaciInstance) RSClose() int32

RSClose close sql statement

func (*WaciInstance) RSHasNext

func (s *WaciInstance) RSHasNext() int32

RSHasNext return is there a next line, 1 is has next row, 0 is no next row

func (*WaciInstance) RSNext

func (s *WaciInstance) RSNext() int32

RSNextLen get one row from result set

func (*WaciInstance) RSNextLen

func (s *WaciInstance) RSNextLen() int32

RSNextLen get result set length from chain

func (*WaciInstance) SuccessResult

func (s *WaciInstance) SuccessResult() int32

SuccessResult record the results of contract execution success

Directories

Path Synopsis
Package wasmer is a complete and mature WebAssembly runtime for Go based on Wasmer (https://github.com/wasmerio/wasmer).
Package wasmer is a complete and mature WebAssembly runtime for Go based on Wasmer (https://github.com/wasmerio/wasmer).
packaged/include
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
packaged/lib
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
packaged/lib/darwin-aarch64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
packaged/lib/darwin-amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
packaged/lib/linux-aarch64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.
packaged/lib/linux-amd64
See https://github.com/golang/go/issues/26366.
See https://github.com/golang/go/issues/26366.

Jump to

Keyboard shortcuts

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