Files
explorer/ffi_off.go
zooqueen 7156dfdd7a feat(single-binary): zip front router + reverse-proxy to in-process Blockscout-rs services
Make the explorer ONE Go binary fronted by github.com/hanzoai/zip (Fiber v3 /
fasthttp) that runs the Blockscout-rs Rust services IN-PROCESS via the existing
cgo FFI staticlib and reverse-proxies to each. Least-work: the Rust services are
not rewritten/ported — their real entrypoints run on Tokio threads inside the
process, keeping their own HTTP servers on loopback.

Front router (front.go): zip owns the public listener; routes in order
  /api/<prefix>/*  -> httputil.ReverseProxy -> 127.0.0.1:<svc_port> (prefix stripped)
  /*               -> the existing net/http explorer mux via zip.AdaptNetHTTP
Security headers + CORS become zip middleware (replaces withSecurity).

Config (services: block, ServicesConfig/resolveServices in config.go+services.go):
single source of truth for enabled services, loopback ports (base 8050,
HTTP=base+2n/gRPC=+1), URL prefixes, and per-service settings JSON; both the
proxy and the FFI launcher read it. startFFIServices now takes resolvedService
and feeds each service its server addr (+ DB url when set).

Status: sig-provider WIRED + PROVEN end-to-end — one process owns :8090 and
:8050, curl /api/sig/health -> {"status":"SERVING"} and the real REST API
/api/sig/api/v1/abi/function -> 200. visualizer + smart-contract-verifier are
stateless and ready to wire (recipe in ffi/README.md). stats +
multichain-aggregator stay DISABLED: blockscout-service-launcher's DB layer is
Postgres-only (initialize_postgres pins DatabaseBackend::Postgres) — no SQLite
without a Rust rewrite — and stats also needs a populated Blockscout indexer
Postgres. The Go side already passes database.url+migrations through, so they
enable with config alone once a Postgres exists.

Build: make single (cargo build ffi/ + go build -tags ffi) unchanged; default
go build ./... is the Go-native binary (ffi_off.go stub, no cgo). go build ./...
and go test ./... pass; make single links the sig-provider symbol and boots.
2026-06-23 21:20:29 -07:00

21 lines
963 B
Go

//go:build !ffi
// Package main — non-FFI build variant (the default).
//
// A plain `go build ./...` compiles this file and NOT ffi_on.go, so the
// explorer builds and runs WITHOUT the Rust staticlib present. The Blockscout-rs
// services are simply not started; everything else (Go-native indexer + graph +
// SPA + realtime) works exactly as before. Build the single all-in-one binary
// with `make single` (which adds -tags ffi and links liblux_explorer_ffi.a).
package main
// ffiEnabled is false in the default build; main.go logs this so it is obvious
// which variant is running.
const ffiEnabled = false
// startFFIServices is a no-op in the non-FFI build: the in-process Rust
// services are simply not launched, so the front router has nothing local to
// proxy to. (The proxies are still mounted by main.go when services.enabled is
// set, and will 502 until a service answers — see services.go.)
func startFFIServices(_ []resolvedService) {}