fix(evmrpc): limit listener max open connections, configurable via max_open_connections (PLT-704)#3637
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit b300366. 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).
|
…connection-config
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3637 +/- ##
==========================================
- Coverage 59.12% 58.15% -0.97%
==========================================
Files 2259 2176 -83
Lines 186489 176903 -9586
==========================================
- Hits 110255 102880 -7375
+ Misses 66353 64930 -1423
+ Partials 9881 9093 -788
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Describe your changes and provide context
Bounds the number of simultaneously accepted connections on the EVM JSON-RPC HTTP (
:8545) and WebSocket (:8546) listeners to protect nodes from connection exhaustion (fd/goroutine pressure) under load or abuse.net.ListeninStart()withnetutil.LimitListener(l, maxOpenConns). Excess connections wait in the accept queue until an active connection closes.max_open_connectionsas an operator config field inevmrpc/config(evm.max_open_connectionsinapp.toml), wired throughReadConfigand the config template.HTTPServer.SetMaxOpenConns, set from config in bothNewEVMHTTPServerandNewEVMWebSocketServerbefore the listener starts.2000. Set to0to disable the limit (unbounded, prior behavior). The wrap is guarded onmaxOpenConns > 0, sincenetutil.LimitListenerwould otherwise block all connections at0.Testing performed to validate your change
TestMaxOpenConns(evmrpc): with a cap of 1, verifies a second connection is not served while the first holds the only slot, and is served once the first closes.evmrpc/configtests for the new field;go test ./evmrpc/... ./evmrpc/config/...passes.go build ./evmrpc/...andgofmt -sclean.