Files
logos-verified-proxy-module/tests
Dario Gabriel LipicarandClaude Opus 5 8400bd7d36 feat: serve a verified JSON-RPC endpoint over HTTP
libverifproxy ships no server: library/verifproxy.nim imports json_rpc_backend
(the client it calls providers with) and the in-process engine/rpc_frontend, but
never json_rpc_frontend — the HTTP/WS server exists only in the standalone
binary, and nm on the archive we link finds zero of its symbols. So the endpoint
is ours.

Opt-in via `httpServer: { enabled, host, port }`, bound to loopback by default
and refusing anything but POST — this answers state queries, so an accidental
0.0.0.0 bind is a different order of mistake than it is for a metrics port.
Uses libmicrohttpd, matching openmetrics-module. Every request is forwarded
through the same proxyCall path the typed methods use, so there is one
verification path and one error shape rather than a second implementation.

Two adaptations are what make "point ethers at it" true rather than nearly true,
and both are measured rather than assumed:

* eth_call / eth_estimateGas / eth_createAccessList (and the op_ twins) take a
  THIRD positional parameter upstream, optimisticStateFetch, which the spec does
  not have. Stock clients send two and the library answers "parameters missing".
  The endpoint appends the default and leaves an explicit third alone. Verified
  against sepolia: a 2-param eth_call now reaches the engine and comes back with
  a *verification* error, not a parameter one.
* eth_blockNumber answers a bare JSON number where every client expects a hex
  QUANTITY (chainId and gasPrice do return hex — upstream is not uniform).
  Promoted to hex here only; rpc() and the typed methods still return what the
  library produced, so this cannot hide an upstream change from a direct caller.

handleBody() is pure apart from its dispatch callback, so the whole protocol
surface is unit-tested without binding a socket: envelopes, id-type
preservation, batches, notifications, the reserved error codes, and both
adaptations. 44 tests pass.

Verified end to end against sepolia: the endpoint answers
{"id":1,"jsonrpc":"2.0","result":"0xb02f64"} where the upstream provider says
"0xb02f65" — same shape, one block behind, which is what a verifying light
client should look like.

This also re-opens the eth_rpc_module integration the plan had ruled out on the
grounds that no port existed: ChainConfig.endpoint can now point here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 21:18:33 -03:00
..