mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
LP-108 Phase 4: stop pretending parallel/auto-select is GPU-accelerated
backend_auto.go used to auto-select CppEVM when a GPU was detected
("parallel backend: GPU detected, backend=cevm, gpu=Metal"). But
cevmExecutor.ExecuteTransaction returned (nil, nil) — every tx fell
through to Go EVM regardless. The "GPU acceleration" log line was
misleading; the real path was always Go EVM.
Per LP-108 "one and one only": collapsed auto-select to GoEVM. The
GPU presence is still detected and logged honestly:
parallel backend: Go EVM (Block-STM across all cores)
cores=10 gpu_status="Metal (detected; cevm dispatch wiring
pending — runs Go EVM)"
To re-enable CppEVM auto-selection, the per-tx → batched-block
adapter in backend_cevm.go::ExecuteTransaction must be completed
AND a parity test against Go EVM Block-STM must pass.
Documented the gap in backend_cevm.go and backend_revm.go executor
comments. The (nil, nil) return is the documented "this backend
declines; use Go EVM" contract that the parallel framework's
DefaultTransactionExecutor expects (parallel.go:107).
Build verified: CGO_ENABLED=0 go build ./core/parallel/... clean.
Reference cevm bridge that needs wiring:
github.com/luxfi/chains/evm/cevm/cevm_cgo.go::ExecuteBlock
takes []Transaction (block-batch), TransactionExecutor is per-tx;
adapter must accumulate per-tx work and submit at block close.
This is the production-wiring counterpart to LP-108 Phase 4 vapor
deletion. The "GPU EVM is plumbed" claim is now contingent on the
adapter, not on ambient registration.
This commit is contained in:
@@ -22,43 +22,41 @@ func init() {
|
||||
selectedOnce.Do(detectBackend)
|
||||
}
|
||||
|
||||
// detectBackend probes for GPU availability and selects the best backend.
|
||||
// detectBackend selects the parallel-EVM backend.
|
||||
//
|
||||
// Priority:
|
||||
// 1. GPU Metal (darwin + CGo + Metal device present)
|
||||
// 2. GPU CUDA (linux + CGo + NVIDIA device present)
|
||||
// 3. CPU Parallel (Block-STM multi-core)
|
||||
// LP-108 (2026-05-04): collapsed to GoEVM only. The previous code
|
||||
// auto-selected CppEVM when a GPU was detected, but the
|
||||
// cevmExecutor.ExecuteTransaction body returned `nil, nil` (always
|
||||
// fell through to Go EVM regardless of selection). That was a
|
||||
// pretense, not an acceleration path.
|
||||
//
|
||||
// This runs exactly once at process startup. No user flag required.
|
||||
// CppEVM and RustEVM are kept behind their respective build tags
|
||||
// (`//go:build cevm` / `//go:build revm`) so the registrations are
|
||||
// only present when those backends are wired through the cgo
|
||||
// bridge and the parity gate against Go EVM is met. Until then,
|
||||
// auto-detect returns Go EVM honestly.
|
||||
//
|
||||
// To re-enable CppEVM auto-selection: complete the cevm bridge in
|
||||
// backend_cevm.go::ExecuteTransaction and add a parity test against
|
||||
// the Go EVM Block-STM path.
|
||||
func detectBackend() {
|
||||
gpu := DefaultGPU()
|
||||
if gpu.Available() {
|
||||
selectedResult = GoEVM
|
||||
if gpu := DefaultGPU(); gpu.Available() {
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
selectedResult = CppEVM
|
||||
selectedGPUName = "Metal"
|
||||
selectedGPUName = "Metal (detected; cevm dispatch wiring pending — runs Go EVM)"
|
||||
case "linux":
|
||||
selectedResult = CppEVM
|
||||
selectedGPUName = "CUDA"
|
||||
selectedGPUName = "CUDA (detected; cevm dispatch wiring pending — runs Go EVM)"
|
||||
default:
|
||||
selectedResult = CppEVM
|
||||
selectedGPUName = "GPU"
|
||||
selectedGPUName = "GPU (detected; cevm dispatch wiring pending — runs Go EVM)"
|
||||
}
|
||||
log.Info("parallel backend: GPU detected",
|
||||
"backend", selectedResult,
|
||||
"gpu", selectedGPUName,
|
||||
"os", runtime.GOOS,
|
||||
"arch", runtime.GOARCH,
|
||||
)
|
||||
return
|
||||
} else {
|
||||
selectedGPUName = "none"
|
||||
}
|
||||
|
||||
// CPU parallel (Block-STM across all cores).
|
||||
selectedResult = GoEVM
|
||||
selectedGPUName = "none"
|
||||
log.Info("parallel backend: CPU parallel (no GPU)",
|
||||
log.Info("parallel backend: Go EVM (Block-STM across all cores)",
|
||||
"backend", selectedResult,
|
||||
"cores", runtime.NumCPU(),
|
||||
"gpu_status", selectedGPUName,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ package parallel
|
||||
//
|
||||
// Build with: go build -tags cevm
|
||||
//
|
||||
// Requires: libcevm.a (compiled from luxfi/cevm)
|
||||
// Requires: libcevm.a (compiled from luxfi/chains/evm/cevm)
|
||||
//
|
||||
// Features:
|
||||
// - Fastest EVM interpreter (~3-5x vs Go EVM, fastest of any backend)
|
||||
@@ -20,7 +20,7 @@ package parallel
|
||||
// The CGo bridge passes StateDB operations through C callbacks:
|
||||
// Go StateDB ← CGo → C++ cevm::HostInterface
|
||||
//
|
||||
// CGo bridge to luxfi/cevm (requires native lib)
|
||||
// CGo bridge to luxfi/chains/evm/cevm (requires native lib)
|
||||
|
||||
import (
|
||||
"github.com/luxfi/evm/core/state"
|
||||
@@ -37,6 +37,23 @@ type cevmExecutor struct{}
|
||||
|
||||
func (c *cevmExecutor) Backend() EVMBackend { return CppEVM }
|
||||
|
||||
// ExecuteTransaction dispatches a single tx to the cevm native engine.
|
||||
//
|
||||
// LP-108 (2026-05-04): the per-tx → batched-block adapter is not
|
||||
// wired. The cgo bridge at github.com/luxfi/chains/evm/cevm exposes
|
||||
// ExecuteBlock([]Transaction) — a block-batch interface — but
|
||||
// TransactionExecutor is per-tx. To complete the wiring requires:
|
||||
// * an accumulator that buffers per-tx work and submits at block close
|
||||
// * receipt reconstruction from the BlockResult ordered output
|
||||
// * EIP-2929 warm-set seeding from the StateDB
|
||||
// * parity test against Go EVM Block-STM
|
||||
//
|
||||
// Until that adapter lands, ExecuteTransaction returns (nil, nil)
|
||||
// — the documented "this backend declines; use Go EVM" contract that
|
||||
// the parallel framework expects (see DefaultTransactionExecutor in
|
||||
// parallel.go). This is the honest answer; the registration exists so
|
||||
// the build-tag gating works, but cevm only executes once the adapter
|
||||
// is in place AND the parity gate passes.
|
||||
func (c *cevmExecutor) ExecuteTransaction(
|
||||
config *ethparams.ChainConfig,
|
||||
header *types.Header,
|
||||
@@ -45,10 +62,14 @@ func (c *cevmExecutor) ExecuteTransaction(
|
||||
vmCfg vm.Config,
|
||||
gasPool uint64,
|
||||
) (*types.Receipt, error) {
|
||||
// Dispatch to cevm native execution engine
|
||||
// For now, return nil to fall through to Go EVM
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// SupportsParallel reports backend capability. The C++ EVM has
|
||||
// Block-STM kernels (Metal + CUDA, see luxcpp/cevm/lib/evm/gpu/),
|
||||
// so the answer is true once the adapter in ExecuteTransaction is wired.
|
||||
func (c *cevmExecutor) SupportsParallel() bool { return true }
|
||||
func (c *cevmExecutor) SupportsGPU() bool { return true }
|
||||
|
||||
// SupportsGPU reports whether the cevm path can dispatch to GPU.
|
||||
// True once the adapter is wired.
|
||||
func (c *cevmExecutor) SupportsGPU() bool { return true }
|
||||
|
||||
@@ -36,6 +36,12 @@ type revmExecutor struct{}
|
||||
|
||||
func (r *revmExecutor) Backend() EVMBackend { return RustEVM }
|
||||
|
||||
// ExecuteTransaction dispatches to revm.
|
||||
//
|
||||
// LP-108 (2026-05-04): same gap as cevm — the FFI bridge to revm
|
||||
// is not wired. Until the adapter lands and a parity test passes,
|
||||
// returns (nil, nil) — the documented "decline" contract that the
|
||||
// parallel framework expects (see parallel.go DefaultTransactionExecutor).
|
||||
func (r *revmExecutor) ExecuteTransaction(
|
||||
config *ethparams.ChainConfig,
|
||||
header *types.Header,
|
||||
@@ -44,8 +50,6 @@ func (r *revmExecutor) ExecuteTransaction(
|
||||
vmCfg vm.Config,
|
||||
gasPool uint64,
|
||||
) (*types.Receipt, error) {
|
||||
// Dispatch to revm Rust execution engine
|
||||
// For now, return nil to fall through to Go EVM
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user