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

Reject Eth subscriptions & filters through the gateway over HTTP #11153

Open
Stebalien opened this issue Aug 9, 2023 · 0 comments
Open

Reject Eth subscriptions & filters through the gateway over HTTP #11153

Stebalien opened this issue Aug 9, 2023 · 0 comments
Labels

Comments

@Stebalien
Copy link
Member

Stebalien commented Aug 9, 2023

Currently, the lotus gateway forgets all eth subscriptions and event filters between HTTP calls. These APIs only work over the websocket transport.

This happens because:

  1. We track filter and subscription IDs in the top-level HTTP request's context.
  2. Even if we didn't do that, we couldn't guarantee that all HTTP requests hit the same API server (e.g., given a load balancer), so the websocket transport is the only reliable way to use these APIs anyways.

See

lotus/gateway/handler.go

Lines 89 to 96 in 9310cd6

func (h RateLimiterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(context.WithValue(r.Context(), perConnLimiterKey, h.limiter))
// also add a filter tracker to the context
r = r.WithContext(context.WithValue(r.Context(), statefulCallTrackerKey, newStatefulCallTracker()))
h.handler.ServeHTTP(w, r)
}

Proposal: In the relevant Eth API methods (all those either taking or returning an EthFilterID and/or an EthSubscriptionID), check if the request is being made via a websocket and, if not, reject it with an error explaining that the API is only supported over the websocket transport.

Motivation: Users aren't confused because this just silently refuses to work. Instead, users will get a nice error message telling them to use a websocket if they need to use this API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant