relayvm

package
v1.22.88 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: BSD-3-Clause Imports: 21 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

This section is empty.

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 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 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 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 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) CloseChannel

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

CloseChannel closes a channel

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) 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) 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 vmcore.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) ReceiveMessage

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

ReceiveMessage processes an incoming message with proof

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) Version

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

Version implements chain.ChainVM

func (*VM) WaitForEvent

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

WaitForEvent implements chain.ChainVM

Jump to

Keyboard shortcuts

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