feat(grpc): add keepalive, LimitListener, and MaxRecvMsgSize to gRPC server :9090 (PLT-705)#3641
feat(grpc): add keepalive, LimitListener, and MaxRecvMsgSize to gRPC server :9090 (PLT-705)#3641amir-deris wants to merge 1 commit into
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit aea7c9d. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3641 +/- ##
==========================================
- Coverage 59.12% 58.16% -0.96%
==========================================
Files 2259 2176 -83
Lines 186489 176950 -9539
==========================================
- Hits 110255 102925 -7330
+ Misses 66353 64931 -1422
+ Partials 9881 9094 -787
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
The gRPC server at
:9090was created with onlygrpc.MaxConcurrentStreams(100)and an unboundednet.Listen. It had no cap on connection count, no bound on inbound message size, and no keepalive policy. This PR adds all three and exposes every parameter as an operator config field under[grpc]inapp.toml. (PLT-705)MaxRecvMsgSize
Sets
grpc.MaxRecvMsgSize()explicitly (default 4 MB, matching gRPC's own default). This bounds per-request memory allocation before the rate limiter fires, so an oversized request can't allocate first and rate-limit second.MaxOpenConnections
Wraps the listener with
netutil.LimitListenerto cap simultaneously-open TCP connections (mirrors the gRPC-Web change in #3605 and the EVMLimitListenerpattern). Keepalive alone bounds neither connection count nor message size — this is the actual DoS bound.0to disable the cap.Keepalive
Adds
keepalive.ServerParametersandkeepalive.EnforcementPolicy. Defaults mirror gRPC's own (i.e. opt-in, no behavior change) with one deliberate exception:MaxConnectionIdleMaxConnectionAgeMaxConnectionAgeGraceMaxConnectionAge; meaningless until age is set.TimeTimeoutEnforcementPolicy.MinTimeEnforcementPolicy.PermitWithoutStreamMaxSendMsgSizeis intentionally not added — PageGuard already bounds row count at the query layer. Revisit if large unpaginated responses surface in the handler inventory.Config plumbing
All fields are exposed under
[grpc]inapp.tomland wired throughDefaultConfig()andGetConfig(). For the bounded defaults (max-recv-msg-size,max-open-connections,max-connection-idle, and the keepalive durations),GetConfigapplies the in-code default when the key is absent, so a node upgrading with an olderapp.tomlstays bounded rather than reverting to unlimited/infinity.Files changed:
sei-cosmos/server/grpc/server.go,sei-cosmos/server/config/config.go,sei-cosmos/server/config/toml.go,sei-cosmos/server/start.go,sei-cosmos/testutil/network/util.goTests
TestDefaultGRPCConfig— asserts all new defaults.TestGetConfigGRPCDefaultsWhenAbsent— a legacyapp.toml(missing the new keys) still resolves to the bounded in-code defaults, including the 5m idle default.TestGetConfigGRPCOverrides— operator-provided values override the defaults.Test plan
go test ./sei-cosmos/server/config/... ./sei-cosmos/server/grpc/...passesgofmt -s -l .prints nothingmake buildsucceeds🤖 Generated with Claude Code