lighthouse/beacon_node/lighthouse_network/src
Divma ceb986549d Self rate limiting dev flag (#3928)
## Issue Addressed
Adds self rate limiting options, mainly with the idea to comply with peer's rate limits in small testnets

## Proposed Changes
Add a hidden flag `self-limiter` this can take no value, or customs values to configure quotas per protocol

## Additional Info
### How to use
`--self-limiter` will turn on the self rate limiter applying the same params we apply to inbound requests (requests from other peers)
`--self-limiter "beacon_blocks_by_range:64/1"` will turn on the self rate limiter for ALL protocols, but change the quota for bbrange to 64 requested blocks per 1 second.
`--self-limiter "beacon_blocks_by_range:64/1;ping:1/10"` same as previous one, changing the quota for ping as well.

### Caveats
- The rate limiter is either on or off for all protocols. I added the custom values to be able to change the quotas per protocol so that some protocols can be given extremely loose or tight quotas. I think this should satisfy every need even if we can't technically turn off rate limits per protocol.
- This reuses the rate limiter struct for the inbound requests so there is this ugly part of the code in which we need to deal with the inbound only protocols (light client stuff) if this becomes too ugly as we add lc protocols, we might want to split the rate limiters. I've checked this and looks doable with const generics to avoid so much code duplication

### Knowing if this is on
```
Feb 06 21:12:05.493 DEBG Using self rate limiting params         config: OutboundRateLimiterConfig { ping: 2/10s, metadata: 1/15s, status: 5/15s, goodbye: 1/10s, blocks_by_range: 1024/10s, blocks_by_root: 128/10s }, service: libp2p_rpc, service: libp2p
```
2023-02-08 02:18:53 +00:00
..
discovery Upgrade to libp2p v0.50.0 (#3764) 2023-01-06 15:59:33 +00:00
peer_manager Upgrade to libp2p v0.50.0 (#3764) 2023-01-06 15:59:33 +00:00
rpc Self rate limiting dev flag (#3928) 2023-02-08 02:18:53 +00:00
service Self rate limiting dev flag (#3928) 2023-02-08 02:18:53 +00:00
types Adding light_client gossip topics (#3693) 2022-12-13 06:24:51 +00:00
config.rs Self rate limiting dev flag (#3928) 2023-02-08 02:18:53 +00:00
lib.rs Libp2p v0.48.0 upgrade (#3547) 2022-09-29 01:50:11 +00:00
metrics.rs Add metrics for subnet queries (#3721) 2022-11-15 13:25:38 +00:00