From 02d56d73ce51ca424e7aa2094cca0190434d4ef5 Mon Sep 17 00:00:00 2001 From: farhoud Date: Tue, 31 May 2022 16:53:36 +0430 Subject: [PATCH 1/9] First draft --- docs/RFCs/peer-routing.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/RFCs/peer-routing.md diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md new file mode 100644 index 0000000..f67bb72 --- /dev/null +++ b/docs/RFCs/peer-routing.md @@ -0,0 +1,36 @@ +# Peer Routing +- Start Date: 2022-05-31 +- RFC PR: [functionland/docs/pull/113](https://github.com/functionland/docs/pull/113) +- Functionland Issue: [functionland/docs/issues/112](https://github.com/functionland/docs/issues/112) +- Status: Draft +- Authors: [Farhoud](https://github.com/farhoud), +- Reviewers: [Aaron](https://github.com/gitaaron), [Ehsan](https://github.com/ehsan6sha), [Masih](https://github.com/orgs/functionland/people/masih) + + +## Summary +[summary]: #summary + +This RFC Will cover +- How peers find address of each other on the network. +- How to connect node that has incompatible transport. +- How to connect node that is behind NAT. + + +## Problem Statement +Our initial design was to use `WebRTC-star` as our transport which has internal peer discovery and peer routing. But things changes: +- For using `IPFS-cluster` we added `go-IPFS`. +- Success Rate of webrtc is not above 80%. +- `fula-react-native` use go-libp2 which does not have `WebRTC-star` transport +- We need other transport to cover offline network. (WebRTC need to have online signaling server). + +Now we need to enable all magic that libp2p has to Enable us: + +### Peer discovery +Its like a dns of web2 there should be a way to get address of node by its peerID. +- `fula-react-native` addBox api should work if user only provide: +`/fula/[peerID]` +- `fula-web` need to way to work offline. + +### Peer routing +- `fula-react-native` and `box` has different and incompatible transport which we can use `go-IPFS` as its relay. + From e715c549d004dbe4a25fc9a23a7ebcba12e7c864 Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 10:48:00 +0430 Subject: [PATCH 2/9] content restructer. --- docs/RFCs/peer-routing.md | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index f67bb72..afd6615 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -10,27 +10,40 @@ ## Summary [summary]: #summary -This RFC Will cover -- How peers find address of each other on the network. -- How to connect node that has incompatible transport. -- How to connect node that is behind NAT. +This RFC Will Cover Peer Discovery and Peer Routing,In simple explanation how we find address of box after that find a route in p2p network and establishing connection. ## Problem Statement -Our initial design was to use `WebRTC-star` as our transport which has internal peer discovery and peer routing. But things changes: +- Find address of node from peer id. +- We have Libp2p with Incompatible transport. +- Most of our boxes will install behind NAT with dynamic IP address (Home Network Environment) and we promised our users zero config Box installation. + +## Motivation +Our initial design was to stick to `JS-Libp2p` and use `WebRTC-star` as our transport which has internal peer discovery and peer routing. But things changed: - For using `IPFS-cluster` we added `go-IPFS`. - Success Rate of webrtc is not above 80%. -- `fula-react-native` use go-libp2 which does not have `WebRTC-star` transport -- We need other transport to cover offline network. (WebRTC need to have online signaling server). +- go-libp2 which does not have `WebRTC-star` transport +- Box should work in offline environment. (`WebRTC-star` need a signaling server) -Now we need to enable all magic that libp2p has to Enable us: -### Peer discovery -Its like a dns of web2 there should be a way to get address of node by its peerID. -- `fula-react-native` addBox api should work if user only provide: -`/fula/[peerID]` -- `fula-web` need to way to work offline. -### Peer routing +## Use Cases +- Box should be able to handle nat-traversal automatically. +- `fula-react-native` addBox api should work with `/fula/[peerID]` +- Box should work in offline environment. - `fula-react-native` and `box` has different and incompatible transport which we can use `go-IPFS` as its relay. + +## Action Items +We will enable all that libp2p has to overcome above use cases. +- Go-IPFS in box should be Mandatory and Delegate Box DHT to go-ipfs. +- Enable all the available transport both on JS and go. +- Enable all the NAT Traversal tooling in libp2p [NAT traversal tracking issue](https://github.com/libp2p/specs/issues/312). +- Use DHT in client for resolving address. +- Having our own bootstrap node. + + +## Related Issue +- [functionland/fula/issues/129](https://github.com/functionland/fula/issues/129) +- [functionland/fula/issues/193](https://github.com/functionland/fula/issues/193) +- [functionland/docs/issues/28](https://github.com/functionland/docs/issues/28) \ No newline at end of file From fb2cc47757ace40e5f94855a306d36f43bf95b4a Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 10:55:48 +0430 Subject: [PATCH 3/9] Over thinking. --- docs/RFCs/peer-routing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index afd6615..393b9a2 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -20,9 +20,9 @@ This RFC Will Cover Peer Discovery and Peer Routing,In simple explanation how we ## Motivation Our initial design was to stick to `JS-Libp2p` and use `WebRTC-star` as our transport which has internal peer discovery and peer routing. But things changed: -- For using `IPFS-cluster` we added `go-IPFS`. -- Success Rate of webrtc is not above 80%. -- go-libp2 which does not have `WebRTC-star` transport +- For using `IPFS-cluster` we added `go-IPFS` as FS layer of `Box`. +- Success Rate of webrtc is not above 80%. [ref](https://github.com/functionland/docs/issues/28) +- `fula-react-native` uses `go-libp2p`. - Box should work in offline environment. (`WebRTC-star` need a signaling server) From ce08874c10a61db524ed8727de18a9bf9bc1beeb Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 11:38:17 +0430 Subject: [PATCH 4/9] Add Implementing first draft. --- docs/RFCs/peer-routing.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index 393b9a2..679296d 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -36,12 +36,30 @@ Our initial design was to stick to `JS-Libp2p` and use `WebRTC-star` as our tran ## Action Items We will enable all that libp2p has to overcome above use cases. -- Go-IPFS in box should be Mandatory and Delegate Box DHT to go-ipfs. +- Go-IPFS in Box should be Mandatory and Delegate Box DHT to go-ipfs. - Enable all the available transport both on JS and go. - Enable all the NAT Traversal tooling in libp2p [NAT traversal tracking issue](https://github.com/libp2p/specs/issues/312). - Use DHT in client for resolving address. - Having our own bootstrap node. +## Implementing +Most of our work is configuration. and using peer routing api in our client. + +### Box +For box usage of go-ipfs should be mandatory and for optimizing performance we delegate peer-routing to go-ipfs ([ref](https://github.com/libp2p/js-libp2p-delegated-peer-routing)). also enable the relay and nat.We have encounter some error's in some environments when enabling NAT so it should be smart and if error happens disable it. +we need another mechanism for box to check if its offline or online. (libp2p break if you listen on inaccessible signalling server) +Try to use MDNS if its offline and if the environment let it. + + +### Fula client (go and js) +Use libp2p peer routing for resolving peer address and routing. +In js we should change `fula-client/src/connection.ts`. +For go we should change `go-fula/fula.go`. +connect api in js should change to accept multi address so if no automatic peer discovery available user can do it manually: +- `/fula/[peerId]` +- `/ip4/127.0.0.1/tcp/4002/p2p/12D3KooWGrkcHUBzAAuYhMRxBreCgofKKDhLgR84FbawknJZHwK1` + + ## Related Issue - [functionland/fula/issues/129](https://github.com/functionland/fula/issues/129) From a6d9028f9eb6cd35a5c64c85a89bbfd95368fc9a Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 13:33:38 +0430 Subject: [PATCH 5/9] Decuple go and js implimention --- docs/RFCs/peer-routing.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index 679296d..b33a1a4 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -51,15 +51,27 @@ we need another mechanism for box to check if its offline or online. (libp2p bre Try to use MDNS if its offline and if the environment let it. -### Fula client (go and js) +### Fula client Use libp2p peer routing for resolving peer address and routing. + +#### js In js we should change `fula-client/src/connection.ts`. -For go we should change `go-fula/fula.go`. -connect api in js should change to accept multi address so if no automatic peer discovery available user can do it manually: +- Use peerstore instead of local array +- Use peer routing api for finding address of peer. +- connect api in js should change to accept multi address so if no automatic peer discovery available user can do it manually: - `/fula/[peerId]` - `/ip4/127.0.0.1/tcp/4002/p2p/12D3KooWGrkcHUBzAAuYhMRxBreCgofKKDhLgR84FbawknJZHwK1` +#### Fula client go +- For go we should change `go-fula/fula.go` peer routing api `find-peer` and add api can accept `/fula/[peerId]` + + +### Fula Infrastructure +- Bootstrap nodes with public address +- Signalling server for WebRtc + + ## Related Issue - [functionland/fula/issues/129](https://github.com/functionland/fula/issues/129) From b915559add67818a9c60043c4ea9c56581273341 Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 13:36:33 +0430 Subject: [PATCH 6/9] Add go-ipfs --- docs/RFCs/peer-routing.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index b33a1a4..81f4f5e 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -49,21 +49,25 @@ Most of our work is configuration. and using peer routing api in our client. For box usage of go-ipfs should be mandatory and for optimizing performance we delegate peer-routing to go-ipfs ([ref](https://github.com/libp2p/js-libp2p-delegated-peer-routing)). also enable the relay and nat.We have encounter some error's in some environments when enabling NAT so it should be smart and if error happens disable it. we need another mechanism for box to check if its offline or online. (libp2p break if you listen on inaccessible signalling server) Try to use MDNS if its offline and if the environment let it. +also enable the relay. + +### go-ipfs +Enable auto relay. ### Fula client Use libp2p peer routing for resolving peer address and routing. -#### js +#### JS In js we should change `fula-client/src/connection.ts`. -- Use peerstore instead of local array +- Use PeerStore instead of local array - Use peer routing api for finding address of peer. - connect api in js should change to accept multi address so if no automatic peer discovery available user can do it manually: - `/fula/[peerId]` - `/ip4/127.0.0.1/tcp/4002/p2p/12D3KooWGrkcHUBzAAuYhMRxBreCgofKKDhLgR84FbawknJZHwK1` -#### Fula client go +#### go - For go we should change `go-fula/fula.go` peer routing api `find-peer` and add api can accept `/fula/[peerId]` From edba36c8b85411aa65f4d175d3fd3e13ff6088e3 Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 13:43:51 +0430 Subject: [PATCH 7/9] Add Future Possibilities --- docs/RFCs/peer-routing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index 81f4f5e..54cfc8d 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -75,7 +75,10 @@ In js we should change `fula-client/src/connection.ts`. - Bootstrap nodes with public address - Signalling server for WebRtc - +## Future Possibilities +- Delegate client dht to some node in Fula Infrastructure. (Reduce resource consumption) +- Create a HA proxy for dht delegation so we can also add box +as dht if they are available ## Related Issue - [functionland/fula/issues/129](https://github.com/functionland/fula/issues/129) From ccc050ac5af4594e17262dc434ba0bf36895a889 Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 13:47:22 +0430 Subject: [PATCH 8/9] some clean up --- docs/RFCs/peer-routing.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index 54cfc8d..049eb51 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -61,14 +61,15 @@ Use libp2p peer routing for resolving peer address and routing. #### JS In js we should change `fula-client/src/connection.ts`. - Use PeerStore instead of local array -- Use peer routing api for finding address of peer. +- Use peer routing API. - connect api in js should change to accept multi address so if no automatic peer discovery available user can do it manually: - `/fula/[peerId]` - `/ip4/127.0.0.1/tcp/4002/p2p/12D3KooWGrkcHUBzAAuYhMRxBreCgofKKDhLgR84FbawknJZHwK1` #### go -- For go we should change `go-fula/fula.go` peer routing api `find-peer` and add api can accept `/fula/[peerId]` +- add peer routing +- addBox api should accept `/fula/[peerId]` ### Fula Infrastructure From 65a28208e75db4b05dd700f2a1ed38d60c763d9f Mon Sep 17 00:00:00 2001 From: farhoud Date: Wed, 1 Jun 2022 13:51:10 +0430 Subject: [PATCH 9/9] Update --- docs/RFCs/peer-routing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/RFCs/peer-routing.md b/docs/RFCs/peer-routing.md index 049eb51..33763ad 100644 --- a/docs/RFCs/peer-routing.md +++ b/docs/RFCs/peer-routing.md @@ -80,6 +80,7 @@ In js we should change `fula-client/src/connection.ts`. - Delegate client dht to some node in Fula Infrastructure. (Reduce resource consumption) - Create a HA proxy for dht delegation so we can also add box as dht if they are available +- Add rendezvous ## Related Issue - [functionland/fula/issues/129](https://github.com/functionland/fula/issues/129)