Help us shape the future of Go! Take the 2026 Go Developer Survey

relayvm

package
v1.24.29 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "relayvm"

	// Message states
	MessagePending   = "pending"
	MessageVerified  = "verified"
	MessageDelivered = "delivered"
	MessageFailed    = "failed"
)

Variables

View Source
var VMID = ids.ID{'r', 'e', 'l', 'a', 'y', 'v', 'm'}

VMID is the unique identifier for RelayVM (R-Chain)

Functions

func ComputeReceiptID added in v1.23.0

func ComputeReceiptID(messageID ids.ID, nodeID ids.NodeID, timestamp uint64) [32]byte

ComputeReceiptID computes a deterministic ID for a signed receipt

func VerifyReceiptInclusionProof added in v1.23.0

func VerifyReceiptInclusionProof(receipt *SignedReceipt, proof [][]byte, root [32]byte, index int) bool

VerifyReceiptInclusionProof verifies a Merkle inclusion proof for a receipt

Types

type Block

type Block struct {
	ParentID_      ids.ID            `json:"parentId"`
	BlockHeight    uint64            `json:"height"`
	BlockTimestamp int64             `json:"timestamp"`
	Messages       []*Message        `json:"messages"`
	Receipts       []*MessageReceipt `json:"receipts,omitempty"`
	StateRoot      []byte            `json:"stateRoot"`

	// Cached values
	ID_ ids.ID
	// contains filtered or unexported fields
}

Block represents a block in the RelayVM chain

func (*Block) Accept

func (b *Block) Accept(ctx context.Context) error

Accept accepts the block

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the block bytes

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (b *Block) ID() ids.ID

ID returns the block ID

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent is an alias for ParentID for compatibility

func (*Block) ParentID

func (b *Block) ParentID() ids.ID

ParentID returns the parent block ID

func (*Block) Reject

func (b *Block) Reject(ctx context.Context) error

Reject rejects the block

func (*Block) Status

func (b *Block) Status() uint8

Status returns the block status

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

Verify verifies the block

type Channel

type Channel struct {
	ID          ids.ID            `json:"id"`
	SourceChain ids.ID            `json:"sourceChain"`
	DestChain   ids.ID            `json:"destChain"`
	Ordering    string            `json:"ordering"` // "ordered" or "unordered"
	Version     string            `json:"version"`
	State       string            `json:"state"` // "open", "closed"
	CreatedAt   time.Time         `json:"createdAt"`
	Metadata    map[string]string `json:"metadata"`
}

Channel represents a cross-chain communication channel

type ChannelReply

type ChannelReply struct {
	ID          string            `json:"id"`
	SourceChain string            `json:"sourceChain"`
	DestChain   string            `json:"destChain"`
	Ordering    string            `json:"ordering"`
	Version     string            `json:"version"`
	State       string            `json:"state"`
	CreatedAt   string            `json:"createdAt"`
	Metadata    map[string]string `json:"metadata"`
}

ChannelReply represents a channel in RPC responses

type CloseChannelArgs

type CloseChannelArgs struct {
	ChannelID string `json:"channelId"`
}

CloseChannelArgs are arguments for CloseChannel

type CloseChannelReply

type CloseChannelReply struct {
	Success bool `json:"success"`
}

CloseChannelReply is the reply for CloseChannel

type Config

type Config struct {
	MaxMessageSize    int      `json:"maxMessageSize"`
	ConfirmationDepth int      `json:"confirmationDepth"`
	RelayTimeout      int      `json:"relayTimeout"`
	TrustedRelayers   []string `json:"trustedRelayers"`
	SupportedChains   []string `json:"supportedChains"`
}

Config holds RelayVM configuration

type DestNonceKey added in v1.24.29

type DestNonceKey struct {
	DestChain ids.ID
	Nonce     uint64
}

DestNonceKey is the conflict key for the Relay VM: (destChain, nonce). Two vertices conflict iff they relay to the same chain with the same nonce.

type Factory

type Factory struct{}

Factory creates new RelayVM instances

func (*Factory) New

func (f *Factory) New(logger log.Logger) (interface{}, error)

New returns a new instance of the RelayVM

type Genesis

type Genesis struct {
	Timestamp int64      `json:"timestamp"`
	Config    *Config    `json:"config,omitempty"`
	Channels  []*Channel `json:"channels,omitempty"`
	Message   string     `json:"message,omitempty"`
}

Genesis represents genesis data for RelayVM

func ParseGenesis

func ParseGenesis(genesisBytes []byte) (*Genesis, error)

ParseGenesis parses genesis bytes

type GetChannelArgs

type GetChannelArgs struct {
	ChannelID string `json:"channelId"`
}

GetChannelArgs are arguments for GetChannel

type GetChannelReply

type GetChannelReply struct {
	Channel ChannelReply `json:"channel"`
}

GetChannelReply is the reply for GetChannel

type GetMessageArgs

type GetMessageArgs struct {
	MessageID string `json:"messageId"`
}

GetMessageArgs are arguments for GetMessage

type GetMessageReply

type GetMessageReply struct {
	Message MessageReply `json:"message"`
}

GetMessageReply is the reply for GetMessage

type GetVerifiedMessageArgs

type GetVerifiedMessageArgs struct {
	MessageID string `json:"messageId"`
}

GetVerifiedMessageArgs are arguments for GetVerifiedMessage

type GetVerifiedMessageReply

type GetVerifiedMessageReply struct {
	SourceChain  string `json:"sourceChain"`
	DestChain    string `json:"destChain"`
	Nonce        uint64 `json:"nonce"`
	Payload      string `json:"payload"`
	Proof        string `json:"proof"`
	SourceHeight uint64 `json:"sourceHeight"`
	Timestamp    int64  `json:"timestamp"`
}

GetVerifiedMessageReply is the reply for GetVerifiedMessage

type HealthArgs

type HealthArgs struct{}

HealthArgs are arguments for Health

type HealthReply

type HealthReply struct {
	Healthy         bool `json:"healthy"`
	Channels        int  `json:"channels"`
	PendingMessages int  `json:"pendingMessages"`
}

HealthReply is the reply for Health

type ListChannelsArgs

type ListChannelsArgs struct {
	State string `json:"state"` // Optional filter by state
}

ListChannelsArgs are arguments for ListChannels

type ListChannelsReply

type ListChannelsReply struct {
	Channels []ChannelReply `json:"channels"`
}

ListChannelsReply is the reply for ListChannels

type Message

type Message struct {
	ID           ids.ID     `json:"id"`
	ChannelID    ids.ID     `json:"channelId"`
	SourceChain  ids.ID     `json:"sourceChain"`
	DestChain    ids.ID     `json:"destChain"`
	Sequence     uint64     `json:"sequence"`
	Payload      []byte     `json:"payload"`
	Proof        []byte     `json:"proof"` // Merkle proof from source chain
	SourceHeight uint64     `json:"sourceHeight"`
	Sender       []byte     `json:"sender"`
	Receiver     []byte     `json:"receiver"`
	Timeout      int64      `json:"timeout"`
	State        string     `json:"state"`
	RelayedBy    ids.NodeID `json:"relayedBy,omitempty"`
	RelayedAt    int64      `json:"relayedAt,omitempty"`
	ConfirmedAt  int64      `json:"confirmedAt,omitempty"`
}

Message represents a cross-chain message

type MessageReceipt

type MessageReceipt struct {
	MessageID   ids.ID `json:"messageId"`
	ChannelID   ids.ID `json:"channelId"`
	Success     bool   `json:"success"`
	ResultHash  []byte `json:"resultHash"`
	BlockHeight uint64 `json:"blockHeight"`
	Timestamp   int64  `json:"timestamp"`
}

MessageReceipt is generated when a message is verified

type MessageReply

type MessageReply struct {
	ID           string `json:"id"`
	ChannelID    string `json:"channelId"`
	SourceChain  string `json:"sourceChain"`
	DestChain    string `json:"destChain"`
	Sequence     uint64 `json:"sequence"`
	Payload      string `json:"payload"` // Base64-encoded
	Sender       string `json:"sender"`
	Receiver     string `json:"receiver"`
	Timeout      int64  `json:"timeout"`
	State        string `json:"state"`
	SourceHeight uint64 `json:"sourceHeight,omitempty"`
	ConfirmedAt  int64  `json:"confirmedAt,omitempty"`
}

MessageReply represents a message in RPC responses

type OpenChannelArgs

type OpenChannelArgs struct {
	SourceChain string `json:"sourceChain"`
	DestChain   string `json:"destChain"`
	Ordering    string `json:"ordering"` // "ordered" or "unordered"
	Version     string `json:"version"`
}

OpenChannelArgs are arguments for OpenChannel

type OpenChannelReply

type OpenChannelReply struct {
	ChannelID string `json:"channelId"`
}

OpenChannelReply is the reply for OpenChannel

type ReceiptCommit added in v1.23.0

type ReceiptCommit struct {
	// CommitID is the unique identifier for this commit
	CommitID [32]byte `json:"commitId"`

	// SessionID that this commit belongs to (if scoped to session)
	SessionID [32]byte `json:"sessionId,omitempty"`

	// Root is the Merkle root over all receipts in this commit
	Root [32]byte `json:"root"`

	// ReceiptCount is the number of receipts in this commit
	ReceiptCount uint32 `json:"receiptCount"`

	// BlockHeight at which this commit was created
	BlockHeight uint64 `json:"blockHeight"`

	// Window defines the receipt timestamp range
	Window struct {
		Start uint64 `json:"start"`
		End   uint64 `json:"end"`
	} `json:"window"`

	// CommittedAt is when this commit was created
	CommittedAt time.Time `json:"committedAt"`
}

ReceiptCommit represents a Merkle root commitment over a set of receipts

type ReceiveMessageArgs

type ReceiveMessageArgs struct {
	MessageID    string `json:"messageId"`
	Proof        string `json:"proof"`        // Base64-encoded Merkle proof
	SourceHeight uint64 `json:"sourceHeight"` // Block height on source chain
}

ReceiveMessageArgs are arguments for ReceiveMessage

type ReceiveMessageReply

type ReceiveMessageReply struct {
	Success     bool   `json:"success"`
	ResultHash  string `json:"resultHash"` // Base64-encoded
	BlockHeight uint64 `json:"blockHeight"`
}

ReceiveMessageReply is the reply for ReceiveMessage

type RelayVertex added in v1.24.29

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

RelayVertex represents a DAG vertex in the Relay chain.

func (*RelayVertex) Accept added in v1.24.29

func (v *RelayVertex) Accept(ctx context.Context) error

func (*RelayVertex) Bytes added in v1.24.29

func (v *RelayVertex) Bytes() []byte

func (*RelayVertex) Conflicts added in v1.24.29

func (v *RelayVertex) Conflicts(other *RelayVertex) bool

Conflicts returns true if this vertex and other share any (destChain, nonce) pair.

func (*RelayVertex) ConflictsVertex added in v1.24.29

func (v *RelayVertex) ConflictsVertex(other vertex.Vertex) bool

ConflictsVertex performs the same check against the vertex.Vertex interface.

func (*RelayVertex) Epoch added in v1.24.29

func (v *RelayVertex) Epoch() uint32

func (*RelayVertex) Height added in v1.24.29

func (v *RelayVertex) Height() uint64

func (*RelayVertex) ID added in v1.24.29

func (v *RelayVertex) ID() ids.ID

func (*RelayVertex) Parents added in v1.24.29

func (v *RelayVertex) Parents() []ids.ID

func (*RelayVertex) Reject added in v1.24.29

func (v *RelayVertex) Reject(ctx context.Context) error

func (*RelayVertex) Status added in v1.24.29

func (v *RelayVertex) Status() choices.Status

func (*RelayVertex) Txs added in v1.24.29

func (v *RelayVertex) Txs() []ids.ID

func (*RelayVertex) Verify added in v1.24.29

func (v *RelayVertex) Verify(ctx context.Context) error

type SendMessageArgs

type SendMessageArgs struct {
	ChannelID string `json:"channelId"`
	Payload   string `json:"payload"`  // Base64-encoded
	Sender    string `json:"sender"`   // Base64-encoded
	Receiver  string `json:"receiver"` // Base64-encoded
	Timeout   int64  `json:"timeout"`  // Unix timestamp
}

SendMessageArgs are arguments for SendMessage

type SendMessageReply

type SendMessageReply struct {
	MessageID string `json:"messageId"`
	Sequence  uint64 `json:"sequence"`
}

SendMessageReply is the reply for SendMessage

type Service

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

Service provides RPC access to the RelayVM

func (*Service) CloseChannel

func (s *Service) CloseChannel(r *http.Request, args *CloseChannelArgs, reply *CloseChannelReply) error

CloseChannel closes a channel

func (*Service) GetChannel

func (s *Service) GetChannel(r *http.Request, args *GetChannelArgs, reply *GetChannelReply) error

GetChannel returns a channel by ID

func (*Service) GetMessage

func (s *Service) GetMessage(r *http.Request, args *GetMessageArgs, reply *GetMessageReply) error

GetMessage returns a message by ID

func (*Service) GetVerifiedMessage

func (s *Service) GetVerifiedMessage(r *http.Request, args *GetVerifiedMessageArgs, reply *GetVerifiedMessageReply) error

GetVerifiedMessage returns a VerifiedMessage artifact

func (*Service) Health

func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error

Health returns health status

func (*Service) ListChannels

func (s *Service) ListChannels(r *http.Request, args *ListChannelsArgs, reply *ListChannelsReply) error

ListChannels lists all channels

func (*Service) OpenChannel

func (s *Service) OpenChannel(r *http.Request, args *OpenChannelArgs, reply *OpenChannelReply) error

OpenChannel opens a new cross-chain channel

func (*Service) ReceiveMessage

func (s *Service) ReceiveMessage(r *http.Request, args *ReceiveMessageArgs, reply *ReceiveMessageReply) error

ReceiveMessage processes an incoming message with proof

func (*Service) SendMessage

func (s *Service) SendMessage(r *http.Request, args *SendMessageArgs, reply *SendMessageReply) error

SendMessage sends a cross-chain message

type SignedReceipt added in v1.23.0

type SignedReceipt struct {
	// MessageID is the ID of the message being receipted
	MessageID ids.ID `json:"messageId"`

	// SessionID links the receipt to a session (if applicable)
	SessionID [32]byte `json:"sessionId"`

	// NodeID of the node signing this receipt
	NodeID ids.NodeID `json:"nodeId"`

	// Timestamp when the receipt was created
	Timestamp uint64 `json:"timestamp"`

	// ContentHash is hash of the message content received
	ContentHash [32]byte `json:"contentHash"`

	// Signature from the node's key over the receipt payload
	Signature []byte `json:"signature"`
}

SignedReceipt represents a node's signed acknowledgment of message receipt

type VM

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

VM implements the RelayVM for cross-chain message relay

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)

BuildBlock implements chain.ChainVM

func (*VM) BuildVertex added in v1.24.29

func (vm *VM) BuildVertex(ctx context.Context) (vertex.Vertex, error)

BuildVertex creates a vertex from pending messages, batching non-conflicting ones.

func (*VM) CloseChannel

func (vm *VM) CloseChannel(channelID ids.ID) error

CloseChannel closes a channel

func (*VM) CommitSessionReceipts added in v1.23.0

func (vm *VM) CommitSessionReceipts(sessionID [32]byte) (*ReceiptCommit, error)

CommitSessionReceipts creates a Merkle root commitment for all receipts in a session

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error

Connected implements chain.ChainVM

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers implements chain.ChainVM

func (*VM) CreateVerifiedMessage

func (vm *VM) CreateVerifiedMessage(msg *Message) (*artifacts.VerifiedMessage, error)

CreateVerifiedMessage creates a VerifiedMessage artifact

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements chain.ChainVM

func (*VM) GenerateReceiptInclusionProof added in v1.23.0

func (vm *VM) GenerateReceiptInclusionProof(sessionID [32]byte, receiptIndex int) ([][]byte, error)

GenerateReceiptInclusionProof generates a Merkle proof for a receipt in a session

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (chain.Block, error)

GetBlock implements chain.ChainVM

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements chain.HeightIndexedChainVM

func (*VM) GetChannel

func (vm *VM) GetChannel(channelID ids.ID) (*Channel, error)

GetChannel returns a channel by ID

func (*VM) GetMessage

func (vm *VM) GetMessage(msgID ids.ID) (*Message, error)

GetMessage returns a message by ID

func (*VM) GetReceiptCommit added in v1.23.0

func (vm *VM) GetReceiptCommit(sessionID [32]byte) (*ReceiptCommit, error)

GetReceiptCommit retrieves a receipt commit for a session

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (chain.HealthResult, error)

HealthCheck implements chain.ChainVM

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	vmInit luxvm.Init,
) error

Initialize implements chain.ChainVM

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements chain.ChainVM

func (*VM) NewHTTPHandler

func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements chain.ChainVM

func (*VM) OpenChannel

func (vm *VM) OpenChannel(sourceChain, destChain ids.ID, ordering, version string) (*Channel, error)

OpenChannel opens a new cross-chain channel

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)

ParseBlock implements chain.ChainVM

func (*VM) ParseVertex added in v1.24.29

func (vm *VM) ParseVertex(ctx context.Context, b []byte) (vertex.Vertex, error)

ParseVertex deserializes a vertex from bytes.

func (*VM) ReceiveMessage

func (vm *VM) ReceiveMessage(msgID ids.ID, proof []byte, sourceHeight uint64) (*MessageReceipt, error)

ReceiveMessage processes an incoming message with proof

func (*VM) RegisterNodePublicKey added in v1.23.4

func (vm *VM) RegisterNodePublicKey(nodeID ids.NodeID, publicKey ed25519.PublicKey) error

RegisterNodePublicKey registers a node's Ed25519 public key for signature verification

func (*VM) SendMessage

func (vm *VM) SendMessage(channelID ids.ID, payload, sender, receiver []byte, timeout int64) (*Message, error)

SendMessage queues a message for relay

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error

SetPreference implements chain.ChainVM

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state uint32) error

SetState implements chain.ChainVM

func (*VM) Shutdown

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

Shutdown implements chain.ChainVM

func (*VM) SubmitSignedReceipt added in v1.23.0

func (vm *VM) SubmitSignedReceipt(receipt *SignedReceipt) error

SubmitSignedReceipt records a signed receipt from a node

func (*VM) Version

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

Version implements chain.ChainVM

func (*VM) WaitForEvent

func (vm *VM) WaitForEvent(ctx context.Context) (luxvm.Message, error)

WaitForEvent implements chain.ChainVM

Jump to

Keyboard shortcuts

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