Start the rate-limiter with 5 tokens instead of 1 token.
On some occasions, a peer will send us addresses a few seconds after the connection is established. As peers start with token=1 and only get an additional token only every 10 seconds, some of these addresses might be rate-limited. The following log snippet contains an example:
004:12:02 [net] Added connection to [redacted] peer=1234
1...
204:12:03 [net] Received addr: 1 addresses (1 processed, 0 rate-limited) from peer=1234
304:12:34 [net] Received addr: 4 addresses (3 processed, 1 rate-limited) from peer=1234
404:13:09 [net] Received addr: 2 addresses (2 processed, 0 rate-limited) from peer=1234
The peer starts with token=1 and uses one for its self-announcement at 04:12:03. Until the next addr message arrives at 04:12:34, it re-gains 3 tokens and uses them, however, the fourth address in this addr message is rate-limited. At 04:13:09, the peer has token=3 and uses 2.
This change gives peers token=5 to start with. To choose this value, I looked at the address relay of freshly connected peers. The data was sampled from the debug.logs from different nodes. It appears, that only very few peers require more than 5 initial tokens.
By increasing the initial tokens to 5, someone could connect, send 5 addresses, disconnect, and repeat to spam the node with addresses. Previously, the same was possible but only one address was processed. I don’t think this is a problem anymore since #30568.