Interval Tree Clocks - Determining the sequence of events in distributed systems

in dawn-network •  8 years ago  (edited)

Continuing



my research into distributed systems I came across the concept of causality determination systems for distributed systems without a centralised clock. It is based on Vector Tree Clocks, and this is a simple diagram that gives you some idea of how it works:

Interval Tree Clocks go a step further and allow you to track events that spawn multiple subprocesses that can converge again as well:

intervaltreeclock.png

TL;DR:

Basically this is a way to positively determine whether an action by one actor, was before, after, or potentially concurrent with another, without having to trust a centralised clock.

This is important because for example the case of a sequence of two spends of a quantity of a cryptocurrency, if a sends 10 to b, and then b sends 10 to c, but you are d, and you heard about 10 going from b to c before you heard about it first going from a to b, when you inspect the stamps you can see the chain that a did the send before b, not by a time stamp, but by the codes in the messages, the first has a send and receive from a to b, and the second from b to c, and the stamps from b can tell you that it received the 10 before it then sent it.

Obviously, as this example shows, you would reject the data if you could not arrange its' order because it would be impossible, in the case that b and c both had zero, how could b send 10 to c if it had zero prior learning about a sending it to b?

I was all girding up to port a java version to go, and then I found this:

https://github.com/fgrid/itc

It's nice when you can just say 'ok, that problem is solved'. Well, mostly. I still have to write the code that actually creates events.

Maintaining lists of peers in a network

I also have found the tool for maintaining lists of nodes in the network , that implements the SWIM protocol (I may have mentioned this before). There is a go implementation of this here: https://github.com/clockworksoul/smudge and interestingly it also provides the possibility of carrying up to 256 bytes of data in the ping/ack packets, which I am considering using as the underlying transport for the Dawn Nexus messaging system, and because it is a reliable protocol operating over unreliable UDP, it will recover when IP addresses change or there is disruptions in the connection.

The Interval Tree Clocks will be the timestamps used for the database synchronisation and transaction transmissions, which will ensure that it isn't possible to fork the network by synchronised sending of differing spends on the same account (double spend attack), as well as a two tier distribution pattern with geographically localised validators that feed transactions up through a global validator set who then send out the synchronisation digests that drop any conflicting transactions between different geographical validator zones.

Thinking further about it, it is possible that Smudge could in fact become the primary transport layer instead of gRPC, which is built on HTTP/2, which is TCP based, meaning it does not cope as well with unstable network environments. gRPC is still the best choice for the interface for database querying by applications, as it is efficient and compact, and protocol buffers also for storage. I will write a packet protocol to put protocol buffers data into the SWIM protocol UDP packets, and the IPC between nodes will be more resistant to partitions in the network cutting a hop in a TCP/IP route, UDP reroutes without needing the time to negotiate a new path.

Anyway, I just wanted to share this thing - I am far from fully understanding it but I think I grasp it well enough to be able to use the logical clock stamps for messages to ensure that transactions always go into the log in the correct order, preventing the possibility of exploiting timing to attack the network, as well as making the network resilent in the face of quite large scale connectivity failures in the internet as a whole.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

a Gantt chart for distributed systems?

it's roughly based on a similar principle to the way that git edit histories are sequenced, it's topological rather than based on a simple linear clock.

meep

THAT's simple?

yeah, it so isn't!

I remember learning matrix mathematics in highschool, but it was so tedious to do calculations with it by hand. I had no idea how useful they were.

I REMEMBER matrix math in high school.
I rember there was something ThERE...something powerful...something beautiful..
But I never could quite grasp it.

this is way over my head, breakdown or summary? i got lost of the first picture

Basically, without having to depend on a centralised accurate clock, by creating clock 'ticks' that identify the program and each event that takes place (parts of algorithms, processes, message sending) in a cluster of applications, such that by inspecting these clock codes you can positively establish if one event happened before another, even if you heard about the subsequent event first.

o thanks a bunch, i just started reading about the process online, interesting stuff!

Hi, @l0k1

Thanks for sharing a little insight into things you're learning and beginning to incorporate into Dawn. Actually, coming across this article in my feed is my first introduction to your Dawn concept, and I'm starting to read things like your terse white paper and your other posts on the topic.

I've been toying with the idea of dipping my toe into blockchain development... Perhaps your project might encourage me to do that? :) We'll see!

😄😇😄

@creatr

I can definitely recommend surfing the information available out there. Some stuff is really really new, like Freeman's Byzantine Fault Tolerant gossip protocol. This stuff has the potential to really change what is possible with distributed systems.... I have this idea of 'the cloud' being the entire internet, so understanding how such complex webs of interactions can be coordinated is critical to developing better solutions in the future. It's about more than money, just like databases are not just ledgers :)

I appreciate your response and encouragement... :)

I'm in a funny place right now. I've got an embedded systems product that I'm struggling to promote in order to keep the bills paid, but it's not moving fast enough. I've spent a lot of my life coding in C and a wide variety of ASMs, and it's probably time for me to dive in and learn some of the newer network coding languages.

Thanks again, I appreciate your article and encouragement. :D

Go is the best language out there for writing distributed applications. I'm not surprised that almost all the newest protocols already have go implementations... You just make less mistakes by following its idiom.

Thank you, @l0k1, for the recommendation!

I've found https://golang.org and I'll read up on it! :D

IoT stuff is where embedded is moving towards and there is a lot more capability, and you can run Go code on most of these SoC devices for doing sensors and data distribution. The nodes can be a lot smarter than they used to be.

I will have to see if there are Go implementations for the Atmel chips that I am very fond of designing for. That may be a good area for my future focus. Thanks! :D