ssbc / ssb-db

A database of unforgeable append-only feeds, optimized for efficient replication for peer to peer protocols
https://scuttlebot.io/
MIT License
1.17k stars 75 forks source link

Implement browser compatibility #179

Open tribou opened 7 years ago

tribou commented 7 years ago

Hello!

I'm coming from the direction of testing y.js for a web-based shared document editor. However, I started looking into your architecture for secure-scuttlebutt, and I really like what I've found so far.

I was curious, is there a browser implementation available or planned for this version of ssb? I ran across dominictarr/localstorage-scuttlebutt along with dominictarr/r-edit, but I'd hate to forego the latest end-to-end security architecture you've been working on lately. Is it possible to run this version of the database in the browser?

dominictarr commented 7 years ago

first, there is "secure-scuttlebutt" and "scuttlebutt" they are based on the same basic idea of a protocol, but otherwise, completely different. those other ones work with scuttlebutt, which isn't secure per se. I am intending to get this working in the browser at some point though, and some sort of mutable document representation on top of it, but not really planning on updating "scuttlebutt"

you might also be interested in http://github.com/dominictarr/epidemic-broadcast-trees it's also about the part essential protocol part to scuttlebutt, but makes it more efficient and scalable!

tribou commented 7 years ago

Thank you for the clarification! I'll check out epidemic-broadcast-trees 👍

Regarding your intentions to get secure-scuttlebutt working in the browser, perhaps we could use this issue to track the progress? I'd be glad to help out where I can. Could you provide a high-level list of steps still needed for that to happen?

The idea that I'm chasing is to create a better opportunity for code-sharing between React, iOS/Android React Native, Electron, and an event-sourcing/AWS Lambda backend. I'm thinking the backend may need some custom logic to provide an initial authentication handshake and persist a snapshot of the state. Anyway, right now I'm just looking for next steps to get this package closer to the browser. Thanks for your help!

dominictarr commented 7 years ago

Well, the main hurdle is getting https://github.com/flumedb in the browser. I am working on this at the moment, actually. the main problem is getting the indexeddb wrapper fast enough to be reasonable. I need to be able to load 100k records (100mb or so) into indexeddb in under 5 minutes.

christianbundy commented 7 years ago

This issue is my main priority -- my daily driver is a Chromebook, and being able to use it in a mobile browser (or app) would be a total game-changer. If there's anything I can do to help this along, I'd be more than happy to throw a few hours at it. Thanks!

dominictarr commented 7 years ago

oh awesome! so the biggest thing single obstical is to get the flume (database) stuff working well in the browser. I want to be able to load say, 150mb of data in at least 10 minutes. that really isn't too much data, but indexeddb (our only storage option, basically) is really quite slow.

From what I've looked into it currently, the best thing is build this api: https://github.com/flumedb/aligned-block-file on top of indexeddb. I also tried going into indexeddb directly, https://github.com/flumedb/flumelog-idb but it's slow with many small writes. It's fairly fast with large writes, which is why I think the best option might be to write a block store on top of indexeddb.

mlegore commented 6 years ago

Is there a fork somewhere of this WIP?

Rob-pw commented 6 years ago

@mlegore, I believe at: https://github.com/ssbc/secure-scuttlebutt/tree/bump-flumedb, I've not yet tested it.

Atavic commented 6 years ago

Decentralization Protocols on Firefox 59: https://github.com/pyllyukko/user.js/issues/366

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tribou commented 5 years ago

I still would love to see a browser implementation, but it sounds like we may need a different way of architecting it to make it performant?

christianbundy commented 5 years ago

Me too! Unfortunately I don't think this is something that we can resolve without replacing flumedb or making significant changes upstream, so I wonder whether this would be better tracked in the flumedb repo. What do you think?

stale[bot] commented 5 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

regular commented 3 years ago

ssb-browser-core got this covered, I think?

tribou commented 3 years ago

Nice, thanks for sharing. Would love to see it added to the ssbc org. Regardless, looks like a huge step forward in available browser APIs!

regular commented 3 years ago

It is! Very exciting! cc @arj03

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?