mirror of
https://github.com/luxfi/cevm.git
synced 2026-10-30 17:00:54 +00:00
C++ bridge: gpu_execute_block_v4 -> gpu_execute_block, CGpuBlockResultV2 -> CGpuBlockResult, gpu_free_result_v2 -> gpu_free_result (unversioned, rebuilt). Go: one ExecuteBlock(backend, txs, opts...) with WithThreads/WithContext functional options + one full BlockResult; deleted ExecuteBlockV2/V3 and BlockResultV2; updated the !cgo mirror + 4 test files. ABIVersion -> 6. Also fixed the cgo include path (../../luxcpp -> ../../../luxcpp; origin couldn't find go_bridge.h) and ordered the lux-crypto archives after -lluxgpu. Package builds CGO=1 and CGO=0. KNOWN PRE-EXISTING GAP (not introduced; origin never linked at all): the TEST binary pulls cevm's full crypto surface where a few bare-C symbols (ed25519_verify, PQCLEAN_randombytes, lux_donna_sr25519_*, evmc_create_cevm) have no provider archive yet — the blake3-class extern-C shim gap, to be closed in luxcpp/cevm + lux-crypto packaging. Co-authored-by: Hanzo Dev <[email protected]>
64 lines
2.0 KiB
Go
64 lines
2.0 KiB
Go
//go:build !cgo
|
|
|
|
package cevm
|
|
|
|
import "fmt"
|
|
|
|
// AutoDetect returns CPUSequential when built without CGo.
|
|
func AutoDetect() Backend { return CPUSequential }
|
|
|
|
// AvailableBackends returns CPUSequential only when built without CGo.
|
|
func AvailableBackends() []Backend { return []Backend{CPUSequential} }
|
|
|
|
// BackendName uses the local Go-side string when CGo is off.
|
|
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. It mirrors the cgo
|
|
// signature exactly — functional options included — so the package surface
|
|
// is identical regardless of build mode.
|
|
func ExecuteBlock(backend Backend, txs []Transaction, opts ...BlockOption) (*BlockResult, error) {
|
|
if len(txs) == 0 {
|
|
return &BlockResult{ABIVersion: ABIVersion}, nil
|
|
}
|
|
return nil, fmt.Errorf("cevm: built without CGo, cannot execute transactions (rebuild with CGO_ENABLED=1)")
|
|
}
|
|
|
|
// 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 indicating CGo is disabled.
|
|
func Health() []HealthReport {
|
|
return []HealthReport{{
|
|
Backend: CPUSequential,
|
|
Name: CPUSequential.String(),
|
|
OK: false,
|
|
Err: fmt.Errorf("cevm: built without CGo, no backends executable"),
|
|
}}
|
|
}
|