dominictarr / scuttlebutt

peer-to-peer replicatable data structure
Other
1.32k stars 66 forks source link

Will time stamp precision be an issue? #46

Open coodoo opened 8 years ago

coodoo commented 8 years ago

Currently the filter function is doing it's comparison based on ts, I was wondering if some of the connected clients has their system clock misconfigured (or intentionally tampered), will those incorrect ts break the comparison hence making the final results inconsistent across all clients?

I see swarm is using lamport timestamp to somehow guarantee the the ts is correct, does that help?

Thanks!

dominictarr commented 8 years ago

each timestamp is generally considered only with respect to the node that recorded that timestamp. so the system will still be eventually consistent even if clocks are skewed.

In the case of scuttlebot/model it will take the most recently (by timestamp) value for a key. This would mean that peers with an early timestamp will win against timestamps set by other peers, However, no one has ever posted an issue saying that this is a problem.

If it was, one simple way to fix this would be to replace the timestamp with a value that was always one more than the latest update you knew about. So I make update 1, then you could make update 2. if I see that I'd make update 3 next. if I didn't see it, i'd make update 2, but that would be okay because these would be compared by our node ids and it would be apparent that we updated concurrently.

re: security, this module should really be called insecure-scuttlebutt. It would be okay if it's running behind your firewall (i.e. you control the code on all peers). I am now working a secure replication system, http://github.com/ssbc/scuttlebot/ it uses the same basic idea as scuttlebutt but has very different project goals.

coodoo commented 8 years ago

Thanks for the detailed information, I will have a good look at secure-scuttlebutt and scuttlebot ASAP.

In the mean time, one quick question, does secure scuttlebot support the use case of letting multiple users working on one document (think google doc)? Which means everyone can edit the document event offline, and the document will eventually converge to the same state across all clients.

Thanks!

dominictarr commented 8 years ago

@coodoo yes absolutely. scuttlebutt/model gives you a simple kv store, and https://github.com/dominictarr/r-edit gives you text editing. see the links in the readme for others.

coodoo commented 8 years ago

Yup I've been working on r-edit/r-array/scuttlebutt example for a while and finally come to an extent I'm feeling comfortable with the whole combinations, I was just about to start revising r-edit with r-string which is more granular and suits my use case better.

I was just under the impression that r-array won't work with secure-scuttlebutt/bot out of the box but seems I'm wrong :)