mirror of
https://github.com/luxfi/precompile.git
synced 2026-07-27 03:33:45 +00:00
The 0x0500..0010 GraphQL precompile (a registered StatefulPrecompiledContract) ran the consensus Run path through four nondeterminism/halt hazards: 1. NIL-CLIENT PANIC (chain halt). The default instance holds a nil client until VM init wires one; Query called a method on the nil interface with no guard, panicking the unrecovered dispatch path and halting every validator that processed the tx. -> nil now returns typed ErrClientNotInitialized. 2. time.Now()/wall-clock (startTime, cache TTL, stats timing) — diverges on per-validator clock skew. -> removed entirely. 3. Process-global in-memory cache (map keyed by query, wall-clock TTL). A warm vs cold validator returned stale-vs-fresh data and a different GasUsed — both consensus-visible. -> removed; every query executes against local DB state. 4. Process-global stats counters mutated per call and returned on-chain via getStats — cross-tx mutable state. -> removed; getStats returns deterministic zero. And executeMultiChainQuery used goroutines whose scheduler-random order decided the result set and 'first error' -> now sequential in TargetChains order (deterministic results + first-error). The precompile is now a stateless pure function of (input, local G-Chain DB): no mutex, no cache, no stats, no goroutines, no wall-clock. Regression: TestGraphQL_NilClientReturnsTypedErrorNotPanic (no panic, typed error via both Query and the Run dispatch path), TestGraphQL_DeterministicAcrossRuns (identical Data+GasUsed, no cache discount), TestGraphQL_MultiChainSequentialDeterministic (chains visited in request order, byte-identical output x50), TestGraphQL_MultiChainFirstErrorDeterministic (first error in request order).