Documentation
¶
Index ¶
- Constants
- Variables
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) Status() uint8
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify(ctx context.Context) error
- type Channel
- type ChannelReply
- type CloseChannelArgs
- type CloseChannelReply
- type Config
- type Factory
- type Genesis
- type GetChannelArgs
- type GetChannelReply
- type GetMessageArgs
- type GetMessageReply
- type GetVerifiedMessageArgs
- type GetVerifiedMessageReply
- type HealthArgs
- type HealthReply
- type ListChannelsArgs
- type ListChannelsReply
- type Message
- type MessageReceipt
- type MessageReply
- type OpenChannelArgs
- type OpenChannelReply
- type ReceiveMessageArgs
- type ReceiveMessageReply
- type SendMessageArgs
- type SendMessageReply
- type Service
- func (s *Service) CloseChannel(r *http.Request, args *CloseChannelArgs, reply *CloseChannelReply) error
- func (s *Service) GetChannel(r *http.Request, args *GetChannelArgs, reply *GetChannelReply) error
- func (s *Service) GetMessage(r *http.Request, args *GetMessageArgs, reply *GetMessageReply) error
- func (s *Service) GetVerifiedMessage(r *http.Request, args *GetVerifiedMessageArgs, reply *GetVerifiedMessageReply) error
- func (s *Service) Health(r *http.Request, args *HealthArgs, reply *HealthReply) error
- func (s *Service) ListChannels(r *http.Request, args *ListChannelsArgs, reply *ListChannelsReply) error
- func (s *Service) OpenChannel(r *http.Request, args *OpenChannelArgs, reply *OpenChannelReply) error
- func (s *Service) ReceiveMessage(r *http.Request, args *ReceiveMessageArgs, reply *ReceiveMessageReply) error
- func (s *Service) SendMessage(r *http.Request, args *SendMessageArgs, reply *SendMessageReply) error
- type VM
- func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)
- func (vm *VM) CloseChannel(channelID ids.ID) error
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error
- func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)
- func (vm *VM) CreateVerifiedMessage(msg *Message) (*artifacts.VerifiedMessage, error)
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) GetBlock(ctx context.Context, blockID ids.ID) (chain.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) GetChannel(channelID ids.ID) (*Channel, error)
- func (vm *VM) GetMessage(msgID ids.ID) (*Message, error)
- func (vm *VM) HealthCheck(ctx context.Context) (*chain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, vmInit vmcore.Init) error
- func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (vm *VM) OpenChannel(sourceChain, destChain ids.ID, ordering, version string) (*Channel, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)
- func (vm *VM) ReceiveMessage(msgID ids.ID, proof []byte, sourceHeight uint64) (*MessageReceipt, error)
- func (vm *VM) SendMessage(channelID ids.ID, payload, sender, receiver []byte, timeout int64) (*Message, error)
- func (vm *VM) SetPreference(ctx context.Context, blockID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) Version(ctx context.Context) (string, error)
- func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)
Constants ¶
const ( Name = "relayvm" // Message states MessagePending = "pending" MessageVerified = "verified" MessageDelivered = "delivered" MessageFailed = "failed" )
Variables ¶
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
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 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 ¶
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 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 ¶
BuildBlock implements chain.ChainVM
func (*VM) CloseChannel ¶
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 ¶
CreateHandlers implements chain.ChainVM
func (*VM) CreateVerifiedMessage ¶
func (vm *VM) CreateVerifiedMessage(msg *Message) (*artifacts.VerifiedMessage, error)
CreateVerifiedMessage creates a VerifiedMessage artifact
func (*VM) Disconnected ¶
Disconnected implements chain.ChainVM
func (*VM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight implements chain.HeightIndexedChainVM
func (*VM) GetChannel ¶
GetChannel returns a channel by ID
func (*VM) GetMessage ¶
GetMessage returns a message by ID
func (*VM) HealthCheck ¶
HealthCheck implements chain.ChainVM
func (*VM) Initialize ¶
Initialize implements chain.ChainVM
func (*VM) LastAccepted ¶
LastAccepted implements chain.ChainVM
func (*VM) NewHTTPHandler ¶
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 ¶
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 ¶
SetPreference implements chain.ChainVM