416-MemoryLane / issue-tracking

0 stars 0 forks source link

[SPIKE] Achieving P2P connection between nodes via IP #11

Closed eysk-io closed 1 year ago

eysk-io commented 1 year ago

The nodes that have access to each album will be connected via a peer-to-peer network. Wingman will be the network layer via which the CmRDTs are maintained and updated by Raccoon which will be shared and synchronised with all the nodes that have the appropriate access to each album, as determined by Galactus. Thus, this eventual delivery will be achieved via this service. Note that a node could have access to multiple albums.

image

eysk-io commented 1 year ago

https://github.com/libp2p/go-libp2p https://dev.to/feliperosa/getting-started-with-libp2p-in-go-4hoa (from our gdocs)

derekcswong commented 1 year ago

There's a lot to untangle here and I think I need some help. Honestly, I'm struggling to come up with a full p2p network solution for our project. A lot of the things we chatted about in our meeting regarding concurrency, peer discover, node communication, data structures, and handling node failures have solutions that exist in a go library called libp2p. But one of the main problems I'm having is understanding exactly how to handle external machines/nodes entering our network (how the bootstrapped node gets initialized etc..) and what this design would even look like in real code.

derekcswong commented 1 year ago

Another problem I think we'll have with the design we had in mind is that if we want to go across machines (like from me to you) we have to handle things like bypassing firewalls

derekcswong commented 1 year ago

With regards to what p2p nodes need to uniquely identify each other and to connect/communicate, libp2p has the concepts of multiaddresses (contains IP version, IP address, transport layer protocol, and port number) and Peer IDs. These can be stored/retrieved with Galactus. The addresses that will be used for communication with peers and will look something like:

<ip-multiaddr>/p2p/<peer-id>

See the p2p branch for more details.

eysk-io commented 1 year ago

@derekcswong see the TODO: https://github.com/416-MemoryLane/MemoryLane/blob/48910dca3cc882e841b04cfba1083156cdf6dd58/app.go#L44-L50.

We will want to parse the correct address to use to send to Galactus to be able to connect to machines on the same network. For example, for the following multiaddrs printed in the for-loop:

Listening on (IP-multiaddrs):
        /ip4/10.0.0.148/udp/64372/quic-v1/webtransport/certhash/...
        /ip4/127.0.0.1/udp/64372/quic-v1/webtransport/certhash/...
        /ip6/.../udp/64373/quic
        /ip6/::1/udp/64373/quic
        /ip6/.../udp/64373/quic-v1
        /ip6/::1/udp/64373/quic-v1
        /ip6/.../udp/64374/quic-v1/webtransport/certhash/...
        /ip6/::1/udp/64374/quic-v1/webtransport/certhash/...
        /ip4/10.0.0.148/tcp/59532
        /ip4/127.0.0.1/tcp/59532
        /ip4/10.0.0.148/udp/64371/quic-v1
        /ip4/127.0.0.1/udp/64371/quic-v1
        /ip4/10.0.0.148/udp/64371/quic
        /ip4/127.0.0.1/udp/64371/quic
        /ip6/.../tcp/59533
        /ip6/::1/tcp/59533

We would specifically want to connect using /ip4/10.0.0.148/tcp/59532 in this case, (this specific addr/port will be different every time the node spins up). i.e. following the README, would use go build -o app && ./app --peer-address /ip4/10.0.0.148/tcp/59532/p2p/<peer-id>