Merkle trees are used extensively in distributed computing. Here's an example: You have many instances serving assets of some kind replicated in several data centers. They are structured in an arbitrary number of branches with many assets in each branch:
How do you make sure the asset trees in the instances are synced up, serving the same assets?
You could compare every bit across every instance, but that would be very inefficient. You could compare the hashes of all the assets at each node of the tree, but you would still end up making many unnecessary comparisons.
You can simply hash each node of the tree based on the hash of its child nodes / assets. This forms a Merkle tree. That way, you can simply compare the root hashes across instances, and if they match, then the whole asset tree must be the same. If they don't match, compare the hashes at the next level of the tree until you find the discrepancy, and sync the nodes / assets where the hashes don't match. Merkle trees can be a very powerful tool for reaching consensus quickly in distributed systems.
Weird coincidence: this post uses Sputter, an EVM implementation written in Clojure, and there's a Clojure-inspired Lisp named "Sputter" at the top of /r/golang right now. Threw me for a loop. Maybe with some tweaking, you could run Sputter in Sputter?
Not that weird of a coincidence, right? The words lisp and sputter are both related to speech, so I wasn't being overly creative when I came up with the name.
I wouldn't recommend using my incarnation of sputter just yet. It's not even close to being production-ready and it's purely interpreted right now and rather slow.
6 comments
[ 3.1 ms ] story [ 24.6 ms ] threadIt seems extremely niche
>ETH crypto and its language
>Library/tool for a single purpose
>Used for decentralized apps
The decentralized apps are my biggest confusion, but I'm looking for feedback from people actively developing apps for ETH.
[1] http://distributeddatastore.blogspot.com/2013/07/cassandra-u...
[2] https://blogs.oracle.com/bonwick/zfs-end-to-end-data-integri...
for a list of uses for merkle trees: https://en.wikipedia.org/wiki/Merkle_tree#Uses
You could compare every bit across every instance, but that would be very inefficient. You could compare the hashes of all the assets at each node of the tree, but you would still end up making many unnecessary comparisons.
You can simply hash each node of the tree based on the hash of its child nodes / assets. This forms a Merkle tree. That way, you can simply compare the root hashes across instances, and if they match, then the whole asset tree must be the same. If they don't match, compare the hashes at the next level of the tree until you find the discrepancy, and sync the nodes / assets where the hashes don't match. Merkle trees can be a very powerful tool for reaching consensus quickly in distributed systems.
I wouldn't recommend using my incarnation of sputter just yet. It's not even close to being production-ready and it's purely interpreted right now and rather slow.