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 initial state [part 8/11] #1172

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

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Nov 6, 2024

Depends on #1142

Motivation

This PR addresses a few architectural shortcomings in the handling of protocol states in P2P. Currently:

  • The HathorProtocol.state attribute is Optional and starts as None, instead of having a well-defined initial state.
  • We store unused state instances indefinitely.
  • The state machine does not specify which state comes after another.
  • There are two types for tracking current state: the PeerState enum and the BaseState subclasses themselves.
  • We only start tracking HathorProtocol instances after they get connected, but it's useful to track them since construction. Specifically, this will be necessary for the P2P Multiprocess project.

Acceptance Criteria

  • Implement new P2P InitialState and change HathorProtocol.state to be non-nullable.
  • Remove PeerState.
  • Add new built_protocol_callback on P2P protocol factory and use it to track built protocol instances in PeerConnections.
  • Implement missing PeerAddress.__hash__ override to consider localhost.

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 added the refactor label Nov 6, 2024
@glevco glevco self-assigned this Nov 6, 2024
@glevco glevco changed the title refactor(p2p): implement initial state refactor(p2p): implement initial state [part 7/8] Nov 6, 2024
@glevco glevco marked this pull request as ready for review November 6, 2024 02:50
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 94.95798% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.87%. Comparing base (bf1e568) to head (659806b).

Files with missing lines Patch % Lines
hathor/p2p/states/base.py 84.61% 2 Missing ⚠️
hathor/p2p/dependencies/protocols.py 0.00% 0 Missing and 1 partial ⚠️
hathor/p2p/factory.py 87.50% 0 Missing and 1 partial ⚠️
hathor/p2p/states/peer_id.py 91.66% 1 Missing ⚠️
hathor/p2p/states/ready.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                       @@
##           refactor/p2p/remove-manager    #1172      +/-   ##
===============================================================
+ Coverage                        84.72%   84.87%   +0.14%     
===============================================================
  Files                              320      321       +1     
  Lines                            24457    24498      +41     
  Branches                          3718     3728      +10     
===============================================================
+ Hits                             20721    20792      +71     
+ Misses                            3004     2987      -17     
+ Partials                           732      719      -13     

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

@glevco glevco changed the title refactor(p2p): implement initial state [part 7/8] refactor(p2p): implement initial state [part 8/10] Nov 6, 2024
@glevco glevco force-pushed the refactor/p2p/remove-manager branch from 58633dc to e9616e9 Compare November 6, 2024 15:29
@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/remove-manager branch from e9616e9 to 45ede7d Compare November 7, 2024 01:59
@glevco glevco force-pushed the refactor/p2p/initial-state branch from 260d851 to 36da2f5 Compare November 7, 2024 01:59
@glevco glevco changed the title refactor(p2p): implement initial state [part 8/10] refactor(p2p): implement initial state [part 8/11] Nov 7, 2024
@glevco glevco force-pushed the refactor/p2p/remove-manager branch from 45ede7d to bf1e568 Compare November 8, 2024 15:45
@glevco glevco force-pushed the refactor/p2p/initial-state branch from 36da2f5 to 659806b 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