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

refactor(p2p): implement P2PConnectionProtocol [part 9/11] #1166

Open
wants to merge 1 commit into
base: refactor/p2p/initial-state
Choose a base branch
from

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Oct 23, 2024

Depends on #1172

Motivation

Continuing with the multiprocess P2P implementation, this PR abstracts the last piece of code that binds individual P2P connections to the rest of the full node: calls from the ConnectionsManager to HathorProtocol instances.

It also adds the currently unimplemented --x-multiprocess-p2p CLI option, and removes the SyncAgentFactory abstraction, which was only necessary for Sync-v1 but not for Sync-v2. I refactored it to remove the ConnectionsManager.get_sync_factory method, which couldn't be called through IPC.

Acceptance Criteria

  • Implement P2PConnectionProtocol, abstracting calls from the ConnectionsManager to individual connections (instances of HathorProtocol).
  • Add unsafe --x-multiprocess-p2p CLI option (currently does nothing).
  • Refactor creation of SyncAgents to remove ConnectionsManager.get_sync_factory, also removing related classes.

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

@glevco glevco self-assigned this Oct 23, 2024
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from 1bb16b8 to 2034c11 Compare October 23, 2024 18:17
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 69.44444% with 33 lines in your changes missing coverage. Please review.

Project coverage is 84.73%. Comparing base (659806b) to head (cb9f709).

Files with missing lines Patch % Lines
hathor/p2p/dependencies/protocols.py 13.33% 0 Missing and 13 partials ⚠️
hathor/p2p/manager.py 74.50% 9 Missing and 4 partials ⚠️
hathor/p2p/sync_agent.py 84.21% 2 Missing and 1 partial ⚠️
hathor/builder/cli_builder.py 33.33% 1 Missing and 1 partial ⚠️
hathor/manager.py 0.00% 1 Missing ⚠️
hathor/p2p/states/ready.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           refactor/p2p/initial-state    #1166      +/-   ##
==============================================================
- Coverage                       84.87%   84.73%   -0.15%     
==============================================================
  Files                             321      318       -3     
  Lines                           24498    24508      +10     
  Branches                         3728     3742      +14     
==============================================================
- Hits                            20792    20766      -26     
- Misses                           2987     3000      +13     
- Partials                          719      742      +23     

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

@glevco glevco marked this pull request as ready for review October 23, 2024 21:16
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from bb266e3 to cc3bba3 Compare October 23, 2024 21:20
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch 2 times, most recently from 72d3563 to f7bf2f2 Compare October 27, 2024 20:53
@glevco glevco force-pushed the refactor/p2p/remove-manager branch from b6b19b2 to 58633dc Compare November 5, 2024 18:51
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from f7bf2f2 to c66b07d Compare November 5, 2024 19:23
@glevco glevco changed the title refactor(p2p): implement P2PConnectionProtocol [part 7/8] refactor(p2p): implement P2PConnectionProtocol [part 8/8] Nov 6, 2024
@glevco glevco changed the base branch from refactor/p2p/remove-manager to refactor/p2p/initial-state November 6, 2024 02:55
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch 3 times, most recently from 08328b2 to b4f9b18 Compare November 6, 2024 14:23
@@ -340,11 +344,11 @@ def send_tx_to_peers(self, tx: BaseTransaction) -> None:
connections = list(self.iter_ready_connections())
self.rng.shuffle(connections)
for conn in connections:
conn.send_tx_to_peer(tx)
self.reactor.callLater(0, conn.send_tx_to_peer, tx)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to unblock the main loop

Comment on lines +366 to +367
protocol = self._connections.get_peer_by_address(addr)
self.reactor.callLater(0, protocol.disconnect, force=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to unblock the main loop

@glevco glevco changed the title refactor(p2p): implement P2PConnectionProtocol [part 8/8] refactor(p2p): implement P2PConnectionProtocol [part 9/10] Nov 6, 2024
@glevco glevco force-pushed the refactor/p2p/initial-state branch from a5399b5 to 260d851 Compare November 6, 2024 15:30
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from b4f9b18 to 44e6db9 Compare November 6, 2024 15:33
@glevco glevco force-pushed the refactor/p2p/initial-state branch from 260d851 to 36da2f5 Compare November 7, 2024 01:59
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from 44e6db9 to 73b394a Compare November 7, 2024 02:00
@glevco glevco changed the title refactor(p2p): implement P2PConnectionProtocol [part 9/10] refactor(p2p): implement P2PConnectionProtocol [part 9/11] Nov 7, 2024
@glevco glevco force-pushed the refactor/p2p/initial-state branch from 36da2f5 to 659806b Compare November 8, 2024 15:45
@glevco glevco force-pushed the refactor/p2p/p2p-connection-protocol branch from 73b394a to cb9f709 Compare November 8, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant