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

y-p2pt provider #524

Open
Weedshaker opened this issue Apr 15, 2023 · 4 comments
Open

y-p2pt provider #524

Weedshaker opened this issue Apr 15, 2023 · 4 comments
Assignees

Comments

@Weedshaker
Copy link

Describe the solution you'd like
I am writing a new Provider for yjs, which uses p2pt called y-p2pt provider:
https://github.com/Weedshaker/y-p2pt

Which is truly decentral, since the handshake server is the central weak point but this approach uses WebTorrent trackers as such. You can find out more details regarding the p2pt repo here:
https://github.com/subins2000/p2pt
Simple WebRTC Peer 2 Peer connections using WebTorrent trackers as the signalling server. Use WebTorrent trackers for any kind of WebRTC app ! 🔥 Make WebRTC apps fast & easy ! 🚀⭐

I would like, if you could support and/or review the y-p2pt provider code, since it is hard to deal with the awareness protocol and not miss any details.

Describe alternatives you've considered
Certainly y-webrtc but it has a central weak point and y-p2pt would be a fantastic solution for that concern. Also P2PT works very performant on our tests so far and the y-p2pt provider also started to work slightly... some parts are still missing as you can see here: https://github.com/Weedshaker/y-p2pt/blob/main/src/es/P2ptProvider.js#L228

Additional context
WebTorrents are growing rapidly since years and there are going to be more and more trackers, which not only help with the handshake. It is a great way to make the web 3.0 and it would be lovely, if @dmonad or an other yjs programmer would support this additional provider.

Thank you very much for your effort in advance 🙏

@dmonad
Copy link
Member

dmonad commented Apr 17, 2023

I didn't know about p2pt. Pretty cool, thanks for sharing!

It is a great way to make the web 3.0 and it would be lovely, if @dmonad or an other yjs programmer would support this additional provider.

The Y project depends on contributors to add more providers and I'm happy that you did. I'd be happy to help if you have any questions. If you want we can add your provider to the list of providers (once you say it works decently well - nothing is perfect!).

Certainly y-webrtc but it has a central weak point and y-p2pt would be a fantastic solution for that concern. Also P2PT works very performant on our tests so far and the y-p2pt provider also started to work slightly... some parts are still missing as you can see here: https://github.com/Weedshaker/y-p2pt/blob/main/src/es/P2ptProvider.js#L228

The commented part is not strictly necessary. y-webrtc connects to local browser-tabs via Broadcastchannel and to remote clients via WebRTC. This is just a small optimization. You can also connect to local browser tabs via WebRTC and don't filter them. By the way: "bc" stands for broadcastchannel.

@Weedshaker
Copy link
Author

Thank you for your answer. Here in this feature Issue, I am going to keep you updated on our progress.

Do you have any good recommendations regarding the awareness protocol. At the moment I am reverse engineering the y-webrtc provider to match the p2pt methods. Although, maybe there are better resources or approaches?

@dmonad
Copy link
Member

dmonad commented Apr 18, 2023

The awareness protocol itself is really simple. Here is a good explanation: https://github.com/yjs/y-protocols/blob/master/PROTOCOL.md

The docs explain the document updates fairly well: https://docs.yjs.dev/api/document-updates

You just somehow need to ensure that all updates are eventually sent to all clients. It doesn't matter if updates are sent in the wrong order. The awareness protocol doesn't even care if some messages get lost.

It's fine to implement syncing by simply broadcasting all updates that are exposed via the update event. If an applied update has already been applied (you received a duplicate) the update event won't fire. This is all that y-webrtc does. It's just that y-webrtc implements a lot of optimizations (e.g. the broadcastchannel communication method) that are not strictly necessary.

@sloev
Copy link

sloev commented Feb 25, 2024

maybe combine webtorrent signalling with the webrtc class in https://github.com/podraven/y-fire/tree/main to create interconnected clusters of webrtc peers that self update on leave/enter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants