dat-ecosystem / dat

:floppy_disk: peer-to-peer sharing & live syncronization of files via command line
https://dat.foundation
BSD 3-Clause "New" or "Revised" License
8.24k stars 449 forks source link

How to hook into Dat at a lower level? #1042

Closed EGreg closed 5 years ago

EGreg commented 5 years ago

I recently came across Dat and devoured the materials with great interest. I have yet to do a deep hands-on dive into hyperdrive and hypercore implementations.

I understand Dat syncs files and has an append-only SLEEP ledger, but I want to hook into this to implement certain byzantine-fault-tolerant distributed systems in order to implement:

1) Streams and Messages - essentially these are various “rooms” with “participants” which take actions and the actions are stored in a hash chain without a fork, and are interpreted differently depending on the application or component (eg chatting, chess game, etc.)

2) Rules - essentially each Stream can have various rules written in a language like Javascript that runs in a VM, if the rule returns true the transaction is valid, if any rule returns false it is not, this is how we implement everything from access control rules to chess game rules to rules about adding and removing rules. Everything is done in order and you can see the whole history of the chess game as you join it for instance.

3) Quorums and Commits - we need to have validators who vote to whether the rules were followed or not

4) Byzantine Consensus - this may alread be handled by Dat, if so how?? I mean, how do you make sure the other Dat clients in the swarm are still holding the same content and didn’t “forget” some changes. If you catch a fork then you complain and gossip claims and end users make up their mind who to stop listening to based on supplied evidence of cheating signed by the cheater. It’s a whole Byzantine consensus system. This is to prevent forks of Streams, ie double spends of Tokens (like, if I paid you $1000 and you gave me the item and then I make the other Dat guys forget that I paid you and the tokens return to me).

Anyway, we want to implement this whole thing on top of Dat and be compatible with it. Is there already a project like this? What is the best way to learn about the internals of hypercore, hyperdrive and SLEEP, and is it even possible to insert hooks in a way that is compatible with other Dat protocol clients?

What we are trying to do is akin to building apps on top of the web, or OSI Layer 7, etc. Where we need to hook into the underlying layer to not sync files, really, but implement the above features.

By way of background this is for the Qbix Platform 2.0 - the first version is already used around the world for commuities to have social networks for their own members, running on their own servers. See below

https://qbix.com/blog/2018/08/28/vision-for-a-new-truly-decentralized-web/

What we already developed:

https://qbix.com/features.pdf

https://vimeo.com/208438090

https://qbix.com/platform/features

We have Group Rides like uber for friends, Group Activities like eventbrite for communities, we are building Group Gifts etc.

joehand commented 5 years ago

See https://github.com/datproject/sdk for future plans around this.