filecoin-project / venus

Filecoin Full Node Implementation in Go
https://venus.filecoin.io
Other
2.05k stars 459 forks source link

Use bootstrap configuration to do inital connections #454

Closed dignifiedquire closed 6 years ago

dignifiedquire commented 6 years ago

Description

Use the bootstrap nodes configuration option, to connect to the filecoin network on startup time.

Acceptance criteria

Risks + pitfalls

Where to begin

phritz commented 6 years ago

@dignifiedquire I'm starting this story, a few clarifications.

It looks like the libp2p basichost requires an id + address to dial a peer (BasicHost.Connect takes a PeerInfo, which has both).

  1. For config we want bootstrap address to be given with a peer id like "/ipv4/.../$protocol/$ID" and not just an address like "/ipv4/..." correct?
  2. I can see node.Host.ID and node.Host.Addrs. Is the right way to put them together into an address like above to do something like (or maybe exactly like) InfoToP2pAddrs (https://github.com/libp2p/go-libp2p-peerstore/blob/master/peerinfo.go#L60)?
  3. Would I just call the above string a 'multiaddr string' or is there a more precise name?
  4. There's a protocol (namespace) for ipfs peer ids of the kind mentioned above. Most/all of the code (eg https://github.com/libp2p/go-libp2p-peerstore/blob/master/peerinfo.go#L34, https://github.com/ipfs/go-ipfs-addr/blob/master/ipfsaddr.go, etc) assumes an ipfs peer id. Is part of this story slightly generalizing peerinfo to be able to use the "fil" protocol for peer ids, not just assume "ipfs"? Or should we be using peerids under ipfs?

Thanks! Edit: edited for clarity as I rubber duckied.

dignifiedquire commented 6 years ago

For now we will want to use addresses that look the same as the ones from IPFS, but will eventually want to transition to /ip4/../p2p/$id. Example addresss

"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"

These are (go-)multiaddrs, with additional constraints, as that we require them to have the ipfs protocol attached. You can see the validation of this in IPFS here: https://github.com/ipfs/go-ipfs/blob/master/repo/config/bootstrap_peers.go

Which uses go-ipfs-addr which we can reuse for now I believe.


The actual details of the bootstrapping process can be found here

The one that IPFS uses is a much simpler process, where as ethereum implements a kademlia style discovery process.

For filling this issue, only doing a periodic bootstrap like go-ipfs is sufficient, and gives us a places to improve on this at some later point if we see the need for it.


On conversion of bootstrap Multiaddrs to PeerInfos, you can find some details here: https://github.com/ipfs/go-ipfs/blob/master/core/bootstrap.go#L202


Would I just call the above string a 'multiaddr string' or is there a more precise name?

Yes those are multiaddrs in their string representation

phritz commented 6 years ago

@dignifiedquire is the scope of this story to connect to bootstrap nodes as peers or is the scope of this story to connect to bootstrap nodes and query them for peers to connect to?

Reading https://github.com/ipfs/go-ipfs/blob/master/core/bootstrap.go#L35 perhaps the question boils down to: are we going to use ipfsdht for peer discovery? If not seems like the former has to be the plan; if so, then we can do the latter.

dignifiedquire commented 6 years ago

just connecting for now, we can do querying later as I am not a 100% sure how that will work

phritz commented 6 years ago

Closed by https://github.com/filecoin-project/go-filecoin/pull/500