filecoin-project / venus

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

Maintain peer list for fetching blockchain data #3054

Closed anorth closed 5 years ago

anorth commented 5 years ago

Description

The current bitswap-based chain fetch mechanism does its own peer management. We intend to switch to using graphsync (or maybe #2065) which will need peers from which to fetch to be explicitly specified.

Implement a small object which maintains a list of peers discovered (through bootstrap config and DHT traversal). This should store the results of "hello" protocol exchanges so it knows the head and height (later: protocol version information) about each peer. Decouple a bit from the so that the syncer can distinguish initial chain sync from ongoing (#1105).

This object should expose a method for selecting one or more peers from which to fetch chain data, to be consumed by a graphsync-based fetcher. There should be some functionality for the fetcher to report a peer as not responding and hence suspending or evicting it.

Later, this object will run the secure bootstrapping mechanism of discovering many random peers and seeking a majority agreement on head CID before syncing a chain (#2674). Right now, we just rely on configured trusted bootstrap nodes.

cc @frrist @hannahhoward

Acceptance criteria

Risks + pitfalls

Libp2p does some implicit things, we don't want the higher level peer list to fall out of sync with peers actually connected.

Where to begin

Begin with the current hello protocol and understanding existing peer bootstrap and discovery. Decouple from the chain syncer.

anorth commented 5 years ago

See also some discussion in #1105. I'm not sure if that means that bootstrapping and peer management need necessarily be linked now, though.

taoshengshi commented 5 years ago

Who will provide this kind of peer nodes ? How to mitigate Eclipse attacks to new comers and DDoS attacks to these peers ?

anorth commented 5 years ago

That's a problem for #2674, which we are not addressing yet (but will soon).

taoshengshi commented 5 years ago

@anorth clear, thanks!

anorth commented 5 years ago

Done in #3163, #3184