Skip to content

Fix/per ip rate limiting - #64

Open
secretnamebasis wants to merge 2 commits into
DEROFDN:community-devfrom
secretnamebasis:fix/per-ip-rate-limiting
Open

Fix/per ip rate limiting#64
secretnamebasis wants to merge 2 commits into
DEROFDN:community-devfrom
secretnamebasis:fix/per-ip-rate-limiting

Conversation

@secretnamebasis

Copy link
Copy Markdown

Description

The incoming-connection rate limiter (accept_limiter) was a single global rate.Limiter
(10/sec, burst of 40) shared across every peer. Under broad legitimate churn from many
different peers, this budget could be exhausted and starve out a single new, otherwise-good
connection attempt — one noisy or high-churn source could crowd out everyone else.

This PR adds a per-source-IP limiter (map[string]*rate.Limiter, 1/sec sustained, burst of 5
each) as the primary fairness gate on the accept path, checked before the global limiter. The
global limiter is kept as a looser ceiling behind it against a genuine multi-source flood, and
bumped to 20/sec, burst 60 to make room for the per-IP gating to do the real work. A 5-minute
ticker evicts per-IP entries idle over 15 minutes so the map doesn't grow unbounded on a
long-running node.

NOTE: The process is the following:

  • Your pull request should be directed to dev branch.
  • When it will be merged in dev, we will merge it to testnet for tests, and then into main for final release.

Fixes # (issue)

Type of change

Please select the right one.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted ?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc (documentation, comments, text...)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

License

I'm am contributing & releasing the code under DERO Research License (which can be found here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant