wasmhost

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OBJTYPE_ARRAY    int32 = 0x20
	OBJTYPE_ARRAY16  int32 = 0x30
	OBJTYPE_CALL     int32 = 0x40
	OBJTYPE_TYPEMASK int32 = 0x0f

	OBJTYPE_ADDRESS    int32 = 1
	OBJTYPE_AGENT_ID   int32 = 2
	OBJTYPE_BYTES      int32 = 3
	OBJTYPE_CHAIN_ID   int32 = 4
	OBJTYPE_COLOR      int32 = 5
	OBJTYPE_HASH       int32 = 6
	OBJTYPE_HNAME      int32 = 7
	OBJTYPE_INT16      int32 = 8
	OBJTYPE_INT32      int32 = 9
	OBJTYPE_INT64      int32 = 10
	OBJTYPE_MAP        int32 = 11
	OBJTYPE_REQUEST_ID int32 = 12
	OBJTYPE_STRING     int32 = 13
)
View Source
const (
	KeyAccountID       = int32(-1)
	KeyAddress         = int32(-2)
	KeyBalances        = int32(-3)
	KeyBase58Decode    = int32(-4)
	KeyBase58Encode    = int32(-5)
	KeyBlsAddress      = int32(-6)
	KeyBlsAggregate    = int32(-7)
	KeyBlsValid        = int32(-8)
	KeyCall            = int32(-9)
	KeyCaller          = int32(-10)
	KeyChainID         = int32(-11)
	KeyChainOwnerID    = int32(-12)
	KeyColor           = int32(-13)
	KeyContract        = int32(-14)
	KeyContractCreator = int32(-15)
	KeyDeploy          = int32(-16)
	KeyEd25519Address  = int32(-17)
	KeyEd25519Valid    = int32(-18)
	KeyEvent           = int32(-19)
	KeyExports         = int32(-20)
	KeyHashBlake2b     = int32(-21)
	KeyHashSha3        = int32(-22)
	KeyHname           = int32(-23)
	KeyIncoming        = int32(-24)
	KeyLength          = int32(-25)
	KeyLog             = int32(-26)
	KeyMaps            = int32(-27)
	KeyMinted          = int32(-28)
	KeyName            = int32(-29)
	KeyPanic           = int32(-30)
	KeyParams          = int32(-31)
	KeyPost            = int32(-32)
	KeyRandom          = int32(-33)
	KeyRequestID       = int32(-34)
	KeyResults         = int32(-35)
	KeyReturn          = int32(-36)
	KeyState           = int32(-37)
	KeyTimestamp       = int32(-38)
	KeyTrace           = int32(-39)
	KeyTransfers       = int32(-40)
	KeyUtility         = int32(-41)
	KeyValid           = int32(-42)

	// KeyZzzzzzz is treated like a version number.
	// When anything changes to the keys give this one a different value
	// and make sure that the client side is updated accordingly
	KeyZzzzzzz = int32(-43)
)
View Source
const KeyFromBytes int32 = 0x4000

flag to indicate that this key id originally comes from a bytes key this allows us to display better readable tracing information

Variables

View Source
var (
	// DisableWasmTimeout can be used to disable the annoying timeout during debugging
	DisableWasmTimeout = false

	// HostTracing turns on debug tracing for ScHost calls
	HostTracing = false

	// HostTracingAll turns on *all* debug tracing for ScHost calls
	HostTracingAll = false

	// WasmTimeout set this to non-zero for a one-time override of the defaultTimeout
	WasmTimeout = 0 * time.Second
)

Functions

This section is empty.

Types

type HostObject

type HostObject interface {
	CallFunc(keyID int32, params []byte) []byte
	Exists(keyID, typeID int32) bool
	GetBytes(keyID, typeID int32) []byte
	GetObjectID(keyID, typeID int32) int32
	GetTypeID(keyID int32) int32
	SetBytes(keyID, typeID int32, bytes []byte)
}

type KvStoreHost

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

KvStoreHost implements WaspLib.client.ScHost interface it allows WasmGoVM to bypass Wasm and access the sandbox directly so that it is possible to debug into SC code that was written in Go

func (*KvStoreHost) CallFunc added in v0.2.0

func (h *KvStoreHost) CallFunc(objID, keyID int32, params []byte) []byte

func (*KvStoreHost) Exists

func (h *KvStoreHost) Exists(objID, keyID, typeID int32) bool

func (*KvStoreHost) FindObject

func (h *KvStoreHost) FindObject(objID int32) HostObject

func (*KvStoreHost) GetBytes

func (h *KvStoreHost) GetBytes(objID, keyID, typeID int32) []byte

func (*KvStoreHost) GetKeyFromID added in v0.2.0

func (h *KvStoreHost) GetKeyFromID(keyID int32) []byte

func (*KvStoreHost) GetKeyIDFromBytes added in v0.2.0

func (h *KvStoreHost) GetKeyIDFromBytes(bytes []byte) int32

func (*KvStoreHost) GetKeyIDFromString added in v0.2.0

func (h *KvStoreHost) GetKeyIDFromString(key string) int32

func (*KvStoreHost) GetKeyStringFromID added in v0.2.0

func (h *KvStoreHost) GetKeyStringFromID(keyID int32) string

func (*KvStoreHost) GetObjectID added in v0.2.0

func (h *KvStoreHost) GetObjectID(objID, keyID, typeID int32) int32

func (*KvStoreHost) Init

func (h *KvStoreHost) Init(scKeys *KvStoreHost)

func (*KvStoreHost) SetBytes

func (h *KvStoreHost) SetBytes(objID, keyID, typeID int32, bytes []byte)

func (*KvStoreHost) TraceAllf added in v0.2.0

func (h *KvStoreHost) TraceAllf(format string, a ...interface{})

func (*KvStoreHost) Tracef added in v0.2.0

func (h *KvStoreHost) Tracef(format string, a ...interface{})

func (*KvStoreHost) TrackObject

func (h *KvStoreHost) TrackObject(obj HostObject) int32

type WasmGoVM added in v0.2.0

type WasmGoVM struct {
	WasmVMBase
	// contains filtered or unexported fields
}

func NewWasmGoVM added in v0.2.0

func NewWasmGoVM(scName string, onLoad func()) *WasmGoVM

func (*WasmGoVM) Interrupt added in v0.2.0

func (vm *WasmGoVM) Interrupt()

func (*WasmGoVM) LoadWasm added in v0.2.0

func (vm *WasmGoVM) LoadWasm(wasmData []byte) error

func (*WasmGoVM) RunFunction added in v0.2.0

func (vm *WasmGoVM) RunFunction(functionName string, args ...interface{}) error

func (*WasmGoVM) RunScFunction added in v0.2.0

func (vm *WasmGoVM) RunScFunction(index int32) error

func (*WasmGoVM) UnsafeMemory added in v0.2.0

func (vm *WasmGoVM) UnsafeMemory() []byte

type WasmHost

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

func (*WasmHost) AddFunc added in v0.2.0

func (host *WasmHost) AddFunc(f func(ctx wasmlib.ScFuncContext)) []func(ctx wasmlib.ScFuncContext)

func (*WasmHost) AddView added in v0.2.0

func (host *WasmHost) AddView(v func(ctx wasmlib.ScViewContext)) []func(ctx wasmlib.ScViewContext)

func (*WasmHost) FunctionFromCode

func (host *WasmHost) FunctionFromCode(code uint32) string

func (*WasmHost) Init

func (host *WasmHost) Init()

func (*WasmHost) InitVM

func (host *WasmHost) InitVM(vm WasmVM, store WasmStore) error

func (*WasmHost) IsView

func (host *WasmHost) IsView(function string) bool

func (*WasmHost) LoadWasm

func (host *WasmHost) LoadWasm(wasmData []byte) error

func (*WasmHost) RunFunction

func (host *WasmHost) RunFunction(functionName string, args ...interface{}) (err error)

func (*WasmHost) RunScFunction

func (host *WasmHost) RunScFunction(functionName string) (err error)

func (*WasmHost) SetExport

func (host *WasmHost) SetExport(index int32, functionName string)

type WasmStore added in v0.2.0

type WasmStore interface {
	GetKvStore(id int32) *KvStoreHost
}

type WasmTimeVM

type WasmTimeVM struct {
	WasmVMBase
	// contains filtered or unexported fields
}

func NewWasmTimeVM

func NewWasmTimeVM() *WasmTimeVM

func (*WasmTimeVM) Interrupt added in v0.2.0

func (vm *WasmTimeVM) Interrupt()

func (*WasmTimeVM) LinkHost

func (vm *WasmTimeVM) LinkHost(impl WasmVM, host *WasmHost) error

func (*WasmTimeVM) LoadWasm

func (vm *WasmTimeVM) LoadWasm(wasmData []byte) error

func (*WasmTimeVM) RunFunction

func (vm *WasmTimeVM) RunFunction(functionName string, args ...interface{}) error

func (*WasmTimeVM) RunScFunction

func (vm *WasmTimeVM) RunScFunction(index int32) error

func (*WasmTimeVM) UnsafeMemory

func (vm *WasmTimeVM) UnsafeMemory() []byte

type WasmVM

type WasmVM interface {
	Interrupt()
	LinkHost(impl WasmVM, host *WasmHost) error
	LoadWasm(wasmData []byte) error
	RunFunction(functionName string, args ...interface{}) error
	RunScFunction(index int32) error
	SaveMemory()
	UnsafeMemory() []byte
	VMGetBytes(offset int32, size int32) []byte
	VMSetBytes(offset int32, size int32, bytes []byte) int32
}

type WasmVMBase added in v0.2.0

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

func (*WasmVMBase) HostFdWrite added in v0.2.0

func (vm *WasmVMBase) HostFdWrite(fd, iovs, size, written int32) int32

func (*WasmVMBase) HostGetBytes added in v0.2.0

func (vm *WasmVMBase) HostGetBytes(objID, keyID, typeID, stringRef, size int32) int32

func (*WasmVMBase) HostGetKeyID added in v0.2.0

func (vm *WasmVMBase) HostGetKeyID(keyRef, size int32) int32

func (*WasmVMBase) HostGetObjectID added in v0.2.0

func (vm *WasmVMBase) HostGetObjectID(objID, keyID, typeID int32) int32

func (*WasmVMBase) HostSetBytes added in v0.2.0

func (vm *WasmVMBase) HostSetBytes(objID, keyID, typeID, stringRef, size int32)

func (*WasmVMBase) LinkHost added in v0.2.0

func (vm *WasmVMBase) LinkHost(impl WasmVM, host *WasmHost) error

func (*WasmVMBase) PostCall added in v0.2.0

func (vm *WasmVMBase) PostCall(frame []byte)

func (*WasmVMBase) PreCall added in v0.2.0

func (vm *WasmVMBase) PreCall() []byte

func (*WasmVMBase) Run added in v0.2.0

func (vm *WasmVMBase) Run(runner func() error) (err error)

func (*WasmVMBase) SaveMemory added in v0.2.0

func (vm *WasmVMBase) SaveMemory()

func (*WasmVMBase) VMGetBytes added in v0.2.0

func (vm *WasmVMBase) VMGetBytes(offset, size int32) []byte

func (*WasmVMBase) VMSetBytes added in v0.2.0

func (vm *WasmVMBase) VMSetBytes(offset, size int32, bytes []byte) int32

Jump to

Keyboard shortcuts

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