mirror of
https://github.com/luxfi/api.git
synced 2026-09-24 00:24:53 +00:00
chore: sync dependencies and format code
This commit is contained in:
+1
-1
@@ -4,8 +4,8 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/api/types"
|
||||
"github.com/luxfi/ids"
|
||||
)
|
||||
|
||||
// AliasArgs are the arguments for calling Alias.
|
||||
|
||||
+1047
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,620 @@
|
||||
//go:build agentic
|
||||
|
||||
// Package agentic provides high-performance RPC for agent networks
|
||||
// Supports ZMQ, Cap'n Proto, and gRPC with post-quantum privacy
|
||||
package agentic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
// Protocol support
|
||||
"capnproto.org/go/capnp/v3"
|
||||
zmq "github.com/pebbe/zmq4"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
// Post-quantum cryptography
|
||||
"github.com/cloudflare/circl/kem/kyber/kyber1024"
|
||||
"github.com/cloudflare/circl/sign/dilithium/mode5"
|
||||
|
||||
// Lux components
|
||||
"github.com/luxfi/api/agentic_capnp"
|
||||
"github.com/luxfi/crypto"
|
||||
"github.com/luxfi/p2p"
|
||||
)
|
||||
|
||||
// AgenticNetwork manages high-performance agent communication
|
||||
type AgenticNetwork struct {
|
||||
agentID AgentID
|
||||
capabilities AgentCapabilities
|
||||
|
||||
// Protocol handlers
|
||||
zmqSockets map[string]*ZMQHandler
|
||||
capnpServers map[string]*CapnpHandler
|
||||
grpcServers map[string]*grpc.Server
|
||||
|
||||
// Post-quantum cryptography
|
||||
kemKeyPair *KEMKeyPair
|
||||
sigKeyPair *SignatureKeyPair
|
||||
|
||||
// Zero-copy shared memory
|
||||
sharedMemory *SharedMemoryPool
|
||||
|
||||
// Message routing
|
||||
routingTable *RoutingTable
|
||||
|
||||
// Privacy and security
|
||||
mixerPool *MixerPool
|
||||
zkProver *ZKProver
|
||||
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// Agent identity with post-quantum keys
|
||||
type AgentID struct {
|
||||
PublicKey []byte
|
||||
Address string
|
||||
Reputation float64
|
||||
Stake uint64
|
||||
}
|
||||
|
||||
type AgentCapabilities struct {
|
||||
ComputeTypes []ComputeType
|
||||
MaxMemory uint64
|
||||
MaxCompute uint64
|
||||
Specializations []string
|
||||
Protocols []Protocol
|
||||
TrustLevel TrustLevel
|
||||
}
|
||||
|
||||
// Post-quantum key pairs
|
||||
type KEMKeyPair struct {
|
||||
PublicKey kyber1024.PublicKey
|
||||
PrivateKey kyber1024.PrivateKey
|
||||
}
|
||||
|
||||
type SignatureKeyPair struct {
|
||||
PublicKey mode5.PublicKey
|
||||
PrivateKey mode5.PrivateKey
|
||||
}
|
||||
|
||||
// Protocol handlers
|
||||
type ZMQHandler struct {
|
||||
socketType zmq.Type
|
||||
socket *zmq.Socket
|
||||
endpoint string
|
||||
options ZMQOptions
|
||||
}
|
||||
|
||||
type CapnpHandler struct {
|
||||
listener net.Listener
|
||||
server *capnp.Server
|
||||
options CapnpOptions
|
||||
}
|
||||
|
||||
type ZMQOptions struct {
|
||||
SocketType zmq.Type
|
||||
HighWaterMark int64
|
||||
Linger time.Duration
|
||||
ReconnectInterval time.Duration
|
||||
MaxReconnects int
|
||||
}
|
||||
|
||||
type CapnpOptions struct {
|
||||
Compression CompressionType
|
||||
PackedEncoding bool
|
||||
TraversalLimit uint64
|
||||
NestingLimit uint32
|
||||
}
|
||||
|
||||
// NewAgenticNetwork creates a new high-performance agent network
|
||||
func NewAgenticNetwork(config *NetworkConfig) (*AgenticNetwork, error) {
|
||||
// Generate post-quantum key pairs
|
||||
kemPub, kemPriv, err := kyber1024.GenerateKeyPair(rand.Reader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate KEM key pair: %w", err)
|
||||
}
|
||||
|
||||
sigPub, sigPriv, err := mode5.GenerateKey(rand.Reader)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to generate signature key pair: %w", err)
|
||||
}
|
||||
|
||||
network := &AgenticNetwork{
|
||||
agentID: AgentID{
|
||||
PublicKey: kemPub.Bytes(),
|
||||
Address: config.Address,
|
||||
Reputation: 1.0,
|
||||
Stake: config.InitialStake,
|
||||
},
|
||||
capabilities: config.Capabilities,
|
||||
kemKeyPair: &KEMKeyPair{
|
||||
PublicKey: *kemPub,
|
||||
PrivateKey: *kemPriv,
|
||||
},
|
||||
sigKeyPair: &SignatureKeyPair{
|
||||
PublicKey: *sigPub,
|
||||
PrivateKey: *sigPriv,
|
||||
},
|
||||
zmqSockets: make(map[string]*ZMQHandler),
|
||||
capnpServers: make(map[string]*CapnpHandler),
|
||||
grpcServers: make(map[string]*grpc.Server),
|
||||
sharedMemory: NewSharedMemoryPool(),
|
||||
routingTable: NewRoutingTable(),
|
||||
mixerPool: NewMixerPool(),
|
||||
zkProver: NewZKProver(),
|
||||
}
|
||||
|
||||
return network, nil
|
||||
}
|
||||
|
||||
// StartZMQEndpoint starts a ZeroMQ endpoint
|
||||
func (an *AgenticNetwork) StartZMQEndpoint(name string, endpoint string, socketType zmq.Type) error {
|
||||
socket, err := zmq.NewSocket(socketType)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create ZMQ socket: %w", err)
|
||||
}
|
||||
|
||||
// Configure socket options
|
||||
socket.SetLinger(5 * time.Second)
|
||||
socket.SetRcvhwm(10000)
|
||||
socket.SetSndhwm(10000)
|
||||
|
||||
// Bind or connect based on socket type
|
||||
switch socketType {
|
||||
case zmq.REP, zmq.ROUTER, zmq.PUB, zmq.PULL:
|
||||
err = socket.Bind(endpoint)
|
||||
case zmq.REQ, zmq.DEALER, zmq.SUB, zmq.PUSH:
|
||||
err = socket.Connect(endpoint)
|
||||
default:
|
||||
return fmt.Errorf("unsupported socket type: %v", socketType)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to bind/connect ZMQ socket: %w", err)
|
||||
}
|
||||
|
||||
handler := &ZMQHandler{
|
||||
socketType: socketType,
|
||||
socket: socket,
|
||||
endpoint: endpoint,
|
||||
}
|
||||
|
||||
an.mu.Lock()
|
||||
an.zmqSockets[name] = handler
|
||||
an.mu.Unlock()
|
||||
|
||||
// Start message handler goroutine
|
||||
go an.handleZMQMessages(name, handler)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartCapnpEndpoint starts a Cap'n Proto endpoint
|
||||
func (an *AgenticNetwork) StartCapnpEndpoint(name string, address string) error {
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to listen on %s: %w", address, err)
|
||||
}
|
||||
|
||||
// Create Cap'n Proto server
|
||||
server := &capnp.Server{
|
||||
Methods: an.createCapnpMethods(),
|
||||
}
|
||||
|
||||
handler := &CapnpHandler{
|
||||
listener: listener,
|
||||
server: server,
|
||||
}
|
||||
|
||||
an.mu.Lock()
|
||||
an.capnpServers[name] = handler
|
||||
an.mu.Unlock()
|
||||
|
||||
// Start serving
|
||||
go func() {
|
||||
log.Printf("Cap'n Proto server listening on %s", address)
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
log.Printf("Failed to accept connection: %v", err)
|
||||
continue
|
||||
}
|
||||
go server.ServeConn(conn)
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartgRPCEndpoint starts a gRPC endpoint
|
||||
func (an *AgenticNetwork) StartgRPCEndpoint(name string, address string) error {
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to listen on %s: %w", address, err)
|
||||
}
|
||||
|
||||
// Create gRPC server with options
|
||||
server := grpc.NewServer(
|
||||
grpc.MaxRecvMsgSize(64*1024*1024), // 64MB
|
||||
grpc.MaxSendMsgSize(64*1024*1024), // 64MB
|
||||
grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||
Time: 60 * time.Second,
|
||||
Timeout: 10 * time.Second,
|
||||
}),
|
||||
)
|
||||
|
||||
// Register agentic service
|
||||
RegisterAgenticServiceServer(server, an)
|
||||
|
||||
an.mu.Lock()
|
||||
an.grpcServers[name] = server
|
||||
an.mu.Unlock()
|
||||
|
||||
// Start serving
|
||||
go func() {
|
||||
log.Printf("gRPC server listening on %s", address)
|
||||
if err := server.Serve(listener); err != nil {
|
||||
log.Printf("gRPC server error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendValueTransfer sends value with post-quantum privacy
|
||||
func (an *AgenticNetwork) SendValueTransfer(ctx context.Context, transfer *ValueTransfer) error {
|
||||
// Create zero-knowledge proof for privacy
|
||||
zkProof, err := an.zkProver.CreateTransferProof(transfer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create ZK proof: %w", err)
|
||||
}
|
||||
|
||||
// Apply mixer for anonymity
|
||||
mixedTransfer, err := an.mixerPool.MixTransfer(transfer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to mix transfer: %w", err)
|
||||
}
|
||||
|
||||
// Encrypt with post-quantum crypto
|
||||
encryptedTransfer, err := an.encryptPQ(mixedTransfer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to encrypt transfer: %w", err)
|
||||
}
|
||||
|
||||
// Create Cap'n Proto message
|
||||
msg := &AgenticMessage{
|
||||
MessageID: generateMessageID(),
|
||||
Timestamp: uint64(time.Now().UnixNano()),
|
||||
SourceAgent: an.agentID,
|
||||
Payload: &ValueTransferPayload{Transfer: encryptedTransfer, ZKProof: zkProof},
|
||||
Encryption: encryptedTransfer.Encryption,
|
||||
}
|
||||
|
||||
// Route and send
|
||||
return an.routeMessage(ctx, msg)
|
||||
}
|
||||
|
||||
// RequestComputation requests computation from another agent
|
||||
func (an *AgenticNetwork) RequestComputation(ctx context.Context, req *ComputationRequest) (*ComputationResult, error) {
|
||||
// Find suitable agents
|
||||
agents, err := an.discoverAgents(ctx, req.Requirements)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to discover agents: %w", err)
|
||||
}
|
||||
|
||||
if len(agents) == 0 {
|
||||
return nil, fmt.Errorf("no suitable agents found")
|
||||
}
|
||||
|
||||
// Select best agent based on price, latency, reputation
|
||||
bestAgent := an.selectBestAgent(agents, req.Requirements)
|
||||
|
||||
// Prepare computation with privacy
|
||||
privacyConfig := req.Privacy
|
||||
var encryptedInput []byte
|
||||
|
||||
switch privacyConfig.InputPrivacy {
|
||||
case PrivacyLevelFHE:
|
||||
// Fully homomorphic encryption
|
||||
encryptedInput, err = an.encryptFHE(req.InputData, bestAgent.PublicKey)
|
||||
case PrivacyLevelMPC:
|
||||
// Multi-party computation
|
||||
encryptedInput, err = an.prepareMPC(req.InputData, privacyConfig.MPC)
|
||||
case PrivacyLevelTEE:
|
||||
// Trusted execution environment
|
||||
encryptedInput, err = an.prepareTEE(req.InputData, privacyConfig.TEE)
|
||||
default:
|
||||
// Standard post-quantum encryption
|
||||
encryptedInput, err = an.encryptPQ(req.InputData)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to prepare computation input: %w", err)
|
||||
}
|
||||
|
||||
// Create computation message
|
||||
computeMsg := &AgenticMessage{
|
||||
MessageID: generateMessageID(),
|
||||
Timestamp: uint64(time.Now().UnixNano()),
|
||||
SourceAgent: an.agentID,
|
||||
TargetAgent: bestAgent.ID,
|
||||
Payload: &ComputationPayload{
|
||||
Request: req,
|
||||
EncryptedInput: encryptedInput,
|
||||
},
|
||||
}
|
||||
|
||||
// Send computation request
|
||||
response, err := an.sendComputeRequest(ctx, computeMsg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send computation request: %w", err)
|
||||
}
|
||||
|
||||
// Decrypt and verify result
|
||||
result, err := an.processComputeResponse(response, privacyConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to process computation response: %w", err)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ShareIntelligence shares AI/ML intelligence with other agents
|
||||
func (an *AgenticNetwork) ShareIntelligence(ctx context.Context, intel *IntelligenceShare) error {
|
||||
// Store in shared memory for zero-copy distribution
|
||||
sharedID := an.sharedMemory.Store(intel.Data.Data)
|
||||
|
||||
// Create intelligence share message
|
||||
msg := &AgenticMessage{
|
||||
MessageID: generateMessageID(),
|
||||
Timestamp: uint64(time.Now().UnixNano()),
|
||||
SourceAgent: an.agentID,
|
||||
Payload: &IntelligencePayload{
|
||||
ShareType: intel.ShareType,
|
||||
Data: intel.Data,
|
||||
Rights: intel.Rights,
|
||||
Provenance: intel.Provenance,
|
||||
Incentives: intel.Incentives,
|
||||
},
|
||||
SharedDataRef: &SharedDataReference{
|
||||
SharedID: sharedID,
|
||||
Size: uint64(len(intel.Data.Data)),
|
||||
},
|
||||
}
|
||||
|
||||
// Broadcast to interested agents
|
||||
return an.broadcastIntelligence(ctx, msg)
|
||||
}
|
||||
|
||||
// CoordinateAgents coordinates multiple agents for complex tasks
|
||||
func (an *AgenticNetwork) CoordinateAgents(ctx context.Context, coordination *CoordinationMessage) (*CoordinationResult, error) {
|
||||
// Implement consensus mechanism
|
||||
switch coordination.Proposal.VotingMechanism {
|
||||
case VotingMechanismQuadratic:
|
||||
return an.runQuadraticVoting(ctx, coordination)
|
||||
case VotingMechanismWeighted:
|
||||
return an.runWeightedVoting(ctx, coordination)
|
||||
case VotingMechanismLiquid:
|
||||
return an.runLiquidDemocracy(ctx, coordination)
|
||||
default:
|
||||
return an.runSimpleVoting(ctx, coordination)
|
||||
}
|
||||
}
|
||||
|
||||
// ZMQ message handler
|
||||
func (an *AgenticNetwork) handleZMQMessages(name string, handler *ZMQHandler) {
|
||||
for {
|
||||
// Receive message
|
||||
msg, err := handler.socket.RecvBytes(0)
|
||||
if err != nil {
|
||||
log.Printf("ZMQ receive error: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Parse Cap'n Proto message
|
||||
capnpMsg, err := capnp.Unmarshal(msg)
|
||||
if err != nil {
|
||||
log.Printf("Failed to unmarshal Cap'n Proto message: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Process message
|
||||
go an.processMessage(capnpMsg)
|
||||
}
|
||||
}
|
||||
|
||||
// Cap'n Proto methods
|
||||
func (an *AgenticNetwork) createCapnpMethods() capnp.Method {
|
||||
return capnp.Method{
|
||||
"sendMessage": an.handleCapnpMessage,
|
||||
"queryAgents": an.handleAgentQuery,
|
||||
"requestCompute": an.handleComputeRequest,
|
||||
}
|
||||
}
|
||||
|
||||
func (an *AgenticNetwork) handleCapnpMessage(ctx context.Context, call capnp.Call) error {
|
||||
// Handle incoming Cap'n Proto message
|
||||
params, err := call.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Extract message
|
||||
agenticMsg, err := ReadRootAgenticMessage(params.Struct())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Process based on payload type
|
||||
return an.processAgenticMessage(ctx, agenticMsg)
|
||||
}
|
||||
|
||||
// Post-quantum encryption
|
||||
func (an *AgenticNetwork) encryptPQ(data interface{}) (*PQEncryption, error) {
|
||||
// Serialize data
|
||||
plaintext, err := an.serialize(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Generate ephemeral key pair
|
||||
ephemeralPub, ephemeralPriv, err := kyber1024.GenerateKeyPair(rand.Reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Key encapsulation
|
||||
ciphertext, sharedSecret, err := kyber1024.EncryptTo(ephemeralPub, rand.Reader, plaintext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create signature
|
||||
signature, err := an.sigKeyPair.PrivateKey.Sign(plaintext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PQEncryption{
|
||||
Algorithm: PQAlgorithmKyber1024,
|
||||
EncryptedData: ciphertext,
|
||||
KeyExchange: &PQKeyExchange{
|
||||
Algorithm: PQAlgorithmKyber1024,
|
||||
PublicKey: ephemeralPub.Bytes(),
|
||||
SessionKey: sharedSecret,
|
||||
},
|
||||
Signature: &PQSignature{
|
||||
Algorithm: PQAlgorithmDilithium5,
|
||||
Signature: signature,
|
||||
PublicKey: an.sigKeyPair.PublicKey.Bytes(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// FHE encryption for homomorphic computation
|
||||
func (an *AgenticNetwork) encryptFHE(data interface{}, recipientPubKey []byte) ([]byte, error) {
|
||||
// Implement FHE encryption using BFV/CKKS schemes
|
||||
// This would integrate with a library like Microsoft SEAL or Lattigo
|
||||
return nil, fmt.Errorf("FHE not yet implemented")
|
||||
}
|
||||
|
||||
// MPC preparation
|
||||
func (an *AgenticNetwork) prepareMPC(data interface{}, mpcConfig *MPCConfig) ([]byte, error) {
|
||||
// Implement MPC secret sharing
|
||||
return nil, fmt.Errorf("MPC not yet implemented")
|
||||
}
|
||||
|
||||
// TEE preparation
|
||||
func (an *AgenticNetwork) prepareTEE(data interface{}, teeConfig *TEEConfig) ([]byte, error) {
|
||||
// Implement TEE attestation and secure computation
|
||||
return nil, fmt.Errorf("TEE not yet implemented")
|
||||
}
|
||||
|
||||
// Agent discovery
|
||||
func (an *AgenticNetwork) discoverAgents(ctx context.Context, requirements *ComputeRequirements) ([]*AgentMatch, error) {
|
||||
// Query network for suitable agents
|
||||
query := &DiscoveryQuery{
|
||||
Criteria: &SearchCriteria{
|
||||
Capabilities: requirements.Specialized,
|
||||
TrustLevel: requirements.TrustRequired,
|
||||
},
|
||||
MaxResults: 10,
|
||||
Timeout: 30,
|
||||
}
|
||||
|
||||
return an.queryNetwork(ctx, query)
|
||||
}
|
||||
|
||||
// Network query
|
||||
func (an *AgenticNetwork) queryNetwork(ctx context.Context, query *DiscoveryQuery) ([]*AgentMatch, error) {
|
||||
// Broadcast discovery query via multiple protocols
|
||||
var matches []*AgentMatch
|
||||
|
||||
// Query via ZMQ
|
||||
zmqMatches, err := an.queryViaZMQ(ctx, query)
|
||||
if err == nil {
|
||||
matches = append(matches, zmqMatches...)
|
||||
}
|
||||
|
||||
// Query via Cap'n Proto
|
||||
capnpMatches, err := an.queryViaCapnp(ctx, query)
|
||||
if err == nil {
|
||||
matches = append(matches, capnpMatches...)
|
||||
}
|
||||
|
||||
// Query via gRPC
|
||||
grpcMatches, err := an.queryViagRPC(ctx, query)
|
||||
if err == nil {
|
||||
matches = append(matches, grpcMatches...)
|
||||
}
|
||||
|
||||
// Deduplicate and rank
|
||||
return an.rankAgents(matches), nil
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
func generateMessageID() uint64 {
|
||||
var buf [8]byte
|
||||
rand.Read(buf[:])
|
||||
return binary.LittleEndian.Uint64(buf[:])
|
||||
}
|
||||
|
||||
func (an *AgenticNetwork) serialize(data interface{}) ([]byte, error) {
|
||||
// Implement efficient serialization (protobuf, cap'n proto, or msgpack)
|
||||
return nil, fmt.Errorf("serialization not implemented")
|
||||
}
|
||||
|
||||
func (an *AgenticNetwork) rankAgents(matches []*AgentMatch) []*AgentMatch {
|
||||
// Implement agent ranking based on reputation, price, latency, etc.
|
||||
return matches
|
||||
}
|
||||
|
||||
// NetworkConfig for initialization
|
||||
type NetworkConfig struct {
|
||||
Address string
|
||||
InitialStake uint64
|
||||
Capabilities AgentCapabilities
|
||||
Protocols []Protocol
|
||||
Security SecurityConfig
|
||||
}
|
||||
|
||||
// Privacy components (placeholder implementations)
|
||||
type MixerPool struct{}
|
||||
|
||||
func NewMixerPool() *MixerPool { return &MixerPool{} }
|
||||
func (mp *MixerPool) MixTransfer(transfer *ValueTransfer) (*ValueTransfer, error) {
|
||||
return transfer, nil
|
||||
}
|
||||
|
||||
type ZKProver struct{}
|
||||
|
||||
func NewZKProver() *ZKProver { return &ZKProver{} }
|
||||
func (zk *ZKProver) CreateTransferProof(transfer *ValueTransfer) (*ZKProof, error) {
|
||||
return &ZKProof{}, nil
|
||||
}
|
||||
|
||||
type RoutingTable struct{}
|
||||
|
||||
func NewRoutingTable() *RoutingTable { return &RoutingTable{} }
|
||||
|
||||
// Placeholder types (implement based on actual requirements)
|
||||
type (
|
||||
Protocol = string
|
||||
ComputeType = string
|
||||
TrustLevel = string
|
||||
ValueTransfer = interface{}
|
||||
ComputationRequest = interface{}
|
||||
ComputationResult = interface{}
|
||||
IntelligenceShare = interface{}
|
||||
CoordinationMessage = interface{}
|
||||
CoordinationResult = interface{}
|
||||
AgentMatch = interface{}
|
||||
ZKProof = interface{}
|
||||
SecurityConfig = interface{}
|
||||
)
|
||||
@@ -4,7 +4,7 @@ go 1.25.5
|
||||
|
||||
require (
|
||||
capnproto.org/go/capnp/v3 v3.1.0-alpha.2
|
||||
github.com/cloudflare/circl v1.6.2
|
||||
github.com/cloudflare/circl v1.6.3
|
||||
github.com/luxfi/crypto v1.17.38
|
||||
github.com/luxfi/formatting v1.0.1
|
||||
github.com/luxfi/ids v1.2.9
|
||||
@@ -25,12 +25,12 @@ require (
|
||||
go.opentelemetry.io/otel v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.39.0 // indirect
|
||||
go.uber.org/mock v0.6.0 // indirect
|
||||
golang.org/x/crypto v0.46.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
|
||||
golang.org/x/net v0.48.0 // indirect
|
||||
golang.org/x/crypto v0.47.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
|
||||
golang.org/x/net v0.49.0 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.39.0 // indirect
|
||||
golang.org/x/text v0.32.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/text v0.33.0 // indirect
|
||||
gonum.org/v1/gonum v0.16.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
capnproto.org/go/capnp/v3 v3.1.0-alpha.2 h1:93ISpqHf2/3WQlfrBP0tT8Dg/RQc3uq6DV36vN0ePWk=
|
||||
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251230134950-44c893854e3f h1:a5PUgHGinaD6XrLmIDLQmGHocjIjBsBAcR5gALjZvMU=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cloudflare/circl v1.6.2 h1:hL7VBpHHKzrV5WTfHCaBsgx/HGbBYlgrwvNXEVDYYsQ=
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/colega/zeropool v0.0.0-20230505084239-6fb4a4f75381 h1:d5EKgQfRQvO97jnISfR89AiCCCJMwMFoSxUiU0OGCRU=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -44,13 +44,12 @@ go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2W
|
||||
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
|
||||
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
|
||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
|
||||
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
|
||||
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
|
||||
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 h1:Z/6YuSHTLOHfNFdb8zVZomZr7cqNgTJvA8+Qz75D8gU=
|
||||
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
|
||||
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
|
||||
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU=
|
||||
google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc=
|
||||
|
||||
+6
-6
@@ -18,10 +18,10 @@ type APIArgs struct {
|
||||
|
||||
// Result describes a health check result.
|
||||
type Result struct {
|
||||
Details interface{} `json:"message,omitempty"`
|
||||
Error *string `json:"error,omitempty"`
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
Duration time.Duration `json:"duration"`
|
||||
ContiguousFailures int64 `json:"contiguousFailures,omitempty"`
|
||||
TimeOfFirstFailure *time.Time `json:"timeOfFirstFailure,omitempty"`
|
||||
Details interface{} `json:"message,omitempty"`
|
||||
Error *string `json:"error,omitempty"`
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
Duration time.Duration `json:"duration"`
|
||||
ContiguousFailures int64 `json:"contiguousFailures,omitempty"`
|
||||
TimeOfFirstFailure *time.Time `json:"timeOfFirstFailure,omitempty"`
|
||||
}
|
||||
|
||||
+12
-12
@@ -6,19 +6,19 @@ package info
|
||||
import "context"
|
||||
|
||||
const (
|
||||
MethodGetNodeVersion = "info.getNodeVersion"
|
||||
MethodGetNodeID = "info.getNodeID"
|
||||
MethodGetNodeIP = "info.getNodeIP"
|
||||
MethodGetNetworkID = "info.getNetworkID"
|
||||
MethodGetNetworkName = "info.getNetworkName"
|
||||
MethodGetNodeVersion = "info.getNodeVersion"
|
||||
MethodGetNodeID = "info.getNodeID"
|
||||
MethodGetNodeIP = "info.getNodeIP"
|
||||
MethodGetNetworkID = "info.getNetworkID"
|
||||
MethodGetNetworkName = "info.getNetworkName"
|
||||
MethodGetBlockchainID = "info.getBlockchainID"
|
||||
MethodPeers = "info.peers"
|
||||
MethodIsBootstrapped = "info.isBootstrapped"
|
||||
MethodUpgrades = "info.upgrades"
|
||||
MethodUptime = "info.uptime"
|
||||
MethodLps = "info.lps"
|
||||
MethodGetTxFee = "info.getTxFee"
|
||||
MethodGetVMs = "info.getVMs"
|
||||
MethodPeers = "info.peers"
|
||||
MethodIsBootstrapped = "info.isBootstrapped"
|
||||
MethodUpgrades = "info.upgrades"
|
||||
MethodUptime = "info.uptime"
|
||||
MethodLps = "info.lps"
|
||||
MethodGetTxFee = "info.getTxFee"
|
||||
MethodGetVMs = "info.getVMs"
|
||||
)
|
||||
|
||||
// Service defines the info API contract.
|
||||
|
||||
+13
-13
@@ -88,17 +88,17 @@ type IsBootstrappedResponse struct {
|
||||
|
||||
// UptimeResponse are the results from calling Uptime.
|
||||
type UptimeResponse struct {
|
||||
RewardingStakePercentage types.Float64 `json:"rewardingStakePercentage"`
|
||||
RewardingStakePercentage types.Float64 `json:"rewardingStakePercentage"`
|
||||
WeightedAveragePercentage types.Float64 `json:"weightedAveragePercentage"`
|
||||
}
|
||||
|
||||
// LP is information about an LP proposal.
|
||||
type LP struct {
|
||||
SupportWeight types.Uint64 `json:"supportWeight"`
|
||||
Supporters set.Set[ids.NodeID] `json:"supporters"`
|
||||
ObjectWeight types.Uint64 `json:"objectWeight"`
|
||||
Objectors set.Set[ids.NodeID] `json:"objectors"`
|
||||
AbstainWeight types.Uint64 `json:"abstainWeight"`
|
||||
SupportWeight types.Uint64 `json:"supportWeight"`
|
||||
Supporters set.Set[ids.NodeID] `json:"supporters"`
|
||||
ObjectWeight types.Uint64 `json:"objectWeight"`
|
||||
Objectors set.Set[ids.NodeID] `json:"objectors"`
|
||||
AbstainWeight types.Uint64 `json:"abstainWeight"`
|
||||
}
|
||||
|
||||
// LPsReply are the results from calling LPs.
|
||||
@@ -108,13 +108,13 @@ type LPsReply struct {
|
||||
|
||||
// GetTxFeeResponse are the results from calling GetTxFee.
|
||||
type GetTxFeeResponse struct {
|
||||
TxFee types.Uint64 `json:"txFee"`
|
||||
CreateAssetTxFee types.Uint64 `json:"createAssetTxFee"`
|
||||
CreateNetworkTxFee types.Uint64 `json:"createNetworkTxFee"`
|
||||
TransformChainTxFee types.Uint64 `json:"transformChainTxFee"`
|
||||
CreateChainTxFee types.Uint64 `json:"createChainTxFee"`
|
||||
AddNetworkValidatorFee types.Uint64 `json:"addNetworkValidatorFee"`
|
||||
AddNetworkDelegatorFee types.Uint64 `json:"addNetworkDelegatorFee"`
|
||||
TxFee types.Uint64 `json:"txFee"`
|
||||
CreateAssetTxFee types.Uint64 `json:"createAssetTxFee"`
|
||||
CreateNetworkTxFee types.Uint64 `json:"createNetworkTxFee"`
|
||||
TransformChainTxFee types.Uint64 `json:"transformChainTxFee"`
|
||||
CreateChainTxFee types.Uint64 `json:"createChainTxFee"`
|
||||
AddNetworkValidatorFee types.Uint64 `json:"addNetworkValidatorFee"`
|
||||
AddNetworkDelegatorFee types.Uint64 `json:"addNetworkDelegatorFee"`
|
||||
}
|
||||
|
||||
// GetVMsReply contains the response metadata for GetVMs.
|
||||
|
||||
+4
-4
@@ -373,10 +373,10 @@ type Server struct {
|
||||
listener *Listener
|
||||
handler Handler
|
||||
|
||||
mu sync.Mutex
|
||||
conns map[*ServerConn]struct{}
|
||||
closed atomic.Bool
|
||||
done chan struct{}
|
||||
mu sync.Mutex
|
||||
conns map[*ServerConn]struct{}
|
||||
closed atomic.Bool
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// NewServer creates a new ZAP server
|
||||
|
||||
Reference in New Issue
Block a user