Files
zeekay ec074f11aa evm, oraclevm, relayvm: a vmID nobody compared, and a policy no rollback could reach
The two shims re-exported luxfi/oracle's and luxfi/relay's private vmID
literals. constants.OracleVMID and constants.RelayVMID exist, agree with them,
and nothing made them agree. This repo builds the plugin binary whose FILENAME
is that id, so the shims now name the constant and their tests compare all
three; a drift upstream fails here instead of producing a chain no node starts.

cevm gets ErrNotLinked, so a caller can tell "this build has no C++ EVM" from
"this input is bad". cevm/parallel's sender-recovery step returned a hard error
for the first, which in a build without the library is every block, forever,
and CEVM_STRICT=0 -- the documented rollback to the Go EVM -- did not reach
that line. It now leaves by declineBlock like every other capability refusal.

Its receipt gate asked whether a transaction carried calldata. A contract
creation with empty init code carries none, so it was receipted as a value
transfer: no ContractAddress, and 21000 intrinsic gas against creation's 53000,
into the cumulative total the header commits to.

ExecuteBlock splits into shape / dispatch / assemble so the parity-critical
half needs no library to exercise. strictGPUEVM loses the sync.Once that fixed
its answer at the first decline and left both branches unreachable from one
process.

The native build referenced gpu_execute_block and gpu_free_result, which ABI v6
removed, so nothing behind lux_cevm_native compiled at all.

The three plugins print the version the VM reports rather than a second literal
beside it, and the vmID the binary must be installed under: a plugin under the
wrong filename is invisible and the chain simply never appears.

cevm/plugin.go is gone. It located a binary at ~/work/luxcpp/evm/build/bin/cevm,
a path that has never existed -- the tree is luxcpp/cevm -- claimed the lux CLI
and universe Makefiles used it, which neither does, and returned "cevm" from a
function called VMID. Its two tests skipped and asserted nothing.

.gitignore's bare `plugin` matched every <vm>/cmd/plugin DIRECTORY, so a new
file under one could not be added: git printed a hint and staged nothing.
mpcvm's and bridgevm's plugin tests are written, pass, and are not in the
repository.

Coverage: evm 0.0 -> 85.0, evm/cevm 71.1 -> 100.0, evm/cevm/parallel 0.0 -> 86.1,
oraclevm 0.0 -> 90.0, oraclevm/cmd/plugin 0.0 -> 72.2, relayvm/cmd/plugin 0.0 -> 72.2.
2026-08-28 15:01:34 -07:00

79 lines
2.6 KiB
Go

//go:build !cgo || !lux_cevm_native
// Pure-Go path, used whenever the native luxcpp EVM is NOT linked in —
// i.e. the default build (cgo without `-tags=lux_cevm_native`) and any
// no-cgo build. Opt in with `-tags=lux_cevm_native` (see cevm_cgo.go)
// once the lux-cevm pkg-config bundle is installed.
package cevm
import "fmt"
// No library linked, so there is no ABI to report.
const ABIVersion uint32 = 0
// AutoDetect returns CPUSequential: with no library there is no lane to detect.
func AutoDetect() Backend { return CPUSequential }
// AvailableBackends returns CPUSequential alone — the only lane a build with no
// library has, and it cannot execute either.
func AvailableBackends() []Backend { return []Backend{CPUSequential} }
// BackendName uses the local Go-side string; there is no library to ask.
func BackendName(b Backend) string { return b.String() }
// LibraryABIVersion returns the Go-side constant when there's no library.
func LibraryABIVersion() uint32 { return ABIVersion }
// ExecuteBlock returns an error when built without CGo. Mirrors the V4
// cgo signature so consumers can call it unconditionally.
func ExecuteBlock(backend Backend, numThreads uint32, txs []Transaction, ctx *BlockContext, state []StateAccount) (*BlockResult, error) {
if len(txs) == 0 {
return &BlockResult{ABIVersion: ABIVersion}, nil
}
_ = ctx
_ = state
return nil, fmt.Errorf("cevm: cannot execute %d transactions: %w", len(txs), ErrNotLinked)
}
// HealthProbeResult mirrors the cgo build's struct so consumers see the same
// API surface either way. Under nocgo the slice is always empty.
type HealthProbeResult struct {
Name string
OK bool
GasUsed uint64
Status TxStatus
Err error
}
// HealthReport is the per-backend result of Health(). The nocgo build only
// reports CPUSequential and never executes — it returns OK=false with an
// explanatory error and an empty ProbeResults slice.
type HealthReport struct {
Backend Backend
Name string
OK bool
Err error
Probe string
ProbesRun int
ProbeResults []HealthProbeResult
GasUsed uint64
Status TxStatus
ExecTime float64
}
// Health returns a single non-OK report naming the reason nothing can execute.
//
// The reason used to read "built without CGo", which is wrong on the default
// build: cgo is on, and what is missing is the lux_cevm_native tag and the
// luxcpp bundle behind it. An operator reading it went and checked
// CGO_ENABLED, which was already 1.
func Health() []HealthReport {
return []HealthReport{{
Backend: CPUSequential,
Name: CPUSequential.String(),
OK: false,
Err: ErrNotLinked,
}}
}