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(networking): unify peer data models, remove StoredInfo #1597

Merged
merged 6 commits into from
Mar 9, 2023

Conversation

alrevuelta
Copy link
Contributor

@alrevuelta alrevuelta commented Mar 7, 2023

Summary:

  • RemotePeerInfo and StoredInfo store very similar content, being totally redundant.
  • Back and forth conversions between both types are all over the codebase.
  • This PR unifies RemotePeerInfo and StoredInfo, removing the later leaving only RemotePeerInfo.

@alrevuelta alrevuelta force-pushed the unify-peer-types branch 2 times, most recently from 1aa7301 to c4c65f8 Compare March 8, 2023 15:35
@alrevuelta alrevuelta marked this pull request as ready for review March 8, 2023 16:40
@alrevuelta alrevuelta requested review from LNSD and jm-clius March 8, 2023 17:14
Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks! This improves consistency. I wouldn't couple concepts around PeerBooks with the Peer though and leave those as part of the waku_peer_store.

Side note: Fwiw, I've never been fully convinced of the term RemotePeerInfo - it was introduced to differentiate it from PeerInfo, which became (but wasn't always) solely local peer info. Perhaps we can think of a better term at some point...

Comment on lines 49 to 68
# Keeps track of the Connectedness state of a peer
ConnectionBook* = ref object of PeerBook[Connectedness]

# Last failed connection attemp timestamp
LastFailedConnBook* = ref object of PeerBook[Moment]

# Failed connection attempts
NumberFailedConnBook* = ref object of PeerBook[int]

# Keeps track of when peers were disconnected in Unix timestamps
DisconnectBook* = ref object of PeerBook[int64]

# Keeps track of the origin of a peer
SourceBook* = ref object of PeerBook[PeerOrigin]

# Direction
DirectionBook* = ref object of PeerBook[PeerDirection]

# ENR Book
ENRBook* = ref object of PeerBook[enr.Record]
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though the peers util module itself should probably move closer to the peer_manager, I don't think the concept of a PeerBook should mix with the concept of a Peer. In other words, I'd leave the Books part of waku_peer_store for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are totally right, fixed c5a699c

(I kind of regret using the peerbook, but that's another story :P)

Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

Overall, LGTM ✅


We should have a conversation about the "Peer" data model. I concur with @jm-clius. The RemotePeerInfo type overlaps with libp2p's PeerId.

As I see it:

We should come up with a "waku peer type" (e.g., as simple as Peer) that should be compatible ad convertible to/from and contain the following peer types and peer info formats:

  • nim-libp2p's PeerId
  • nim-ibp2p's Multiaddress
  • nim-eth PeerId
  • nim-eth ENR Record

This also affects the key types. Additionally, we should come up with a "waku key type" (e.g., as simple as Key) that should be compatible ad convertible to/from and contain the following key types:

  • nim-eth key types
  • nim-libp2p key types

@alrevuelta alrevuelta merged commit 622ec27 into master Mar 9, 2023
@alrevuelta alrevuelta deleted the unify-peer-types branch March 9, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants