Skip to content

refactor(p2p): add PublicPeer and PrivatePeer to simplify Peer#1115

Merged
jansegre merged 1 commit intomasterfrom
refactor/p2p-peer-types
Oct 7, 2024
Merged

refactor(p2p): add PublicPeer and PrivatePeer to simplify Peer#1115
jansegre merged 1 commit intomasterfrom
refactor/p2p-peer-types

Conversation

@jansegre
Copy link
Member

@jansegre jansegre commented Aug 20, 2024

Motivation

The hathor.p2p.peer.Peer type represents multiple types of peers, which makes it needed to check for None on its properties and also makes it more cumbersome to check for some invariants.

Acceptance Criteria

  • Split hathor.p2p.peer.Peer into Peer, PublicPeer and PrivatePeer
  • Peer is just the base type with no public or private key, it implies that the peer-id cannot be verified because of the lack of a public key
  • Peer is renamed to UnverifiedPeer
  • PublicPeer (internally has an UnverifiedPeer) has a public-key, which can be used to verify its peer-id, it's implied that we've connected to this peer before and thus we verified its public-key
  • PrivatePeer (internally has a PublicPeer) has a private-key, in practice it's only used for the node's own peer-id
  • Split PeerStorage into a VerifiedPeerStorage that can only store PublicPeer and a UnverifiedPeerStorage that only stores UnverifiedPeer

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

@jansegre jansegre self-assigned this Aug 20, 2024
@jansegre jansegre requested a review from msbrogli as a code owner August 20, 2024 16:36
@jansegre jansegre force-pushed the refactor/p2p-peer-use-peer-id branch from 9c218c4 to 255b1d4 Compare August 20, 2024 21:23
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch 2 times, most recently from f74ca68 to ecf70e9 Compare August 21, 2024 00:31
@codecov
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 90.36145% with 32 lines in your changes missing coverage. Please review.

Project coverage is 84.47%. Comparing base (335d050) to head (646878b).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
hathor/p2p/peer.py 93.58% 11 Missing and 1 partial ⚠️
hathor/p2p/manager.py 72.72% 7 Missing and 2 partials ⚠️
hathor/p2p/sync_v2/agent.py 70.58% 4 Missing and 1 partial ⚠️
hathor/builder/cli_builder.py 60.00% 1 Missing and 1 partial ⚠️
hathor/p2p/peer_storage.py 90.90% 2 Missing ⚠️
hathor/p2p/states/ready.py 83.33% 1 Missing ⚠️
hathor/simulator/fake_connection.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1115      +/-   ##
==========================================
+ Coverage   84.42%   84.47%   +0.04%     
==========================================
  Files         317      317              
  Lines       24303    24366      +63     
  Branches     3698     3705       +7     
==========================================
+ Hits        20519    20582      +63     
- Misses       3070     3071       +1     
+ Partials      714      713       -1     

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

@jansegre jansegre requested a review from glevco August 22, 2024 00:36
@jansegre jansegre force-pushed the refactor/p2p-peer-use-peer-id branch from 255b1d4 to ada19b8 Compare August 22, 2024 14:45
Base automatically changed from refactor/p2p-peer-use-peer-id to master August 22, 2024 16:33
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch from ecf70e9 to f239f23 Compare August 22, 2024 22:15
@github-actions
Copy link

github-actions bot commented Aug 22, 2024

🐰 Bencher Report

Branchrefactor/p2p-peer-types
Testbedubuntu-22.04
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Lower Boundary
nanoseconds (ns)
(Limit %)
Upper Boundary
nanoseconds (ns)
(Limit %)
sync-v2 (up to 20000 blocks)📈 view plot
🚷 view threshold
101,390,226,466.26
(-0.62%)
91,823,280,390.41
(90.56%)
112,228,453,810.50
(90.34%)
🐰 View full continuous benchmarking report in Bencher

msbrogli
msbrogli previously approved these changes Aug 26, 2024
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch 4 times, most recently from 4c3bbd0 to 663d965 Compare September 16, 2024 18:37
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch from 663d965 to e3dd601 Compare September 30, 2024 17:06
glevco
glevco previously approved these changes Oct 2, 2024
msbrogli
msbrogli previously approved these changes Oct 3, 2024
@jansegre jansegre dismissed stale reviews from msbrogli and glevco via 447cc30 October 3, 2024 21:28
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch 2 times, most recently from 447cc30 to 0749a20 Compare October 3, 2024 21:28
glevco
glevco previously approved these changes Oct 3, 2024
msbrogli
msbrogli previously approved these changes Oct 3, 2024
@jansegre jansegre mentioned this pull request Oct 4, 2024
2 tasks
@jansegre jansegre dismissed stale reviews from msbrogli and glevco via 646878b October 7, 2024 18:44
@jansegre jansegre force-pushed the refactor/p2p-peer-types branch from 0749a20 to 646878b Compare October 7, 2024 18:44
@jansegre jansegre merged commit 8da62a1 into master Oct 7, 2024
@jansegre jansegre deleted the refactor/p2p-peer-types branch October 7, 2024 20:43
jansegre added a commit that referenced this pull request Oct 11, 2024
fix(cli): subcommand quick_test not stopping after #1115
@jansegre jansegre mentioned this pull request Dec 11, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants