Files
evm/core/parallel/backend_cevm.go
zeekay 1775ee8ff1 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.
2026-05-04 17:01:33 -07:00

76 lines
2.6 KiB
Go

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build cevm
package parallel
// cevm backend — Lux C++ EVM via CGo.
//
// Build with: go build -tags cevm
//
// Requires: libcevm.a (compiled from luxfi/chains/evm/cevm)
//
// Features:
// - Fastest EVM interpreter (~3-5x vs Go EVM, fastest of any backend)
// - SIMD-optimized opcode execution (AVX2/NEON)
// - Native GPU kernel dispatch (CUDA/Metal) for batch operations
// - Parallel block execution via Block-STM with GPU acceleration
//
// The CGo bridge passes StateDB operations through C callbacks:
// Go StateDB ← CGo → C++ cevm::HostInterface
//
// CGo bridge to luxfi/chains/evm/cevm (requires native lib)
import (
"github.com/luxfi/evm/core/state"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
ethparams "github.com/luxfi/geth/params"
)
func init() {
RegisterTransactionExecutor(CppEVM, &cevmExecutor{})
}
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,
tx *types.Transaction,
statedb *state.StateDB,
vmCfg vm.Config,
gasPool uint64,
) (*types.Receipt, error) {
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 }
// SupportsGPU reports whether the cevm path can dispatch to GPU.
// True once the adapter is wired.
func (c *cevmExecutor) SupportsGPU() bool { return true }