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

Signed Peer Records #630

Closed
wants to merge 3 commits into from
Closed

Conversation

aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented May 6, 2020

For #558

Backward compatible for now.

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

A good start, but there are no tests. In particular, it would be really nice to get some interoperability tests (e.g. with Testground) as a sanity check. Also, we don't do anything about signed peer records for handleGetProviders.

This PR also increases bandwidth usage by sending both signed and unsigned peer records so it would be nice to quantify that in some way. If it's substantial then perhaps it's worth waiting for a DHT version upgrade before doing this so that we don't have to duplicate messages.

We might be able to save bandwidth by only sending the signature + public key instead of the entire signed envelope. Unfortunately the signed peer records were setup as signatures over the protobufs of the PeerRecord struct and protobufs do not have guaranteed canonical serialization...

I'd like to better understand why we're doing this now (as opposed to after we get our network upgrading strategy set up) and how much it's going to cost the network in bandwidth.

}
c := ConnectionType(n.Connectedness(peerrec.PeerID))

bz, err := peerRecords[i].Marshal()
Copy link
Contributor

Choose a reason for hiding this comment

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

bz?

// github.com/libp2p/go-libp2p-core/peer/pb/peer_record.proto for message definitions.
bytes signedPeerRecord = 1;
// used to signal the sender's connection capabilities to the peer
ConnectionType connection = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to embed the connection here? What do we get out of duplicating this state from the regular peer records?

continue
}

evs[peer.PeerID] = RawSignedPeerRecordConn{ev, peer.Addrs, Connectedness(pbsp[i].Connection)}
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about adding in checks here to make sure we haven't been sent multiple records for the same peer?

Comment on lines +406 to +411
// return if we got a nil response
// This happens if the self peer decides to not run the query RPC on the remote peer for some reason
if newPeers == nil {
ch <- &queryUpdate{cause: p, heard: nil, queried: []peer.ID{p}, queryDuration: queryDuration}
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm just missing it, but where do we get err != nil && newPeers == nil?

Comment on lines +426 to +427
// add any other know addresses for the candidate peer.
curInfo := q.dht.peerstore.PeerInfo(pid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we doing this? If the signed record on its own doesn't warrant being queried on its own then why should we help it by adding externally learned addresses?

Comment on lines +439 to +440
// process unsigned peers
for _, next := range newPeers.unsignedPeers {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to explicitly not check unsigned addresses for a peer for which we received signed addresses.

Comment on lines 88 to +89
resp.CloserPeers = pb.PeerInfosToPBPeers(dht.host.Network(), closerinfos)

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to send all unsigned addresses from our peerstore instead of just taking the signed addresses and extracting them?

Comment on lines 317 to +318
resp.CloserPeers = pb.PeerInfosToPBPeers(dht.host.Network(), withAddresses)

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@Stebalien Stebalien removed their request for review May 7, 2020 08:10
@Stebalien
Copy link
Member

I'm deferring to @aschmahmann for now. Please re-add me for review when done.

@aschmahmann aschmahmann added the status/blocked Unable to be worked further until needs are met label Jul 29, 2020
@aschmahmann
Copy link
Contributor

While I'd like to get signed peer records into the DHT there are a couple higher priority items, so I'm calling this blocked for now.

  1. A solution to Gradual Network Upgrades #616 so that we can reliably demand signed peer records instead of suffering from downgrade attacks
  2. Remove special cases for Peer and Provider records #584

@aschmahmann
Copy link
Contributor

There have been a lot of changes since this was put up and this is a server side change which comes with some complexity. We'll have to revisit this when there's more time to resolve #558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/blocked Unable to be worked further until needs are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants