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

REST VC: Subscribe to Beacon API events #13453

Merged
merged 11 commits into from
Jan 18, 2024
Merged

REST VC: Subscribe to Beacon API events #13453

merged 11 commits into from
Jan 18, 2024

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Jan 11, 2024

What type of PR is this?

Other

What does this PR do? Why is it needed?

This is a better alternative to #13354. We reverted the original PR before a release because the functionality was not tested properly. As it turns out, restarting the node broke the stream and the original PR didn't have a recovery mechanism.

There is not need to review the first commit because it's only reapplying the reverted PR.

@rkapka rkapka requested a review from a team as a code owner January 11, 2024 16:31
@rkapka rkapka changed the title Use a single rest handler REST VC: Subscribe to Beacon API events Jan 11, 2024
@rkapka rkapka force-pushed the subscribe-to-slots branch 4 times, most recently from d60df01 to 4c29055 Compare January 11, 2024 16:54
@@ -25,10 +26,6 @@ type BeaconApiJsonRestHandler struct {
// Get sends a GET request and decodes the response body as a JSON object into the passed in object.
// If an HTTP error is returned, the body is decoded as a DefaultJsonError JSON object and returned as the first return value.
func (c BeaconApiJsonRestHandler) Get(ctx context.Context, endpoint string, resp interface{}) error {
if resp == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"/eth/v1/node/health" doesn't return a body

log.WithError(err).Error("Failed to create HTTP request")
}
req.Header.Set("Accept", api.EventStreamMediaType)
req.Header.Set("Connection", "keep-alive")
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add this to the API constants? ( keep-alive)

go func() {
h.running = true
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm is this the best approach to this/ is this safe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be improved, I think. I will push a new commit


// EventStreamIsRunning returns a dummy value for gRPC
func (c *grpcValidatorClient) EventStreamIsRunning() bool {
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have a log at least for the dummy value.. same with the above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would actually be better to panic because these functions should never be called

@rkapka rkapka force-pushed the subscribe-to-slots branch from 4c29055 to adb1638 Compare January 12, 2024 14:05
if err = v.StartEventStream(ctx); err != nil {
log.WithError(err).Fatal("Could not start API event stream")
if features.Get().EnableBeaconRESTApi {
if err = v.StartEventStream(ctx); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not move it into the below check, there are 2 features.Get().EnableBeaconRestApi

@rkapka rkapka force-pushed the subscribe-to-slots branch from 8cf821a to 0f873aa Compare January 15, 2024 13:53
@james-prysm
Copy link
Contributor

There are possible issues with setting the runner bool on errors that should be accounted for. please do not approve until they are resolved.

@rkapka rkapka enabled auto-merge January 18, 2024 00:27
@rkapka rkapka added this pull request to the merge queue Jan 18, 2024
Merged via the queue into develop with commit 204de13 Jan 18, 2024
17 checks passed
@rkapka rkapka deleted the subscribe-to-slots branch January 18, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants