arwen

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLen = 32
View Source
const AddressLenEth = 20
View Source
const ArgumentLenEth = 32
View Source
const BalanceLen = 32
View Source
const HashLen = 32
View Source
const InitFunctionName = "init"
View Source
const InitFunctionNameEth = "solidity.ctor"

Variables

View Source
var ErrFuncNotFound = errors.New("function not found")
View Source
var ErrFunctionRunError = errors.New("function run error")
View Source
var ErrInitFuncCalledInRun = errors.New("it is not allowed to call init in run")
View Source
var ErrInvalidCallOnReadOnlyMode = errors.New("operation not permitted in read only mode")
View Source
var ErrNotEnoughGas = errors.New("not enough gas")
View Source
var ErrReturnCodeNotOk = errors.New("return not is not ok")
View Source
var ErrUnhandledRuntimeBreakpoint = errors.New("unhandled runtime breakpoint")
View Source
var InstanceStackUnderflow = errors.New("Instance stack underflow")
View Source
var StateStackUnderflow = errors.New("State stack underflow")

Functions

func AddHostContext added in v0.2.5

func AddHostContext(ctx VMHost) int

func ConvertReturnValue added in v0.2.5

func ConvertReturnValue(wasmValue wasmer.Value) *big.Int

func GetCryptoContext added in v0.2.5

func GetCryptoContext(context unsafe.Pointer) vmcommon.CryptoHook

func GuardedGetBytesSlice added in v0.3.2

func GuardedGetBytesSlice(data []byte, offset int32, length int32) ([]byte, error)

func GuardedMakeByteSlice2D added in v0.3.2

func GuardedMakeByteSlice2D(length int32) ([][]byte, error)

func InverseBytes added in v0.3.2

func InverseBytes(data []byte) []byte

func RemoveHostContext added in v0.2.5

func RemoveHostContext(idx int)

Types

type BigIntContext added in v0.2.5

type BigIntContext interface {
	StateStack

	Put(value int64) int32
	GetOne(id int32) *big.Int
	GetTwo(id1, id2 int32) (*big.Int, *big.Int)
	GetThree(id1, id2, id3 int32) (*big.Int, *big.Int, *big.Int)
}

func GetBigIntContext added in v0.2.5

func GetBigIntContext(context unsafe.Pointer) BigIntContext

type BlockchainContext added in v0.3.3

type BlockchainContext interface {
	NewAddress(creatorAddress []byte) ([]byte, error)
	AccountExists(addr []byte) bool
	GetBalance(addr []byte) []byte
	GetNonce(addr []byte) (uint64, error)
	CurrentEpoch() uint32
	GetStateRootHash() []byte
	LastTimeStamp() uint64
	LastNonce() uint64
	LastRound() uint64
	LastEpoch() uint32
	CurrentRound() uint64
	CurrentNonce() uint64
	CurrentTimeStamp() uint64
	CurrentRandomSeed() []byte
	LastRandomSeed() []byte
	IncreaseNonce(addr []byte)
	GetCodeHash(addr []byte) ([]byte, error)
	GetCode(addr []byte) ([]byte, error)
	GetCodeSize(addr []byte) (int32, error)
	BlockHash(number int64) []byte
}

func GetBlockchainContext added in v0.3.3

func GetBlockchainContext(context unsafe.Pointer) BlockchainContext

type BreakpointValue added in v0.3.3

type BreakpointValue uint64
const (
	BreakpointNone        BreakpointValue = 0
	BreakpointAbort       BreakpointValue = 1
	BreakpointAsyncCall   BreakpointValue = 2
	BreakpointSignalError BreakpointValue = 3
	BreakpointSignalExit  BreakpointValue = 4
	BreakpointOutOfGas    BreakpointValue = 5
)

type MeteringContext added in v0.3.3

type MeteringContext interface {
	GasSchedule() *config.GasCost
	UseGas(gas uint64)
	FreeGas(gas uint64)
	GasLeft() uint64
	BoundGasLimit(value int64) uint64
	BlockGasLimit() uint64
	DeductInitialGasForExecution(input *vmcommon.ContractCallInput, contract []byte) (uint64, error)
	DeductInitialGasForDirectDeployment(input *vmcommon.ContractCreateInput) (uint64, error)
	DeductInitialGasForIndirectDeployment(input *vmcommon.ContractCreateInput) (uint64, error)
}

func GetMeteringContext added in v0.3.3

func GetMeteringContext(context unsafe.Pointer) MeteringContext

type OutputContext added in v0.3.3

type OutputContext interface {
	StateStack

	GetOutputAccount(address []byte) (*vmcommon.OutputAccount, bool)
	WriteLog(address []byte, topics [][]byte, data []byte)
	Transfer(destination []byte, sender []byte, gasLimit uint64, value *big.Int, input []byte)
	SelfDestruct(address []byte, beneficiary []byte)
	GetRefund() uint64
	SetRefund(refund uint64)
	ReturnCode() vmcommon.ReturnCode
	SetReturnCode(returnCode vmcommon.ReturnCode)
	ReturnMessage() string
	SetReturnMessage(message string)
	ReturnData() [][]byte
	ClearReturnData()
	Finish(data []byte)
	FinishValue(value wasmer.Value)
	GetVMOutput(result wasmer.Value) *vmcommon.VMOutput
	AddTxValueToAccount(address []byte, value *big.Int)
	DeployCode(address []byte, code []byte)
	CreateVMOutputInCaseOfError(errCode vmcommon.ReturnCode, message string) *vmcommon.VMOutput
}

TODO find a better name

func GetOutputContext added in v0.3.3

func GetOutputContext(context unsafe.Pointer) OutputContext

type RuntimeContext added in v0.3.3

type RuntimeContext interface {
	StateStack

	InitStateFromContractCallInput(input *vmcommon.ContractCallInput)
	GetVMInput() *vmcommon.VMInput
	SetVMInput(vmInput *vmcommon.VMInput)
	GetSCAddress() []byte
	SetSCAddress(scAddress []byte)
	GetVMType() []byte
	Function() string
	Arguments() [][]byte
	SignalUserError(message string)
	SignalExit(exitCode int)
	SetRuntimeBreakpointValue(value BreakpointValue)
	GetRuntimeBreakpointValue() BreakpointValue
	PushInstance()
	PopInstance() error
	ReadOnly() bool
	SetReadOnly(readOnly bool)
	CreateWasmerInstance(contract []byte, gasLimit uint64) error
	SetInstanceContext(instCtx *wasmer.InstanceContext)
	GetInstanceContext() *wasmer.InstanceContext
	GetInstanceExports() wasmer.ExportsMap
	GetInitFunction() wasmer.ExportedFunctionCallback
	GetFunctionToCall() (wasmer.ExportedFunctionCallback, error)
	GetPointsUsed() uint64
	SetPointsUsed(gasPoints uint64)
	MemStore(offset int32, data []byte) error
	MemLoad(offset int32, length int32) ([]byte, error)
	CleanInstance()
	SetInstanceContextId(id int)
}

func GetRuntimeContext added in v0.3.3

func GetRuntimeContext(context unsafe.Pointer) RuntimeContext

type StateStack added in v0.3.3

type StateStack interface {
	InitState()
	PushState()
	PopState() error
}

type StorageContext added in v0.3.3

type StorageContext interface {
	GetStorageUpdates(address []byte) map[string]*vmcommon.StorageUpdate
	GetStorage(address []byte, key []byte) []byte
	SetStorage(address []byte, key []byte, value []byte) int32
}

func GetStorageContext added in v0.3.3

func GetStorageContext(context unsafe.Pointer) StorageContext

type StorageStatus

type StorageStatus int
const (
	StorageUnchanged StorageStatus = 0
	StorageModified  StorageStatus = 1
	StorageAdded     StorageStatus = 3
	StorageDeleted   StorageStatus = 4
)

type VMHost added in v0.3.3

type VMHost interface {
	StateStack

	Crypto() vmcommon.CryptoHook
	Blockchain() BlockchainContext
	Runtime() RuntimeContext
	BigInt() BigIntContext
	Output() OutputContext
	Metering() MeteringContext
	Storage() StorageContext

	CreateNewContract(input *vmcommon.ContractCreateInput) ([]byte, error)
	ExecuteOnSameContext(input *vmcommon.ContractCallInput) error
	ExecuteOnDestContext(input *vmcommon.ContractCallInput) error
	EthereumCallData() []byte
}

func GetVmContext added in v0.3.3

func GetVmContext(context unsafe.Pointer) VMHost

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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