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

move setting route handlers to registration from start #13676

Merged
merged 3 commits into from Feb 28, 2024
Merged

Conversation

james-prysm
Copy link
Contributor

@james-prysm james-prysm commented Feb 27, 2024

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

There is a race introduced by registering the route at the start of the services within the beacon chain particularly between the rpc service and the grpc gateway service which use the underlying route. under these conditions if the enduser calls an endpoint without a pause at the start of the service a panic may occur. This PR moves the setting of route handlers in the registration instead of when the service starts.

example of an error

2024/02/23 09:24:09 http: panic serving 172.18.0.6:59022: runtime error: invalid memory address or nil pointer dereference
goroutine 214271 [running]:
net/http.(*conn).serve.func1()
	GOROOT/src/net/http/server.go:1868 +0xb9
panic({0x42c7e0?, 0x33f1ee0?})
	GOROOT/src/runtime/panic.go:920 +0x270
github.com/gorilla/mux.(*Route).Match(0xc003ad4460?, 0x0?, 0xc00f08c420?)
	external/com_github_gorilla_mux/route.go:42 +0x1a
github.com/gorilla/mux.(*Router).Match(0xc0001d8240, 0x1?, 0xc00f08c420)
	external/com_github_gorilla_mux/mux.go:138 +0x6b
github.com/gorilla/mux.(*Router).ServeHTTP(0xc0001d8240, {0xd109e0, 0xc009229a40}, 0xc006a43900)
	external/com_github_gorilla_mux/mux.go:196 +0xd9
github.com/rs/cors.(*Cors).Handler-fm.(*Cors).Handler.func1({0xd109e0, 0xc009229a40}, 0xc006a43900)
	external/com_github_rs_cors/cors.go:219 +0x17e
net/http.HandlerFunc.ServeHTTP(0x3788780?, {0xd109e0?, 0xc009229a40?}, 0xc00238fb50?)
	GOROOT/src/net/http/server.go:2136 +0x29
net/http.serverHandler.ServeHTTP({0xc00f08c240?}, {0xd109e0?, 0xc009229a40?}, 0x6?)
	GOROOT/src/net/http/server.go:2938 +0x8e

@james-prysm james-prysm added Bug Something isn't working API Api related tasks labels Feb 27, 2024
@james-prysm james-prysm requested review from rkapka and nisdas and removed request for potuz and terencechain February 27, 2024 20:55
@@ -557,8 +425,6 @@ func (s *Service) Start() {
// Register reflection service on gRPC server.
reflection.Register(s.grpcServer)

validatorServer.PruneBlobsBundleCacheRoutine()
Copy link
Member

Choose a reason for hiding this comment

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

why is this moved ?

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's not, it's part of the Start() function still but the validator server needed to be set somewhere, i moved all of the initialization functions out of start and introduced the validator server as another variable to be used.

see line 587 s.validatorServer.PruneBlobsBundleCacheRoutine()

@rkapka rkapka added this pull request to the merge queue Feb 28, 2024
Merged via the queue into develop with commit 6d3c6a6 Feb 28, 2024
17 checks passed
@rkapka rkapka deleted the move-routes branch February 28, 2024 12:05
nalepae pushed a commit that referenced this pull request Feb 29, 2024
* moving route registration out of the start function and into registration

* moving where grpc is set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants