Documentation
¶
Index ¶
- Constants
- type AIAgent
- type AITask
- type Block
- func (b *Block) Accept(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) Reject(context.Context) error
- func (b *Block) Status() choices.Status
- func (b *Block) Timestamp() time.Time
- func (b *Block) Verify(ctx context.Context) error
- type ComputeMetrics
- type DiscountTier
- type Factory
- type GPUProvider
- type GPUSpec
- type GPUSubnet
- type GPUSubnetConfig
- type GPUSubnetManager
- type GPUTask
- type GPUTaskResult
- type Pricing
- type PricingModel
- type ProviderInfo
- type ProviderStatus
- type QualityRequirement
- type SubnetMetrics
- type TaskRequirements
- type TaskResult
- type TaskStatus
- type VM
- func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
- func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, ...) error
- func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
- func (vm *VM) BuildBlock(ctx context.Context) (block.Block, error)
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
- func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)
- func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, ...) error
- func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *common.AppError) error
- func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, msg []byte) error
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) GetBlock(ctx context.Context, blkID ids.ID) (block.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) HealthCheck(context.Context) (any, error)
- func (vm *VM) Initialize(ctx context.Context, chainCtx *consensusctx.Context, db database.Database, ...) error
- func (vm *VM) LastAccepted(context.Context) (ids.ID, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (block.Block, error)
- func (vm *VM) SetPreference(ctx context.Context, blkID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state core.State) error
- func (vm *VM) Shutdown(context.Context) error
- func (vm *VM) Version(context.Context) (string, error)
Constants ¶
const (
Name = "aivm"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIAgent ¶
type AIAgent struct {
ID ids.ShortID `json:"id"`
Name string `json:"name"`
Capabilities []string `json:"capabilities"`
Subnet ids.ID `json:"subnet"`
Endpoint string `json:"endpoint"`
PublicKey []byte `json:"publicKey"`
}
AIAgent represents an AI agent or model provider
type AITask ¶
type AITask struct {
ID ids.ID `json:"id"`
Requester ids.ShortID `json:"requester"`
TaskType string `json:"taskType"`
Parameters []byte `json:"parameters"`
Status TaskStatus `json:"status"`
Result []byte `json:"result,omitempty"`
ProofOfWork []byte `json:"proofOfWork,omitempty"`
Fee uint64 `json:"fee"`
CreatedAt int64 `json:"createdAt"`
CompletedAt int64 `json:"completedAt,omitempty"`
}
AITask represents an AI computation task
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block represents a block in the AI Chain
type ComputeMetrics ¶ added in v1.20.0
type ComputeMetrics struct {
ExecutionTime time.Duration `json:"executionTime"`
GPUTime time.Duration `json:"gpuTime"`
MemoryUsed uint64 `json:"memoryUsed"`
PowerUsed float64 `json:"powerUsed"` // Watts
Accuracy float64 `json:"accuracy,omitempty"`
Throughput float64 `json:"throughput,omitempty"`
}
ComputeMetrics tracks computation metrics
type DiscountTier ¶ added in v1.20.0
type DiscountTier struct {
MinHours uint64 `json:"minHours"`
Discount float64 `json:"discount"` // Percentage
}
DiscountTier defines volume discounts
type GPUProvider ¶
type GPUProvider struct {
NodeID ids.NodeID `json:"nodeId"`
ProviderInfo ProviderInfo `json:"providerInfo"`
GPUs []GPUSpec `json:"gpus"`
Status ProviderStatus `json:"status"`
Reputation float64 `json:"reputation"`
TasksHandled uint64 `json:"tasksHandled"`
JoinedAt time.Time `json:"joinedAt"`
}
GPUProvider represents a GPU compute provider
type GPUSpec ¶ added in v1.20.0
type GPUSpec struct {
Model string `json:"model"` // e.g., "RTX 4090", "A100", "H100"
Memory uint64 `json:"memory"` // VRAM in GB
ComputeUnits int `json:"computeUnits"`
Performance float64 `json:"performance"` // TFLOPS
Available bool `json:"available"`
Temperature float64 `json:"temperature"`
Utilization float64 `json:"utilization"`
}
GPUSpec defines GPU specifications
type GPUSubnet ¶ added in v1.20.0
type GPUSubnet struct {
SubnetID ids.ID `json:"subnetId"`
Name string `json:"name"`
Config GPUSubnetConfig `json:"config"`
Providers []GPUProvider `json:"providers"`
Tasks []GPUTask `json:"tasks"`
Performance SubnetMetrics `json:"performance"`
// contains filtered or unexported fields
}
GPUSubnet represents a GPU-powered subnet for AI computation
func (*GPUSubnet) GetSubnetStats ¶ added in v1.20.0
func (s *GPUSubnet) GetSubnetStats() SubnetMetrics
GetSubnetStats returns subnet statistics
func (*GPUSubnet) RegisterProvider ¶ added in v1.20.0
RegisterProvider registers a GPU provider to a subnet
type GPUSubnetConfig ¶ added in v1.20.0
type GPUSubnetConfig struct {
MinGPUCount int `json:"minGpuCount"`
RequiredGPUTypes []string `json:"requiredGpuTypes"`
TaskTypes []string `json:"taskTypes"`
PricingModel PricingModel `json:"pricingModel"`
QualityMetrics QualityRequirement `json:"qualityMetrics"`
NetworkTopology string `json:"networkTopology"` // "mesh", "star", "hybrid"
}
GPUSubnetConfig defines configuration for GPU subnet
func TestGPUSubnet ¶ added in v1.20.0
func TestGPUSubnet() *GPUSubnetConfig
TestGPUSubnet creates a test GPU subnet configuration
type GPUSubnetManager ¶ added in v1.20.0
type GPUSubnetManager struct {
// contains filtered or unexported fields
}
GPUSubnetManager manages GPU subnets
func NewGPUSubnetManager ¶ added in v1.20.0
func NewGPUSubnetManager(aivm *VM, log log.Logger) *GPUSubnetManager
NewGPUSubnetManager creates a new GPU subnet manager
func (*GPUSubnetManager) CreateSubnet ¶ added in v1.20.0
func (m *GPUSubnetManager) CreateSubnet(name string, config GPUSubnetConfig) (*GPUSubnet, error)
CreateSubnet creates a new GPU subnet
type GPUTask ¶ added in v1.20.0
type GPUTask struct {
TaskID ids.ID `json:"taskId"`
Type string `json:"type"` // "training", "inference", "rendering", "mining"
Requirements TaskRequirements `json:"requirements"`
Requester ids.ShortID `json:"requester"`
Provider ids.NodeID `json:"provider"`
Status TaskStatus `json:"status"`
Result GPUTaskResult `json:"result"`
CreatedAt time.Time `json:"createdAt"`
StartedAt time.Time `json:"startedAt"`
CompletedAt time.Time `json:"completedAt"`
}
GPUTask represents an AI computation task
type GPUTaskResult ¶ added in v1.20.0
type GPUTaskResult struct {
Success bool `json:"success"`
Output []byte `json:"output,omitempty"`
Metrics ComputeMetrics `json:"metrics"`
ProofOfWork []byte `json:"proofOfWork"`
Error string `json:"error,omitempty"`
}
GPUTaskResult contains GPU task execution results
type Pricing ¶ added in v1.20.0
type Pricing struct {
HourlyRate uint64 `json:"hourlyRate"`
MinDuration time.Duration `json:"minDuration"`
MaxDuration time.Duration `json:"maxDuration"`
Currency string `json:"currency"` // "LUX"
}
Pricing contains provider-specific pricing
type PricingModel ¶ added in v1.20.0
type PricingModel struct {
BasePrice uint64 `json:"basePrice"` // Per GPU hour
PricePerTFLOPS uint64 `json:"pricePerTflops"`
SurgeMultiplier float64 `json:"surgeMultiplier"`
DiscountTiers []DiscountTier `json:"discountTiers"`
}
PricingModel defines pricing for GPU compute
type ProviderInfo ¶ added in v1.20.0
type ProviderInfo struct {
Name string `json:"name"`
Location string `json:"location"`
Capabilities []string `json:"capabilities"`
Pricing Pricing `json:"pricing"`
}
ProviderInfo contains provider details
type ProviderStatus ¶ added in v1.20.0
type ProviderStatus struct {
Online bool `json:"online"`
LastSeen time.Time `json:"lastSeen"`
Uptime float64 `json:"uptime"`
FailureRate float64 `json:"failureRate"`
CurrentTasks int `json:"currentTasks"`
MaxTasks int `json:"maxTasks"`
}
ProviderStatus represents provider status
type QualityRequirement ¶ added in v1.20.0
type QualityRequirement struct {
MinReputation float64 `json:"minReputation"`
MaxFailureRate float64 `json:"maxFailureRate"`
MinUptime float64 `json:"minUptime"`
RequireSLA bool `json:"requireSla"`
}
QualityRequirement defines quality requirements
type SubnetMetrics ¶ added in v1.20.0
type SubnetMetrics struct {
TotalTasks uint64 `json:"totalTasks"`
CompletedTasks uint64 `json:"completedTasks"`
FailedTasks uint64 `json:"failedTasks"`
AverageLatency time.Duration `json:"averageLatency"`
TotalGPUHours float64 `json:"totalGpuHours"`
NetworkHashrate float64 `json:"networkHashrate"`
ActiveProviders int `json:"activeProviders"`
}
SubnetMetrics tracks subnet performance
type TaskRequirements ¶ added in v1.20.0
type TaskRequirements struct {
GPUModel string `json:"gpuModel,omitempty"`
MinMemory uint64 `json:"minMemory"`
MinCompute float64 `json:"minCompute"`
MaxLatency time.Duration `json:"maxLatency"`
DataSize uint64 `json:"dataSize"`
ModelSize uint64 `json:"modelSize,omitempty"`
Framework string `json:"framework,omitempty"` // "pytorch", "tensorflow", "jax"
CustomParams map[string]string `json:"customParams,omitempty"`
}
TaskRequirements defines task requirements
type TaskResult ¶
type TaskResult struct {
TaskID ids.ID `json:"taskId"`
ExecutorID ids.ShortID `json:"executorId"`
Result []byte `json:"result"`
Proof []byte `json:"proof"`
ComputeTime uint64 `json:"computeTime"`
}
TaskResult represents the result of an AI task
type TaskStatus ¶
type TaskStatus uint8
TaskStatus represents the status of an AI task
const ( TaskPending TaskStatus = iota TaskAssigned TaskProcessing TaskCompleted TaskFailed )
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM implements the chain.ChainVM interface for the AI Chain (A-Chain) This chain is specialized for AI computation and agent coordination
func (*VM) AppRequest ¶
func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error
AppRequest implements the common.AppHandler interface
func (*VM) AppRequestFailed ¶
func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error
AppRequestFailed implements the common.AppHandler interface
func (*VM) AppResponse ¶
func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
AppResponse implements the common.AppHandler interface
func (*VM) BuildBlock ¶
BuildBlock implements the chain.ChainVM interface
func (*VM) Connected ¶
func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
Connected implements the validators.Connector interface
func (*VM) CreateHandlers ¶
CreateHandlers implements the core.VM interface
func (*VM) CrossChainAppRequest ¶
func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, msg []byte) error
CrossChainAppRequest implements the core.VM interface
func (*VM) CrossChainAppRequestFailed ¶
func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *common.AppError) error
CrossChainAppRequestFailed implements the core.VM interface
func (*VM) CrossChainAppResponse ¶
func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, msg []byte) error
CrossChainAppResponse implements the core.VM interface
func (*VM) Disconnected ¶
Disconnected implements the validators.Connector interface
func (*VM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight implements the chain.ChainVM interface
func (*VM) HealthCheck ¶
HealthCheck implements the health.Checker interface
func (*VM) Initialize ¶
func (vm *VM) Initialize( ctx context.Context, chainCtx *consensusctx.Context, db database.Database, genesisBytes []byte, upgradeBytes []byte, configBytes []byte, toEngine chan<- block.Message, fxs []*consensus.Fx, appSender appsender.AppSender, ) error
Initialize implements the core.VM interface
func (*VM) LastAccepted ¶
LastAccepted implements the chain.ChainVM interface
func (*VM) ParseBlock ¶
ParseBlock implements the chain.ChainVM interface
func (*VM) SetPreference ¶
SetPreference implements the chain.ChainVM interface