Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional proxy to exchange APIs for light clients #487

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

str4d
Copy link
Collaborator

@str4d str4d commented May 28, 2024

This enables light clients to authenticate directly to exchange APIs without revealing their IP address.

To-do:

  • Enforce per-client per-target rate limits on session creation.
  • Enforce per-client per-target rate limits on session traffic (by detecting request-response patterns in the proxied TCP traffic).

This enables light clients to authenticate directly to exchange APIs
without revealing their IP address.
return fmt.Errorf("no matching dial port found for target: %s|%s", ss.Target.ID, ss.Target.Type)
}

// TODO: Enforce per-client (`ss.Addr`) rate limit.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably use https://pkg.go.dev/golang.org/x/time/rate for this. What we want is:

  • A request rate limiter per exchange, that we configure with their respective public API limits.
  • A session rate limiter per client, that we configure with some low rate that is sufficient for the kinds of requests that honest light clients will be making ("infrequent" queries of market tickers).
    • We can probably initially assume that we have one session per request, but HTTP connection pooling on the light client side may break this assumption.
    • Once we have request-response detection, we can change this to (or add) a request rate limiter per client.
  • Some mechanism for fairly distributing per-exchange request rate limit tokens amongst connected clients (subject to the per-client rate limiter).

@str4d
Copy link
Collaborator Author

str4d commented Jun 6, 2024

This PR will probably get closed, as instead of writing the client side of this (in the necessary Kotlin and Swift), I've integrated Arti into the Swift SDK for Tor support and am using that to fetch exchange rates (Electric-Coin-Company/zcash-light-client-ffi#142, Electric-Coin-Company/zcash-swift-wallet-sdk#1446).

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