Skip to content

Conversation

@Liquid369
Copy link
Member

As of recent there was a release on https://www.halborn.com/blog/post/halborn-discovers-zero-day-impacting-dogecoin-and-280-networks
We want to address potential situation that can cause network instability and node attacks.

This PR back ports
bitcoin#22387
bitcoin#15617

This implements a token bucket for rate limiting addresses, allowing up to 1000 in one request. Getaddr requests are exempt from this rate limiting. Then we are also no longer going to relay to other nodes peers we have banned. Functional tests included.

@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch 2 times, most recently from 98bf8ce to fb8f511 Compare March 28, 2023 14:41
@Fuzzbawls Fuzzbawls changed the title [Bug] Rate limiting rumored address processing [P2P] Rate limiting rumored address processing Apr 1, 2023
@Fuzzbawls Fuzzbawls added this to the 6.0.0 milestone Apr 1, 2023
@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch 2 times, most recently from fea7667 to a6d69d8 Compare April 8, 2023 00:09
@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch from a6d69d8 to 3c6280b Compare April 14, 2023 12:45
@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch from 3c6280b to 0c2deb2 Compare April 27, 2023 19:33
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

Functional ACK, one minor clang-tidy cleanup.

@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch from 0c2deb2 to 01e2e26 Compare May 2, 2023 11:30
Fuzzbawls
Fuzzbawls previously approved these changes May 3, 2023
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK 01e2e26f905850a878e438c124b7a00cb6011ed2

Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

Left a couple of comments

@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch 4 times, most recently from 611cd77 to 3717978 Compare May 10, 2023 20:48
Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

another comment on the latest commit

Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

a couple more comments

Choose a reason for hiding this comment

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

Wrote yesterday on discord, but rewriting here so we don't forget:
Imo the assert here should not be changed because we are functional testing a specific expected behaviour. If this change is due to the fact that m_addr_token_bucket is empty then it is better if you change the node time to refill it, if it's not that then the PR introduced a bug

Choose a reason for hiding this comment

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

same comment here, an assert that tested an expected result has been changed. If this was due to the fact that the bucket is empty then ok change the node's time to refill it and the unchanged assert should pass. If it does not a bug was introduced

Copy link
Member Author

Choose a reason for hiding this comment

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

In this regard, I have restored the old logs but have changed the addr_token_bucket from 1.0 to 10.0 to reflect the logging more accurately rather than accounting for a stricter rate limit.
Take a look let me know, ima try to get this last test working...again

Set for every instance and fix test peer, remove var
Refactor debug logs

Adjust p2p invalid msgs
@Liquid369 Liquid369 force-pushed the 2023_rate_limit_getaddr branch from 0e7eb41 to c5fd91e Compare May 15, 2023 13:09
Copy link

@panleone panleone left a comment

Choose a reason for hiding this comment

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

tACK c5fd91e
All my feedbacks have been implemented, tested on mainnet: the bucket is filled quick enough in such a way that in normal condition no requests are limited

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK c5fd91e

@Fuzzbawls Fuzzbawls merged commit cfc110e into PIVX-Project:master May 21, 2023
@Fuzzbawls Fuzzbawls modified the milestones: 6.0.0, 5.6.0 Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants