Files
chains/evm/cevm/cevm_nocgo.go
T
zeekayandHanzo Dev 6223789846 The cevm executor runs what cevm declines on the Go EVM
cevm's Go entry is gpu_execute_block (go_bridge.h, ABI 6); the
gpu_execute_block_v4 and gpu_free_result_v2 this package called are gone
from the library, so the native build did not link. The entry answers ok=0
for any block it does not run — any batch with code, and any refusal on
balance, nonce, price, block gas limit, revision or hashes — and that block
is the caller's. ExecuteBlock returns ErrDeclined for it, with no result,
and the executor declines the block to the Go EVM: (nil, nil), counted. A
decline is never an error, so CEVM_STRICT and ErrGPUEVMRequired are gone;
the state processor fell through on that error anyway.

Nothing wider than the 64-bit wire reaches cevm. A gas price or fee cap
above 2^64-1 crossed as 0; it, a value, a base fee or a chain id that does
not fit now declines the block, as does a tx the wire drops part of: an
access list, a blob or set-code tx, a tip above its fee cap.

Snapshot rows carry what the header asks for: keccak256 of nothing and the
empty trie root for an account that does not exist — the StateDB answers
zero, which cevm reads as saying nothing and declines — the real storage
root otherwise, and a row for the coinbase. cevm_cgo.go checks the four C
structs' sizes at compile time, so a header that grows a field cannot have
it cross as zero unnoticed.

The call into cevm is a field on the Executor, so the tests show a declined
block going to the Go EVM and a value of 2^64 never reaching cevm without
the library.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-23 09:22:10 -07:00

80 lines
2.7 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 ErrNotLinked for any transactions: no library is
// linked. It mirrors the 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,
}}
}