mirror of
https://github.com/luxfi/chains.git
synced 2026-09-24 00:26:00 +00:00
cevm: bind to the clean unversioned C ABI, drop the compat shim
The Go bindings called gpu_execute_block_v4 / gpu_free_result_v2, which luxcpp/cevm main does not export — it renamed those to gpu_execute_block / gpu_free_result. A luxd built CGO_ENABLED=1 against the shipped libs would have failed to link, not merely mismatched a version. It stayed hidden because production builds pure-Go and this box had stale branch-built libs installed. cevm_v4compat.h and cevm_abi_v4compat_cgo.go existed only to bridge that gap — 113 lines whose own comment described the header and library being out of step. Deleted; cgo already includes the library header directly. ABIVersion is now taken from that header (C.EVM_GPU_ABI_VERSION) instead of a hand-maintained Go constant that had drifted to 7 while the header said 6. One definition, so the two cannot disagree; a runtime panic no longer has to catch what the compiler can. go vet clean; ./evm/cevm and ./evm/cevm/parallel both pass. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
+1
-1
@@ -205,7 +205,7 @@ type BlockContext struct {
|
||||
// the GPU a state snapshot (account nonce, balance, code, code_hash) so
|
||||
// the kernel CALL/CREATE path resolves targets on-device instead of
|
||||
// returning CallNotSupported. V3 callers still see the same wire shape.
|
||||
const ABIVersion uint32 = 6
|
||||
//
|
||||
|
||||
// StateAccount is one entry in the snapshot of touched accounts handed to
|
||||
// ExecuteBlockV4. Fields mirror the C-side CGpuStateAccount byte-for-byte
|
||||
|
||||
@@ -52,6 +52,10 @@ func AutoDetect() Backend {
|
||||
// module's expected ABIVersion. A mismatch means the binary and the cevm
|
||||
// module were built against incompatible C++ headers and any execution would
|
||||
// produce silently wrong results — fail fast at process start instead.
|
||||
// ABIVersion is the ABI this build was compiled against, taken from the
|
||||
// library's own header. There is no second copy to keep in sync.
|
||||
const ABIVersion = uint32(C.EVM_GPU_ABI_VERSION)
|
||||
|
||||
func init() {
|
||||
got := uint32(C.gpu_abi_version())
|
||||
if got != ABIVersion {
|
||||
@@ -262,7 +266,7 @@ func ExecuteBlockV4(backend Backend, numThreads uint32, txs []Transaction, ctx *
|
||||
}
|
||||
}
|
||||
|
||||
result := C.gpu_execute_block_v4(
|
||||
result := C.gpu_execute_block(
|
||||
&ctxs[0],
|
||||
C.uint32_t(len(ctxs)),
|
||||
C.uint8_t(backend),
|
||||
@@ -274,7 +278,7 @@ func ExecuteBlockV4(backend Backend, numThreads uint32, txs []Transaction, ctx *
|
||||
codePtr,
|
||||
C.uint32_t(codeSize),
|
||||
)
|
||||
defer C.gpu_free_result_v2(&result)
|
||||
defer C.gpu_free_result(&result)
|
||||
runtime.KeepAlive(ctxs)
|
||||
runtime.KeepAlive(cctxStorage)
|
||||
runtime.KeepAlive(cAccts)
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
package cevm
|
||||
|
||||
// No library linked, so there is no ABI to report.
|
||||
const ABIVersion uint32 = 0
|
||||
|
||||
import "fmt"
|
||||
|
||||
// AutoDetect returns CPUSequential when built without CGo.
|
||||
|
||||
Reference in New Issue
Block a user