Versions in this module Expand all Collapse all v0 v0.0.1 Oct 8, 2022 Changes in this version + const AddressLen + const AndesVersion + const AsyncCallPending + const AsyncCallRejected + const AsyncCallResolved + const AsyncDataPrefix + const BalanceLen + const CallbackFunctionName + const CodeMetadataLen + const HashLen + const InitFunctionName + const InitFunctionNameEth + const ProtectedStoragePrefix + const TimeLockKeyPrefix + const UpgradeFunctionName + var ErrAccountNotPayable = errors.New("sending value to non payable contract") + var ErrArgIndexOutOfRange = errors.New("argument index out of range") + var ErrArgOutOfRange = errors.New("argument out of range") + var ErrAsyncContextDoesNotExist = errors.New("async context does not exist") + var ErrBadBounds = errors.New("bad bounds") + var ErrBadLowerBounds = fmt.Errorf("%w (lower)", ErrBadBounds) + var ErrBadUpperBounds = fmt.Errorf("%w (upper)", ErrBadBounds) + var ErrBitwiseNegative = errors.New("bitwise operations only allowed on positive integers") + var ErrBuiltinCallOnSameContextDisallowed = errors.New("calling built-in function on the same context is disallowed") + var ErrCallBackFuncCalledInRun = fmt.Errorf("%w (calling callBack() directly is forbidden)", ErrInvalidFunction) + var ErrCallBackFuncNotExpected = fmt.Errorf("%w (unexpected callback was received)", ErrInvalidFunction) + var ErrCannotWriteProtectedKey = errors.New("cannot write to protected key") + var ErrContractInvalid = fmt.Errorf("invalid contract code") + var ErrContractNotFound = fmt.Errorf("%w (not found)", ErrContractInvalid) + var ErrDeploymentOverExistingAccount = errors.New("cannot deploy over existing account") + var ErrDivZero = errors.New("division by 0") + var ErrExecutionFailed = errors.New("execution failed") + var ErrFailedTransfer = errors.New("failed transfer") + var ErrFuncNotFound = fmt.Errorf("%w (not found)", ErrInvalidFunction) + var ErrFunctionNonvoidSignature = fmt.Errorf("%w (nonvoid signature)", ErrInvalidFunction) + var ErrInitFuncCalledInRun = fmt.Errorf("%w (calling init() directly is forbidden)", ErrInvalidFunction) + var ErrInputAndOutputGasDoesNotMatch = errors.New("input and output gas does not match") + var ErrInvalidAccount = errors.New("account does not exist") + var ErrInvalidCallOnReadOnlyMode = errors.New("operation not permitted in read only mode") + var ErrInvalidFunction = errors.New("invalid function") + var ErrInvalidFunctionName = fmt.Errorf("%w (invalid name)", ErrInvalidFunction) + var ErrInvalidPublicKeySize = errors.New("invalid public key size") + var ErrInvalidUpgradeArguments = fmt.Errorf("%w (invalid arguments)", ErrUpgradeFailed) + var ErrMaxInstancesReached = fmt.Errorf("%w (max instances reached)", ErrExecutionFailed) + var ErrMemoryDeclarationMissing = fmt.Errorf("%w (missing memory declaration)", ErrContractInvalid) + var ErrNegativeLength = errors.New("negative length") + var ErrNilCallbackFunction = errors.New("nil callback function") + var ErrNilContract = errors.New("nil contract") + var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler") + var ErrNonPayableFunctionMect = errors.New("function does not accept MECT payment") + var ErrNonPayableFunctionMoa = errors.New("function does not accept MOA payment") + var ErrNotEnoughGas = errors.New("not enough gas") + var ErrReturnCodeNotOk = errors.New("return code is not ok") + var ErrShiftNegative = errors.New(...) + var ErrSignalError = errors.New("error signalled by smartcontract") + var ErrStorageValueOutOfRange = errors.New("storage value out of range") + var ErrStoreMotherEarthReservedKey = errors.New("cannot write to storage under MotherEarth reserved key") + var ErrSyncExecutionNotInSameShard = errors.New("sync execution request is not in the same shard") + var ErrTransferInsufficientFunds = fmt.Errorf("%w (insufficient funds)", ErrFailedTransfer) + var ErrTransferNegativeValue = fmt.Errorf("%w (negative value)", ErrFailedTransfer) + var ErrTransferValueOnMECTCall = errors.New("transfer value on mect call") + var ErrUnhandledRuntimeBreakpoint = errors.New("unhandled runtime breakpoint") + var ErrUpgradeFailed = errors.New("upgrade failed") + var ErrUpgradeNotAllowed = errors.New("upgrade not allowed") + var One = big.NewInt(1) + var Zero = big.NewInt(0) + func BooleanToInt(b bool) int + func CustomStorageKey(keyType string, associatedKey []byte) []byte + func GetCryptoContext(vmHostPtr unsafe.Pointer) crypto.VMCrypto + func GetSCCode(fileName string) []byte + func GuardedGetBytesSlice(data []byte, offset int32, length int32) ([]byte, error) + func GuardedMakeByteSlice2D(length int32) ([][]byte, error) + func IfNil(checker nilInterfaceChecker) bool + func InverseBytes(data []byte) []byte + func PadBytesLeft(data []byte, size int) []byte + func SetLoggingForTests() + func U64ToLEB128(n uint64) (out []byte) + func WithFault(err error, vmHostPtr unsafe.Pointer, failExecution bool) bool + func WithFaultAndHost(host VMHost, err error, failExecution bool) bool + type AsyncCallExecutionMode uint + const AsyncBuiltinFuncCrossShard + const AsyncBuiltinFuncIntraShard + const AsyncUnknown + const MECTTransferOnCallBack + const SyncCall + type AsyncCallInfo struct + Data []byte + Destination []byte + GasLimit uint64 + GasLocked uint64 + ValueBytes []byte + func (aci *AsyncCallInfo) GetData() []byte + func (aci *AsyncCallInfo) GetDestination() []byte + func (aci *AsyncCallInfo) GetGasLimit() uint64 + func (aci *AsyncCallInfo) GetGasLocked() uint64 + func (aci *AsyncCallInfo) GetValueBytes() []byte + type AsyncCallInfoHandler interface + GetData func() []byte + GetDestination func() []byte + GetGasLimit func() uint64 + GetGasLocked func() uint64 + GetValueBytes func() []byte + type AsyncCallStatus uint8 + type AsyncContext struct + AsyncCalls []*AsyncGeneratedCall + Callback string + type AsyncContextInfo struct + AsyncContextMap map[string]*AsyncContext + CallerAddr []byte + ReturnData []byte + type AsyncGeneratedCall struct + Data []byte + Destination []byte + ErrorCallback string + GasLimit uint64 + ProvidedGas uint64 + Status AsyncCallStatus + SuccessCallback string + ValueBytes []byte + func (ac *AsyncGeneratedCall) GetData() []byte + func (ac *AsyncGeneratedCall) GetDestination() []byte + func (ac *AsyncGeneratedCall) GetGasLimit() uint64 + func (ac *AsyncGeneratedCall) GetGasLocked() uint64 + func (ac *AsyncGeneratedCall) GetValueBytes() []byte + func (ac *AsyncGeneratedCall) IsInterfaceNil() bool + type BigIntContext interface + GetOne func(id int32) *big.Int + GetThree func(id1, id2, id3 int32) (*big.Int, *big.Int, *big.Int) + GetTwo func(id1, id2 int32) (*big.Int, *big.Int) + Put func(value int64) int32 + func GetBigIntContext(vmHostPtr unsafe.Pointer) BigIntContext + type BlockchainContext interface + AccountExists func(addr []byte) bool + BlockHash func(number int64) []byte + CurrentEpoch func() uint32 + CurrentNonce func() uint64 + CurrentRandomSeed func() []byte + CurrentRound func() uint64 + CurrentTimeStamp func() uint64 + GetBalance func(addr []byte) []byte + GetBalanceBigInt func(addr []byte) *big.Int + GetCode func(addr []byte) ([]byte, error) + GetCodeHash func(addr []byte) []byte + GetCodeSize func(addr []byte) (int32, error) + GetCompiledCode func(codeHash []byte) (bool, []byte) + GetMECTToken func(address []byte, tokenID []byte, nonce uint64) (*mect.MECToken, error) + GetNonce func(addr []byte) (uint64, error) + GetOwnerAddress func() ([]byte, error) + GetShardOfAddress func(addr []byte) uint32 + GetSnapshot func() int + GetStateRootHash func() []byte + GetUserAccount func(address []byte) (vmcommon.UserAccountHandler, error) + IncreaseNonce func(addr []byte) + IsPayable func(address []byte) (bool, error) + IsSmartContract func(addr []byte) bool + LastEpoch func() uint32 + LastNonce func() uint64 + LastRandomSeed func() []byte + LastRound func() uint64 + LastTimeStamp func() uint64 + NewAddress func(creatorAddress []byte) ([]byte, error) + ProcessBuiltInFunction func(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) + RevertToSnapshot func(snapshot int) + SaveCompiledCode func(codeHash []byte, code []byte) + func GetBlockchainContext(vmHostPtr unsafe.Pointer) BlockchainContext + type BreakpointValue uint64 + const BreakpointAsyncCall + const BreakpointExecutionFailed + const BreakpointNone + const BreakpointOutOfGas + const BreakpointSignalError + type CallArgsParser interface + IsInterfaceNil func() bool + ParseData func(data string) (string, [][]byte, error) + type CodeDeployInput struct + CodeDeployerAddress []byte + ContractAddress []byte + ContractCode []byte + ContractCodeMetadata []byte + type InstanceBuilder interface + NewInstanceFromCompiledCodeWithOptions func(compiledCode []byte, options wasmer.CompilationOptions) (wasmer.InstanceHandler, error) + NewInstanceWithOptions func(contractCode []byte, options wasmer.CompilationOptions) (wasmer.InstanceHandler, error) + type MeteringContext interface + BlockGasLimit func() uint64 + BoundGasLimit func(value int64) uint64 + ComputeGasLockedForAsync func() uint64 + DeductInitialGasForDirectDeployment func(input CodeDeployInput) error + DeductInitialGasForExecution func(contract []byte) error + DeductInitialGasForIndirectDeployment func(input CodeDeployInput) error + FreeGas func(gas uint64) + GasLeft func() uint64 + GasSchedule func() *config.GasCost + GasSpentByContract func() uint64 + GasUsedForExecution func() uint64 + GetGasForExecution func() uint64 + GetGasLocked func() uint64 + GetGasProvided func() uint64 + GetSCPrepareInitialCost func() uint64 + InitStateFromContractCallInput func(input *vmcommon.VMInput) + PopMergeActiveState func() + RestoreGas func(gas uint64) + SetGasSchedule func(gasMap config.GasScheduleMap) + TrackGasUsedByBuiltinFunction func(builtinInput *vmcommon.ContractCallInput, builtinOutput *vmcommon.VMOutput, ...) + UpdateGasStateOnFailure func(vmOutput *vmcommon.VMOutput) + UpdateGasStateOnSuccess func(vmOutput *vmcommon.VMOutput) error + UseGas func(gas uint64) + UseGasBounded func(gasToUse uint64) error + UseGasForAsyncStep func() error + func GetMeteringContext(vmHostPtr unsafe.Pointer) MeteringContext + type OutputContext interface + AddToActiveState func(rightOutput *vmcommon.VMOutput) + AddTxValueToAccount func(address []byte, value *big.Int) + CensorVMOutput func() + ClearReturnData func() + CreateVMOutputInCaseOfError func(err error) *vmcommon.VMOutput + DeleteOutputAccount func(address []byte) + DeployCode func(input CodeDeployInput) + Finish func(data []byte) + GetOutputAccount func(address []byte) (*vmcommon.OutputAccount, bool) + GetOutputAccounts func() map[string]*vmcommon.OutputAccount + GetRefund func() uint64 + GetVMOutput func() *vmcommon.VMOutput + PopMergeActiveState func() + PrependFinish func(data []byte) + ReturnCode func() vmcommon.ReturnCode + ReturnData func() [][]byte + ReturnMessage func() string + SelfDestruct func(address []byte, beneficiary []byte) + SetRefund func(refund uint64) + SetReturnCode func(returnCode vmcommon.ReturnCode) + SetReturnMessage func(message string) + Transfer func(destination []byte, sender []byte, gasLimit uint64, gasLocked uint64, ...) error + TransferMECT func(destination []byte, sender []byte, tokenIdentifier []byte, nonce uint64, ...) (uint64, error) + TransferValueOnly func(destination []byte, sender []byte, value *big.Int, checkPayable bool) error + WriteLog func(address []byte, topics [][]byte, data []byte) + func GetOutputContext(vmHostPtr unsafe.Pointer) OutputContext + type RuntimeContext interface + AddAsyncContextCall func(contextIdentifier []byte, asyncCall *AsyncGeneratedCall) error + AddError func(err error, otherInfo ...string) + Arguments func() [][]byte + BigIntAPIErrorShouldFailExecution func() bool + CleanWasmerInstance func() + CryptoAPIErrorShouldFailExecution func() bool + ExecuteAsyncCall func(address []byte, data []byte, value []byte) error + ExtractCodeUpgradeFromArgs func() ([]byte, []byte, error) + FailExecution func(err error) + Function func() string + GetAllErrors func() error + GetAsyncCallInfo func() *AsyncCallInfo + GetAsyncContext func(contextIdentifier []byte) (*AsyncContext, error) + GetAsyncContextInfo func() *AsyncContextInfo + GetCurrentTxHash func() []byte + GetFunctionToCall func() (wasmer.ExportedFunctionCallback, error) + GetInitFunction func() wasmer.ExportedFunctionCallback + GetInstance func() wasmer.InstanceHandler + GetInstanceExports func() wasmer.ExportsMap + GetOriginalTxHash func() []byte + GetPointsUsed func() uint64 + GetRuntimeBreakpointValue func() BreakpointValue + GetSCAddress func() []byte + GetSCCode func() ([]byte, error) + GetSCCodeSize func() uint64 + GetVMInput func() *vmcommon.VMInput + GetVMType func() []byte + InitStateFromContractCallInput func(input *vmcommon.ContractCallInput) + IsContractOnTheStack func(address []byte) bool + IsFunctionImported func(name string) bool + IsWarmInstance func() bool + MemLoad func(offset int32, length int32) ([]byte, error) + MemLoadMultiple func(offset int32, lengths []int32) ([][]byte, error) + MemStore func(offset int32, data []byte) error + MotherEarthAPIErrorShouldFailExecution func() bool + MotherEarthSyncExecAPIErrorShouldFailExecution func() bool + MustVerifyNextContractCode func() + ReadOnly func() bool + ReplaceInstanceBuilder func(builder InstanceBuilder) + ResetWarmInstance func() + RunningInstancesCount func() uint64 + SetAsyncCallInfo func(asyncCallInfo *AsyncCallInfo) + SetCustomCallFunction func(callFunction string) + SetMaxInstanceCount func(uint64) + SetPointsUsed func(gasPoints uint64) + SetReadOnly func(readOnly bool) + SetRuntimeBreakpointValue func(value BreakpointValue) + SetSCAddress func(scAddress []byte) + SetVMInput func(vmInput *vmcommon.VMInput) + SignalUserError func(message string) + StartWasmerInstance func(contract []byte, gasLimit uint64, newCode bool) error + VerifyContractCode func() error + func GetRuntimeContext(vmHostPtr unsafe.Pointer) RuntimeContext + type StateStack interface + ClearStateStack func() + InitState func() + PopDiscard func() + PopSetActiveState func() + PushState func() + type StorageContext interface + GetStorage func(key []byte) []byte + GetStorageFromAddress func(address []byte, key []byte) []byte + GetStorageUnmetered func(key []byte) []byte + GetStorageUpdates func(address []byte) map[string]*vmcommon.StorageUpdate + SetAddress func(address []byte) + SetProtectedStorage func(key []byte, value []byte) (StorageStatus, error) + SetStorage func(key []byte, value []byte) (StorageStatus, error) + func GetStorageContext(vmHostPtr unsafe.Pointer) StorageContext + type StorageStatus int + const StorageAdded + const StorageDeleted + const StorageModified + const StorageUnchanged + type VMHost interface + AreInSameShard func(leftAddress []byte, rightAddress []byte) bool + BigInt func() BigIntContext + Blockchain func() BlockchainContext + CreateNewContract func(input *vmcommon.ContractCreateInput) ([]byte, error) + Crypto func() crypto.VMCrypto + ExecuteMECTTransfer func(destination []byte, sender []byte, tokenIdentifier []byte, nonce uint64, ...) (*vmcommon.VMOutput, uint64, error) + ExecuteOnDestContext func(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, *AsyncContextInfo, error) + ExecuteOnSameContext func(input *vmcommon.ContractCallInput) (*AsyncContextInfo, error) + GetAPIMethods func() *wasmer.Imports + GetContexts func() (BigIntContext, BlockchainContext, MeteringContext, OutputContext, ...) + GetGasScheduleMap func() config.GasScheduleMap + InitState func() + IsAheadOfTimeCompileEnabled func() bool + IsAndesV2Enabled func() bool + IsAndesV3Enabled func() bool + IsBuiltinFunctionName func(functionName string) bool + IsDynamicGasLockingEnabled func() bool + IsMECTFunctionsEnabled func() bool + Metering func() MeteringContext + Output func() OutputContext + Runtime func() RuntimeContext + SetBuiltInFunctionsContainer func(builtInFuncs vmcommon.BuiltInFunctionContainer) + SetRuntimeContext func(runtime RuntimeContext) + Storage func() StorageContext + func GetVMHost(vmHostPtr unsafe.Pointer) VMHost + type VMHostParameters struct + BlockGasLimit uint64 + BuiltInFuncContainer vmcommon.BuiltInFunctionContainer + EnableEpochsHandler vmcommon.EnableEpochsHandler + GasSchedule config.GasScheduleMap + MotherEarthProtectedKeyPrefix []byte + UseWarmInstance bool + VMType []byte + type WrappableError interface + GetAllErrors func() []error + GetBaseError func() error + GetLastError func() error + Is func(target error) bool + Unwrap func() error + WrapWithError func(err error, otherInfo ...string) WrappableError + WrapWithMessage func(errMessage string) WrappableError + WrapWithStackTrace func() WrappableError + func WrapError(err error, otherInfo ...string) WrappableError