Documentation ¶
Overview ¶
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Variables
- func BlockHeight(proc *exec.Process) uint32
- func CallContract(proc *exec.Process, contractAddr uint32, inputPtr uint32, inputLen uint32) uint32
- func CallOutputLength(proc *exec.Process) uint32
- func CallerAddress(proc *exec.Process, dst uint32)
- func Checkwitness(proc *exec.Process, dst uint32) uint32
- func ContractCreate(proc *exec.Process, codePtr uint32, codeLen uint32, vmType uint32, ...) uint32
- func ContractDestroy(proc *exec.Process)
- func ContractMigrate(proc *exec.Process, codePtr uint32, codeLen uint32, vmType uint32, ...) uint32
- func Debug(proc *exec.Process, ptr uint32, len uint32)
- func EntryAddress(proc *exec.Process, dst uint32)
- func GetAddressBuff(addrs []common.Address) ([]byte, int)
- func GetCallOut(proc *exec.Process, dst uint32)
- func GetCurrentBlockHash(proc *exec.Process, ptr uint32) uint32
- func GetCurrentTxHash(proc *exec.Process, ptr uint32) uint32
- func GetInput(proc *exec.Process, dst uint32)
- func InputLength(proc *exec.Process) uint32
- func NewHostModule() *wasm.Module
- func Notify(proc *exec.Process, ptr uint32, l uint32)
- func RaiseException(proc *exec.Process, ptr uint32, len uint32)
- func ReadWasmMemory(proc *exec.Process, ptr uint32, len uint32) ([]byte, error)
- func ReadWasmModule(code []byte, verify config.VerifyMethod) (*exec.CompiledModule, error)
- func Ret(proc *exec.Process, ptr uint32, len uint32)
- func SelfAddress(proc *exec.Process, dst uint32)
- func Sha256(proc *exec.Process, src uint32, slen uint32, dst uint32)
- func StorageDelete(proc *exec.Process, keyPtr uint32, keyLen uint32)
- func StorageRead(proc *exec.Process, keyPtr uint32, klen uint32, val uint32, vlen uint32, ...) uint32
- func StorageWrite(proc *exec.Process, keyPtr uint32, keyLen uint32, valPtr uint32, valLen uint32)
- func Timestamp(proc *exec.Process) uint64
- func WasmjitValidate(wasmCode []byte) error
- type ContractType
- type Runtime
- type WasmVmService
- func (self *WasmVmService) DeleteCurrentContractStorage() error
- func (self *WasmVmService) DeployContract(code []byte, vmType uint32, name, version, author, email, desc []byte) (addr common.Address, err error)
- func (this *WasmVmService) Invoke() (interface{}, error)
- func (self *WasmVmService) MigrateCurrentContractStorageTo(newAddress common.Address) error
Constants ¶
This section is empty.
Variables ¶
var ( TIMESTAMP_GAS uint64 = 1 BLOCK_HEGHT_GAS uint64 = 1 SELF_ADDRESS_GAS uint64 = 1 CALLER_ADDRESS_GAS uint64 = 1 ENTRY_ADDRESS_GAS uint64 = 1 CHECKWITNESS_GAS uint64 = 200 CALL_CONTRACT_GAS uint64 = 10 CONTRACT_CREATE_GAS uint64 = 20000000 CONTRACT_MIGRATE_GAS uint64 = 20000000 NATIVE_INVOKE_GAS uint64 = 1000 CURRENT_BLOCK_HASH_GAS uint64 = 100 CURRENT_TX_HASH_GAS uint64 = 100 STORAGE_GET_GAS uint64 = 200 STORAGE_PUT_GAS uint64 = 4000 STORAGE_DELETE_GAS uint64 = 100 UINT_DEPLOY_CODE_LEN_GAS uint64 = 200000 PER_UNIT_CODE_LEN uint64 = 1024 SHA256_GAS uint64 = 10 )
var ( ERR_CHECK_STACK_SIZE = errors.NewErr("[WasmVmService] vm over max stack size!") ERR_EXECUTE_CODE = errors.NewErr("[WasmVmService] vm execute code invalid!") ERR_GAS_INSUFFICIENT = errors.NewErr("[WasmVmService] gas insufficient") VM_EXEC_STEP_EXCEED = errors.NewErr("[WasmVmService] vm execute step exceed!") CONTRACT_NOT_EXIST = errors.NewErr("[WasmVmService] Get contract code from db fail") DEPLOYCODE_TYPE_ERROR = errors.NewErr("[WasmVmService] DeployCode type error!") VM_EXEC_FAULT = errors.NewErr("[WasmVmService] vm execute state fault!") VM_INIT_FAULT = errors.NewErr("[WasmVmService] vm init state fault!") CODE_CACHE_SIZE = 100 CONTRACT_METHOD_NAME = "invoke" //max memory size of wasm vm WASM_MEM_LIMITATION uint64 = 10 * 1024 * 1024 VM_STEP_LIMIT = 40000000 WASM_CALLSTACK_LIMIT = 1024 CodeCache *lru.ARCCache )
Functions ¶
func BlockHeight ¶ added in v1.8.0
func CallContract ¶ added in v1.8.0
func CallOutputLength ¶ added in v1.8.0
func CallerAddress ¶ added in v1.8.0
func ContractCreate ¶ added in v1.8.0
func ContractDestroy ¶ added in v1.8.0
func ContractMigrate ¶ added in v1.8.0
func EntryAddress ¶ added in v1.8.0
func GetCallOut ¶ added in v1.8.0
func GetCurrentBlockHash ¶ added in v1.8.0
func GetCurrentTxHash ¶ added in v1.8.0
func InputLength ¶ added in v1.8.0
func NewHostModule ¶ added in v1.8.0
func RaiseException ¶ added in v1.8.0
func ReadWasmMemory ¶ added in v1.8.0
func ReadWasmModule ¶ added in v1.8.0
func ReadWasmModule(code []byte, verify config.VerifyMethod) (*exec.CompiledModule, error)
func SelfAddress ¶ added in v1.8.0
func StorageDelete ¶ added in v1.8.0
func StorageRead ¶ added in v1.8.0
func StorageWrite ¶ added in v1.8.0
func WasmjitValidate ¶ added in v1.9.0
Types ¶
type ContractType ¶ added in v1.8.0
type ContractType byte
const ( NATIVE_CONTRACT ContractType = iota NEOVM_CONTRACT WASMVM_CONTRACT UNKOWN_CONTRACT )
type Runtime ¶ added in v1.8.0
type Runtime struct { Service *WasmVmService Input []byte Output []byte CallOutPut []byte }
type WasmVmService ¶
type WasmVmService struct { CacheDB *storage.CacheDB ContextRef context.ContextRef Notifications []*event.NotifyEventInfo Code []byte Tx *types.Transaction Time uint32 Height uint32 BlockHash common.Uint256 PreExec bool GasPrice uint64 GasLimit *uint64 ExecStep *uint64 GasFactor uint64 IsTerminate bool JitMode bool ServiceIndex uint64 // contains filtered or unexported fields }
func (*WasmVmService) DeleteCurrentContractStorage ¶ added in v1.13.0
func (self *WasmVmService) DeleteCurrentContractStorage() error
func (*WasmVmService) DeployContract ¶ added in v1.13.0
func (*WasmVmService) Invoke ¶ added in v1.8.0
func (this *WasmVmService) Invoke() (interface{}, error)
func (*WasmVmService) MigrateCurrentContractStorageTo ¶ added in v1.13.0
func (self *WasmVmService) MigrateCurrentContractStorageTo(newAddress common.Address) error