feat(ratelimiter): add RateLimiterRegistry + evmrpc config fields#3507
feat(ratelimiter): add RateLimiterRegistry + evmrpc config fields#3507amir-deris wants to merge 27 commits into
Conversation
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit 57e9ff3. 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).
|
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3507 +/- ##
==========================================
- Coverage 59.22% 58.35% -0.87%
==========================================
Files 2214 2140 -74
Lines 183402 174855 -8547
==========================================
- Hits 108619 102040 -6579
+ Misses 64994 63725 -1269
+ Partials 9789 9090 -699
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Build-vs-buy on The rate-limiting core here is solid and appropriately simple — I'd keep it:
The part worth not hand-rolling is client-IP extraction —
This would replace roughly the lower half of
One thing no extraction library solves, so it stays in-house: IPv6 should be bucketed by prefix — mask the extracted IP to /64 before it becomes the limiter key, otherwise a client with a /64 rotates addresses for a fresh bucket per request. That's a one-liner in the keying step. Net: keep |
@bdchatham Thanks for great feedback. About using the external library for the IP extraction part, I believe that is not necessary as the library The other issues are very valid, I will work on fixing them! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f3c25e1. Configure here.

Summary
ratelimiterpackage withRegistry: per-IP token-bucket rate limiter backed by an expirable LRU (50k entries, 1h TTL) usinggolang.org/x/time/rateAllow(ctx, ip, plane, method)enforces the limit and increments therpc_rate_limit_rejected_total{plane, method}OTel counter on rejectionIPFromHTTPRequest/IPFromGRPCContextextract the real client IP, honouringX-Forwarded-Foronly whenRemoteAddr/ peer address is within a configured trusted proxy CIDRrate_limiting_enabled,ip_rate_limit_rps, andip_rate_limit_burstfields toevmrpc/config(defaults: enabled, 200 RPS, 400 burst);trusted_proxy_cidrswill be added when request-path wiring lands; existing nodes without these fields inapp.tomlfall back to defaults safely