Skip to content

fix(site): raise gateway-proxy rate limit so encrypted chat works#134

Merged
marinom2 merged 1 commit into
mainfrom
fix/gateway-ratelimit-chat
Jun 12, 2026
Merged

fix(site): raise gateway-proxy rate limit so encrypted chat works#134
marinom2 merged 1 commit into
mainfrom
fix/gateway-ratelimit-chat

Conversation

@marinom2

Copy link
Copy Markdown
Owner

The bug

On lightnode.app the encrypted chat/playground 'starts creating the session and returns nothing.'

Root cause (a regression I introduced in #111)

One encrypted inference through /api/gw/* is not one request:

  • ~5 setup calls: auth challenge + verify, session select, prepare, blob upload
  • a relay-token poll that fires up to 30 times (once a second until the worker is ready)
  • the playground retries up to 3 workers

The rate limiting in #111 capped /api/gw/ at 30/min per IP, so the moment the worker takes more than ~25s (a full run is ~50s) the token poll gets 429'd, the relay token never resolves, and the answer never streams.

Proof

I ran a LightChallenge-style judge prompt through lightnode-sdk 0.19.1 directly against the mainnet gateway (no proxy, no cap): a real worker returned a correct verdict in ~50s (PASS for a valid 10,234-step proof, {"passed": false} for a 4,201-step one). So the worker network and SDK are healthy; the only thing breaking the browser path was my proxy cap.

Fix

Raise /api/gw/ to 600/min per IP (one inference is ~35 calls; this leaves room for retries and a few inferences while still bounding abuse of the open proxy; the upstream LightChain gateway enforces its own limits). DAO/operator-preview keep 30/min.

Tests updated; tsc clean.

Regression from the rate-limiting in #111. One encrypted inference through
/api/gw/* is not one request: it is ~5 setup calls (auth challenge + verify,
session select, prepare, blob upload) PLUS a relay-token poll that fires up to
30 times (once a second until the worker is ready), and the playground retries
up to 3 workers. The 30/min per-IP cap 429'd the token poll whenever the worker
took more than ~25s (the common case - a full run is ~50s), so the relay token
never resolved and the answer never streamed: the 'starts the session, returns
nothing' chat bug. A direct-gateway SDK call (no proxy, no cap) returns a worker
verdict in ~50s, which isolates the cap as the cause.

Raise /api/gw/ to 600/min per IP (the upstream gateway has its own limits; this
only stops gross abuse of the open proxy). DAO/operator-preview keep 30/min.
@marinom2 marinom2 merged commit dee3c00 into main Jun 12, 2026
@marinom2 marinom2 deleted the fix/gateway-ratelimit-chat branch June 12, 2026 07:51
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightnode Ready Ready Preview, Comment Jun 12, 2026 7:52am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant