Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

119 lines
3.0 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Package zwarp provides ZAP transport for warp messaging.
package zwarp
import (
"context"
"errors"
"fmt"
zapwire "github.com/luxfi/api/zap"
"github.com/luxfi/node/vms/platformvm/warp"
)
var (
_ warp.Signer = (*Client)(nil)
ErrSigningFailed = errors.New("zwarp: signing failed")
)
// Client implements warp.Signer over ZAP transport
type Client struct {
conn *zapwire.Conn
}
// NewClient creates a new ZAP-based warp signer client
func NewClient(conn *zapwire.Conn) *Client {
return &Client{conn: conn}
}
// Sign implements warp.Signer
func (c *Client) Sign(unsignedMsg *warp.UnsignedMessage) ([]byte, error) {
req := &zapwire.WarpSignRequest{
NetworkID: unsignedMsg.NetworkID,
SourceChainID: unsignedMsg.SourceChainID[:],
Payload: unsignedMsg.Payload,
}
buf := zapwire.GetBuffer()
defer zapwire.PutBuffer(buf)
req.Encode(buf)
respType, respData, err := c.conn.Call(context.Background(), zapwire.MsgWarpSign, buf.Bytes())
if err != nil {
return nil, fmt.Errorf("zwarp sign: %w", err)
}
if respType&^zapwire.MsgResponseFlag != zapwire.MsgWarpSign {
return nil, fmt.Errorf("zwarp: unexpected response type %d", respType)
}
resp := &zapwire.WarpSignResponse{}
if err := resp.Decode(zapwire.NewReader(respData)); err != nil {
return nil, fmt.Errorf("zwarp decode response: %w", err)
}
if resp.Error != "" {
return nil, fmt.Errorf("%w: %s", ErrSigningFailed, resp.Error)
}
return resp.Signature, nil
}
// BatchSign signs multiple messages in a single call (optimization for HFT)
func (c *Client) BatchSign(messages []*warp.UnsignedMessage) ([][]byte, []error) {
req := &zapwire.WarpBatchSignRequest{
Messages: make([]zapwire.WarpSignRequest, len(messages)),
}
for i, msg := range messages {
req.Messages[i] = zapwire.WarpSignRequest{
NetworkID: msg.NetworkID,
SourceChainID: msg.SourceChainID[:],
Payload: msg.Payload,
}
}
buf := zapwire.GetBuffer()
defer zapwire.PutBuffer(buf)
req.Encode(buf)
respType, respData, err := c.conn.Call(context.Background(), zapwire.MsgWarpBatchSign, buf.Bytes())
if err != nil {
errs := make([]error, len(messages))
for i := range errs {
errs[i] = err
}
return nil, errs
}
if respType&^zapwire.MsgResponseFlag != zapwire.MsgWarpBatchSign {
errs := make([]error, len(messages))
for i := range errs {
errs[i] = fmt.Errorf("zwarp: unexpected response type %d", respType)
}
return nil, errs
}
resp := &zapwire.WarpBatchSignResponse{}
if err := resp.Decode(zapwire.NewReader(respData)); err != nil {
errs := make([]error, len(messages))
for i := range errs {
errs[i] = fmt.Errorf("zwarp decode batch response: %w", err)
}
return nil, errs
}
// Convert errors
errs := make([]error, len(resp.Errors))
for i, errStr := range resp.Errors {
if errStr != "" {
errs[i] = fmt.Errorf("%w: %s", ErrSigningFailed, errStr)
}
}
return resp.Signatures, errs
}