Skip to content

Serve browser (gRPC-web) clients with an operator origin policy - #18

Merged
elicbarbieri merged 6 commits into
mainfrom
feat/origin-policy
Nov 12, 2026
Merged

elicbarbieri merged 6 commits into
mainfrom
feat/origin-policy

Conversation

@elicbarbieri

Copy link
Copy Markdown
Collaborator

Enables browser wallets to connect to zingod directly via gRPC-web, with a per-origin kill switch and rate-exemption operated from the CLI.

  • [serve] grpc_web = true (default off) serves gRPC-web on the existing gRPC listener. tower-http answers the browser preflight & tonic-web translates the framing.
  • zingod origin block|allow|reset manages per-origin policy via markers under <state_dir>/origins, picked up by a running zingod
    • block → every request from the origin gets PermissionDenied
    • allow → exempt from the work-stream limit (never turned away)
    • keyed by registrable domain (eTLD+1). public suffixes (com, github.io) are refused.
  • Metric zingod_grpc_origin_requests_total{verdict} — browser load by blocked/allowed/default (bounded labels; native requests not counted here).

@danielgorgonha

Copy link
Copy Markdown

@elicbarbieri thanks for this. It is the piece browser wallets need: today our in-browser scan benchmark (konclave-benchmark) reaches public light wallet servers only through gRPC-web proxies we host, and this would let it talk to a zingod directly. We read the diff. We have not run it yet.

One point on allow. docs/running.md calls it a loaded gun for a vetted wallet, and says the per-IP connection cap and max_streams_per_connection still bound a spoofer. With the defaults those two caps allow 128 × 100 = 12,800 streams from one address, about six times max_work_streams (2048), and across addresses the only ceiling left is max_connections × max_streams_per_connection (409,600). admit_exempt has no limit of its own and also skips the adaptive limit, so requests with an allowed Origin keep being admitted when the node has already lowered its limit under load. The header is read on every request, so a native client can send it too, and an allowed wallet's domain is public.

A ceiling for exempt slots (for example a configurable quota above max_work_streams) would keep the worst case set by the operator, and allow would still spare known wallets at normal load.

A smaller one: admit_exempt is called with the request's class, so an allowed origin also passes max_subscriptions on GetMempoolStream. The docs name only the work-stream limit.

We can test the gRPC-web path with our browser client after November 17 and report back here.

@elicbarbieri
elicbarbieri added this pull request to stack #20 November 12, 2026 19:52
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@elicbarbieri
elicbarbieri merged commit f55cc9c into main Nov 12, 2026
3 checks passed
@elicbarbieri
elicbarbieri deleted the feat/origin-policy branch November 12, 2026 22:43
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.

2 participants