Files
evm/core/parallel/interface.go
zeekayandHanzo Dev 2f9a315893 One EVM per process; other EVMs are plugins the host loads
The C++ and Rust EVMs are separate luxd plugins. The host spawns every VM with
VM_TRANSPORT=zap (node/vms/rpcchainvm/factory.go) and the cevm binary is
exercised that way cross-process today. Choosing an EVM is choosing which plugin
binary runs -- not a switch inside the Go EVM.

This tree carried a second mechanism for the same choice: an in-process cgo
bridge that linked C++ into the Go binary behind -tags cevm/revm, with a
per-transaction executor registry, an evm_setBackend RPC to flip between
backends at runtime, a resident-store config knob, and a startup log naming the
chosen backend. Its executor returned nil, nil; its tagged build did not compile
(cevm_resident_store.go referenced symbols cevmbridge never defined); and no
build produced a binary that used it. 3,961 lines, gone.

What stays is what the Go EVM actually has: the BlockExecutor seam and
Block-STM behind it (blockstm.go), and the GPU accelerator seam with its
darwin/cgo bridge into luxfi/gpu (gpu_bridge.go). The state processor consults
both and falls through to sequential execution when neither is registered.

Note for the record: nothing in the shipped binary registers a BlockExecutor,
so blocks run sequentially on the Go interpreter. The removed startup log said
"Block-STM across all cores"; it was not describing this binary. Wiring
Block-STM into the production path changes consensus execution and is a
separate decision, made deliberately, with a parity gate.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-09 12:53:54 -07:00

53 lines
2.1 KiB
Go

// Copyright (C) 2025-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Package parallel is the Go EVM's optional parallel block executor
// (Block-STM, blockstm.go) and its optional GPU accelerator (gpu_bridge.go,
// cgo && darwin, backed by luxfi/gpu). Both are registered from init() and
// consulted by the state processor; when neither is registered the fallbacks
// answer "not handled" and execution is sequential on the Go interpreter.
//
// Other EVM implementations are not linked into this process. The C++ and
// Rust EVMs are separate luxd plugins that the host loads over ZAP, the same
// way it loads this one -- choosing one is choosing which plugin binary runs,
// not a switch inside the Go EVM.
package parallel
import (
"github.com/luxfi/evm/core/state"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
ethparams "github.com/luxfi/geth/params"
)
// BlockExecutor processes all transactions in a block.
// The default implementation delegates to sequential per-tx execution.
// The parallel implementation uses Block-STM speculative execution.
type BlockExecutor interface {
// ExecuteBlock processes all transactions in a block.
// Returns receipts in original transaction order, or an error.
// A nil return (nil, nil) means "not handled, fall through to sequential."
ExecuteBlock(
config *ethparams.ChainConfig,
header *types.Header,
txs types.Transactions,
statedb *state.StateDB,
vmCfg vm.Config,
) ([]*types.Receipt, error)
}
// GPUAccelerator provides optional GPU-offloaded crypto operations.
// The default implementation returns Available() == false.
type GPUAccelerator interface {
// Available reports whether a GPU backend is detected.
Available() bool
// BatchEcrecover recovers sender addresses for a batch of transactions.
// Returns a map from tx hash to recovered sender address.
BatchEcrecover(txs []*types.Transaction) (map[common.Hash]common.Address, error)
// BatchKeccak hashes multiple inputs on GPU.
BatchKeccak(inputs [][]byte) ([]common.Hash, error)
}