vm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "ldvm"
)

Variables

View Source
var (
	// pjjsfTNAgQnP7zdpKfRcmicXGbk87xXznJmJZtqDAyRaNEhEL
	LDVMID = avaids.ID{'l', 'd', 'v', 'm'}
)
View Source
var (
	Version = &version.Semantic{
		Major: 1,
		Minor: 0,
		Patch: 0,
	}
)

Functions

This section is empty.

Types

type Factory

type Factory struct{}

Factory ...

func (*Factory) New

func (f *Factory) New(*snow.Context) (any, error)

New ...

type PushNetwork

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

type RPCServer added in v0.1.0

type RPCServer interface {
	Start(h http.Handler, addr string)
	Shutdown(ctx context.Context) error
	Done() <-chan struct{}
	Err() error
}

type VM

type VM struct {
	Log avalogging.Logger
	// contains filtered or unexported fields
}

VM implements the snowman.VM interface

func (*VM) AppGossip

func (v *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

AppGossip implements the common.VM AppHandler AppGossip interface This VM doesn't (currently) have any app-specific messages

Notify this engine of a gossip message from [nodeID].

The meaning of [msg] is application (VM) specific, and the VM defines how to react to this message.

This message is not expected in response to any event, and it does not need to be responded to.

A node may gossip the same message multiple times. That is, AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) may be called multiple times.

func (*VM) AppRequest

func (v *VM) AppRequest(ctx context.Context, id avaids.NodeID, requestID uint32, deadline time.Time, request []byte) error

AppRequest implements the common.VM AppRequest interface This VM doesn't (currently) have any app-specific messages

Notify this engine of a request for data from [nodeID].

The meaning of [request], and what should be sent in response to it, is application (VM) specific.

It is not guaranteed that: * [request] is well-formed/valid.

This node should typically send an AppResponse to [nodeID] in response to a valid message using the same request ID before the deadline. However, the VM may arbitrarily choose to not send a response to this request.

func (*VM) AppRequestFailed

func (v *VM) AppRequestFailed(ctx context.Context, id avaids.NodeID, requestID uint32) error

AppRequestFailed implements the common.VM AppRequestFailed interface This VM doesn't (currently) have any app-specific messages

Notify this engine that an AppRequest message it sent to [nodeID] with request ID [requestID] failed.

This may be because the request timed out or because the message couldn't be sent to [nodeID].

It is guaranteed that: * This engine sent a request to [nodeID] with ID [requestID]. * AppRequestFailed([nodeID], [requestID]) has not already been called. * AppResponse([nodeID], [requestID]) has not already been called.

func (*VM) AppResponse

func (v *VM) AppResponse(ctx context.Context, id avaids.NodeID, requestID uint32, response []byte) error

AppResponse implements the common.VM AppResponse interface This VM doesn't (currently) have any app-specific messages

Notify this engine of a response to the AppRequest message it sent to [nodeID] with request ID [requestID].

The meaning of [response] is application (VM) specifc.

It is guaranteed that: * This engine sent a request to [nodeID] with ID [requestID]. * AppRequestFailed([nodeID], [requestID]) has not already been called. * AppResponse([nodeID], [requestID]) has not already been called.

It is not guaranteed that: * [response] contains the expected response * [response] is well-formed/valid.

If [response] is invalid or not the expected response, the VM chooses how to react. For example, the VM may send another AppRequest, or it may give up trying to get the requested information.

func (*VM) BuildBlock

func (v *VM) BuildBlock(ctx context.Context) (snowman.Block, error)

BuildBlock implements the block.ChainVM BuildBlock interface

BuildBlock attempt to create a new block from data contained in the VM. If the VM doesn't want to issue a new block, an error should be returned.

func (*VM) Connected

func (v *VM) Connected(ctx context.Context, id avaids.NodeID, nodeVersion *version.Application) error

Connected implements the common.VM validators.Connector Connected interface Connector represents a handler that is called when a connection is marked as connected

func (*VM) CreateHandlers

func (v *VM) CreateHandlers(ctx context.Context) (map[string]*common.HTTPHandler, error)

CreateHandlers implements the common.VM CreateHandlers interface Creates the HTTP handlers for custom chain network calls.

This exposes handlers that the outside world can use to communicate with the chain. Each handler has the path: [Address of node]/ext/bc/[chain ID]/[extension]

func (*VM) CreateStaticHandlers

func (v *VM) CreateStaticHandlers(ctx context.Context) (map[string]*common.HTTPHandler, error)

CreateStaticHandlers implements the common.VM CreateStaticHandlers interface Creates the HTTP handlers for custom VM network calls.

This exposes handlers that the outside world can use to communicate with a static reference to the VM. Each handler has the path: [Address of node]/ext/vm/[VM ID]/[extension]

func (*VM) CrossChainAppRequest

func (v *VM) CrossChainAppRequest(ctx context.Context, chainID avaids.ID, requestID uint32, deadline time.Time, request []byte) error

CrossChainAppRequest Notify this engine of a request for data from [chainID].

The meaning of [request], and what should be sent in response to it, is application (VM) specific.

Guarantees surrounding the request are specific to the implementation of the requesting VM. For example, the request may or may not be guaranteed to be well-formed/valid depending on the implementation of the requesting VM.

This node should typically send a CrossChainAppResponse to [chainID] in response to a valid message using the same request ID before the deadline. However, the VM may arbitrarily choose to not send a response to this request.

func (*VM) CrossChainAppRequestFailed

func (v *VM) CrossChainAppRequestFailed(ctx context.Context, chainID avaids.ID, requestID uint32) error

CrossChainAppRequestFailed notifies this engine that a CrossChainAppRequest message it sent to [chainID] with request ID [requestID] failed.

This may be because the request timed out or because the message couldn't be sent to [chainID].

It is guaranteed that: * This engine sent a request to [chainID] with ID [requestID]. * CrossChainAppRequestFailed([chainID], [requestID]) has not already been called. * CrossChainAppResponse([chainID], [requestID]) has not already been called.

func (*VM) CrossChainAppResponse

func (v *VM) CrossChainAppResponse(ctx context.Context, chainID avaids.ID, requestID uint32, response []byte) error

CrossChainAppResponse notifies this engine of a response to the CrossChainAppRequest message it sent to [chainID] with request ID [requestID].

The meaning of [response] is application (VM) specific.

It is guaranteed that: * This engine sent a request to [chainID] with ID [requestID]. * CrossChainAppRequestFailed([chainID], [requestID]) has not already been called. * CrossChainAppResponse([chainID], [requestID]) has not already been called.

Guarantees surrounding the response are specific to the implementation of the responding VM. For example, the response may or may not be guaranteed to be well-formed/valid depending on the implementation of the requesting VM.

If [response] is invalid or not the expected response, the VM chooses how to react. For example, the VM may send another CrossChainAppRequest, or it may give up trying to get the requested information.

func (*VM) Disconnected

func (v *VM) Disconnected(ctx context.Context, id avaids.NodeID) error

Disconnected implements the common.VM Disconnected interface Connector represents a handler that is called when a connection is marked as disconnected

func (*VM) GetBlock

func (v *VM) GetBlock(ctx context.Context, id avaids.ID) (blk snowman.Block, err error)

GetBlock implements the block.ChainVM GetBlock interface

GetBlock attempt to fetch a block by it's ID If the block does not exist, an error should be returned.

func (*VM) GetBlockIDAtHeight

func (v *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (avaids.ID, error)

GetBlockIDAtHeight implements the block.HeightIndexedChainVM GetBlockIDAtHeight interface GetBlockIDAtHeight returns the ID of the block that was accepted with [height].

func (*VM) HealthCheck

func (v *VM) HealthCheck(ctx context.Context) (any, error)

HealthCheck implements the common.VM health.Checker HealthCheck interface Returns nil if the VM is healthy. Periodically called and reported via the node's Health API.

func (*VM) Initialize

func (v *VM) Initialize(
	cc context.Context,
	ctx *snow.Context,
	dbManager manager.Manager,
	genesisData []byte,
	upgradeData []byte,
	configData []byte,
	toEngine chan<- common.Message,
	_ []*common.Fx,
	appSender common.AppSender,
) (err error)

Initialize implements the common.VM Initialize interface Initialize this VM. [ctx]: Metadata about this VM.

[ctx.networkID]: The ID of the network this VM's chain is running on.
[ctx.chainID]: The unique ID of the chain this VM is running on.
[ctx.Log]: Used to log messages
[ctx.NodeID]: The unique staker ID of this node.
[ctx.Lock]: A Read/Write lock shared by this VM and the consensus
            engine that manages this VM. The write lock is held
            whenever code in the consensus engine calls the VM.

[dbManager]: The manager of the database this VM will persist data to. [genesisBytes]: The byte-encoding of the genesis information of this

VM. The VM uses it to initialize its state. For
example, if this VM were an account-based payments
system, `genesisBytes` would probably contain a genesis
transaction that gives coins to some accounts, and this
transaction would be in the genesis block.

[toEngine]: The channel used to send messages to the consensus engine. [fxs]: Feature extensions that attach to this VM.

func (*VM) LastAccepted

func (v *VM) LastAccepted(ctx context.Context) (avaids.ID, error)

LastAccepted implements the block.ChainVM LastAccepted interface

LastAccepted returns the ID of the last accepted block. If no blocks have been accepted by consensus yet, it is assumed there is a definitionally accepted block, the Genesis block, that will be returned.

func (*VM) NewPushNetwork

func (v *VM) NewPushNetwork()

func (*VM) ParseBlock

func (v *VM) ParseBlock(ctx context.Context, data []byte) (blk snowman.Block, err error)

ParseBlock implements the block.ChainVM ParseBlock interface

ParseBlock attempt to fetch a block by its bytes.

func (*VM) SetPreference

func (v *VM) SetPreference(ctx context.Context, id avaids.ID) error

SetPreference implements the block.ChainVM SetPreference interface

SetPreference notify the VM of the currently preferred block. This should always be a block that has no children known to consensus.

func (*VM) SetState

func (v *VM) SetState(ctx context.Context, state snow.State) error

SetState implements the common.VM SetState interface SetState communicates to VM its next state it starts

func (*VM) Shutdown

func (v *VM) Shutdown(ctx context.Context) error

Shutdown implements the common.VM Shutdown interface Shutdown is called when the node is shutting down.

func (*VM) VerifyHeightIndex

func (v *VM) VerifyHeightIndex(ctx context.Context) error

VerifyHeightIndex implements the block.HeightIndexedChainVM VerifyHeightIndex interface VerifyHeightIndex should return: - nil if the height index is available. - ErrHeightIndexedVMNotImplemented if the height index is not supported. - ErrIndexIncomplete if the height index is not currently available. - Any other non-standard error that may have occurred when verifying the index.

func (*VM) Version

func (v *VM) Version(ctx context.Context) (string, error)

Version implements the common.VM Version interface Version returns the version of the VM this node is running.

func (*VM) WithRPCServer added in v0.1.0

func (v *VM) WithRPCServer(s RPCServer)

Jump to

Keyboard shortcuts

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