aivm

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Overview

Package aivm GPU backend — runtime-loaded plugin bridge.

Unlike cevm/cevm_cgo.go (which links libevm + libevm-gpu via pkg-config), AIVM resolves its GPU backend at PROCESS START via dlopen/dlsym against the lux-gpu-kernels plugin DSOs. This keeps the chains module compilable without the lux GPU plugin present in the build tree — the plugin is fully optional.

Lookup order (handled by backend.go):

libluxgpu_backend_cuda.so       (Linux x86_64 + NVIDIA)
libluxgpu_backend_hip.so        (Linux x86_64 + AMD ROCm)
libluxgpu_backend_metal.dylib   (macOS Apple Silicon / Intel)
libluxgpu_backend_vulkan.so/.dylib   (any Vulkan ICD)
libluxgpu_backend_webgpu.so/.dylib   (Dawn / wgpu-native)

Each plugin exports six extern "C" host launchers per backend:

lux_<backend>_aivm_attestation_apply
lux_<backend>_aivm_provenance_apply
lux_<backend>_aivm_anchor_apply
lux_<backend>_aivm_epoch_transition
lux_<backend>_aivm_inference_step
lux_<backend>_aivm_proof_verify

Struct layout matches ops/aivm/cuda/aivm_kernels_common.cuh byte-for-byte (asserted by init()). Pointer ABI is HOST pointers — the launcher does H2D-upload / dispatch / D2H-download internally.

Package aivm provides the AI Virtual Machine for the Lux network.

AIVM is the AI compute coordination layer. It works on ANY Lux L1/L2 (mainnet primary network, testnet, devnet, white-label chains) with NO trusted dealer, NO TEE requirement, and NO single point of trust.

Verification model (per VerificationMode):

  • ModeOptimistic (DEFAULT, public-BFT-safe): providers post results with hash-commitment + bond; N-block challenge period; uncontested results finalise; challenged results enter fraud-proof flow with slashing of the losing side. No TEE assumption. Works on any L1/L2 that has Pulsar/Corona for finality.

  • ModeMultiPartyRedundant: M-of-N validators run the same inference and consensus on the output hash. No single provider needs trust; malicious providers diverge from the majority and are slashed. Public-BFT-safe. Cost: M× compute per task.

  • ModeTEEAttested: when a provider has SGX/SEV-SNP/TDX/nvtrust available, the attestation is FOLDED INTO the trust score as an accelerator (skip the challenge period for high-trust-score providers). TEE never CHANGES the trust root — only reduces latency-to-finality for already-bonded providers.

The TEE path (luxfi/ai/pkg/attestation) is OPTIONAL across all modes. Setting RequireTEEAttestation=true is a deployment policy choice for permissioned/regulated subnets; the public-chain default is VerificationMode=ModeOptimistic + RequireTEEAttestation=false.

Other features:

  • Task submission and assignment (chain-agnostic)
  • Mining rewards (paid in the host chain's native token)
  • Optional anchoring to Q-Chain for cross-chain settlement (controlled by HostChainID: when "primary", anchor to Q-Chain; otherwise anchor to the host chain's own finality)

Index

Constants

View Source
const (
	InferenceInDim  = 32
	InferenceHidden = 16
	InferenceOutDim = 1
)

InferenceWeights mirrors aivm::cuda::InferenceWeights (672 bytes). 32→16→1 quantized classifier weights.

Variables

View Source
var (
	Version = &version.Semantic{
		Major: 1,
		Minor: 0,
		Patch: 0,
	}

	ErrNotInitialized   = errors.New("vm not initialized")
	ErrInvalidTask      = errors.New("invalid task")
	ErrProviderNotFound = errors.New("provider not found")
)
View Source
var ErrGPUNotAvailable = errors.New("aivm: no GPU plugin available")

ErrGPUNotAvailable is returned by every GPUBackend method when no plugin was loadable at init time. Callers fall through to the existing Go path.

View Source
var VMID = ids.ID{'a', 'i', 'v', 'm'}

VMID is the unique identifier for AIVM (A-Chain)

Functions

func NewService

func NewService(vm *VM) http.Handler

NewService creates a new AIVM service

func SetBackend added in v1.3.0

func SetBackend(m Mode)

SetBackend selects the active AIVM transition mode for the process. Use AutoAIVM (the default) to let init()'s dlopen probe pick the best available backend.

Types

type AIVMEpochState added in v1.3.0

type AIVMEpochState struct {
	CurrentEpoch            uint64
	NextEpochHeight         uint64
	TotalActiveAttestations uint64
	ActiveModelCount        uint32
	ExpiredAttestationCount uint32
	AttestationRoot         [32]byte
	ModelRegistryRoot       [32]byte
	AuditRoot               [32]byte
	AIVMStateRoot           [32]byte
}

AIVMEpochState mirrors aivm::cuda::AIVMEpochState (160 bytes).

type AIVMRoundDescriptor added in v1.3.0

type AIVMRoundDescriptor struct {
	ChainID            uint64
	Round              uint64
	TimestampNS        uint64
	Epoch              uint64
	Mode               uint32
	AttestationOpCount uint32
	ModelOpCount       uint32
	AnchorOpCount      uint32
	ClosingFlag        uint32

	ParentAIVMRoot [32]byte
	// contains filtered or unexported fields
}

AIVMRoundDescriptor mirrors aivm::cuda::AIVMRoundDescriptor (96 bytes).

type AIVMTransitionResult added in v1.3.0

type AIVMTransitionResult struct {
	Status                uint32
	AttestationApplyCount uint32
	ModelApplyCount       uint32
	AnchorApplyCount      uint32
	ActiveAttestations    uint32
	ExpiredAttestations   uint32
	ModelCount            uint32
	AnchorCount           uint32
	Epoch                 uint64
	TotalModels           uint64
	TotalAnchors          uint64

	AttestationRoot   [32]byte
	ModelRegistryRoot [32]byte
	AuditRoot         [32]byte
	AIVMStateRoot     [32]byte
	// contains filtered or unexported fields
}

AIVMTransitionResult mirrors aivm::cuda::AIVMTransitionResult (192 bytes).

type AIVertex

type AIVertex struct {
	// contains filtered or unexported fields
}

AIVertex represents a DAG vertex in the AI chain. Conflict key: jobID. Independent jobs commute; same job conflicts.

func (*AIVertex) Accept

func (v *AIVertex) Accept(ctx context.Context) error

func (*AIVertex) Bytes

func (v *AIVertex) Bytes() []byte

func (*AIVertex) Conflicts

func (v *AIVertex) Conflicts(other *AIVertex) bool

Conflicts returns true if this vertex and other reference the same jobID.

func (*AIVertex) ConflictsVertex

func (v *AIVertex) ConflictsVertex(other vertex.Vertex) bool

ConflictsVertex performs the same check against the vertex.Vertex interface.

func (*AIVertex) Epoch

func (v *AIVertex) Epoch() uint32

func (*AIVertex) Height

func (v *AIVertex) Height() uint64

func (*AIVertex) ID

func (v *AIVertex) ID() ids.ID

func (*AIVertex) Parents

func (v *AIVertex) Parents() []ids.ID

func (*AIVertex) Reject

func (v *AIVertex) Reject(ctx context.Context) error

func (*AIVertex) Status

func (v *AIVertex) Status() choices.Status

func (*AIVertex) Txs

func (v *AIVertex) Txs() []ids.ID

func (*AIVertex) Verify

func (v *AIVertex) Verify(ctx context.Context) error

type AnchorOp added in v1.3.0

type AnchorOp struct {
	CommitRoot               [32]byte
	ParentRoot               [32]byte
	ValidatorSetRootAtCommit [32]byte
	Height                   uint64
	TimestampNS              uint64
	Epoch                    uint32
	// contains filtered or unexported fields
}

AnchorOp mirrors aivm::cuda::AnchorOp (128 bytes).

type Attestation added in v1.3.0

type Attestation struct {
	TEEQuoteDigest [32]byte
	Measurement    [32]byte
	AttestingKey   [48]byte
	ExpiryNS       uint64
	Kind           uint32
	EvidenceOffset uint32
	EvidenceLen    uint32
	Status         uint32
	Occupied       uint32
	// contains filtered or unexported fields
}

Attestation mirrors aivm::cuda::Attestation (144 bytes).

type AttestationOp added in v1.3.0

type AttestationOp struct {
	TEEQuoteDigest [32]byte
	Measurement    [32]byte
	AttestingKey   [48]byte
	ExpiryNS       uint64
	Kind           uint32
	EvidenceOffset uint32
	EvidenceLen    uint32
	Epoch          uint32
	// contains filtered or unexported fields
}

AttestationOp mirrors aivm::cuda::AttestationOp (144 bytes).

type AuditAnchor added in v1.3.0

type AuditAnchor struct {
	CommitRoot               [32]byte
	ParentRoot               [32]byte
	ValidatorSetRootAtCommit [32]byte
	Height                   uint64
	TimestampNS              uint64
	Occupied                 uint32
	// contains filtered or unexported fields
}

AuditAnchor mirrors aivm::cuda::AuditAnchor (128 bytes).

type BackendKind added in v1.3.0

type BackendKind uint8

BackendKind identifies which lux-gpu-kernels plugin satisfied the runtime dlopen probe. AvailableNone is the sentinel "fall through to Go".

const (
	AvailableNone   BackendKind = 0
	AvailableCUDA   BackendKind = 1
	AvailableHIP    BackendKind = 2
	AvailableMetal  BackendKind = 3
	AvailableVulkan BackendKind = 4
	AvailableWebGPU BackendKind = 5
)

func EffectiveBackendKind added in v1.3.0

func EffectiveBackendKind() BackendKind

EffectiveBackendKind returns which backend the next transition will actually use given (ActiveMode, ActiveGPUBackend). Useful for logging at boot.

func (BackendKind) String added in v1.3.0

func (k BackendKind) String() string

String returns the human-readable name for the backend kind.

type Block

type Block struct {
	ID_        ids.ID    `json:"id"`
	ParentID_  ids.ID    `json:"parentID"`
	Height_    uint64    `json:"height"`
	Timestamp_ time.Time `json:"timestamp"`

	// AI-specific data
	Tasks        []aivm.Task       `json:"tasks,omitempty"`
	Results      []aivm.TaskResult `json:"results,omitempty"`
	MerkleRoot   [32]byte          `json:"merkleRoot"`
	ProviderRegs []ProviderReg     `json:"providerRegs,omitempty"`
	// contains filtered or unexported fields
}

Block represents an AIVM block

func (*Block) Accept

func (blk *Block) Accept(ctx context.Context) error

Accept accepts the block

func (*Block) Bytes

func (blk *Block) Bytes() []byte

Bytes returns the serialized block

func (*Block) Height

func (blk *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (blk *Block) ID() ids.ID

ID returns the block ID

func (*Block) Parent

func (blk *Block) Parent() ids.ID

Parent returns the parent block ID

func (*Block) ParentID

func (blk *Block) ParentID() ids.ID

ParentID returns the parent block ID

func (*Block) Reject

func (blk *Block) Reject(ctx context.Context) error

Reject rejects the block

func (*Block) Status

func (blk *Block) Status() uint8

Status returns the block status

func (*Block) Timestamp

func (blk *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) Verify

func (blk *Block) Verify(ctx context.Context) error

Verify verifies the block

type Config

type Config struct {
	// Network settings
	MaxProvidersPerNode int `serialize:"true" json:"maxProvidersPerNode"`
	MaxTasksPerProvider int `serialize:"true" json:"maxTasksPerProvider"`

	// HostChainID identifies which Lux L1/L2 this AIVM instance runs on.
	// "primary" = primary network (mainnet/testnet/devnet); anchor to
	// Q-Chain for cross-chain settlement. Any other value = white-label
	// L1/L2 (Hanzo, Zoo, Pars, Liquidity); anchor to the host chain's
	// own finality. AIVM is chain-agnostic — same code runs everywhere.
	HostChainID string `serialize:"true" json:"hostChainID"`

	// VerificationMode selects the result-verification strategy.
	// Default: ModeOptimistic (public-BFT-safe).
	VerificationMode VerificationMode `serialize:"true" json:"verificationMode"`

	// ChallengeWindowBlocks is the number of L1/L2 blocks during which
	// any party can submit a fraud proof against a posted result. Only
	// used by ModeOptimistic. Default 100 blocks (~5-10 minutes on
	// most Lux L1/L2 instances).
	ChallengeWindowBlocks uint64 `serialize:"true" json:"challengeWindowBlocks"`

	// RedundancyFactor is M (signatures required) for
	// ModeMultiPartyRedundant. Total providers N is committed in the
	// task spec; M-of-N must produce the same result hash for
	// acceptance. Default 3-of-5.
	RedundancyFactor int `serialize:"true" json:"redundancyFactor"`

	// MinProviderBond is the minimum stake (in host-chain native tokens,
	// wei-equivalent) a provider must lock to register. Forfeited on
	// successful fraud proof or majority-divergence. Default 1000 LUX.
	MinProviderBond uint64 `serialize:"true" json:"minProviderBond"`

	// Attestation settings — TEE is OPT-IN, NOT required by default.
	// On public chains keep RequireTEEAttestation=false; setting it true
	// restricts the provider set to TEE-equipped operators only, which
	// is a permissioned-subnet policy choice.
	RequireTEEAttestation bool   `serialize:"true" json:"requireTEEAttestation"`
	MinTrustScore         uint8  `serialize:"true" json:"minTrustScore"`
	AttestationTimeout    string `serialize:"true" json:"attestationTimeout"`

	// Task settings
	MaxTaskQueueSize int    `serialize:"true" json:"maxTaskQueueSize"`
	TaskTimeout      string `serialize:"true" json:"taskTimeout"`

	// Reward settings
	BaseReward       uint64 `serialize:"true" json:"baseReward"`
	EpochDuration    string `serialize:"true" json:"epochDuration"`
	MerkleAnchorFreq int    `serialize:"true" json:"merkleAnchorFreq"` // Blocks between Q-Chain anchors
}

Config contains AIVM configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default AIVM configuration suitable for ANY public Lux L1/L2 (no trusted dealer, no TEE requirement). The public-BFT-safe defaults are:

  • VerificationMode = ModeOptimistic (fraud-proof flow)
  • RequireTEEAttestation = false (TEE is optional acceleration)
  • HostChainID = "primary" (override per L1/L2 instance)

Permissioned/regulated subnets can opt into ModeTEEAttested + RequireTEEAttestation=true as a policy choice.

func DefaultPermissionedConfig added in v1.2.6

func DefaultPermissionedConfig() Config

DefaultPermissionedConfig returns AIVM config for a permissioned subnet (regulated AI compute, KYC'd provider set). Sets RequireTEEAttestation=true and VerificationMode=ModeTEEAttested. NOT for public mainnet use.

type Factory

type Factory struct{}

Factory implements vms.Factory interface for creating AIVM instances

func (*Factory) New

func (f *Factory) New(log.Logger) (interface{}, error)

New creates a new AIVM instance. Allocates a per-VM GPU session at PriorityNormal for future batch attestation verification and tensor proof checks.

type GPUBackend added in v1.3.0

type GPUBackend struct {
	// contains filtered or unexported fields
}

GPUBackend is a handle to an open lux-gpu-kernels plugin. Zero value is usable (every method returns ErrGPUNotAvailable). The active backend is stored at package level by backend.go's init(); call ActiveGPUBackend() to retrieve it.

func ActiveGPUBackend added in v1.3.0

func ActiveGPUBackend() *GPUBackend

ActiveGPUBackend returns the backend resolved at init time. Always non-nil — when no plugin loaded it returns a zero-value *GPUBackend whose IsAvailable() reports false. Callers test IsAvailable() / Kind() to decide whether to opt into the GPU path.

func (*GPUBackend) AnchorApply added in v1.3.0

func (b *GPUBackend) AnchorApply(
	desc *AIVMRoundDescriptor,
	ops []AnchorOp,
	anchors []AuditAnchor,
	appliedOut *uint32,
) error

AnchorApply runs the GPU audit-anchor kernel.

func (*GPUBackend) AttestationApply added in v1.3.0

func (b *GPUBackend) AttestationApply(
	desc *AIVMRoundDescriptor,
	ops []AttestationOp,
	attestations []Attestation,
	appliedOut *uint32,
) error

AttestationApply runs the GPU attestation kernel. `attestations` is read+ written in place; `appliedOut` is the count of successfully applied ops.

func (*GPUBackend) Close added in v1.3.0

func (b *GPUBackend) Close() error

Close releases the dlopen handle. Idempotent — safe to call on a nil receiver or an already-closed backend.

func (*GPUBackend) EpochTransition added in v1.3.0

func (b *GPUBackend) EpochTransition(
	desc *AIVMRoundDescriptor,
	attestations []Attestation,
	models []ModelRegistryEntry,
	anchors []AuditAnchor,
	epoch *AIVMEpochState,
	result *AIVMTransitionResult,
) error

EpochTransition runs the GPU epoch-finalisation kernel. Composes per-epoch attestation_root / model_registry_root / audit_root / aivm_state_root.

func (*GPUBackend) InferenceStep added in v1.3.0

func (b *GPUBackend) InferenceStep(
	weights *InferenceWeights,
	ops []InferenceOp,
	batchInputs []int8,
	batchOutputs []int8,
	results []InferenceResult,
) error

InferenceStep runs the deterministic int8 32→16→1 inference kernel. `batchInputs` is op_count × 32 bytes of input rows; `batchOutputs` receives op_count × 1 byte of output values. Determinism contract: byte-equal to the CPU reference + every other backend.

func (*GPUBackend) IsAvailable added in v1.3.0

func (b *GPUBackend) IsAvailable() bool

IsAvailable reports whether the backend is loaded AND all six host launchers were successfully resolved. Used by vm.go's gpuAvailable().

func (*GPUBackend) Kind added in v1.3.0

func (b *GPUBackend) Kind() BackendKind

Kind returns which backend satisfied the dlopen probe.

func (*GPUBackend) Path added in v1.3.0

func (b *GPUBackend) Path() string

Path returns the absolute path of the loaded plugin DSO.

func (*GPUBackend) ProofVerify added in v1.3.0

func (b *GPUBackend) ProofVerify(
	ops []ProofVerifyOp,
	results []ProofVerifyResult,
) error

ProofVerify runs the TEE-attestation envelope check kernel.

func (*GPUBackend) ProvenanceApply added in v1.3.0

func (b *GPUBackend) ProvenanceApply(
	desc *AIVMRoundDescriptor,
	ops []ModelOp,
	models []ModelRegistryEntry,
	appliedOut *uint32,
) error

ProvenanceApply runs the GPU provenance (model-registry) kernel.

type Genesis

type Genesis struct {
	Version   int    `json:"version"`
	Message   string `json:"message"`
	Timestamp int64  `json:"timestamp"`
}

Genesis represents the genesis state

type InferenceOp added in v1.3.0

type InferenceOp struct {
	ModelHash      [32]byte
	PolicyHash     [32]byte
	Salt           [32]byte
	Mode           uint32
	InputOffset    uint32
	InputLen       uint32
	OutputOffset   uint32
	OutputCapacity uint32

	RoundID     uint64
	TimestampNS uint64
	// contains filtered or unexported fields
}

InferenceOp mirrors aivm::cuda::InferenceOp (144 bytes).

type InferenceResult added in v1.3.0

type InferenceResult struct {
	Status           uint32
	OutputLen        uint32
	InputCommitment  [32]byte
	OutputCommitment [32]byte
	AttestationRoot  [32]byte
	// contains filtered or unexported fields
}

InferenceResult mirrors aivm::cuda::InferenceResult (112 bytes).

type InferenceWeights added in v1.3.0

type InferenceWeights struct {
	W1     [InferenceInDim * InferenceHidden]int8
	B1     [InferenceHidden]int32
	W2     [InferenceHidden * InferenceOutDim]int8
	B2     [InferenceOutDim]int32
	Shift1 int8
	Shift2 int8

	ModelHash       [32]byte
	ModelConfigHash [32]byte
	// contains filtered or unexported fields
}

type Mode added in v1.3.0

type Mode uint8

Mode selects the AIVM transition execution mode. AutoAIVM (the default) uses the resolved GPU backend if available and falls back to CPUAIVM otherwise. CPUAIVM forces the Go path even when a plugin is loaded.

const (
	// AutoAIVM picks the GPU plugin when available, else CPUAIVM.
	AutoAIVM Mode = 0
	// CPUAIVM forces the pure-Go transition path.
	CPUAIVM Mode = 1
	// GPUAIVM forces the GPU path. Panics if no plugin is loaded.
	GPUAIVM Mode = 2
)

func ActiveMode added in v1.3.0

func ActiveMode() Mode

ActiveMode returns the current transition mode set by SetBackend().

func (Mode) String added in v1.3.0

func (m Mode) String() string

String returns the human-readable name for the mode.

type ModelOp added in v1.3.0

type ModelOp struct {
	ModelRoot   [32]byte
	WeightHash  [32]byte
	LicenseRoot [32]byte
	OwnerAddr   [20]byte

	ParameterCount uint64
	Modality       uint32
	Kind           uint32
	Epoch          uint32
	// contains filtered or unexported fields
}

ModelOp mirrors aivm::cuda::ModelOp (160 bytes).

type ModelRegistryEntry added in v1.3.0

type ModelRegistryEntry struct {
	ModelRoot   [32]byte
	WeightHash  [32]byte
	LicenseRoot [32]byte
	OwnerAddr   [20]byte

	Version        uint64
	ParameterCount uint64
	Modality       uint32
	Occupied       uint32
	// contains filtered or unexported fields
}

ModelRegistryEntry mirrors aivm::cuda::ModelRegistryEntry (160 bytes).

type ProofVerifyOp added in v1.3.0

type ProofVerifyOp struct {
	Measurement  [32]byte
	AttestingKey [48]byte
	Signature    [96]byte
	MessageHash  [32]byte
	ExpiryNS     uint64
	TimestampNS  uint64
	Kind         uint32
	Nonce        uint32
	// contains filtered or unexported fields
}

ProofVerifyOp mirrors aivm::cuda::ProofVerifyOp (240 bytes).

type ProofVerifyResult added in v1.3.0

type ProofVerifyResult struct {
	Status      uint32
	Kind        uint32
	BindingHash [32]byte
	// contains filtered or unexported fields
}

ProofVerifyResult mirrors aivm::cuda::ProofVerifyResult (48 bytes).

type ProviderReg

type ProviderReg struct {
	ProviderID     string                        `json:"providerId"`
	WalletAddress  string                        `json:"walletAddress"`
	Endpoint       string                        `json:"endpoint"`
	CPUAttestation *attestation.AttestationQuote `json:"cpuAttestation,omitempty"`
	GPUAttestation *attestation.GPUAttestation   `json:"gpuAttestation,omitempty"`
}

ProviderReg represents a provider registration in a block

type RegisterProviderRequest

type RegisterProviderRequest struct {
	ID             string                      `json:"id"`
	WalletAddress  string                      `json:"wallet_address"`
	Endpoint       string                      `json:"endpoint"`
	GPUs           []aivm.GPUInfo              `json:"gpus"`
	GPUAttestation *attestation.GPUAttestation `json:"gpu_attestation,omitempty"`
}

RegisterProviderRequest is the request for registering a provider

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides AIVM RPC service

type SubmitResultRequest

type SubmitResultRequest struct {
	TaskID      string          `json:"task_id"`
	ProviderID  string          `json:"provider_id"`
	Output      json.RawMessage `json:"output"`
	ComputeTime uint64          `json:"compute_time_ms"`
	Proof       []byte          `json:"proof"`
	Error       string          `json:"error,omitempty"`
}

SubmitResultRequest is the request for submitting a task result

type SubmitTaskRequest

type SubmitTaskRequest struct {
	ID    string          `json:"id"`
	Type  string          `json:"type"`
	Model string          `json:"model"`
	Input json.RawMessage `json:"input"`
	Fee   uint64          `json:"fee"`
}

SubmitTaskRequest is the request for submitting a task

type VM

type VM struct {
	// contains filtered or unexported fields
}

VM implements the AI Virtual Machine

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)

BuildBlock implements chain.ChainVM interface

func (*VM) BuildVertex

func (vm *VM) BuildVertex(ctx context.Context) (vertex.Vertex, error)

BuildVertex creates a vertex from pending tasks/results, batching independent jobs.

func (*VM) ClaimRewards

func (vm *VM) ClaimRewards(providerID string) (string, error)

ClaimRewards claims pending rewards for a provider

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error

Connected notifies the VM about connected nodes

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers returns HTTP handlers

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected notifies the VM about disconnected nodes

func (*VM) FeePolicy added in v1.2.6

func (vm *VM) FeePolicy() fee.Policy

FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, id ids.ID) (chain.Block, error)

GetBlock implements chain.ChainVM interface

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements chain.ChainVM interface

func (*VM) GetMerkleRoot

func (vm *VM) GetMerkleRoot() [32]byte

GetMerkleRoot returns merkle root for Q-Chain anchoring

func (*VM) GetModels

func (vm *VM) GetModels() []*aivm.ModelInfo

GetModels returns available AI models

func (*VM) GetProviders

func (vm *VM) GetProviders() []*aivm.Provider

GetProviders returns all registered providers

func (*VM) GetRewardStats

func (vm *VM) GetRewardStats(providerID string) (map[string]interface{}, error)

GetRewardStats returns reward statistics for a provider

func (*VM) GetStats

func (vm *VM) GetStats() map[string]interface{}

GetStats returns VM statistics

func (*VM) GetTask

func (vm *VM) GetTask(taskID string) (*aivm.Task, error)

GetTask returns a task by ID

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (chain.HealthResult, error)

HealthCheck implements chain.ChainVM interface

func (*VM) Initialize

func (vm *VM) Initialize(ctx context.Context, init vmcore.Init) error

Initialize initializes the VM with the unified Init struct

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements chain.ChainVM interface

func (*VM) NewHTTPHandler

func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements chain.ChainVM interface

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, bytes []byte) (chain.Block, error)

ParseBlock implements chain.ChainVM interface

func (*VM) ParseVertex

func (vm *VM) ParseVertex(ctx context.Context, b []byte) (vertex.Vertex, error)

ParseVertex deserializes a vertex from bytes.

func (*VM) RegisterProvider

func (vm *VM) RegisterProvider(provider *aivm.Provider) error

RegisterProvider registers a new AI compute provider.

Public-BFT-safe path (VerificationMode=ModeOptimistic, default):

  • Provider locks MinProviderBond in the host chain's escrow
  • TEE attestation is OPTIONAL — providers without TEE register under the optimistic-verification flow (challenge period + fraud proofs handle correctness without trusting the provider)

Permissioned path (RequireTEEAttestation=true, opt-in):

  • Provider MUST present valid TEE attestation
  • TrustScore must meet MinTrustScore
  • Used on permissioned subnets where the validator set vets hardware operators by policy

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, id ids.ID) error

SetPreference implements chain.ChainVM interface

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state uint32) error

SetState implements chain.ChainVM interface

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown shuts down the VM

func (*VM) SubmitResult

func (vm *VM) SubmitResult(result *aivm.TaskResult) error

SubmitResult submits a task result

func (*VM) SubmitTask

func (vm *VM) SubmitTask(task *aivm.Task) error

SubmitTask submits a new AI task. This is the canonical user-task admission point on A-Chain — the HTTP /tasks handler routes through here. The FeePolicy gate refuses zero-fee tasks before they touch the core queue. Internal callers (consensus replay) bypass by reaching vm.core.SubmitTask directly.

func (*VM) VerifyGPUAttestation

func (vm *VM) VerifyGPUAttestation(att *attestation.GPUAttestation) (*attestation.DeviceStatus, error)

VerifyGPUAttestation verifies GPU attestation (local nvtrust - no cloud)

func (*VM) Version

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

Version implements chain.ChainVM interface

func (*VM) WaitForEvent

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

WaitForEvent implements chain.ChainVM interface

type VerificationMode added in v1.2.6

type VerificationMode uint8

VerificationMode selects the AIVM result-verification strategy.

Public chains MUST use ModeOptimistic or ModeMultiPartyRedundant — these are public-BFT-safe and do not require any single trusted party. ModeTEEAttested is permitted but the TEE is treated as acceleration, never as the trust root.

const (
	// ModeOptimistic is the default for public chains.
	// Providers post results with bond. N-block challenge period.
	// Public-BFT-safe — anyone can submit a fraud proof.
	ModeOptimistic VerificationMode = 0

	// ModeMultiPartyRedundant has M-of-N providers run the same task;
	// consensus on the result hash. Divergent providers are slashed.
	// Public-BFT-safe — no single provider can corrupt the result.
	ModeMultiPartyRedundant VerificationMode = 1

	// ModeTEEAttested is OPT-IN. Providers with valid TEE attestation
	// can shortcut the challenge period. TEE never changes the trust
	// root; it accelerates settlement for high-trust providers.
	// Use only on permissioned/regulated subnets where TEE-vendor
	// trust is acceptable; not the default for public mainnet.
	ModeTEEAttested VerificationMode = 2
)

type VerifyAttestationRequest

type VerifyAttestationRequest struct {
	GPUAttestation *attestation.GPUAttestation `json:"gpu_attestation"`
}

VerifyAttestationRequest is the request for verifying attestation

Directories

Path Synopsis
cmd
plugin command

Jump to

Keyboard shortcuts

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