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 limit outgoing p2p http connections #5931

Merged

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Feb 6, 2024

Summary

Make P2PNetwork to produce rate limiting outgoing HTTP clients. There are some some movements into subpackages to allow both network, p2p, peerstore to use some utilities/functionality.

  • addr.go -> network/addr
  • phonebook -> network/phonebook (to make peerstore's interface compatible with phonebook)
  • dialer, ratelimit transport -> network/limitcaller

Had to modify phonebook interface to accept both string and p2p.peer.AddrInfo (alternative is to marshal AddrInfo to bytes, cast and unmarshal but it is kind of the same). Plus, the current peerstore's implementation of Phonebook interface uses "host:port" as peerID and works only with "host:port" addresses and not with any kind of p2p addresses so it requires some change anyway. This is a first step.

Test Plan

Added a unit test.

@algorandskiy algorandskiy added Enhancement p2p Work related to the p2p project labels Feb 6, 2024
@algorandskiy algorandskiy self-assigned this Feb 6, 2024
@algorandskiy algorandskiy marked this pull request as ready for review February 6, 2024 21:27
@algorandskiy algorandskiy force-pushed the pavel/p2p-http-outgoing-rate branch from 1469fbc to c5d2a66 Compare February 6, 2024 23:44
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (200e0bb) 55.67% compared to head (c5d2a66) 56.06%.

Files Patch % Lines
network/p2p/http.go 0.00% 7 Missing ⚠️
network/p2pNetwork.go 80.00% 2 Missing ⚠️
catchup/universalFetcher.go 50.00% 0 Missing and 1 partial ⚠️
cmd/algod/main.go 0.00% 1 Missing ⚠️
cmd/goal/node.go 0.00% 1 Missing ⚠️
network/addr.go 66.66% 1 Missing ⚠️
network/p2p/peerstore/peerstore.go 92.30% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           feature/p2p    #5931      +/-   ##
===============================================
+ Coverage        55.67%   56.06%   +0.39%     
===============================================
  Files              482      481       -1     
  Lines            68120    68072      -48     
===============================================
+ Hits             37927    38167     +240     
+ Misses           27570    27296     -274     
+ Partials          2623     2609      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@algorandskiy algorandskiy merged commit 472f01b into algorand:feature/p2p Feb 7, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement p2p Work related to the p2p project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant