Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(p2p): channels with limit of send and recv rate #753

Merged
merged 12 commits into from
Mar 12, 2024

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Mar 8, 2024

Issue being fixed or feature implemented

Mempool sync can DoS a node by sending thousands of transactions and filling whole p2p connection.

What was done?

Introduced new type of channel that can limit send and receive rate of messages and implemented it for mempool.

Changed ChannelIterator to interface, to allow multiple implementations, and implemented throttledChannelIterator to read from channel with recv rate limits applied.

Introduced new [mempool] settings (disabled by default):

  • tx-send-rate-limit is the rate limit for sending transactions to peers, in transactions per second.
  • tx-recv-rate-limit is the rate limit for receiving transactions from peers, in transactions per second.
  • tx-recv-rate-punish-peer set to true means that when tx-recv-rate-limit is reached, the peer will be punished (disconnected).

How Has This Been Tested?

Added unit tests

Tested during Dash Platform load testing.

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@lklimek lklimek enabled auto-merge (squash) March 12, 2024 08:54
Copy link
Member

@shumkov shumkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lklimek lklimek merged commit 2c28a4f into v0.14-dev Mar 12, 2024
15 checks passed
@lklimek lklimek deleted the feat/rate-limiting-channels branch March 12, 2024 15:52
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.

None yet

2 participants