types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

DumbGasMeter - gas meter that doesn't count amount of gas during usage.

Errors.

Events types.

Genesis state for VM block.

Basic constants and function to work with types.

Index

Constants

View Source
const (
	CodeEmptyContractCode = 101

	CodeErrWrongAddressLength     = 201
	CodeErrWrongArgTypeTag        = 202
	CodeErrWrongExecutionResponse = 203

	// Errors related to DS (Data Source).
	CodeErrDSMissedValue = 401

	// VM related status codes
	VMCodeExecuted = 4001
)
View Source
const (
	// Event types.
	EventTypeContractStatus = "contract_status"
	EventTypeMvirEvent      = "contract_events"

	// Attributes keys
	AttrKeyStatus         = "status"
	AttrKeyMajorStatus    = "major_status"
	AttrKeySubStatus      = "sub_status"
	AttrKeyMessage        = "message"
	AttrKeySequenceNumber = "sequence_number"
	AttrKeyType           = "type"
	AttrKeyData           = "data"
	AttrKeyGuid           = "guid"

	// Values.
	StatusDiscard = "discard"
	StatusKeep    = "keep"
	StatusError   = "error"
)
View Source
const (
	ModuleName = "vm"

	StoreKey  = ModuleName
	RouterKey = ModuleName

	Codespace         types.CodespaceType = ModuleName
	DefaultParamspace                     = ModuleName

	VmAddressLength = 32
	VmGasPrice      = 1
	VmUnknowTagType = -1
)

Variables

View Source
var (
	MsgDeployModuleType  = "deploy_module"
	MsgExecuteScriptType = "execute_script"
)
View Source
var (
	KeyGenesis = []byte("gen") // used to save genesis
)

VM related variables.

View Source
var ModuleCdc *codec.Codec

module codec

Functions

func Bech32ToLibra

func Bech32ToLibra(acc types.AccAddress) string

Convert bech32 to libra hex.

func ErrDSMissedValue

func ErrDSMissedValue(accessPath vm_grpc.VMAccessPath) sdk.Error

Value missed in Data Source server

func ErrEmptyContract

func ErrEmptyContract() sdk.Error

Msg contract bytes (Module / Script) are empty

func ErrWrongAddressLength

func ErrWrongAddressLength(address sdk.AccAddress) sdk.Error

Wrong address length

func ErrWrongArgTypeTag

func ErrWrongArgTypeTag(err error) sdk.Error

Converting msg.Args VMTypeTag to string failed

func ErrWrongExecutionResponse

func ErrWrongExecutionResponse(resp vm_grpc.VMExecuteResponses) sdk.Error

Move VM can't process request correctly: number of resp.Executions != 1

func GetVMTypeByString

func GetVMTypeByString(typeTag string) (vm_grpc.VMTypeTag, error)

Get TypeTag by string TypeTag representation.

func NewDumbGasMeter

func NewDumbGasMeter() sdk.GasMeter

func NewEventDiscard

func NewEventDiscard(errorStatus *vm_grpc.VMStatus) sdk.Event

New event with discard status.

func NewEventError

func NewEventError(vmStatus *vm_grpc.VMStatus) sdk.Event

New event with error status.

func NewEventFromVM

func NewEventFromVM(event *vm_grpc.VMEvent) sdk.Event

Parse VM event to standard SDK event. In case of event data equal "struct" we don't process struct, and just keep bytes, as for any other type.

func NewEventKeep

func NewEventKeep() sdk.Event

New event with keep status.

func PathToHex

func PathToHex(path vm_grpc.VMAccessPath) string

Convert VMAccessPath to hex string

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func VMTypeToString

func VMTypeToString(tag vm_grpc.VMTypeTag) (string, error)

Convert TypeTag to string representation.

func VMTypeToStringPanic

func VMTypeToStringPanic(tag vm_grpc.VMTypeTag) string

Convert TypeTag to string representation with panic.

Types

type Contract

type Contract []byte

Type of Move contract (bytes).

type DumbGasMeter

type DumbGasMeter struct {
}

func (*DumbGasMeter) ConsumeGas

func (g *DumbGasMeter) ConsumeGas(_ sdk.Gas, _ string)

func (DumbGasMeter) GasConsumed

func (g DumbGasMeter) GasConsumed() sdk.Gas

func (DumbGasMeter) GasConsumedToLimit

func (g DumbGasMeter) GasConsumedToLimit() sdk.Gas

func (DumbGasMeter) IsOutOfGas

func (g DumbGasMeter) IsOutOfGas() bool

func (DumbGasMeter) IsPastLimit

func (g DumbGasMeter) IsPastLimit() bool

func (DumbGasMeter) Limit

func (g DumbGasMeter) Limit() sdk.Gas

type ErrVMCrashed

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

Special type for VM crashes, so we can detect later, that it's VM crash error and break consensus

func NewErrVMCrashed

func NewErrVMCrashed(err error) ErrVMCrashed

Move VM crashes, means don't return response, disconnect, etc

type GenesisState

type GenesisState struct {
	WriteSet []GenesisWriteOp `json:"write_set"`
}

Genesis state contains write operations.

type GenesisWriteOp

type GenesisWriteOp struct {
	Address string `json:"address"`
	Path    string `json:"path"`
	Value   string `json:"value"`
}

Genesis write operations.

type MsgDeployModule

type MsgDeployModule struct {
	Signer sdk.AccAddress `json:"signer"`
	Module Contract       `json:"module"`
}

Message to deploy contract.

func NewMsgDeployModule

func NewMsgDeployModule(signer sdk.AccAddress, module Contract) MsgDeployModule

func (MsgDeployModule) GetSignBytes

func (msg MsgDeployModule) GetSignBytes() []byte

func (MsgDeployModule) GetSigners

func (msg MsgDeployModule) GetSigners() []sdk.AccAddress

func (MsgDeployModule) Route

func (MsgDeployModule) Route() string

func (MsgDeployModule) Type

func (MsgDeployModule) Type() string

func (MsgDeployModule) ValidateBasic

func (msg MsgDeployModule) ValidateBasic() sdk.Error

type MsgExecuteScript

type MsgExecuteScript struct {
	Signer sdk.AccAddress `json:"signer"`
	Script Contract       `json:"script"`
	Args   []ScriptArg    `json:"args"`
}

Message for contract script (execution).

func NewMsgExecuteScript

func NewMsgExecuteScript(signer sdk.AccAddress, script Contract, args []ScriptArg) MsgExecuteScript

func (MsgExecuteScript) GetSignBytes

func (msg MsgExecuteScript) GetSignBytes() []byte

func (MsgExecuteScript) GetSigners

func (msg MsgExecuteScript) GetSigners() []sdk.AccAddress

func (MsgExecuteScript) Route

func (MsgExecuteScript) Route() string

func (MsgExecuteScript) Type

func (MsgExecuteScript) Type() string

func (MsgExecuteScript) ValidateBasic

func (msg MsgExecuteScript) ValidateBasic() sdk.Error

type QueryAccessPath

type QueryAccessPath struct {
	Address []byte `json:"address"`
	Path    []byte `json:"path"`
}

Query when access path to read value.

type QueryValueResp

type QueryValueResp struct {
	Value string `json:"value"`
}

Query response.

func (QueryValueResp) String

func (resp QueryValueResp) String() string

type ScriptArg

type ScriptArg struct {
	Value string            `json:"value"`
	Type  vm_grpc.VMTypeTag `json:"type"`
}

Arguments to execute script.

func NewScriptArg

func NewScriptArg(value string, typeTag vm_grpc.VMTypeTag) ScriptArg

New ScriptArg from arguments.

Jump to

Keyboard shortcuts

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