-
Notifications
You must be signed in to change notification settings - Fork 448
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: certified addressbook #683
Conversation
bb915aa
to
9ff5cad
Compare
Non certified addresses should be expired by TTL. When we receive a new Peer Record, the record with the highest sequence wins, the other certified addresses should be removed.
We should trigger the change. While the underlying multiaddr didn't change, our state did. This is helpful for apps that may want to take action when addresses become certified.
We should check the TTL on load for these and only keep them if it hasn't expired. I haven't checked the address book code yet, let me know if you want me to give that a pass. |
56e4dd9
to
40f4217
Compare
Since we now have self being stored in the AddressBook, should we filter out |
Just noticed that gossipsub v1.1 will need to import from this repo at runtime to access |
Yes! I am not a fan of requiring stuff as |
a947283
to
4792ebb
Compare
40f4217
to
44aef5b
Compare
4976483
to
adad74e
Compare
adad74e
to
9ee0499
Compare
9ee0499
to
864d153
Compare
src/peer-store/index.js
Outdated
@@ -37,9 +37,11 @@ class PeerStore extends EventEmitter { | |||
/** | |||
* @constructor | |||
*/ | |||
constructor () { | |||
constructor ({ peerId } = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this optional? I don't see a use case for it and it just adds unnecessary checks when filtering self out.
src/record/envelope/index.js
Outdated
* @param {Buffer} data | ||
* @return {Promise<Envelope>} | ||
*/ | ||
Envelope.createFromProtobuf = unmarshalEnvelope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set the function here and avoid two names for the same method?
f812c05
to
90b8761
Compare
90b8761
to
5019a60
Compare
* @param {PeerId} peerId | ||
* @return {Buffer} | ||
*/ | ||
getRawEnvelope (peerId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a convenience method for getRawSelfEnvelope
?
We are using this providing own peerId in the identify protocol, and I am also using it now in rendezvous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the need here? We should already have easy access to libp2p, libp2p.peerStore.addressBook.getRawEnvelope(libp2p.peerId)
, I'm not seeing what we'd gain from this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not needed, but could potentially help. I did not have access to the self peerId in the rendezvous server (in the previous PR state), and I needed to change everything to provide libp2p because of that. But yeah, it was mostly a question, we don't need it, it could just help in some cases
* @param {PeerId} peerId | ||
* @return {Buffer} | ||
*/ | ||
getRawEnvelope (peerId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the need here? We should already have easy access to libp2p, libp2p.peerStore.addressBook.getRawEnvelope(libp2p.peerId)
, I'm not seeing what we'd gain from this.
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just 2 minor language suggestions.
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This PR adds the signed peer records in the AddressBook as part of #653
Remaining:
Needs:
The protobuf definition for persistence was inspired (copied) from go-libp2p, and the API to consume and get the records was inspired on go-libp2p CertifiedAddressBook interface.
The AddressBook was previously holding
Map<string, Array<Address>>
, which mapped a peer id string identifier to an Array of Address (object with multiaddr property). It was changed toMap<string, Array<Entry>>
, where the Entry is an object containing{ addresses: Array<Address>, record: { raw: Buffer, seqNumber: number} }
. The Address now also includes aisCertified
property that aims to allow subsystems to filter known multiaddrs of a peer that are certified without a need to unmarshall the record. Theraw
envelope is stored for being exchanged easily with other peers.There are 3 remaining questions to be answered:
change:multiaddrs
when a peer has new multiaddrs. The question is, what if we already know a multiaddr but it is now certified? From the persistence layer standpoint, it is important to receive the event, but is this expected from a regular listener of the events?