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): relay all recently-seen peers for neighbors #782

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

msbrogli
Copy link
Member

@msbrogli msbrogli commented Sep 22, 2023

Motivation

The full node currently relays only connections in the ready state. So, if a connection drops for just a few seconds, we might not relay this peer information to our neighbors.

The current behavior of the full node involves requesting peer information from a neighboring node exclusively during the initial connection establishment phase. Consequently, if the full node attempts to establish a connection with a peer and that peer rejects the connection, there is a risk that the full node will subsequently remove this peer from its peer storage. As a result, there would be no further attempts made to connect to this particular peer in the future.

Acceptance Criteria

  1. Clean up aged peers in ConnectionsManager.peer_storage.
  2. Add PeerId.last_seen: float.
  3. Update protocol.peer.last_seen when the connection is ready and when new messages are received.
  4. Add known_peers.last_seen to /v1a/status API.
  5. Remove time.time() from hathor.p2p.resources.StatusResource.
  6. Add a looping call to call send_get_peers() every 5 minutes.
  7. Relay only peer information that contains at least one entrypoint.

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@msbrogli msbrogli added the enhancement New feature or request label Sep 22, 2023
@msbrogli msbrogli requested a review from glevco September 22, 2023 07:16
@msbrogli msbrogli requested a review from jansegre as a code owner September 22, 2023 07:16
@msbrogli msbrogli self-assigned this Sep 22, 2023
@msbrogli msbrogli changed the base branch from master to feat/p2p-max-conn-per-ip September 22, 2023 07:16
@msbrogli msbrogli force-pushed the feat/p2p-peer-relay branch 3 times, most recently from 2a5cd3c to c2f8dc7 Compare September 22, 2023 08:09
@msbrogli msbrogli force-pushed the feat/p2p-max-conn-per-ip branch 3 times, most recently from cf72e8d to 941d9fb Compare September 22, 2023 09:00
@msbrogli msbrogli force-pushed the feat/p2p-peer-relay branch 3 times, most recently from e253018 to 885ac3f Compare September 22, 2023 09:09
@msbrogli msbrogli force-pushed the feat/p2p-max-conn-per-ip branch 4 times, most recently from ce879c5 to 7a0ccab Compare September 22, 2023 21:26
@msbrogli msbrogli force-pushed the feat/p2p-peer-relay branch 3 times, most recently from 99e9f3b to 1caa136 Compare September 22, 2023 21:46
hathor/p2p/manager.py Outdated Show resolved Hide resolved
@msbrogli msbrogli requested a review from jansegre September 22, 2023 22:48
@msbrogli msbrogli force-pushed the feat/p2p-max-conn-per-ip branch from 7a0ccab to 2542e8a Compare September 22, 2023 22:51
glevco
glevco previously approved these changes Sep 22, 2023
hathor/p2p/manager.py Outdated Show resolved Hide resolved
jansegre
jansegre previously approved these changes Sep 22, 2023
hathor/p2p/manager.py Outdated Show resolved Hide resolved
hathor/p2p/manager.py Show resolved Hide resolved
@msbrogli msbrogli force-pushed the feat/p2p-peer-relay branch 2 times, most recently from f994480 to a6ceae7 Compare September 23, 2023 00:56
@msbrogli msbrogli force-pushed the feat/p2p-max-conn-per-ip branch 2 times, most recently from 617b327 to 6289b36 Compare September 23, 2023 02:42
@jansegre jansegre changed the title feat(p2p): Relay all recently-seen peers for neighbors. feat(p2p): relay all recently-seen peers for neighbors. Sep 29, 2023
@jansegre jansegre changed the title feat(p2p): relay all recently-seen peers for neighbors. feat(p2p): relay all recently-seen peers for neighbors Sep 29, 2023
@jansegre jansegre changed the base branch from feat/p2p-max-conn-per-ip to master September 29, 2023 15:05
@jansegre jansegre dismissed stale reviews from glevco and themself September 29, 2023 15:05

The base branch was changed.

@jansegre jansegre self-assigned this Sep 29, 2023
@jansegre jansegre force-pushed the feat/p2p-peer-relay branch 2 times, most recently from bab33f4 to 2e4a962 Compare October 11, 2023 19:24
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

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

Comparison is base (fd3c1ff) 84.66% compared to head (2e4a962) 84.69%.
Report is 5 commits behind head on master.

❗ Current head 2e4a962 differs from pull request most recent head e305645. Consider uploading reports for the commit e305645 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #782      +/-   ##
==========================================
+ Coverage   84.66%   84.69%   +0.03%     
==========================================
  Files         264      266       +2     
  Lines       22034    22117      +83     
  Branches     3369     3378       +9     
==========================================
+ Hits        18654    18731      +77     
- Misses       2725     2728       +3     
- Partials      655      658       +3     
Files Coverage Δ
hathor/builder/cli_builder.py 74.48% <100.00%> (ø)
hathor/conf/mainnet.py 100.00% <ø> (ø)
hathor/conf/settings.py 97.29% <100.00%> (+0.11%) ⬆️
hathor/conf/testnet.py 100.00% <ø> (ø)
hathor/indexes/base_index.py 100.00% <100.00%> (ø)
hathor/indexes/height_index.py 96.61% <100.00%> (ø)
hathor/indexes/memory_height_index.py 83.33% <100.00%> (ø)
hathor/indexes/memory_info_index.py 91.66% <100.00%> (ø)
hathor/indexes/rocksdb_height_index.py 94.17% <100.00%> (+0.05%) ⬆️
hathor/p2p/peer_id.py 97.18% <100.00%> (-0.92%) ⬇️
... and 18 more

... and 4 files with indirect coverage changes

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

@jansegre jansegre force-pushed the feat/p2p-peer-relay branch 2 times, most recently from 7855318 to 0c2d15d Compare October 17, 2023 18:33
@jansegre jansegre force-pushed the feat/p2p-peer-relay branch from 0c2d15d to e305645 Compare October 17, 2023 18:34
@msbrogli msbrogli merged commit e305645 into master Oct 17, 2023
@msbrogli msbrogli deleted the feat/p2p-peer-relay branch October 17, 2023 19:14
This was referenced Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants