mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
Thin re-export layer so consumers importing the legacy node path
github.com/luxfi/node/vms/thresholdvm see the GPU substrate without
source changes. ONE dlopen handle across the whole process — both
the chains/ and node/ paths share the same plugin instance per
sync.Once in chains/thresholdvm/backend.go.
Files (under vms/thresholdvm/):
- thresholdvm_gpu.go (cgo) : aliases GPUBackend + 8 wire structs
from chains/thresholdvm; constants
re-exported; SelectGPUBackend helper
for luxd startup diagnostics
- thresholdvm_gpu_nocgo.go (!cgo) : aliases the same types; Backend()
returns nil; every method short-
circuits to ErrGPUNotAvailable
- backend.go (cgo) : SelectGPUBackend() — one-line
diagnostic string in the cevm.go
pattern (chains/evm/backend_cgo.go)
- thresholdvm_gpu_test.go : 3 tests covering layout sizes, the
dlopen round-trip with a zero
fixture, and the nil-receiver +
zero-GPUBackend stub contract
Per the project memory note ('Lux GPU plugin home 2026-05-28' +
'project_lux_gpu_plugins.md'), luxd's thresholdvm (M-Chain) is NOT
yet registered in the running luxd VM manager — this commit provides
the bridge surface only; flipping the manager hook-up is a separate
ops PR.
Constraints honored:
- Existing thresholdvm.go re-export (chains/thresholdvm alias wrapper)
NOT modified — bridge is opt-in alongside it
- Both build flavors compile: go build + CGO_ENABLED=0 go build
- Tests pass: 3/3 under cgo, 3/3 under nocgo, race-clean
50 lines
1.8 KiB
Go
50 lines
1.8 KiB
Go
// Copyright (C) 2026, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
//go:build !cgo
|
|
|
|
// nocgo re-export of the chains/thresholdvm GPU bridge. Under !cgo the
|
|
// upstream GPUBackend methods all return ErrGPUNotAvailable and
|
|
// Backend() returns nil; this layer transparently passes that through
|
|
// so callers see identical behaviour regardless of build mode.
|
|
//
|
|
// One and only one nocgo stub for the entire process: it lives in
|
|
// chains/thresholdvm. This package just re-exports the types and the
|
|
// sentinel error.
|
|
|
|
package thresholdvm
|
|
|
|
import "github.com/luxfi/chains/thresholdvm"
|
|
|
|
type (
|
|
GPUBackend = thresholdvm.GPUBackend
|
|
GPUBackendKind = thresholdvm.GPUBackendKind
|
|
|
|
GPUCeremony = thresholdvm.GPUCeremony
|
|
GPUKeyShare = thresholdvm.GPUKeyShare
|
|
GPUContribution = thresholdvm.GPUContribution
|
|
GPUMPCVMState = thresholdvm.GPUMPCVMState
|
|
GPUMPCVMRoundDescriptor = thresholdvm.GPUMPCVMRoundDescriptor
|
|
GPUCeremonyOp = thresholdvm.GPUCeremonyOp
|
|
GPUContributionOp = thresholdvm.GPUContributionOp
|
|
GPUMPCVMTransitionResult = thresholdvm.GPUMPCVMTransitionResult
|
|
)
|
|
|
|
const (
|
|
GPUBackendNone = thresholdvm.GPUBackendNone
|
|
GPUBackendCUDA = thresholdvm.GPUBackendCUDA
|
|
GPUBackendHIP = thresholdvm.GPUBackendHIP
|
|
GPUBackendMetal = thresholdvm.GPUBackendMetal
|
|
GPUBackendVulkan = thresholdvm.GPUBackendVulkan
|
|
GPUBackendWebGPU = thresholdvm.GPUBackendWebGPU
|
|
)
|
|
|
|
var ErrGPUNotAvailable = thresholdvm.ErrGPUNotAvailable
|
|
|
|
// GPUBackendInstance returns nil under !cgo — the upstream Backend()
|
|
// returns nil because no dlopen ever happens. Callers branch on the
|
|
// IsAvailable() check (or `g == nil`) and route to the CPU reference.
|
|
func GPUBackendInstance() *GPUBackend {
|
|
return thresholdvm.Backend()
|
|
}
|