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

[P2P] Rate limiting rumored address processing #2824

Merged
merged 1 commit into from May 21, 2023

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
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.

src/net_processing.cpp Outdated Show resolved Hide resolved
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 01e2e26

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

src/net_processing.cpp Outdated Show resolved Hide resolved
@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

src/net_processing.cpp Show resolved Hide resolved
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

'received: addrv2 (131 bytes) peer=0',
'sending addrv2 (131 bytes) peer=1',
'sending addrv2 (14 bytes) peer=1',

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

@@ -58,13 +74,76 @@ def run_test(self):
addr_receiver = self.nodes[0].add_p2p_connection(AddrReceiver())
msg.addrs = ADDRS
with self.nodes[0].assert_debug_log([
'Added 10 addresses from 127.0.0.1: 0 tried',
'received: addr (301 bytes) peer=0',

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
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
21 checks passed
@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.

None yet

3 participants