Skip to content

node/gointerfaces/grpcutil: unify grpc server bring-up across daemons#22171

Merged
yperbasis merged 2 commits into
mainfrom
yperbasis/grpcutil-start-server
Jul 3, 2026
Merged

node/gointerfaces/grpcutil: unify grpc server bring-up across daemons#22171
yperbasis merged 2 commits into
mainfrom
yperbasis/grpcutil-start-server

Conversation

@yperbasis

@yperbasis yperbasis commented Jul 2, 2026

Copy link
Copy Markdown
Member

cmd/downloader, txnprovider/txpool, node/privateapi, and p2p/sentry each re-inlined the interceptor/keepalive option block that grpcutil.NewServer already builds — two of them complete with its dead commented-out metrics hooks — and all four repeated the same listen + health-server + serve-goroutine tail.

NewServer(rateLimit, creds) now delegates to a new NewServerWithOpts(creds, extraOpts...) (nil-safe creds, no forced MaxConcurrentStreams), and StartServer/StartServerOnListener own the listen/health/serve tail. The four sites convert onto these.

Option preservation was the review focus, per site: downloader and txpool still run without MaxConcurrentStreams (as before); txpool keeps its explicit ReadBufferSize(0)/WriteBufferSize(0); privateapi/sentry keep health registration gated on their healthCheck flag while downloader/txpool keep it unconditional; existing NewServer callers see byte-identical behavior.

Two deliberate exceptions to strict preservation:

  • Both converted StartGrpcs now take credentials.TransportCredentials by value (as privateapi.StartGrpc already does) instead of pointer-to-interface, dropping the identical unwrap shim at each site; their sole callers pass literal nil and are unchanged.
  • The txpool serve-failure log now reads txpool gRPC server fail instead of the private RPC server fail string copy-pasted from privateapi — in the standalone txpool daemon, --private.api.addr names the remote node it connects to, so the old label pointed triage at the wrong process. Nothing greps or asserts these strings.

Otherwise no behavior change — existing tests are the safety net (txpool, privateapi, sentry suites green). Full make lint clean, make erigon integration build. Net −117 lines.

Part of a dedup series; siblings #22165#22170.

…privateapi, p2p/sentry: unify grpc server bring-up

Four sites re-inlined the interceptor/keepalive option block that
grpcutil.NewServer already builds (two of them including its dead
commented-out metrics hooks) and all four repeated the listen + health +
serve tail. Split NewServer into NewServerWithOpts (no
MaxConcurrentStreams, nil-safe creds) plus StartServer/
StartServerOnListener, and convert the sites. Per-site options are
unchanged: downloader/txpool still run without MaxConcurrentStreams,
txpool keeps ReadBufferSize(0)/WriteBufferSize(0), health registration
stays gated where it was gated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors gRPC server initialization across multiple daemons to remove duplicated option/interceptor/keepalive blocks and centralize the common listen + (optional) health server + serve-goroutine startup logic in grpcutil.

Changes:

  • Added grpcutil.NewServerWithOpts for composing a standard server with optional extra grpc.ServerOptions (and nil-safe creds handling).
  • Added grpcutil.StartServer / StartServerOnListener to own the common listener + health registration + Serve goroutine tail.
  • Updated downloader, txpool, privateapi, and sentry to use the unified helpers while preserving per-site option differences (e.g., txpool buffer sizes, healthCheck gating).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
node/gointerfaces/grpcutil/utils.go Introduces NewServerWithOpts and shared StartServer* helpers for consistent gRPC bring-up.
cmd/downloader/main.go Switches downloader gRPC startup to grpcutil.NewServerWithOpts + grpcutil.StartServer.
txnprovider/txpool/txpool_grpc_server.go Switches txpool gRPC startup to grpcutil.NewServerWithOpts (preserving buffer opts) + grpcutil.StartServer.
node/privateapi/all.go Switches privateapi server startup to grpcutil.StartServer (preserving healthCheck gating).
p2p/sentry/sentry_grpc_server.go Switches sentry server startup tail to grpcutil.StartServerOnListener (preserving custom listen config + healthCheck gating).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread node/gointerfaces/grpcutil/utils.go
…creds by value, relabel txpool serve error

Drop the *credentials.TransportCredentials pointer-to-interface params and
their unwrap shims (sole callers pass literal nil); relabel the txpool
serve-failure log, previously copy-pasted from privateapi; grammar-fix a
moved comment.
@yperbasis yperbasis marked this pull request as ready for review July 3, 2026 08:34
@yperbasis yperbasis requested a review from Copilot July 3, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread node/gointerfaces/grpcutil/utils.go
@yperbasis yperbasis added this pull request to the merge queue Jul 3, 2026
Merged via the queue into main with commit 285eb0a Jul 3, 2026
126 of 175 checks passed
@yperbasis yperbasis deleted the yperbasis/grpcutil-start-server branch July 3, 2026 13:27
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.

3 participants