This PR adds a sender-based rate limiter to proxyd. This rate limiter throttles eth_sendRawTransaction requests based on sender in order to prevent abusive behavior on the sequencer.
Integration tests have been added to test this functionality.
The backend rate limiter is in place to protect upstreams like the sequencer. However, in many cases it isn't needed and it causes unnecessary requests to Redis. This PR allows this to be disabled, and disables this by default.
Integrates the custom rate limiter in the previous PR into the rest of the application. Also takes the opportunity to clean up how we instantiate Redis clients so that we can share them among multiple different services.
There are some config changes in this PR. Specifically, you must specify a `base_rate` and `base_interval` in the rate limit config.
Our current proxyd deployment does not share rate limit state across multiple servers within a backend group. This means that rate limits on the public endpoint are artifically high.
This PR adds a Redis-based rate limiter to fix this problem. While our current rate limiting library (github.com/sethvargo/go-limiter) _does_ support Redis, the client library it uses is not type safe, is less performant, and would require us to update the other places we use Redis. To avoid these issues, I created a simple rate limiting interface with both Redis and memory backend.
Note that this PR only adds the new implementations - it does not integrate them with the rest of the codebase. I'll do that in a separate PR to make review easier.
* proxyd: Add batch size metric and configurable max
The max batch size will be overwritten if it is over `MaxBatchRPCCallsHardLimit`.
Builds on https://github.com/ethereum-optimism/optimism/pull/3544.
* changeset
* fix lint
* fix test
* proxyd: Add customizable whitelist error message
Alchemy is asking for this so that we can include their affiliate link.
* add missing test case
* fix error message
* goimports
* proxyd: Fix error message in tests
The custom error message wasn't being carried over in batch responses.
* review fixes
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>