-
Notifications
You must be signed in to change notification settings - Fork 132
core/validatorapi: support proxy of SSE events #4140
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4140 +/- ##
==========================================
- Coverage 56.43% 56.36% -0.08%
==========================================
Files 245 245
Lines 31175 31223 +48
==========================================
+ Hits 17595 17598 +3
- Misses 11272 11320 +48
+ Partials 2308 2305 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
970dd4c to
1d1b39c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for proxying Server-Sent Events (SSE) from beacon nodes by implementing a dedicated reverse proxy handler for the /eth/v1/events endpoint. The implementation extends the existing validator API infrastructure to handle streaming responses that require persistent connections.
Key changes:
- Added
Address()andHeaders()methods to client interfaces to support direct beacon node proxying - Implemented
eventsHandlerusing Go'shttputil.ReverseProxyfor SSE streaming - Created
proxyResponseWriterwrapper for error metrics instrumentation
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
core/validatorapi/router.go |
Added SSE events handler with reverse proxy implementation and proxyResponseWriter wrapper |
core/validatorapi/validatorapi.go |
Implemented Address() and Headers() methods for Component |
core/validatorapi/router_internal_test.go |
Added Address() and Headers() methods to testHandler mock |
core/validatorapi/mocks/handler.go |
Generated mock implementations for new interface methods |
app/eth2wrap/eth2wrap_gen.go |
Added Address() and Headers() to Client interface definition |
app/eth2wrap/httpwrap.go |
Implemented Headers() method to return custom headers |
app/eth2wrap/lazy.go |
Added lazy wrapper implementation for Headers() method |
app/eth2wrap/multi.go |
Implemented Address() and Headers() methods for multi-client wrapper |
app/eth2wrap/mocks/client.go |
Generated mock implementation for Headers() method |
testutil/beaconmock/beaconmock.go |
Added Headers() method to Mock returning nil |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| // Start a proxy server that will proxy to the target server. | ||
| ctx, cancel := context.WithCancel(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using t.Context() wherever you can in tests.
|



The previous PR #4042 added
eth2wraplogic (multi,lazy,etc) to proxied requests but broke SSE requests.This PR fixes this issue by using
proxy.ServeHTTP(proxyResponseWriter{w.(writeFlusher)}, clonedReq)to maintain a long lived HTTP connection between BN and VC.category: bug
ticket: none